language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | mrdoob | three.js | fbac88d731b85fc9b25c69ce7161edd2566ed40c.json | remove references to XXXBufferGeometry | threejs/lessons/ja/threejs-primitives.md | @@ -25,51 +25,32 @@ Three.jsใฏๅคใใฎใใชใใใฃใใใใใพใใ
ใใฎใใใๅฟ
่ฆใซๅฟใใฆใไธๆใไฝฟใๅใใใใจใใงใใพใใ
-<div id="Diagram-BoxBufferGeometry" data-primitive="BoxBufferGeometry">็ซๆนไฝ</div>
-<div id="Diagram-CircleBufferGeometry" data-primitive="CircleBufferGeometry">2ๆฌกๅ
ใฎๅ</div>
-<div id="Diagram-ConeBufferGeometry" data-primitive="ConeBufferGeometry">ๅ้</div>
-<div id="Diagram-CylinderBufferGeometry" data-primitive="CylinderBufferGeometry">ๅ็ญ</div>
-<div id="Diagram-DodecahedronBufferGeometry" data-primitive="DodecahedronBufferGeometry">ๅไบ้ขไฝ๏ผ12้ขใฎใใฎ๏ผ</div>
-<div id="Diagram-ExtrudeBufferGeometry" data-primitive="ExtrudeBufferGeometry">
+<div id="Diagram-BoxGeometry" data-primitive="BoxGeometry">็ซๆนไฝ</div>
+<div id="Diagram-CircleGeometry" data-primitive="CircleGeometry">2ๆฌกๅ
ใฎๅ</div>
+<div id="Diagram-ConeGeometry" data-primitive="ConeGeometry">ๅ้</div>
+<div id="Diagram-CylinderGeometry" data-primitive="CylinderGeometry">ๅ็ญ</div>
+<div id="Diagram-DodecahedronGeometry" data-primitive="DodecahedronGeometry">ๅไบ้ขไฝ๏ผ12้ขใฎใใฎ๏ผ</div>
+<div id="Diagram-ExtrudeGeometry" data-primitive="ExtrudeGeometry">
ๆผใๅบใใงใงใใ2ๆฌกๅ
ๅฝข็ถใใใใซใชใใทใงใณไปใใ
-ใใใฏ<code>TextBufferGeometry</code>ใจ<code>TextGeometry</code>ใฎใใใใใฎๅบ็คใซใชใใใจใซๆณจๆใใฆใใ ใใใ</div>
-<div id="Diagram-IcosahedronBufferGeometry" data-primitive="IcosahedronBufferGeometry">ไบๅ้ขไฝ๏ผ20้ขใฎใใฎ๏ผ</div>
-<div id="Diagram-LatheBufferGeometry" data-primitive="LatheBufferGeometry">็ทใๅ่ปขใใใฆใงใใๅฝข็ถใไพใจใใฆใฏใใใชใจใใใงใใใใ๏ผใฉใณใใใใผใชใณใฐใฎใใณใใใใใใใใใใ็ซใฆใใฏใคใณใฐใฉในใใใชใณใฏใฐใฉในใใชใฉใชใฉ...ใ็นใฎ้ฃ็ถใจใใฆ2ๆฌกๅ
ใฎ่ผช้ญใไธใใใใฎ่ผช้ญใ่ปธใฎๅจใใงๅ่ปขใใใ้ใซใใฉใฎใใใ็ดฐๅๅใใใthree.jsใซๆ็คบใใใใจใใงใใพใใ</div>
-<div id="Diagram-OctahedronBufferGeometry" data-primitive="OctahedronBufferGeometry">ๅ
ซ้ขไฝ๏ผ8้ข๏ผ</div>
-<div id="Diagram-ParametricBufferGeometry" data-primitive="ParametricBufferGeometry">้ขๆฐใไธใใใใจใงใงใใ่กจ้ขใใใฎ้ขๆฐใฏใใฐใชใใไธ2ๆฌกๅ
ใฎ็นใๅผๆฐใซๅใใๅฏพๅฟใใ3ๆฌกๅ
ใฎ็นใ่ฟใใ</div>
-<div id="Diagram-PlaneBufferGeometry" data-primitive="PlaneBufferGeometry">2ๆฌกๅ
ใฎๅ่งๅฝข</div>
-<div id="Diagram-PolyhedronBufferGeometry" data-primitive="PolyhedronBufferGeometry">ไธ่งๅฝขใ็นใฎๅจใใซ้ใใฆ็ไฝใซใใ</div>
-<div id="Diagram-RingBufferGeometry" data-primitive="RingBufferGeometry">็ใไธญใซ็ฉดใฎใใใๅ็ค</div>
-<div id="Diagram-ShapeBufferGeometry" data-primitive="ShapeBufferGeometry">ไธ่งๅฝขๅๅฒใใใ2ๆฌกๅ
ใฎ่ผช้ญ</div>
-<div id="Diagram-SphereBufferGeometry" data-primitive="SphereBufferGeometry">็ไฝ</div>
-<div id="Diagram-TetrahedronBufferGeometry" data-primitive="TetrahedronBufferGeometry">ๅ้ขไฝ๏ผ4้ขใฎใใฎ๏ผ</div>
-<div id="Diagram-TextBufferGeometry" data-primitive="TextBufferGeometry">3Dใใฉใณใใจๆๅญๅใใใงใใใ3Dใใญในใ</div>
-<div id="Diagram-TorusBufferGeometry" data-primitive="TorusBufferGeometry">ๅ็ฐ๏ผใใผใใ๏ผ</div>
-<div id="Diagram-TorusKnotBufferGeometry" data-primitive="TorusKnotBufferGeometry">ๅ็ฐ๏ผ็ตใณ็ฎ๏ผ</div>
-<div id="Diagram-TubeBufferGeometry" data-primitive="TubeBufferGeometry">็ต่ทฏใใชใใใใ็ฎก</div>
+ใใใฏ<code>TextGeometry</code>ใจ<code>TextGeometry</code>ใฎใใใใใฎๅบ็คใซใชใใใจใซๆณจๆใใฆใใ ใใใ</div>
+<div id="Diagram-IcosahedronGeometry" data-primitive="IcosahedronGeometry">ไบๅ้ขไฝ๏ผ20้ขใฎใใฎ๏ผ</div>
+<div id="Diagram-LatheGeometry" data-primitive="LatheGeometry">็ทใๅ่ปขใใใฆใงใใๅฝข็ถใไพใจใใฆใฏใใใชใจใใใงใใใใ๏ผใฉใณใใใใผใชใณใฐใฎใใณใใใใใใใใใใ็ซใฆใใฏใคใณใฐใฉในใใใชใณใฏใฐใฉในใใชใฉใชใฉ...ใ็นใฎ้ฃ็ถใจใใฆ2ๆฌกๅ
ใฎ่ผช้ญใไธใใใใฎ่ผช้ญใ่ปธใฎๅจใใงๅ่ปขใใใ้ใซใใฉใฎใใใ็ดฐๅๅใใใthree.jsใซๆ็คบใใใใจใใงใใพใใ</div>
+<div id="Diagram-OctahedronGeometry" data-primitive="OctahedronGeometry">ๅ
ซ้ขไฝ๏ผ8้ข๏ผ</div>
+<div id="Diagram-ParametricGeometry" data-primitive="ParametricGeometry">้ขๆฐใไธใใใใจใงใงใใ่กจ้ขใใใฎ้ขๆฐใฏใใฐใชใใไธ2ๆฌกๅ
ใฎ็นใๅผๆฐใซๅใใๅฏพๅฟใใ3ๆฌกๅ
ใฎ็นใ่ฟใใ</div>
+<div id="Diagram-PlaneGeometry" data-primitive="PlaneGeometry">2ๆฌกๅ
ใฎๅ่งๅฝข</div>
+<div id="Diagram-PolyhedronGeometry" data-primitive="PolyhedronGeometry">ไธ่งๅฝขใ็นใฎๅจใใซ้ใใฆ็ไฝใซใใ</div>
+<div id="Diagram-RingGeometry" data-primitive="RingGeometry">็ใไธญใซ็ฉดใฎใใใๅ็ค</div>
+<div id="Diagram-ShapeGeometry" data-primitive="ShapeGeometry">ไธ่งๅฝขๅๅฒใใใ2ๆฌกๅ
ใฎ่ผช้ญ</div>
+<div id="Diagram-SphereGeometry" data-primitive="SphereGeometry">็ไฝ</div>
+<div id="Diagram-TetrahedronGeometry" data-primitive="TetrahedronGeometry">ๅ้ขไฝ๏ผ4้ขใฎใใฎ๏ผ</div>
+<div id="Diagram-TextGeometry" data-primitive="TextGeometry">3Dใใฉใณใใจๆๅญๅใใใงใใใ3Dใใญในใ</div>
+<div id="Diagram-TorusGeometry" data-primitive="TorusGeometry">ๅ็ฐ๏ผใใผใใ๏ผ</div>
+<div id="Diagram-TorusKnotGeometry" data-primitive="TorusKnotGeometry">ๅ็ฐ๏ผ็ตใณ็ฎ๏ผ</div>
+<div id="Diagram-TubeGeometry" data-primitive="TubeGeometry">็ต่ทฏใใชใใใใ็ฎก</div>
<div id="Diagram-EdgesGeometry" data-primitive="EdgesGeometry">็ฐใชใใธใชใกใใชใๅ
ฅๅใจใใฆใใใฎ้ขๅๅฃซใฎ่งๅบฆใ้พๅคไปฅไธใชใ่งใไฝใๅบใใ่ฃๅฉใชใใธใงใฏใใไพใใฐใ่จไบใฎๆๅใฎๆนใง็ดนไปใใ็ซๆนไฝใ่ฆใฆใฟใใจใใใใใใฎ้ขใซใ็ซๆนไฝใไฝใฃใฆใใๅ
จใฆใฎไธ่งๅฝขใฎ็ทใ่กจ็คบใใใฆใใพใใ<code>EdgesGeometry</code>ใไปฃใใใซไฝฟใใใจใงใ้ขๅ
ใฎ็ทใฏๅ
จใฆ้คๅปใใใพใใไธ่จใฎthresholdAngleใ่ชฟๆดใใฆใฟใฆใใ ใใใ้พๅคไปฅไธใฎ่งใๆถใใฆ่ฆใใใงใใใใ</div>
<div id="Diagram-WireframeGeometry" data-primitive="WireframeGeometry">1ใคใฎ่งใใจใซ1ใคใฎ็ทๅ๏ผ2็น๏ผใๆใคใธใชใกใใชใ็ๆใใใWebGLใฏ็ทๅใไฝใใฎใซ2็นใๅฟ
่ฆใชใฎใงใใใฎๆฉ่ฝใใชใใจใใใฐใใฐ่งใๅฟใใใใไฝๅใช่งใไฝใฃใฆใใพใใงใใใใไพใใฐใใใฃใ3็นใใใชใ1ใคใฎไธ่งๅฝขใใใจใใพใใ<code>wireframe: true</code>ใฎใใใชใขใซใไฝฟใฃใฆใใใๆใใใจใใๅ ดๅใ1ๆฌใฎ็ทๅใใๅพใใใพใใใ<code>WireframeGeometry</code>ใซใใฎไธ่งๅฝขใฎใธใชใกใใชใๆธกใใจใ6็นใใใชใ3ใคใฎ็ทๅใๆใฃใๆฐใใใธใชใกใใชใ็ๆใใพใใ</div>
-ใปใจใใฉใฎใใชใใใฃใใฏ`Geometry`ใ`BufferGeometry`ใฎ2ใคใฎ็จฎ้กใใใใใจใซๆฐใฅใใใใใใใพใใใ
-ใใฎ2ใคใฎ้ใใฏใ้ซใๆ่ปๆงใจใใใฉใผใใณในใงใใ
-
-`BufferGeometry`ใซๅบใฅใใใใชใใใฃใใฏใใใฉใผใใณในๅฟๅใฎ็จฎ้กใงใใ
-ใธใชใกใใชใฎ้ ็นใฏใGPUใซใขใใใญใผใใใฆๆ็ปใใใฎใซ้ฉใใ้
ๅๅฝขๅผใธใ็ดๆฅๅคๆใใใพใใ
-ใใใฏใ่ตทๅใ้ใ็ใกใขใชใงใใใใจใๆๅณใใพใใใใใผใฟใฎไฟฎๆญฃใซใใ่ค้ใชใใญใฐใฉใใณใฐใๅฟ
่ฆใซใชใใใจใๅคใใงใใ
-
-`Geometry`ใซๅบใฅใใใใชใใใฃใใฏๆ่ปใงใๆไฝใใใใ็จฎ้กใงใใ
-ใใใใฏใ3ๆฌกๅ
ใฎ็นใฎใใใฎ`Vector3`ใไธ่งๅฝขใฎใใใฎ`Face3`ใฎใใใชJavaScriptใซๅบใฅใใฏใฉในใใใงใใฆใใพใใ็ตๆงใกใขใชใๅฟ
่ฆใจใใพใใใthree.jsใซใฌใณใใชใณใฐใใใๅใซใๅฏพๅฟใใ`BufferGeometry`่กจ็พใซไผผใใใฎใซๅคๆใใๅฟ
่ฆใใใใพใใ
-
-ใใชใใใฃใใๆไฝใใชใใใจใๅใใฃใฆใใใใ่จ็ฎใใใฆๅ
้จใๆไฝใใใใจใซๆตๆใใชใใชใใ
-`BufferGeometry`ใซๅบใฅใใใใชใใใฃใใไฝฟใใฎใใในใใงใใ
-ไธๆนใงใๆ็ปๅใซๅคๅฐใฎๅคๆดใใใใใชใใ`Geometry`ใซๅบใฅใใใใชใใใฃใใไฝฟใใจใ
-ใใ็ฐกๅใซๆฑใใใจใใงใใพใใ
-
-ๅ็ดใชไพใ ใจใ`BufferGeometry`ใฏๆฐใใ้ ็น็พคใ็ฐกๅใซ่ฟฝๅ ใงใใพใใใ
-ไฝฟใ้ ็นใฎๆฐใฏไฝๆๆใซๅฎฃ่จใใใ่จๆถ้ ๅใ็ขบไฟใใใใใผใฟใๆธใ่พผใพใใพใใ
-ไธๆนใ`Geometry`ใฏใใฟใชใใใใใใใใใซ้ ็น็พคใ่ฟฝๅ ใงใใพใใ
-
-[ๅฅใฎ่จไบ](threejs-custom-geometry.html)ใงใใซในใฟใ ใธใชใกใใชใฎไฝๆใซใคใใฆ่ชฌๆใใพใใ
+[ๅฅใฎ่จไบ](threejs-custom-buffergeometry.html)ใงใใซในใฟใ ใธใชใกใใชใฎไฝๆใซใคใใฆ่ชฌๆใใพใใ
ไปใฏใใใใใฎ็จฎ้กใฎใใชใใใฃใใไฝๆใใไพใไฝใฃใฆใฟใพใใ
[ไปฅๅใฎ่จไบ](threejs-responsive.html)ใไพใซๅงใใพใใใใ
@@ -139,7 +120,7 @@ function createMaterial() {
ใใใฏthreeใซๅฝข็ถใไฝใใจใใซไธ่งๅฝขใฎไธก้ขใๆใใใใซๆ็คบใใพใใ
็ไฝใ็ซๆนไฝใฎใใใช็ซไฝๅฝข็ถใซใฏใๅฝข็ถใฎๅ
ๅดใๅใใฆใใ่ฃๅดใๆใ
็็ฑใฏใใใพใใใ
-ใใใใใฎไพใ ใจใ2ๆฌกๅ
ใง่ฃๅดใๅญๅจใใชใ`PlaneBufferGeometry`ใ`ShapeBufferGeometry`ใฎใใใชใใฎใๆใใใจใใฆใใพใใ
+ใใใใใฎไพใ ใจใ2ๆฌกๅ
ใง่ฃๅดใๅญๅจใใชใ`PlaneGeometry`ใ`ShapeGeometry`ใฎใใใชใใฎใๆใใใจใใฆใใพใใ
`side: THREE.DoubleSide`ใ่จญๅฎใใชใใจใ่ฃๅดใ่ฆใใจใใซๆถใใฆใใพใใใจใงใใใใ
`side: THREE.DoubleSide`ใซ**not**ใ่จญๅฎใใใๆนใใๆ็ปใ้ใใชใใพใใ
@@ -163,7 +144,7 @@ function addSolidGeometry(x, y, geometry) {
const width = 8;
const height = 8;
const depth = 8;
- addSolidGeometry(-2, -2, new THREE.BoxBufferGeometry(width, height, depth));
+ addSolidGeometry(-2, -2, new THREE.BoxGeometry(width, height, depth));
}
```
@@ -174,7 +155,7 @@ function addSolidGeometry(x, y, geometry) {
{{{example url="../threejs-primitives.html" }}}
ไธ่จใฎใใฟใผใณใซใฏใ2ใคใฎ็น็ญใในใไพๅคใใใใพใใ
-ไธ็ชๅคงใใชใใฎใฏใใใถใ`TextBufferGeometry`ใงใใใใญในใใฎใกใใทใฅใไฝใใจใใฏใไบๅใซ3Dใใฉใณใใใผใฟใ่ชญใฟ่พผใๅฟ
่ฆใใใใพใใใใฎใใผใฟใฎ่ชญใฟ่พผใฟใฏ้ๅๆ็ใซ่กใใใใฎใงใใธใชใกใใชใไฝใใใจใใๅใซใ่ชญใฟ่พผใฟใๅพ
ใคๅฟ
่ฆใใใใพใใใใฉใณใใฎ่ชญใฟ่พผใฟใซpromiseใไฝฟใใจใใใฃใจ้ใ่ชญใฟ่พผใใใจใใงใใพใใ
+ไธ็ชๅคงใใชใใฎใฏใใใถใ`TextGeometry`ใงใใใใญในใใฎใกใใทใฅใไฝใใจใใฏใไบๅใซ3Dใใฉใณใใใผใฟใ่ชญใฟ่พผใๅฟ
่ฆใใใใพใใใใฎใใผใฟใฎ่ชญใฟ่พผใฟใฏ้ๅๆ็ใซ่กใใใใฎใงใใธใชใกใใชใไฝใใใจใใๅใซใ่ชญใฟ่พผใฟใๅพ
ใคๅฟ
่ฆใใใใพใใใใฉใณใใฎ่ชญใฟ่พผใฟใซpromiseใไฝฟใใจใใใฃใจ้ใ่ชญใฟ่พผใใใจใใงใใพใใ
`FontLoader`ใไฝๆใใ่ชญใฟ่พผใฟใๅฎไบใใใจใใฉใณใใๆไพใใฆใใใpromiseใ่ฟใ`loadFont`้ขๆฐใไฝใใพใใ
ๆฌกใซใ`doit` ใจๅผใฐใใ`async`้ขๆฐใไฝใใ`await`ใไฝฟใฃใฆใใฉใณใใ่ชญใฟ่พผใฟใพใใ
ๆๅพใซใใธใชใกใใชใไฝใใ`addObject`ใๅผใใงใทใผใณใซ่ฟฝๅ ใใพใใ
@@ -191,7 +172,7 @@ function addSolidGeometry(x, y, geometry) {
async function doit() {
const font = await loadFont('resources/threejs/fonts/helvetiker_regular.typeface.json'); /* threejsfundamentals: url */
- const geometry = new THREE.TextBufferGeometry('three.js', {
+ const geometry = new THREE.TextGeometry('three.js', {
font: font,
size: 3.0,
height: .2,
@@ -265,7 +246,7 @@ threeใ็ฅใๆๅฉใใใใพใใ
const radius = 7;
const widthSegments = 12;
const heightSegments = 8;
-const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+const geometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
const material = new THREE.PointsMaterial({
color: 'red',
size: 0.2, // in world units
@@ -301,9 +282,9 @@ const material = new THREE.PointsMaterial({
ไพใใฐใ
<div class="spread">
-<div data-diagram="SphereBufferGeometryLow"></div>
-<div data-diagram="SphereBufferGeometryMedium"></div>
-<div data-diagram="SphereBufferGeometryHigh"></div>
+<div data-diagram="SphereGeometryLow"></div>
+<div data-diagram="SphereGeometryMedium"></div>
+<div data-diagram="SphereGeometryHigh"></div>
</div>
ๆๅใฎ็ไฝใฏใ15ใปใฐใกใณใใพใใฏ30ๅใฎไธ่งๅฝขใซใชใใๅจๅฒใซ5ใปใฐใกใณใใ้ซใ3ใงใใ
@@ -315,9 +296,9 @@ const material = new THREE.PointsMaterial({
ๅฝฑใใชใใใใจใงใใใฎใใใซใชใใพใใ
<div class="spread">
-<div data-diagram="SphereBufferGeometryLowSmooth"></div>
-<div data-diagram="SphereBufferGeometryMediumSmooth"></div>
-<div data-diagram="SphereBufferGeometryHighSmooth"></div>
+<div data-diagram="SphereGeometryLowSmooth"></div>
+<div data-diagram="SphereGeometryMediumSmooth"></div>
+<div data-diagram="SphereGeometryHighSmooth"></div>
</div>
5000ๅใฎไธ่งๅฝขใใใงใใๅณๅดใฎ็ไฝใใใใฃใ480ๅใฎไธ่งๅฝขใใใงใใ็ใไธญใฎ็ไฝใใใ่ฏใใใฏใๆใใใงใฏใใใพใใใ
@@ -332,8 +313,8 @@ const material = new THREE.PointsMaterial({
้ธใถใฎใ็ฐกๅใชใจใใใใใพใใไพใใฐใๅนณ้ขใฎ็ดฐๅๅใ้ธใถใใจใใงใใพใใ
<div class="spread">
-<div data-diagram="PlaneBufferGeometryLow"></div>
-<div data-diagram="PlaneBufferGeometryHigh"></div>
+<div data-diagram="PlaneGeometryLow"></div>
+<div data-diagram="PlaneGeometryHigh"></div>
</div>
ๅทฆๅดใฎๅ่งๅฝขใฏ2ๅใฎไธ่งๅฝขใใใงใใฆใใพใใๅณๅดใฎๅ่งๅฝขใฏ200ๅใฎไธ่งๅฝขใใใงใใฆใใพใใ
@@ -347,8 +328,7 @@ const material = new THREE.PointsMaterial({
ใฟใชใใใฎ็จ้ใซ้ฉใใๅฝข็ถใใชใใชใใไพใใฐใ[.obj file](threejs-load-obj.html)
ใ[.gltf file](threejs-load-gltf.html)ใใใธใชใกใใชใ่ชญใฟ่พผใใใจใใงใใพใใ
-[ใซในใฟใ ใธใชใกใใช](threejs-custom-geometry.html)
-ใ[ใซในใฟใ BufferGeometry](threejs-custom-buffergeometry.html)ใไฝใใใจใใงใใพใใ
+[ใซในใฟใ BufferGeometry](threejs-custom-buffergeometry.html)ใไฝใใใจใใงใใพใใ
ๆฌกใฏใ[threeใฎใทใผใณใฐใฉใใฎๅใๆนใจไฝฟใๆน](threejs-scenegraph.html)ใ่ชฌๆใใพใใ
| true |
Other | mrdoob | three.js | fbac88d731b85fc9b25c69ce7161edd2566ed40c.json | remove references to XXXBufferGeometry | threejs/lessons/kr/threejs-primitives.md | @@ -22,59 +22,32 @@ Three.js์๋ ๋ค์ํ ์์ ๋ชจ๋ธ์ด ์์ต๋๋ค. ๋จผ์ Three.js์ ์
์์ผ๋ก ์๊ฐํ ์์ ๋ชจ๋ธ๋ค์ ๋๋ถ๋ถ ๊ธฐ๋ณธ๊ฐ์ด ์์ผ๋ฏ๋ก ํ์์ ๋ฐ๋ผ
์ธ์๋ฅผ ๋ฃ์ด์ฃผ๋ฉด ๋ฉ๋๋ค.
-<div id="Diagram-BoxBufferGeometry" data-primitive="BoxBufferGeometry">์ก๋ฉด์ฒด(Box)</div>
-<div id="Diagram-CircleBufferGeometry" data-primitive="CircleBufferGeometry">์(flat circle)</div>
-<div id="Diagram-ConeBufferGeometry" data-primitive="ConeBufferGeometry">์๋ฟ(Cone)</div>
-<div id="Diagram-CylinderBufferGeometry" data-primitive="CylinderBufferGeometry">์ํต(Cylinder)</div>
-<div id="Diagram-DodecahedronBufferGeometry" data-primitive="DodecahedronBufferGeometry">์ญ์ด๋ฉด์ฒด(Dodecahedron)</div>
-<div id="Diagram-ExtrudeBufferGeometry" data-primitive="ExtrudeBufferGeometry">์ฌ๊ฐ(bevel)์ ์ฃผ์ด ๊น์๋ธ(extruded) 2D ๋ชจ์์
๋๋ค.
-์๋์์๋ ํํธ ๋ชจ์์ผ๋ก ๊น์๋์ฃ . <code>ExtrudedBufferGeometry</code>๋ ๋์ค์ ์ค๋ช
ํ
-<code>TextBufferGeometry</code>๊ณผ <code>TextGeometry</code>์ ๊ธฐ์ด ๋ชจ๋ธ์
๋๋ค.</div>
-<div id="Diagram-IcosahedronBufferGeometry" data-primitive="IcosahedronBufferGeometry">์ด์ญ๋ฉด์ฒด(Icosahedron)</div>
-<div id="Diagram-LatheBufferGeometry" data-primitive="LatheBufferGeometry">์ (line)์ ํ์ ์์ผ ๋ง๋ ๋ชจ์์
๋๋ค. ๋จํ, ๋ณผ๋งํ, ์ด, ์ด ๋ฐ์นจ, ์์ธ์, ์ ๋ฆฌ์ ๋ฑ์ด ์์ฃ (๋ฌผ๋ ๋ก ๋์๊ธฐ๋ฅผ ๋ง๋๋ ๊ฒ์ฒ๋ผ. ์ญ์ฃผ). 2D ํํ๋ฅผ ์ (point, Vector2 ํด๋์ค๋ฅผ ๋งํจ. ์ญ์ฃผ)์ ์ฌ์ฉํด ์ง์ ํ๊ณ , Three.js์๊ฒ ์ถ์ ๋ฐ๋ผ ์ธ๋ถ๊ฐ(์๋ ์์ ์ <code>segments</code> ๊ฐ. ์ญ์ฃผ)๊ณผ ํ์ ๊ฐ(์๋ ์์ ์ <code>phiLength</code> ๊ฐ. ์ญ์ฃผ)์ ์ง์ ํด์ฃผ๋ฉด ๋ฉ๋๋ค.</div>
-<div id="Diagram-OctahedronBufferGeometry" data-primitive="OctahedronBufferGeometry">ํ๋ฉด์ฒด(Octahedron)</div>
-<div id="Diagram-ParametricBufferGeometry" data-primitive="ParametricBufferGeometry">2D ๊ฒฉ์๊ฐ(๊ฒฉ์ ํ๋์ ๋ฒกํฐ๊ฐ)์ ๋ฐ์ 3D ๊ฐ์ ๋ฐํํ๋ ํจ์๋ฅผ ์ธ์๋ก ์ ๋ฌํ์ฌ ๋ฉด์ ๋ง๋ญ๋๋ค.</div>
-<div id="Diagram-PlaneBufferGeometry" data-primitive="PlaneBufferGeometry">2D ํ๋ฉด(2D plane)</div>
-<div id="Diagram-PolyhedronBufferGeometry" data-primitive="PolyhedronBufferGeometry">๋ค๋ฉด์ฒด์
๋๋ค. ์ฃผ์ด์ง 3D ์ ๋ค(์๋ <code>verticesOfCube</code>. ์ญ์ฃผ)์ ์ค์ฌ์ผ๋ก ์ผ๊ฐํ(์๋ <code>indicesOfFaces</code>. ์ญ์ฃผ)์ ๊ตฌ ํํ๋ก ์์ต๋๋ค.</div>
-<div id="Diagram-RingBufferGeometry" data-primitive="RingBufferGeometry">์ค์์ด ๋น 2D ๋์คํฌ(disc)์
๋๋ค.</div>
-<div id="Diagram-ShapeBufferGeometry" data-primitive="ShapeBufferGeometry">์ผ๊ฐํ์ผ๋ก ์ด๋ฃจ์ด์ง 2D ์ค๊ณฝ์ ์
๋๋ค.</div>
-<div id="Diagram-SphereBufferGeometry" data-primitive="SphereBufferGeometry">๊ตฌ(Sphere)</div>
-<div id="Diagram-TetrahedronBufferGeometry" data-primitive="TetrahedronBufferGeometry">์ฌ๋ฉด์ฒด(tetrahedron)</div>
-<div id="Diagram-TextBufferGeometry" data-primitive="TextBufferGeometry">3D ํฐํธ์ ๋ฌธ์์ด๋ก ๋ง๋ 3D ํ
์คํธ์
๋๋ค.</div>
-<div id="Diagram-TorusBufferGeometry" data-primitive="TorusBufferGeometry">์ํ์ฒด(torus), ๋๋(donut)</div>
-<div id="Diagram-TorusKnotBufferGeometry" data-primitive="TorusKnotBufferGeometry">์ํ์ฒด ๋งค๋ญ(torus knot)</div>
-<div id="Diagram-TubeBufferGeometry" data-primitive="TubeBufferGeometry">ํจ์ค๋ฅผ ๋ฐ๋ผ ์ด์ด์ง ์์
๋๋ค.</div>
+<div id="Diagram-BoxGeometry" data-primitive="BoxGeometry">์ก๋ฉด์ฒด(Box)</div>
+<div id="Diagram-CircleGeometry" data-primitive="CircleGeometry">์(flat circle)</div>
+<div id="Diagram-ConeGeometry" data-primitive="ConeGeometry">์๋ฟ(Cone)</div>
+<div id="Diagram-CylinderGeometry" data-primitive="CylinderGeometry">์ํต(Cylinder)</div>
+<div id="Diagram-DodecahedronGeometry" data-primitive="DodecahedronGeometry">์ญ์ด๋ฉด์ฒด(Dodecahedron)</div>
+<div id="Diagram-ExtrudeGeometry" data-primitive="ExtrudeGeometry">์ฌ๊ฐ(bevel)์ ์ฃผ์ด ๊น์๋ธ(extruded) 2D ๋ชจ์์
๋๋ค.
+์๋์์๋ ํํธ ๋ชจ์์ผ๋ก ๊น์๋์ฃ . <code>ExtrudedGeometry</code>๋ ๋์ค์ ์ค๋ช
ํ
+<code>TextGeometry</code>๊ณผ <code>TextGeometry</code>์ ๊ธฐ์ด ๋ชจ๋ธ์
๋๋ค.</div>
+<div id="Diagram-IcosahedronGeometry" data-primitive="IcosahedronGeometry">์ด์ญ๋ฉด์ฒด(Icosahedron)</div>
+<div id="Diagram-LatheGeometry" data-primitive="LatheGeometry">์ (line)์ ํ์ ์์ผ ๋ง๋ ๋ชจ์์
๋๋ค. ๋จํ, ๋ณผ๋งํ, ์ด, ์ด ๋ฐ์นจ, ์์ธ์, ์ ๋ฆฌ์ ๋ฑ์ด ์์ฃ (๋ฌผ๋ ๋ก ๋์๊ธฐ๋ฅผ ๋ง๋๋ ๊ฒ์ฒ๋ผ. ์ญ์ฃผ). 2D ํํ๋ฅผ ์ (point, Vector2 ํด๋์ค๋ฅผ ๋งํจ. ์ญ์ฃผ)์ ์ฌ์ฉํด ์ง์ ํ๊ณ , Three.js์๊ฒ ์ถ์ ๋ฐ๋ผ ์ธ๋ถ๊ฐ(์๋ ์์ ์ <code>segments</code> ๊ฐ. ์ญ์ฃผ)๊ณผ ํ์ ๊ฐ(์๋ ์์ ์ <code>phiLength</code> ๊ฐ. ์ญ์ฃผ)์ ์ง์ ํด์ฃผ๋ฉด ๋ฉ๋๋ค.</div>
+<div id="Diagram-OctahedronGeometry" data-primitive="OctahedronGeometry">ํ๋ฉด์ฒด(Octahedron)</div>
+<div id="Diagram-ParametricGeometry" data-primitive="ParametricGeometry">2D ๊ฒฉ์๊ฐ(๊ฒฉ์ ํ๋์ ๋ฒกํฐ๊ฐ)์ ๋ฐ์ 3D ๊ฐ์ ๋ฐํํ๋ ํจ์๋ฅผ ์ธ์๋ก ์ ๋ฌํ์ฌ ๋ฉด์ ๋ง๋ญ๋๋ค.</div>
+<div id="Diagram-PlaneGeometry" data-primitive="PlaneGeometry">2D ํ๋ฉด(2D plane)</div>
+<div id="Diagram-PolyhedronGeometry" data-primitive="PolyhedronGeometry">๋ค๋ฉด์ฒด์
๋๋ค. ์ฃผ์ด์ง 3D ์ ๋ค(์๋ <code>verticesOfCube</code>. ์ญ์ฃผ)์ ์ค์ฌ์ผ๋ก ์ผ๊ฐํ(์๋ <code>indicesOfFaces</code>. ์ญ์ฃผ)์ ๊ตฌ ํํ๋ก ์์ต๋๋ค.</div>
+<div id="Diagram-RingGeometry" data-primitive="RingGeometry">์ค์์ด ๋น 2D ๋์คํฌ(disc)์
๋๋ค.</div>
+<div id="Diagram-ShapeGeometry" data-primitive="ShapeGeometry">์ผ๊ฐํ์ผ๋ก ์ด๋ฃจ์ด์ง 2D ์ค๊ณฝ์ ์
๋๋ค.</div>
+<div id="Diagram-SphereGeometry" data-primitive="SphereGeometry">๊ตฌ(Sphere)</div>
+<div id="Diagram-TetrahedronGeometry" data-primitive="TetrahedronGeometry">์ฌ๋ฉด์ฒด(tetrahedron)</div>
+<div id="Diagram-TextGeometry" data-primitive="TextGeometry">3D ํฐํธ์ ๋ฌธ์์ด๋ก ๋ง๋ 3D ํ
์คํธ์
๋๋ค.</div>
+<div id="Diagram-TorusGeometry" data-primitive="TorusGeometry">์ํ์ฒด(torus), ๋๋(donut)</div>
+<div id="Diagram-TorusKnotGeometry" data-primitive="TorusKnotGeometry">์ํ์ฒด ๋งค๋ญ(torus knot)</div>
+<div id="Diagram-TubeGeometry" data-primitive="TubeGeometry">ํจ์ค๋ฅผ ๋ฐ๋ผ ์ด์ด์ง ์์
๋๋ค.</div>
<div id="Diagram-EdgesGeometry" data-primitive="EdgesGeometry">๋ค๋ฅธ <code>geometry</code>๋ฅผ ๋ฐ๋ ํฌํผ ๊ฐ์ฒด๋ก, ๊ฐ ๋ฉด ์ฌ์ด์ ๊ฐ์ด ์ผ์ ๊ฐ ์ด์์ผ ๋๋ง ๋ชจ์๋ฆฌ๋ฅผ ํ์ํฉ๋๋ค. ์๋จ์ ์ก๋ฉด์ฒด ์์ ๋ฅผ ๋ณด๋ฉด ์ก๋ฉด์ฒด๋ฅผ ๋ง๋๋ ์ผ๊ฐํ์ด ํ๋ฉด์ ์ ๋ถ ํ์๋ ๊ฒ์ ํ์ธํ ์ ์๋๋ฐ, <code>EdgesGeometry</code>๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ ํ๋ฉด์ ์๋ ์ ๋ค์ด ์ ๋ถ ์ฌ๋ผ์ง๋๋ค. ์๋ ์์ ์ <code>thresholdAngle</code> ๊ฐ์ ์กฐ์ ํด ํด๋น ๊ฐ ์ดํ์ธ ๋ชจ์๋ฆฌ๊ฐ ์ ๋ถ ์ฌ๋ผ์ง๋ ๊ฒ์ ํ์ธํด๋ณด์ธ์.</div>
<div id="Diagram-WireframeGeometry" data-primitive="WireframeGeometry">๋งค๊ฐ๋ณ์๋ก ๋ฐ์ <code>geometry</code>์ ๋ชจ์๋ฆฌ ํ๋๋น ํ๋์ ์ ๋ถ(2๊ฐ์ ์ )์ ๊ฐ์ง <code>geometry</code>๋ฅผ ์์ฑํฉ๋๋ค. WebGl์ ๋ณดํต ์ ๋ถ ํ๋๋น 2๊ฐ์ ์ ์ ํ์๋ก ํฉ๋๋ค. ๋๋ฌธ์ ์ด ๋ชจ๋ธ์ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ, ๋ชจ์๋ฆฌ๊ฐ ์์ด์ง๊ฑฐ๋ ์ถ๊ฐ๋๋ ํ์์ด ๋ฐ์ํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด 2D ์ผ๊ฐํ์ ๋ง๋๋ ๊ฒฝ์ฐ, ๋๋ถ๋ถ 3๊ฐ์ ์ ์ ์ด์ฉํด ์ผ๊ฐํ์ ๋ง๋ค๋ ค๊ณ ํ ๊ฒ๋๋ค. <code>wireframe: true</code>๋ผ๋ ์ต์
์ด ์๊ธฐ๋ ํ๋, ์ด๋ฅผ ์ด์ฉํด ์ผ๊ฐํ์ ๋ง๋ค๋ฉด (WebGl์ ์ผ๊ฐํ์ ๋ง๋ค ๋ 6๊ฐ์ ์ ์ ์๊ตฌํ๋ฏ๋ก. ์ญ์ฃผ) ์ถ๋ ฅ๋๋ ๊ฑด ์ ํ๋ ๋ฟ์ผ ๊ฒ๋๋ค. ์ผ๊ฐํ <code>geometry</code>๋ฅผ <code>WireframeGeometry</code>์ ๋๊ฒจ์ฃผ๋ฉด 6๊ฐ์ ์ ๊ณผ 3๊ฐ์ ์ ๋ถ์ ๊ฐ์ง ์ <code>geometry</code>๋ฅผ ์์ฑํฉ๋๋ค.</div>
-๋์น์ฑ์
จ๊ฒ ์ง๋ง ๋๋ถ๋ถ์ ์์ ๋ชจ๋ธ์ `Geometry`์ `BufferGeometry`๊ฐ
-์ง์ ์ด๋ฃน๋๋ค. ๋ค๋ฅธ ์ฐจ์ด์ ๋ค๋ ์์ง๋ง ๋์ ๊ฐ์ฅ ํฐ ์ฐจ์ด์ ์ ์ฑ๋ฅ๊ณผ
-ํ์ฅ์ฑ์
๋๋ค.
-
-`BufferGeometry` ๊ธฐ๋ฐ์ ์์ ๋ชจ๋ธ์ ์ฑ๋ฅ์ ์ต์ ํ๋ ๋ชจ๋ธ์
๋๋ค.
-`geometry`์ ์ ์ ๋ค์ ๋ฐ๋ก ๋ ๋๋ง ์ GPU์์ ๋ถ๋ฌ์ค๊ธฐ ์ข์ ๋ฐฐ์ด
-ํํ๋ก ์ต์ ํ๋ฉ๋๋ค. ๋๋ฌธ์ ์ด๊ธฐํ ์๋๋ ๋น ๋ฅด๊ณ ๋ฉ๋ชจ๋ฆฌ ์ ์ ์จ๋
-๋ฎ์ง๋ง, ์ด `geometry`์ ๋ฐ์ดํฐ๋ฅผ ์์ ํ๋ ค๋ฉด ๋ณต์กํ ํ๋ก๊ทธ๋๋ฐ ๊ณผ์ ์
-๊ฑฐ์ณ์ผ ํฉ๋๋ค.
-
-์ด์ ๋ฐํด `Geometry` ๊ธฐ๋ฐ์ ์์ ๋ชจ๋ธ์ ํจ์ฌ ๋ค๋ฃจ๊ธฐ ์ฝ์ต๋๋ค.
-3D ์ ์ ์ ๋ง๋๋ ๋ฐ๋ `Vector3` ํด๋์ค, ์ผ๊ฐํ์ ๋ง๋๋ ๋ฐ๋
-`Face3` ํด๋์ค ๋ฑ ์๋ฐ์คํฌ๋ฆฝํธ ๊ธฐ๋ฐ ํด๋์ค๋ก ์ด๋ฃจ์ด์ ธ ์์ฃ .
-๋ค๋ง `BufferGeometry`์ ๋นํด ์ฝ๊ฐ ๋ง์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ ์ฐจ์งํ๊ณ ,
-๋ ๋๋ง์ ์ํด Three.js๊ฐ ์ด ๋ชจ๋ธ๊ณผ ์ ์ฌํ `BufferGeometry`๋ก
-๋ณํ์ํค๋ ๊ณผ์ ์ด ๋ค์ด๊ฐ๋ค๋ ๊ฒ์ด ๋จ์ ์
๋๋ค.
-
-์์ ๋ชจ๋ธ์ ์ฌ์ฉํ์ง ์์ ๊ณํ์ด๊ฑฐ๋, ๊ธฐํํ ๋ชจ๋ธ์ ์ํ์ ์ผ๋ก
-๊ณ์ฐํ๋ ๋ฐ ์ต์ํ๋ค๋ฉด, `BufferGeometry` ๊ธฐ๋ฐ์ ์์ ๋ชจ๋ธ์
-์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ๋ ๋๋ง ์ ์ ์ด๋ค ๊ฐ์ ์์ ํด์ผ ํ๋ค๋ฉด
-`Geometry`๊ฐ ํจ์ฌ ๋ค๋ฃจ๊ธฐ ์ฝ๊ฒ ์ฃ .
-
-ํ๋ ์๋ฅผ ๋ค๋ฉด, `BufferGeometry`๋ ์ ์ ์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ด๋ ต์ต๋๋ค.
-`BufferGeometry`๋ ์์ฑ ์์ ์ ์ ์ ์๊ฐ ์ ํด์ง๋ฉฐ, ๋ฉ๋ชจ๋ฆฌ์ ํ ๋น๋๊ณ ,
-๊ทธ ๋ค์ ์ ์ ๋ฐ์ดํฐ๋ฅผ ์ฑ์ ๋ฃ์ต๋๋ค. ๋ฐ๋ฉด์ `Geometry`๋ ์์ฑ ํ์๋
-์ผ๋ง๋ ์ง ์ ์ ์ ์ถ๊ฐํ ์ ์์ฃ .
-
-[์ปค์คํ
geometry๋ฅผ ๋ง๋๋ ๋ฒ](threejs-custom-geometry.html)์ ๋ํด์๋
+[์ปค์คํ
geometry๋ฅผ ๋ง๋๋ ๋ฒ](threejs-custom-buffergeometry.html)์ ๋ํด์๋
๋์ค์ ์์ธํ ๋ค๋ฃฐ ๊ฒ์ด๋ฏ๋ก, ์ง๊ธ์ ๊ฐ ์์ ๋ชจ๋ธ๋ก ์์ ๋ฅผ ๋ง๋ค์ด ๋ณด๊ฒ ์ต๋๋ค.
์์ ์ฝ๋๋ [์ง๋ ๊ธ](threejs-responsive.html)์์ ์ผ๋ ์์ ๋ฅผ ์ธ ๊ฑฐ์์.
@@ -146,8 +119,8 @@ function createMaterial() {
์ ์์ ์์๋ `material`์ `side: THREE.DoubleSide` ์ต์
์
์ง์ ํ์ต๋๋ค. ์ด๋ Three.js์๊ฒ ์ผ๊ฐํ์ ์๋ฉด ๋ชจ๋๋ฅผ ๋ ๋๋งํ๋ผ๊ณ
์๋ ค์ฃผ๋ ๊ฒ์ด์ฃ . ๊ตฌ๋ ์ ์ก๋ฉด์ฒด ๊ฐ์ ๋ฌผ์ฒด๋ ๋ณด์ด์ง ์๋ ์์ชฝ ๋ฉด์
-๊ตณ์ด ๋ ๋๋งํ ์ด์ ๊ฐ ์์ง๋ง, ์์ ์ ๊ฒฝ์ฐ `PlaneBufferGeometry`๋
-`ShapeBufferGeometry` ๋ฑ ์์ชฝ ๋ฉด์ด ์๋ ๋ฌผ์ฒด๋ฅผ ๋ง๋ค ๊ฒ์ด๋ฏ๋ก
+๊ตณ์ด ๋ ๋๋งํ ์ด์ ๊ฐ ์์ง๋ง, ์์ ์ ๊ฒฝ์ฐ `PlaneGeometry`๋
+`ShapeGeometry` ๋ฑ ์์ชฝ ๋ฉด์ด ์๋ ๋ฌผ์ฒด๋ฅผ ๋ง๋ค ๊ฒ์ด๋ฏ๋ก
`side: THREE.DoubleSide` ์ต์
์ ์ค์ ํ์ง ์์ผ๋ฉด ๋ฐ๋ํธ์์ ๋ดค์ ๋
๋ฌผ์ฒด๊ฐ ์ฌ๋ผ์ง ๊ฒ์ฒ๋ผ ๋ณด์ผ ๊ฒ๋๋ค.
@@ -174,16 +147,16 @@ function addSolidGeometry(x, y, geometry) {
const width = 8;
const height = 8;
const depth = 8;
- addSolidGeometry(-2, -2, new THREE.BoxBufferGeometry(width, height, depth));
+ addSolidGeometry(-2, -2, new THREE.BoxGeometry(width, height, depth));
}
```
์๋ ์ฝ๋๋ฅผ ๋ณด๋ฉด ๊ฐ `geometry`๋ง๋ค ๋น์ทํ ๋จ๋ฝ์ผ๋ก ์ด๋ฃจ์ด์ง ๊ฒ์ ํ์ธํ ์ ์์ต๋๋ค.
{{{example url="../threejs-primitives.html" }}}
-๋ช๋ช ์์ธ๊ฐ ๋ณด์ผ ํ
๋ฐ, ๊ฐ์ฅ ํฌ๊ฒ ๋๋๋ฌ์ง ๊ฒ์ ์๋ง `TextBufferGeometry`์ผ ๊ฒ๋๋ค.
-`TextBufferGeometry`๋ ํ
์คํธ์ `mesh`๋ฅผ ์์ฑํ๊ธฐ ์ํด 3D ํฐํธ ๋ฐ์ดํฐ๋ฅผ ํ์๋ก ํฉ๋๋ค.
+๋ช๋ช ์์ธ๊ฐ ๋ณด์ผ ํ
๋ฐ, ๊ฐ์ฅ ํฌ๊ฒ ๋๋๋ฌ์ง ๊ฒ์ ์๋ง `TextGeometry`์ผ ๊ฒ๋๋ค.
+`TextGeometry`๋ ํ
์คํธ์ `mesh`๋ฅผ ์์ฑํ๊ธฐ ์ํด 3D ํฐํธ ๋ฐ์ดํฐ๋ฅผ ํ์๋ก ํฉ๋๋ค.
์ด ๋ฐ์ดํฐ๋ ๋น๋๊ธฐ๋ก ๋ก๋๋๋ฏ๋ก, ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ธฐ ์ ์ 3D ํฐํธ ๋ฐ์ดํฐ๊ฐ ๋ก๋๋๊ธฐ๋ฅผ ๊ธฐ๋ค๋ ค์ผ
ํ์ฃ . ํฐํธ ๋ก๋ ๊ณผ์ ์ ํ๋ก๋ฏธ์คํ ํ๋ฉด ์ด ๊ณผ์ ๋ฅผ ๋ ์ฝ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค. ๋จผ์ `FontLoader`๋ฅผ
์์ฑํ๊ณ , Promise๋ฅผ ๋ฐํํ๋ `loadFont` ํจ์๋ฅผ ๋ง๋ค์ด ์์ฒญ์ Promise๋ก ๊ฐ์๋๋ค.
@@ -202,7 +175,7 @@ function addSolidGeometry(x, y, geometry) {
async function doit() {
const font = await loadFont('resources/threejs/fonts/helvetiker_regular.typeface.json'); /* threejsfundamentals: url */
- const geometry = new THREE.TextBufferGeometry('three.js', {
+ const geometry = new THREE.TextGeometry('three.js', {
font: font,
size: 3.0,
height: .2,
@@ -278,7 +251,7 @@ function addLineGeometry(x, y, geometry) {
const radius = 7;
const widthSegments = 12;
const heightSegments = 8;
-const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+const geometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
const material = new THREE.PointsMaterial({
color: 'red',
size: 0.2, // ๊ธ๋ก๋ฒ ๋จ์
@@ -314,9 +287,9 @@ const material = new THREE.PointsMaterial({
๋ฐ์ต๋๋ค.
<div class="spread">
-<div data-diagram="SphereBufferGeometryLow"></div>
-<div data-diagram="SphereBufferGeometryMedium"></div>
-<div data-diagram="SphereBufferGeometryHigh"></div>
+<div data-diagram="SphereGeometryLow"></div>
+<div data-diagram="SphereGeometryMedium"></div>
+<div data-diagram="SphereGeometryHigh"></div>
</div>
์ ๊ทธ๋ฆผ์์ ์ฒซ ๋ฒ์งธ ๊ตฌ์ฒด๋ ๋๋ ๋ก 5๊ฐ, ๋์ด๋ก 3๊ฐ์ ๋ฉด์ผ๋ก ๋ถํ ๋์์ต๋๋ค.
@@ -329,9 +302,9 @@ const material = new THREE.PointsMaterial({
์๋์ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ ๋์ต๋๋ค.
<div class="spread">
-<div data-diagram="SphereBufferGeometryLowSmooth"></div>
-<div data-diagram="SphereBufferGeometryMediumSmooth"></div>
-<div data-diagram="SphereBufferGeometryHighSmooth"></div>
+<div data-diagram="SphereGeometryLowSmooth"></div>
+<div data-diagram="SphereGeometryMediumSmooth"></div>
+<div data-diagram="SphereGeometryHighSmooth"></div>
</div>
5000 ์ผ๊ฐํ์ธ ์ค๋ฅธ์ชฝ ๊ตฌ์ฒด๊ฐ 480 ์ผ๊ฐํ์ธ ์ค๊ฐ ๊ตฌ์ฒด๋ณด๋ค ํจ์ฌ ์ข๋ค๊ณ
@@ -345,8 +318,8 @@ const material = new THREE.PointsMaterial({
๋ฌผ๋ก ์ ํ์ด ์ฌ์ด ๊ฒฝ์ฐ๋ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ํ๋ฉด์ ๋ถํ ํ๋ค๊ณ ํด๋ณด์ฃ .
<div class="spread">
-<div data-diagram="PlaneBufferGeometryLow"></div>
-<div data-diagram="PlaneBufferGeometryHigh"></div>
+<div data-diagram="PlaneGeometryLow"></div>
+<div data-diagram="PlaneGeometryHigh"></div>
</div>
์ผ์ชฝ์ ํ๋ฉด์ 2 ์ผ๊ฐํ์
๋๋ค. ์ค๋ฅธ์ชฝ ํ๋ฉด์ 200 ์ผ๊ฐํ์ด์ฃ .
@@ -360,7 +333,7 @@ const material = new THREE.PointsMaterial({
์์ ๋ชจ๋ธ ์ค ์ด๋ค ๊ฒ๋ ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํ๊ธฐ๊ฐ ์ด๋ ต๋ค๋ฉด,
[.obj ํ์ผ](threejs-load-obj.html) ๋๋ [.gltf ํ์ผ](threejs-load-gltf.html)์
-๋ก๋ํ์ฌ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋๋ [์ปค์คํ
Geometry](threejs-custom-geometry.html)๋
+๋ก๋ํ์ฌ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋๋
[์ปค์คํ
BufferGeometry](threejs-custom-buffergeometry.html)๋ฅผ ์์ฑํ ์๋ ์์ฃ .
๋ค์ ์ฅ์์๋ [์ฌ ๊ทธ๋ํ์ ๊ทธ ์ฌ์ฉ๋ฒ](threejs-scenegraph.html)์ ๋ํด | true |
Other | mrdoob | three.js | fbac88d731b85fc9b25c69ce7161edd2566ed40c.json | remove references to XXXBufferGeometry | threejs/lessons/resources/threejs-primitives.js | @@ -19,7 +19,7 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
});
const diagrams = {
- BoxBufferGeometry: {
+ BoxGeometry: {
ui: {
width: { type: 'range', min: 1, max: 10, precision: 1, },
height: { type: 'range', min: 1, max: 10, precision: 1, },
@@ -29,30 +29,30 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
depthSegments: { type: 'range', min: 1, max: 10, },
},
create(width = 8, height = 8, depth = 8) {
- return new THREE.BoxBufferGeometry(width, height, depth);
+ return new THREE.BoxGeometry(width, height, depth);
},
create2(width = 8, height = 8, depth = 8, widthSegments = 4, heightSegments = 4, depthSegments = 4) {
- return new THREE.BoxBufferGeometry(
+ return new THREE.BoxGeometry(
width, height, depth,
widthSegments, heightSegments, depthSegments);
},
},
- CircleBufferGeometry: {
+ CircleGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
segments: { type: 'range', min: 1, max: 50, },
thetaStart: { type: 'range', min: 0, max: 2, mult: Math.PI },
thetaLength: { type: 'range', min: 0, max: 2, mult: Math.PI },
},
create(radius = 7, segments = 24) {
- return new THREE.CircleBufferGeometry(radius, segments);
+ return new THREE.CircleGeometry(radius, segments);
},
create2(radius = 7, segments = 24, thetaStart = Math.PI * 0.25, thetaLength = Math.PI * 1.5) {
- return new THREE.CircleBufferGeometry(
+ return new THREE.CircleGeometry(
radius, segments, thetaStart, thetaLength);
},
},
- ConeBufferGeometry: {
+ ConeGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
height: { type: 'range', min: 1, max: 10, precision: 1, },
@@ -63,17 +63,17 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
thetaLength: { type: 'range', min: 0, max: 2, mult: Math.PI },
},
create(radius = 6, height = 8, radialSegments = 16) {
- return new THREE.ConeBufferGeometry(radius, height, radialSegments);
+ return new THREE.ConeGeometry(radius, height, radialSegments);
},
create2(radius = 6, height = 8, radialSegments = 16, heightSegments = 2, openEnded = true, thetaStart = Math.PI * 0.25, thetaLength = Math.PI * 1.5) {
- return new THREE.ConeBufferGeometry(
+ return new THREE.ConeGeometry(
radius, height,
radialSegments, heightSegments,
openEnded,
thetaStart, thetaLength);
},
},
- CylinderBufferGeometry: {
+ CylinderGeometry: {
ui: {
radiusTop: { type: 'range', min: 0, max: 10, precision: 1, },
radiusBottom: { type: 'range', min: 0, max: 10, precision: 1, },
@@ -85,30 +85,30 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
thetaLength: { type: 'range', min: 0, max: 2, mult: Math.PI },
},
create(radiusTop = 4, radiusBottom = 4, height = 8, radialSegments = 12) {
- return new THREE.CylinderBufferGeometry(
+ return new THREE.CylinderGeometry(
radiusTop, radiusBottom, height, radialSegments);
},
create2(radiusTop = 4, radiusBottom = 4, height = 8, radialSegments = 12, heightSegments = 2, openEnded = false, thetaStart = Math.PI * 0.25, thetaLength = Math.PI * 1.5) {
- return new THREE.CylinderBufferGeometry(
+ return new THREE.CylinderGeometry(
radiusTop, radiusBottom, height,
radialSegments, heightSegments,
openEnded,
thetaStart, thetaLength);
},
},
- DodecahedronBufferGeometry: {
+ DodecahedronGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
detail: { type: 'range', min: 0, max: 5, precision: 0, },
},
create(radius = 7) {
- return new THREE.DodecahedronBufferGeometry(radius);
+ return new THREE.DodecahedronGeometry(radius);
},
create2(radius = 7, detail = 2) {
- return new THREE.DodecahedronBufferGeometry(radius, detail);
+ return new THREE.DodecahedronGeometry(radius, detail);
},
},
- ExtrudeBufferGeometry: {
+ ExtrudeGeometry: {
ui: {
steps: { type: 'range', min: 1, max: 100, },
depth: { type: 'range', min: 1, max: 20, precision: 1, },
@@ -139,7 +139,7 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
bevelSegments,
};
- const geometry = new THREE.ExtrudeBufferGeometry(shape, extrudeSettings);
+ const geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings);
return geometry;
},
src: `
@@ -163,7 +163,7 @@ const extrudeSettings = {
bevelSegments: 2, // ui: bevelSegments
};
-const geometry = THREE.ExtrudeBufferGeometry(shape, extrudeSettings);
+const geometry = THREE.ExtrudeGeometry(shape, extrudeSettings);
`,
create2(steps = 100) {
const outline = new THREE.Shape([
@@ -193,7 +193,7 @@ const geometry = THREE.ExtrudeBufferGeometry(shape, extrudeSettings);
extrudePath: shape,
};
- const geometry = new THREE.ExtrudeBufferGeometry(outline, extrudeSettings);
+ const geometry = new THREE.ExtrudeGeometry(outline, extrudeSettings);
return geometry;
},
src2: `
@@ -224,23 +224,23 @@ const extrudeSettings = {
extrudePath: shape,
};
-const geometry = new THREE.ExtrudeBufferGeometry(outline, extrudeSettings);
+const geometry = new THREE.ExtrudeGeometry(outline, extrudeSettings);
return geometry;
`,
},
- IcosahedronBufferGeometry: {
+ IcosahedronGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
detail: { type: 'range', min: 0, max: 5, precision: 0, },
},
create(radius = 7) {
- return new THREE.IcosahedronBufferGeometry(radius);
+ return new THREE.IcosahedronGeometry(radius);
},
create2(radius = 7, detail = 2) {
- return new THREE.IcosahedronBufferGeometry(radius, detail);
+ return new THREE.IcosahedronGeometry(radius, detail);
},
},
- LatheBufferGeometry: {
+ LatheGeometry: {
ui: {
segments: { type: 'range', min: 1, max: 50, },
phiStart: { type: 'range', min: 0, max: 2, mult: Math.PI },
@@ -251,30 +251,30 @@ return geometry;
for (let i = 0; i < 10; ++i) {
points.push(new THREE.Vector2(Math.sin(i * 0.2) * 3 + 3, (i - 5) * .8));
}
- return new THREE.LatheBufferGeometry(points);
+ return new THREE.LatheGeometry(points);
},
create2(segments = 12, phiStart = Math.PI * 0.25, phiLength = Math.PI * 1.5) {
const points = [];
for (let i = 0; i < 10; ++i) {
points.push(new THREE.Vector2(Math.sin(i * 0.2) * 3 + 3, (i - 5) * .8));
}
- return new THREE.LatheBufferGeometry(
+ return new THREE.LatheGeometry(
points, segments, phiStart, phiLength);
},
},
- OctahedronBufferGeometry: {
+ OctahedronGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
detail: { type: 'range', min: 0, max: 5, precision: 0, },
},
create(radius = 7) {
- return new THREE.OctahedronBufferGeometry(radius);
+ return new THREE.OctahedronGeometry(radius);
},
create2(radius = 7, detail = 2) {
- return new THREE.OctahedronBufferGeometry(radius, detail);
+ return new THREE.OctahedronGeometry(radius, detail);
},
},
- ParametricBufferGeometry: {
+ ParametricGeometry: {
ui: {
stacks: { type: 'range', min: 1, max: 50, },
slices: { type: 'range', min: 1, max: 50, },
@@ -328,27 +328,27 @@ return geometry;
target.set(x, y, z).multiplyScalar(0.75);
}
- return new THREE.ParametricBufferGeometry(
+ return new THREE.ParametricGeometry(
klein, slices, stacks);
},
},
- PlaneBufferGeometry: {
+ PlaneGeometry: {
ui: {
width: { type: 'range', min: 1, max: 10, precision: 1, },
height: { type: 'range', min: 1, max: 10, precision: 1, },
widthSegments: { type: 'range', min: 1, max: 10, },
heightSegments: { type: 'range', min: 1, max: 10, },
},
create(width = 9, height = 9) {
- return new THREE.PlaneBufferGeometry(width, height);
+ return new THREE.PlaneGeometry(width, height);
},
create2(width = 9, height = 9, widthSegments = 2, heightSegments = 2) {
- return new THREE.PlaneBufferGeometry(
+ return new THREE.PlaneGeometry(
width, height,
widthSegments, heightSegments);
},
},
- PolyhedronBufferGeometry: {
+ PolyhedronGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
detail: { type: 'range', min: 0, max: 5, precision: 0, },
@@ -366,11 +366,11 @@ return geometry;
2, 3, 7, 7, 6, 2,
4, 5, 6, 6, 7, 4,
];
- return new THREE.PolyhedronBufferGeometry(
+ return new THREE.PolyhedronGeometry(
verticesOfCube, indicesOfFaces, radius, detail);
},
},
- RingBufferGeometry: {
+ RingGeometry: {
ui: {
innerRadius: { type: 'range', min: 1, max: 10, precision: 1, },
outerRadius: { type: 'range', min: 1, max: 10, precision: 1, },
@@ -380,17 +380,17 @@ return geometry;
thetaLength: { type: 'range', min: 0, max: 2, mult: Math.PI },
},
create(innerRadius = 2, outerRadius = 7, thetaSegments = 18) {
- return new THREE.RingBufferGeometry(
+ return new THREE.RingGeometry(
innerRadius, outerRadius, thetaSegments);
},
create2(innerRadius = 2, outerRadius = 7, thetaSegments = 18, phiSegments = 2, thetaStart = Math.PI * 0.25, thetaLength = Math.PI * 1.5) {
- return new THREE.RingBufferGeometry(
+ return new THREE.RingGeometry(
innerRadius, outerRadius,
thetaSegments, phiSegments,
thetaStart, thetaLength);
},
},
- ShapeBufferGeometry: {
+ ShapeGeometry: {
ui: {
curveSegments: { type: 'range', min: 1, max: 30, },
},
@@ -405,7 +405,7 @@ return geometry;
shape.bezierCurveTo(x + 6, y + 7.7, x + 8, y + 4.5, x + 8, y + 3.5);
shape.bezierCurveTo(x + 8, y + 3.5, x + 8, y, x + 5, y);
shape.bezierCurveTo(x + 3.5, y, x + 2.5, y + 2.5, x + 2.5, y + 2.5);
- return new THREE.ShapeBufferGeometry(shape);
+ return new THREE.ShapeGeometry(shape);
},
create2(curveSegments = 5) {
const shape = new THREE.Shape();
@@ -418,10 +418,10 @@ return geometry;
shape.bezierCurveTo(x + 6, y + 7.7, x + 8, y + 4.5, x + 8, y + 3.5);
shape.bezierCurveTo(x + 8, y + 3.5, x + 8, y, x + 5, y);
shape.bezierCurveTo(x + 3.5, y, x + 2.5, y + 2.5, x + 2.5, y + 2.5);
- return new THREE.ShapeBufferGeometry(shape, curveSegments);
+ return new THREE.ShapeGeometry(shape, curveSegments);
},
},
- SphereBufferGeometry: {
+ SphereGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
widthSegments: { type: 'range', min: 1, max: 30, },
@@ -432,29 +432,29 @@ return geometry;
thetaLength: { type: 'range', min: 0, max: 1, mult: Math.PI },
},
create(radius = 7, widthSegments = 12, heightSegments = 8) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
create2(radius = 7, widthSegments = 12, heightSegments = 8, phiStart = Math.PI * 0.25, phiLength = Math.PI * 1.5, thetaStart = Math.PI * 0.25, thetaLength = Math.PI * 0.5) {
- return new THREE.SphereBufferGeometry(
+ return new THREE.SphereGeometry(
radius,
widthSegments, heightSegments,
phiStart, phiLength,
thetaStart, thetaLength);
},
},
- TetrahedronBufferGeometry: {
+ TetrahedronGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
detail: { type: 'range', min: 0, max: 5, precision: 0, },
},
create(radius = 7) {
- return new THREE.TetrahedronBufferGeometry(radius);
+ return new THREE.TetrahedronGeometry(radius);
},
create2(radius = 7, detail = 2) {
- return new THREE.TetrahedronBufferGeometry(radius, detail);
+ return new THREE.TetrahedronGeometry(radius, detail);
},
},
- TextBufferGeometry: {
+ TextGeometry: {
ui: {
text: { type: 'text', maxLength: 30, },
size: { type: 'range', min: 1, max: 10, precision: 1, },
@@ -471,7 +471,7 @@ return geometry;
create(text = 'three.js', size = 3, height = 0.2, curveSegments = 12, bevelEnabled = true, bevelThickness = 0.15, bevelSize = 0.3, bevelSegments = 5) {
return new Promise((resolve) => {
fontPromise.then((font) => {
- resolve(new THREE.TextBufferGeometry(text, {
+ resolve(new THREE.TextGeometry(text, {
font: font,
size,
height,
@@ -489,7 +489,7 @@ const loader = new THREE.FontLoader();
loader.load('../resources/threejs/fonts/helvetiker_regular.typeface.json', (font) => {
const text = 'three.js'; // ui: text
- const geometry = new THREE.TextBufferGeometry(text, {
+ const geometry = new THREE.TextGeometry(text, {
font: font,
size: 3, // ui: size
height: 0.2, // ui: height
@@ -503,20 +503,20 @@ loader.load('../resources/threejs/fonts/helvetiker_regular.typeface.json', (font
});
`,
},
- TorusBufferGeometry: {
+ TorusGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
tubeRadius: { type: 'range', min: 1, max: 10, precision: 1, },
radialSegments: { type: 'range', min: 1, max: 30, },
tubularSegments: { type: 'range', min: 1, max: 100, },
},
create(radius = 5, tubeRadius = 2, radialSegments = 8, tubularSegments = 24) {
- return new THREE.TorusBufferGeometry(
+ return new THREE.TorusGeometry(
radius, tubeRadius,
radialSegments, tubularSegments);
},
},
- TorusKnotBufferGeometry: {
+ TorusKnotGeometry: {
ui: {
radius: { type: 'range', min: 1, max: 10, precision: 1, },
tubeRadius: { type: 'range', min: 1, max: 10, precision: 1, },
@@ -526,11 +526,11 @@ loader.load('../resources/threejs/fonts/helvetiker_regular.typeface.json', (font
q: { type: 'range', min: 1, max: 20, },
},
create(radius = 3.5, tubeRadius = 1.5, radialSegments = 8, tubularSegments = 64, p = 2, q = 3) {
- return new THREE.TorusKnotBufferGeometry(
+ return new THREE.TorusKnotGeometry(
radius, tubeRadius, tubularSegments, radialSegments, p, q);
},
},
- TubeBufferGeometry: {
+ TubeGeometry: {
ui: {
tubularSegments: { type: 'range', min: 1, max: 100, },
radius: { type: 'range', min: 1, max: 10, precision: 1, },
@@ -552,7 +552,7 @@ loader.load('../resources/threejs/fonts/helvetiker_regular.typeface.json', (font
}
const path = new CustomSinCurve(4);
- return new THREE.TubeBufferGeometry(
+ return new THREE.TubeGeometry(
path, tubularSegments, radius, radialSegments, closed);
},
},
@@ -563,23 +563,22 @@ loader.load('../resources/threejs/fonts/helvetiker_regular.typeface.json', (font
create() {
return {
lineGeometry: new THREE.EdgesGeometry(
- new THREE.BoxBufferGeometry(8, 8, 8)),
+ new THREE.BoxGeometry(8, 8, 8)),
};
},
create2(thresholdAngle = 1) {
return {
lineGeometry: new THREE.EdgesGeometry(
- new THREE.SphereBufferGeometry(7, 6, 3), thresholdAngle),
+ new THREE.SphereGeometry(7, 6, 3), thresholdAngle),
};
},
- nonBuffer: false,
addConstCode: false,
src: `
const size = 8;
const widthSegments = 2;
const heightSegments = 2;
const depthSegments = 2;
-const boxGeometry = new THREE.BoxBufferGeometry(
+const boxGeometry = new THREE.BoxGeometry(
size, size, size,
widthSegments, heightSegments, depthSegments);
const geometry = new THREE.EdgesGeometry(boxGeometry);
@@ -588,7 +587,7 @@ const geometry = new THREE.EdgesGeometry(boxGeometry);
const radius = 7;
const widthSegments = 6;
const heightSegments = 3;
-const sphereGeometry = new THREE.SphereBufferGeometry(
+const sphereGeometry = new THREE.SphereGeometry(
radius, widthSegments, heightSegments);
const thresholdAngle = 1; // ui: thresholdAngle
const geometry = new THREE.EdgesGeometry(sphereGeometry, thresholdAngle);
@@ -603,20 +602,19 @@ const geometry = new THREE.EdgesGeometry(sphereGeometry, thresholdAngle);
create(widthSegments = 2, heightSegments = 2, depthSegments = 2) {
const size = 8;
return {
- lineGeometry: new THREE.WireframeGeometry(new THREE.BoxBufferGeometry(
+ lineGeometry: new THREE.WireframeGeometry(new THREE.BoxGeometry(
size, size, size,
widthSegments, heightSegments, depthSegments)),
};
},
- nonBuffer: false,
addConstCode: false,
src: `
const size = 8;
const widthSegments = 2; // ui: widthSegments
const heightSegments = 2; // ui: heightSegments
const depthSegments = 2; // ui: depthSegments
const geometry = new THREE.WireframeGeometry(
- new THREE.BoxBufferGeometry(
+ new THREE.BoxGeometry(
size, size, size,
widthSegments, heightSegments, depthSegments));
`,
@@ -626,7 +624,7 @@ const geometry = new THREE.WireframeGeometry(
const radius = 7;
const widthSegments = 12;
const heightSegments = 8;
- const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ const geometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
const material = new THREE.PointsMaterial({
color: 'red',
size: 0.2,
@@ -643,7 +641,7 @@ const geometry = new THREE.WireframeGeometry(
const radius = 7;
const widthSegments = 12;
const heightSegments = 8;
- const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ const geometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
const material = new THREE.PointsMaterial({
color: 'red',
size: 3 * window.devicePixelRatio,
@@ -656,50 +654,50 @@ const geometry = new THREE.WireframeGeometry(
};
},
},
- SphereBufferGeometryLow: {
+ SphereGeometryLow: {
create(radius = 7, widthSegments = 5, heightSegments = 3) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
},
- SphereBufferGeometryMedium: {
+ SphereGeometryMedium: {
create(radius = 7, widthSegments = 24, heightSegments = 10) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
},
- SphereBufferGeometryHigh: {
+ SphereGeometryHigh: {
create(radius = 7, widthSegments = 50, heightSegments = 50) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
},
- SphereBufferGeometryLowSmooth: {
+ SphereGeometryLowSmooth: {
create(radius = 7, widthSegments = 5, heightSegments = 3) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
showLines: false,
flatShading: false,
},
- SphereBufferGeometryMediumSmooth: {
+ SphereGeometryMediumSmooth: {
create(radius = 7, widthSegments = 24, heightSegments = 10) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
showLines: false,
flatShading: false,
},
- SphereBufferGeometryHighSmooth: {
+ SphereGeometryHighSmooth: {
create(radius = 7, widthSegments = 50, heightSegments = 50) {
- return new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ return new THREE.SphereGeometry(radius, widthSegments, heightSegments);
},
showLines: false,
flatShading: false,
},
- PlaneBufferGeometryLow: {
+ PlaneGeometryLow: {
create(width = 9, height = 9, widthSegments = 1, heightSegments = 1) {
- return new THREE.PlaneBufferGeometry(width, height, widthSegments, heightSegments);
+ return new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
},
},
- PlaneBufferGeometryHigh: {
+ PlaneGeometryHigh: {
create(width = 9, height = 9, widthSegments = 10, heightSegments = 10) {
- return new THREE.PlaneBufferGeometry(width, height, widthSegments, heightSegments);
+ return new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);
},
},
};
@@ -753,10 +751,6 @@ const geometry = new THREE.WireframeGeometry(
const right = addDiv(pair, 'desc');
addDeepLink(right, '#', `#${base.id}`);
addLink(right, name);
- if (info.nonBuffer !== false) {
- addElem(right, 'span', '', ', ');
- addLink(right, name.replace('Buffer', ''));
- }
addDiv(right, '.note').innerHTML = text;
// I get that this is super brittle. I think I'd have to | true |
Other | mrdoob | three.js | fbac88d731b85fc9b25c69ce7161edd2566ed40c.json | remove references to XXXBufferGeometry | threejs/lessons/ru/threejs-primitives.md | @@ -18,59 +18,31 @@ Three.js ะธะผะตะตั ะฑะพะปััะพะต ะบะพะปะธัะตััะฒะพ ะฟัะธะผะธัะธะฒะพะฒ. ะ
ัะพะทะดะฐะฝะธะต ะธ ะทะฐะณััะทะบั ะดะฐะฝะฝัั
ะธะท ะฝะตัะบะพะปัะบะธั
ะฟัะพะณัะฐะผะผ 3D-ะผะพะดะตะปะธัะพะฒะฐะฝะธั.
ะ ัะตะนัะฐั ะดะฐะฒะฐะนัะต ัะฐััะผะพััะธะผ ะฝะตะบะพัะพััะต ะธะท ะดะพัััะฟะฝัั
ะฟัะธะผะธัะธะฒะพะฒ.
-<div id="Diagram-BoxBufferGeometry" data-primitive="BoxBufferGeometry">ะััะผะพัะณะพะปัะฝัะน ะฟะฐัะฐะปะปะตะปะตะฟะธะฟะตะด</div>
-<div id="Diagram-CircleBufferGeometry" data-primitive="CircleBufferGeometry">ะััะณ</div>
-<div id="Diagram-ConeBufferGeometry" data-primitive="ConeBufferGeometry">ะะพะฝัั</div>
-<div id="Diagram-CylinderBufferGeometry" data-primitive="CylinderBufferGeometry">ะฆะธะปะธะฝะดั</div>
-<div id="Diagram-DodecahedronBufferGeometry" data-primitive="DodecahedronBufferGeometry">ะะพะดะตะบะฐัะดั (12 ะณัะฐะฝะตะน)</div>
-<div id="Diagram-ExtrudeBufferGeometry" data-primitive="ExtrudeBufferGeometry">ะัะดะฐะฒะปะตะฝะฝะฐั 2d ัะธะณััะฐ ั ัะบััะณะปะตะฝะฝัะผะธ ะบัะฐัะผะธ.
+<div id="Diagram-BoxGeometry" data-primitive="BoxGeometry">ะััะผะพัะณะพะปัะฝัะน ะฟะฐัะฐะปะปะตะปะตะฟะธะฟะตะด</div>
+<div id="Diagram-CircleGeometry" data-primitive="CircleGeometry">ะััะณ</div>
+<div id="Diagram-ConeGeometry" data-primitive="ConeGeometry">ะะพะฝัั</div>
+<div id="Diagram-CylinderGeometry" data-primitive="CylinderGeometry">ะฆะธะปะธะฝะดั</div>
+<div id="Diagram-DodecahedronGeometry" data-primitive="DodecahedronGeometry">ะะพะดะตะบะฐัะดั (12 ะณัะฐะฝะตะน)</div>
+<div id="Diagram-ExtrudeGeometry" data-primitive="ExtrudeGeometry">ะัะดะฐะฒะปะตะฝะฝะฐั 2d ัะธะณััะฐ ั ัะบััะณะปะตะฝะฝัะผะธ ะบัะฐัะผะธ.
ะะดะตัั ะผั ะฒัะดะฐะฒะปะธะฒะฐะตะผ ัะพัะผั ัะตัะดัะฐ. ะะฑัะฐัะธัะต ะฒะฝะธะผะฐะฝะธะต, ััะพ ะพัะฝะพะฒะฐ
-ะดะปั <code>TextBufferGeometry</code> ะธ <code>TextGeometry</code> ัะพะพัะฒะตัััะฒะตะฝะฝะพ.</div>
-<div id="Diagram-IcosahedronBufferGeometry" data-primitive="IcosahedronBufferGeometry">ะะบะพัะฐัะดั (20 ะณัะฐะฝะตะน)</div>
-<div id="Diagram-LatheBufferGeometry" data-primitive="LatheBufferGeometry">ะคะพัะผะฐ, ัะพะทะดะฐะฝะฝะฐั ะฒัะฐัะตะฝะธะตะผ ะปะธะฝะธะธ. ะะฐะฟัะธะผะตั, ะปะฐะผะฟั, ะบะตะณะปะธ ะดะปั ะฑะพัะปะธะฝะณะฐ, ัะฒะตัะธ, ะฟะพะดัะฒะตัะฝะธะบะธ, ะฑะพะบะฐะปั ะดะปั ะฒะธะฝะฐ, ััะฐะบะฐะฝั ะดะปั ะฟะธััั ะธ ั. ะ. ะั ัะบะฐะทัะฒะฐะตัะต 2-ะผะตัะฝัะน ัะธะปััั ะฒ ะฒะธะดะต ัะตัะธะธ ัะพัะตะบ, ะฐ ะทะฐัะตะผ ัะบะฐะทัะฒะฐะตัะต three.js , ัะบะพะปัะบะพ ัะตะบัะธะน ะฝัะถะฝะพ ัะดะตะปะฐัั, ะบะพะณะดะฐ ะพะฝ ะฒัะฐัะฐะตั ัะธะปััั ะฒะพะบััะณ ะพัะธ.</div>
-<div id="Diagram-OctahedronBufferGeometry" data-primitive="OctahedronBufferGeometry">ะะบัะฐัะดั (8 ะณัะฐะฝะตะน)</div>
-<div id="Diagram-ParametricBufferGeometry" data-primitive="ParametricBufferGeometry">ะะพะฒะตัั
ะฝะพััั, ัะพะทะดะฐะฝะฝะฐั ะฟััะตะผ ะฟัะตะดะพััะฐะฒะปะตะฝะธั ััะฝะบัะธะธ, ะบะพัะพัะฐั ะฑะตัะตั 2d ัะพัะบั ะธะท ัะตัะบะธ ะธ ะฒะพะทะฒัะฐัะฐะตั ัะพะพัะฒะตัััะฒััััั 3d ัะพัะบั.</div>
-<div id="Diagram-PlaneBufferGeometry" data-primitive="PlaneBufferGeometry">2D ะฟะปะพัะบะพััั</div>
-<div id="Diagram-PolyhedronBufferGeometry" data-primitive="PolyhedronBufferGeometry">ะะตัะตั ะฝะฐะฑะพั ััะตัะณะพะปัะฝะธะบะพะฒ ั ัะตะฝััะพะผ ะฒะพะบััะณ ัะพัะบะธ ะธ ะฟัะพะตัะธััะตั ะธั
ะฝะฐ ััะตัั</div>
-<div id="Diagram-RingBufferGeometry" data-primitive="RingBufferGeometry">2D ะดะธัะบ ั ะพัะฒะตัััะธะตะผ ะฒ ัะตะฝััะต</div>
-<div id="Diagram-ShapeBufferGeometry" data-primitive="ShapeBufferGeometry">2D ะบะพะฝััั, ะบะพัะพััะน ัััะพะธััั ะธะท ััะตัะณะพะปัะฝะธะบะพะฒ</div>
-<div id="Diagram-SphereBufferGeometry" data-primitive="SphereBufferGeometry">ะกัะตัะฐ</div>
-<div id="Diagram-TetrahedronBufferGeometry" data-primitive="TetrahedronBufferGeometry">ะขะตัะฐัะดั (4 ะณัะฐะฝะธ)</div>
-<div id="Diagram-TextBufferGeometry" data-primitive="TextBufferGeometry">3D-ัะตะบัั, ัะณะตะฝะตัะธัะพะฒะฐะฝะฝัะน ะธะท 3D-ััะธััะฐ ะธ ัััะพะบะธ</div>
-<div id="Diagram-TorusBufferGeometry" data-primitive="TorusBufferGeometry">ะขะพั (ะฟะพะฝัะธะบ)</div>
-<div id="Diagram-TorusKnotBufferGeometry" data-primitive="TorusKnotBufferGeometry">ะขะพัะธัะตัะบะธะน ัะทะตะป</div>
-<div id="Diagram-TubeBufferGeometry" data-primitive="TubeBufferGeometry">ะขััะฑะฐ - ะบััะณ ะฟัะพั
ะพะดััะธะน ะฟััั</div>
+ะดะปั <code>TextGeometry</code> ะธ <code>TextGeometry</code> ัะพะพัะฒะตัััะฒะตะฝะฝะพ.</div>
+<div id="Diagram-IcosahedronGeometry" data-primitive="IcosahedronGeometry">ะะบะพัะฐัะดั (20 ะณัะฐะฝะตะน)</div>
+<div id="Diagram-LatheGeometry" data-primitive="LatheGeometry">ะคะพัะผะฐ, ัะพะทะดะฐะฝะฝะฐั ะฒัะฐัะตะฝะธะตะผ ะปะธะฝะธะธ. ะะฐะฟัะธะผะตั, ะปะฐะผะฟั, ะบะตะณะปะธ ะดะปั ะฑะพัะปะธะฝะณะฐ, ัะฒะตัะธ, ะฟะพะดัะฒะตัะฝะธะบะธ, ะฑะพะบะฐะปั ะดะปั ะฒะธะฝะฐ, ััะฐะบะฐะฝั ะดะปั ะฟะธััั ะธ ั. ะ. ะั ัะบะฐะทัะฒะฐะตัะต 2-ะผะตัะฝัะน ัะธะปััั ะฒ ะฒะธะดะต ัะตัะธะธ ัะพัะตะบ, ะฐ ะทะฐัะตะผ ัะบะฐะทัะฒะฐะตัะต three.js , ัะบะพะปัะบะพ ัะตะบัะธะน ะฝัะถะฝะพ ัะดะตะปะฐัั, ะบะพะณะดะฐ ะพะฝ ะฒัะฐัะฐะตั ัะธะปััั ะฒะพะบััะณ ะพัะธ.</div>
+<div id="Diagram-OctahedronGeometry" data-primitive="OctahedronGeometry">ะะบัะฐัะดั (8 ะณัะฐะฝะตะน)</div>
+<div id="Diagram-ParametricGeometry" data-primitive="ParametricGeometry">ะะพะฒะตัั
ะฝะพััั, ัะพะทะดะฐะฝะฝะฐั ะฟััะตะผ ะฟัะตะดะพััะฐะฒะปะตะฝะธั ััะฝะบัะธะธ, ะบะพัะพัะฐั ะฑะตัะตั 2d ัะพัะบั ะธะท ัะตัะบะธ ะธ ะฒะพะทะฒัะฐัะฐะตั ัะพะพัะฒะตัััะฒััััั 3d ัะพัะบั.</div>
+<div id="Diagram-PlaneGeometry" data-primitive="PlaneGeometry">2D ะฟะปะพัะบะพััั</div>
+<div id="Diagram-PolyhedronGeometry" data-primitive="PolyhedronGeometry">ะะตัะตั ะฝะฐะฑะพั ััะตัะณะพะปัะฝะธะบะพะฒ ั ัะตะฝััะพะผ ะฒะพะบััะณ ัะพัะบะธ ะธ ะฟัะพะตัะธััะตั ะธั
ะฝะฐ ััะตัั</div>
+<div id="Diagram-RingGeometry" data-primitive="RingGeometry">2D ะดะธัะบ ั ะพัะฒะตัััะธะตะผ ะฒ ัะตะฝััะต</div>
+<div id="Diagram-ShapeGeometry" data-primitive="ShapeGeometry">2D ะบะพะฝััั, ะบะพัะพััะน ัััะพะธััั ะธะท ััะตัะณะพะปัะฝะธะบะพะฒ</div>
+<div id="Diagram-SphereGeometry" data-primitive="SphereGeometry">ะกัะตัะฐ</div>
+<div id="Diagram-TetrahedronGeometry" data-primitive="TetrahedronGeometry">ะขะตัะฐัะดั (4 ะณัะฐะฝะธ)</div>
+<div id="Diagram-TextGeometry" data-primitive="TextGeometry">3D-ัะตะบัั, ัะณะตะฝะตัะธัะพะฒะฐะฝะฝัะน ะธะท 3D-ััะธััะฐ ะธ ัััะพะบะธ</div>
+<div id="Diagram-TorusGeometry" data-primitive="TorusGeometry">ะขะพั (ะฟะพะฝัะธะบ)</div>
+<div id="Diagram-TorusKnotGeometry" data-primitive="TorusKnotGeometry">ะขะพัะธัะตัะบะธะน ัะทะตะป</div>
+<div id="Diagram-TubeGeometry" data-primitive="TubeGeometry">ะขััะฑะฐ - ะบััะณ ะฟัะพั
ะพะดััะธะน ะฟััั</div>
<div id="Diagram-EdgesGeometry" data-primitive="EdgesGeometry">ะัะฟะพะผะพะณะฐัะตะปัะฝัะน ะพะฑัะตะบั, ะบะพัะพััะน ะฟัะธะฝะธะผะฐะตั ะดััะณัั ะณะตะพะผะตััะธั ะฒ ะบะฐัะตััะฒะต ะฒั
ะพะดะฝัั
ะดะฐะฝะฝัั
ะธ ะณะตะฝะตัะธััะตั ัะตะฑัะฐ, ัะพะปัะบะพ ะตัะปะธ ัะณะพะป ะผะตะถะดั ะณัะฐะฝัะผะธ ะฑะพะปััะต ะฝะตะบะพัะพัะพะณะพ ะฟะพัะพะณะฐ. ะะฐะฟัะธะผะตั, ะตัะปะธ ะฒั ะฟะพัะผะพััะธัะต ะฝะฐ ะฟััะผะพัะณะพะปัะฝะธะบ ัะฒะตัั
ั, ะพะฝ ะฟะพะบะฐะทัะฒะฐะตั ะปะธะฝะธั, ะฟัะพั
ะพะดัััั ัะตัะตะท ะบะฐะถะดัั ะณัะฐะฝั, ะฟะพะบะฐะทัะฒะฐั ะบะฐะถะดัะน ััะตัะณะพะปัะฝะธะบ, ะธะท ะบะพัะพัะพะณะพ ัะพััะพะธั ะฟััะผะพัะณะพะปัะฝะธะบ. ะัะฟะพะปัะทัั EdgesGeometry, ะฒะผะตััะพ ััะพะณะพ ัะดะฐะปััััั ััะตะดะฝะธะต ะปะธะฝะธะธ.</div>
<div id="Diagram-WireframeGeometry" data-primitive="WireframeGeometry">ะกะพะทะดะฐะตั ะณะตะพะผะตััะธั, ะบะพัะพัะฐั ัะพะดะตัะถะธั ะพะดะธะฝ ะพััะตะทะพะบ (2 ัะพัะบะธ) ะฝะฐ ัะตะฑัะพ ะฒ ะทะฐะดะฐะฝะฝะพะน ะณะตะพะผะตััะธะธ. ะะตะท ััะพะณะพ ะฒั ัะฐััะพ ัะตััะตัะต ัะตะฑัะฐ ะธะปะธ ะฟะพะปััะฐะตัะต ะดะพะฟะพะปะฝะธัะตะปัะฝัะต ัะตะฑัะฐ, ะฟะพัะบะพะปัะบั WebGL ะพะฑััะฝะพ ััะตะฑัะตั 2 ัะพัะบะธ ะฝะฐ ะพััะตะทะพะบ. ะะฐะฟัะธะผะตั, ะตัะปะธ ะฑั ั ะฒะฐั ะฑัะป ัะพะปัะบะพ ะพะดะธะฝ ััะตัะณะพะปัะฝะธะบ, ะฑัะปะพ ะฑั ัะพะปัะบะพ 3 ะพัะบะฐ. ะัะปะธ ะฒั ะฟะพะฟััะฐะตัะตัั ะฝะฐัะธัะพะฒะฐัั ะตะณะพ, ะธัะฟะพะปัะทัั ะผะฐัะตัะธะฐะป ั <code>wireframe: true</code> ะฒั ะฟะพะปััะธัะต ัะพะปัะบะพ ะพะดะฝั ะปะธะฝะธั. ะ ะฟะตัะตะดะฐัะฐ ััะพะน triangle geometry ะฒ <code>WireframeGeometry</code> ัะพะทะดะฐัั ะฝะพะฒัั ะณะตะพะผะตััะธั, ะบะพัะพัะฐั ะธะผะตะตั 3 ะพััะตะทะบะฐ ะปะธะฝะธะน, ะธัะฟะพะปัะทัั 6 ัะพัะตะบ..</div>
-ะั ะผะพะถะตัะต ะทะฐะผะตัะธัั, ััะพ ะฑะพะปััะธะฝััะฒะพ ะธะท ะฝะธั
ะฟัะธั
ะพะดัั ะฟะฐัะฐะผะธ `Geometry`
-ะธะปะธ `BufferGeometry`. ะ ะฐะทะฝะธัะฐ ะผะตะถะดั ััะธะผะธ ะดะฒัะผั ัะธะฟะฐะผะธ ะทะฐะบะปััะฐะตััั
-ะฒ ะณะธะฑะบะพััะธ ะธ ะฟัะพะธะทะฒะพะดะธัะตะปัะฝะพััะธ.
-
-`BufferGeometry` ะพัะฝะพะฒะฐะฝะฝัะต ะฝะฐ ะฟัะธะผะธัะธะฒะฐั
ัะธะฟั ะพัะธะตะฝัะธัะพะฒะฐะฝั ะฝะฐ ะฟัะพะธะทะฒะพะดะธัะตะปัะฝะพััั.
-ะะตััะธะฝั ะดะปั ะณะตะพะผะตััะธะธ ะณะตะฝะตัะธัััััั ะฝะตะฟะพััะตะดััะฒะตะฝะฝะพ ะฒ ัััะตะบัะธะฒะฝัะน ัะพัะผะฐั
-ัะธะฟะธะทะธัะพะฒะฐะฝะฝะพะณะพ ะผะฐััะธะฒะฐ, ะณะพัะพะฒัะน ะดะปั ะทะฐะณััะทะบะธ ะฒ ะณัะฐัะธัะตัะบะธะน ะฟัะพัะตััะพั
-ะดะปั ัะตะฝะดะตัะธะฝะณะฐ. ะญัะพ ะพะทะฝะฐัะฐะตั, ััะพ ะพะฝะธ ะฑััััะตะต ะทะฐะฟััะบะฐัััั ะธ ะทะฐะฝะธะผะฐัั
-ะผะตะฝััะต ะฟะฐะผััะธ, ะฝะพ ะตัะปะธ ะฒั ั
ะพัะธัะต ะธะทะผะตะฝะธัั ะธั
ะดะฐะฝะฝัะต, ะพะฝะธ ะฑะตััั ัะพ,
-ััะพ ัะฐััะพ ััะธัะฐะตััั ะฑะพะปะตะต ัะปะพะถะฝัะผ ะฟัะพะณัะฐะผะผะธัะพะฒะฐะฝะธะตะผ ะดะปั ะผะฐะฝะธะฟัะปะธัะพะฒะฐะฝะธั.
-
-`Geometry` ะพัะฝะพะฒะฐะฝะฝัะต ะฝะฐ ะฟัะธะผะธัะธะฒะฐั
ัะฒะปััััั ะฑะพะปะตะต ะณะธะฑะบะธะผะธ, ะปะตะณัะต ะผะฐะฝะธะฟัะปะธัะพะฒะฐัั ัะธะฟะพะผ.
-ะะฝะธ ะฟะพัััะพะตะฝั ะฝะฐ ะพัะฝะพะฒะต ะบะปะฐััะพะฒ JavaScript, ัะฐะบะธั
ะบะฐะบ `Vector3` ะดะปั 3D-ัะพัะบะธ, `Face3`
-ะดะปั ััะตัะณะพะปัะฝะธะบะพะฒ. ะะฝะธ ะทะฐะฝะธะผะฐัั ะฝะตะผะฝะพะณะพ ะฟะฐะผััะธ, ะธ ะฟัะตะถะดะต ัะตะผ ะธั
ะผะพะถะฝะพ ะฑัะดะตั ะพัะพะฑัะฐะทะธัั,
-ะฝัะถะฝะพ ะฑัะดะตั ะฟัะตะพะฑัะฐะทะพะฒะฐัั ะธั
ะฒะพ ััะพ-ัะพ ะฟะพั
ะพะถะตะต ะฝะฐ ัะพะพัะฒะตัััะฒัััะตะต
-`BufferGeometry` ะฟัะตะดััะฐะฒะปะตะฝะธะต.
-
-ะัะปะธ ะฒั ะทะฝะฐะตัะต, ััะพ ะฝะต ัะพะฑะธัะฐะตัะตัั ะผะฐะฝะธะฟัะปะธัะพะฒะฐัั ะฟัะธะผะธัะธะฒะพะผ ะธะปะธ ะตัะปะธ ะฒะฐะผ ัะดะพะฑะฝะพ
-ะฒัะฟะพะปะฝััั ะผะฐัะตะผะฐัะธะบั ะฝะฐ ะฟััะผัั, ััะพะฑั ะผะฐะฝะธะฟัะปะธัะพะฒะฐัั ะธั
ะฒะฝัััะตะฝะฝะพัััะผะธ, ัะพ ะปัััะต
-ะธัะฟะพะปัะทะพะฒะฐัั ะพัะฝะพะฒะฐะฝะฝัะต ะฝะฐ `BufferGeometry` ะฟัะธะผะธัะธะฒั.
-ะัะปะธ, ั ะดััะณะพะน ััะพัะพะฝั, ะฒั ั
ะพัะธัะต ะธะทะผะตะฝะธัั ะฝะตะบะพัะพััะต ะฒะตัะธ ะฟะตัะตะด ัะตะฝะดะตัะธะฝะณะพะผ,
-ะฒะฐะผ ะผะพะถะตั ะฑััั ะฟัะพัะต ัะฐะฑะพัะฐัั ั ะฟัะธะผะธัะธะฒะฐะผะธ ะพัะฝะพะฒะฐะฝะฝัะผะธ ะฝะฐ `Geometry`.
-
-ะ ะบะฐัะตััะฒะต ะฟัะพััะพะณะพ ะฟัะธะผะตัะฐ ะฒ `BufferGeometry` ะฝะต ะผะพะณัั ะฑััั ะปะตะณะบะพ ะดะพะฑะฐะฒะปะตะฝั ะฝะพะฒัะต ะฒะตััะธะฝั.
-ะะพะปะธัะตััะฒะพ ะธัะฟะพะปัะทัะตะผัั
ะฒะตััะธะฝ ะพะฟัะตะดะตะปัะตััั ะฒะพ ะฒัะตะผั ัะพะทะดะฐะฝะธั, ัะพะทะดะฐะตััั
-ั
ัะฐะฝะธะปะธัะต, ะฐ ะทะฐัะตะผ ะทะฐะฟะพะปะฝััััั ะดะฐะฝะฝัะต ะดะปั ะฒะตััะธะฝ. ะ ัะพ ะฒัะตะผั ะบะฐะบ ั `Geometry`
-ะฒั ะผะพะถะตัะต ะดะพะฑะฐะฒะปััั ะฒะตััะธะฝั ะฟะพ ะผะตัะต ะฝะตะพะฑั
ะพะดะธะผะพััะธ.
-
ะั ัะฐััะผะพััะธะผ ัะพะทะดะฐะฝะธะต ะฟะพะปัะทะพะฒะฐัะตะปััะบะพะน ะณะตะพะผะตััะธะธ ะฒ ะดััะณะพะน ััะฐััะต.
ะ ะฟะพะบะฐ ะดะฐะฒะฐะนัะต ัะพะทะดะฐะดะธะผ ะฟัะธะผะตั ัะพะทะดะฐะฝะธั ะบะฐะถะดะพะณะพ ัะธะฟะฐ ะฟัะธะผะธัะธะฒะฐ.
ะะฐัะฝะตะผ ั [ะฟัะธะผะตัะพะฒ ะธะท ะฟัะตะดัะดััะตะน ััะฐััะธ](threejs-responsive.html).
@@ -145,7 +117,7 @@ function createMaterial() {
ัะฐะบะพะน ะบะฐะบ ััะตัะฐ ะธะปะธ ะบัะฑ, ะพะฑััะฝะพ ะฝะตั ะฟัะธัะธะฝ ัะธัะพะฒะฐัั
ะทะฐะดะฝะธะต ััะพัะพะฝั ััะตัะณะพะปัะฝะธะบะพะฒ, ะฟะพัะบะพะปัะบั ะฒัะต ะพะฝะธ ะพะฑัะฐัะตะฝั
ะฒะฝัััั ัะธะณััั. ะ ะฝะฐัะตะผ ัะปััะฐะต ะผั ัะธััะตะผ ะฝะตัะบะพะปัะบะพ ะฒะตัะตะน,
-ัะฐะบะธั
ะบะฐะบ `PlaneBufferGeometry` ะธ `ShapeBufferGeometry`
+ัะฐะบะธั
ะบะฐะบ `PlaneGeometry` ะธ `ShapeGeometry`
ะบะพัะพััะต ัะฒะปััััั ะดะฒัั
ะผะตัะฝัะผะธ ะธ ะฟะพััะพะผั ะฝะต ะธะผะตัั ะฒะฝัััะตะฝะฝะตะน
ัะฐััะธ. ะะตะท ัััะฐะฝะพะฒะบะธ `side: THREE.DoubleSide` ะพะฝะธ ะธััะตะทะฝัั,
ะฟัะธ ะฒะทะณะปัะดะต ะฝะฐ ะธั
ะทะฐะดะฝะธะต ััะพัะพะฝั.
@@ -175,7 +147,7 @@ function addSolidGeometry(x, y, geometry) {
const width = 8;
const height = 8;
const depth = 8;
- addSolidGeometry(-2, -2, new THREE.BoxBufferGeometry(width, height, depth));
+ addSolidGeometry(-2, -2, new THREE.BoxGeometry(width, height, depth));
}
```
@@ -187,7 +159,7 @@ function addSolidGeometry(x, y, geometry) {
{{{example url="../threejs-primitives.html" }}}
ะััั ะฝะตัะบะพะปัะบะพ ะทะฐะผะตัะฝัั
ะธัะบะปััะตะฝะธะน ะธะท ัะฐะฑะปะพะฝะฐ ะฒััะต.
-ะกะฐะผัะผ ะฑะพะปััะธะผ, ะฒะตัะพััะฝะพ, ัะฒะปัะตััั `TextBufferGeometry`. ะะฝ ะดะพะปะถะตะฝ
+ะกะฐะผัะผ ะฑะพะปััะธะผ, ะฒะตัะพััะฝะพ, ัะฒะปัะตััั `TextGeometry`. ะะฝ ะดะพะปะถะตะฝ
ะทะฐะณััะทะธัั ะดะฐะฝะฝัะต 3D ััะธััะฐ, ะฟัะตะถะดะต ัะตะผ ะพะฝ ัะผะพะถะตั ัะณะตะฝะตัะธัะพะฒะฐัั
ัะตัะบั ะดะปั ัะตะบััะฐ. ะญัะธ ะดะฐะฝะฝัะต ะทะฐะณััะถะฐัััั ะฐัะธะฝั
ัะพะฝะฝะพ, ะฟะพััะพะผั
ะฝะฐะผ ะฝัะถะฝะพ ะดะพะถะดะฐัััั ะธั
ะทะฐะณััะทะบะธ, ะฟัะตะถะดะต ัะตะผ ะฟััะฐัััั ัะพะทะดะฐัั
@@ -201,7 +173,7 @@ function addSolidGeometry(x, y, geometry) {
{
const loader = new THREE.FontLoader();
loader.load('../resources/threejs/fonts/helvetiker_regular.typeface.json', (font) => {
- const geometry = new THREE.TextBufferGeometry('three.js', {
+ const geometry = new THREE.TextGeometry('three.js', {
font: font,
size: 3.0,
height: .2,
@@ -279,9 +251,9 @@ function addLineGeometry(x, y, geometry) {
ะะฐะฟัะธะผะตั
<div class="spread">
-<div data-diagram="SphereBufferGeometryLow"></div>
-<div data-diagram="SphereBufferGeometryMedium"></div>
-<div data-diagram="SphereBufferGeometryHigh"></div>
+<div data-diagram="SphereGeometryLow"></div>
+<div data-diagram="SphereGeometryMedium"></div>
+<div data-diagram="SphereGeometryHigh"></div>
</div>
ะะตัะฒะฐั ััะตัะฐ ะธะผะตะตั 5 ัะตะณะผะตะฝัะพะฒ ะฒะพะบััะณ ะธ 3 ะฒััะพัั, ััะพ ัะพััะฐะฒะปัะตั 15 ัะตะณะผะตะฝัะพะฒ
@@ -294,9 +266,9 @@ function addLineGeometry(x, y, geometry) {
ะธ ะผั ะฟะพะปััะธะผ ััะพ
<div class="spread">
-<div data-diagram="SphereBufferGeometryLowSmooth"></div>
-<div data-diagram="SphereBufferGeometryMediumSmooth"></div>
-<div data-diagram="SphereBufferGeometryHighSmooth"></div>
+<div data-diagram="SphereGeometryLowSmooth"></div>
+<div data-diagram="SphereGeometryMediumSmooth"></div>
+<div data-diagram="SphereGeometryHighSmooth"></div>
</div>
ะกะตะนัะฐั ะฝะต ะพัะตะฝั ะฟะพะฝััะฝะพ, ััะพ ัะพั, ะบะพัะพััะน ัะฟัะฐะฒะฐ ั 5000 ััะตัะณะพะปัะฝะธะบะฐะผะธ,
@@ -312,8 +284,8 @@ function addLineGeometry(x, y, geometry) {
ะะฝะพะณะดะฐ ะฒัะฑัะฐัั ะปะตะณะบะพ. ะะฐะฟัะธะผะตั, ะฒั ะผะพะถะตัะต ะฒัะฑัะฐัั ัะฐะทะดะตะปะตะฝะธะต ะดะปั ะฟะปะพัะบะพััะธ.
<div class="spread">
-<div data-diagram="PlaneBufferGeometryLow"></div>
-<div data-diagram="PlaneBufferGeometryHigh"></div>
+<div data-diagram="PlaneGeometryLow"></div>
+<div data-diagram="PlaneGeometryHigh"></div>
</div>
ะะปะพัะบะพััั ัะปะตะฒะฐ - ััะพ 2 ััะตัะณะพะปัะฝะธะบะฐ. ะะปะพัะบะพััั ัะฟัะฐะฒะฐ - ััะพ 200 ััะตัะณะพะปัะฝะธะบะพะฒ. | true |
Other | mrdoob | three.js | fbac88d731b85fc9b25c69ce7161edd2566ed40c.json | remove references to XXXBufferGeometry | threejs/lessons/threejs-primitives.md | @@ -24,62 +24,32 @@ primitives.
Many of the primitives below have defaults for some or all of their
parameters so you can use more or less depending on your needs.
-<div id="Diagram-BoxBufferGeometry" data-primitive="BoxBufferGeometry">A Box</div>
-<div id="Diagram-CircleBufferGeometry" data-primitive="CircleBufferGeometry">A flat circle</div>
-<div id="Diagram-ConeBufferGeometry" data-primitive="ConeBufferGeometry">A Cone</div>
-<div id="Diagram-CylinderBufferGeometry" data-primitive="CylinderBufferGeometry">A Cylinder</div>
-<div id="Diagram-DodecahedronBufferGeometry" data-primitive="DodecahedronBufferGeometry">A dodecahedron (12 sides)</div>
-<div id="Diagram-ExtrudeBufferGeometry" data-primitive="ExtrudeBufferGeometry">An extruded 2d shape with optional bevelling.
+<div id="Diagram-BoxGeometry" data-primitive="BoxGeometry">A Box</div>
+<div id="Diagram-CircleGeometry" data-primitive="CircleGeometry">A flat circle</div>
+<div id="Diagram-ConeGeometry" data-primitive="ConeGeometry">A Cone</div>
+<div id="Diagram-CylinderGeometry" data-primitive="CylinderGeometry">A Cylinder</div>
+<div id="Diagram-DodecahedronGeometry" data-primitive="DodecahedronGeometry">A dodecahedron (12 sides)</div>
+<div id="Diagram-ExtrudeGeometry" data-primitive="ExtrudeGeometry">An extruded 2d shape with optional bevelling.
Here we are extruding a heart shape. Note this is the basis
-for <code>TextBufferGeometry</code> and <code>TextGeometry</code> respectively.</div>
-<div id="Diagram-IcosahedronBufferGeometry" data-primitive="IcosahedronBufferGeometry">An icosahedron (20 sides)</div>
-<div id="Diagram-LatheBufferGeometry" data-primitive="LatheBufferGeometry">A shape generated by spinning a line. Examples would be: lamps, bowling pins, candles, candle holders, wine glasses, drinking glasses, etc... You provide the 2d silhouette as series of points and then tell three.js how many subdivisions to make as it spins the silhouette around an axis.</div>
-<div id="Diagram-OctahedronBufferGeometry" data-primitive="OctahedronBufferGeometry">An Octahedron (8 sides)</div>
-<div id="Diagram-ParametricBufferGeometry" data-primitive="ParametricBufferGeometry">A surface generated by providing a function that takes a 2D point from a grid and returns the corresponding 3d point.</div>
-<div id="Diagram-PlaneBufferGeometry" data-primitive="PlaneBufferGeometry">A 2D plane</div>
-<div id="Diagram-PolyhedronBufferGeometry" data-primitive="PolyhedronBufferGeometry">Takes a set of triangles centered around a point and projects them onto a sphere</div>
-<div id="Diagram-RingBufferGeometry" data-primitive="RingBufferGeometry">A 2D disc with a hole in the center</div>
-<div id="Diagram-ShapeBufferGeometry" data-primitive="ShapeBufferGeometry">A 2D outline that gets triangulated</div>
-<div id="Diagram-SphereBufferGeometry" data-primitive="SphereBufferGeometry">A sphere</div>
-<div id="Diagram-TetrahedronBufferGeometry" data-primitive="TetrahedronBufferGeometry">A tetrahedron (4 sides)</div>
-<div id="Diagram-TextBufferGeometry" data-primitive="TextBufferGeometry">3D text generated from a 3D font and a string</div>
-<div id="Diagram-TorusBufferGeometry" data-primitive="TorusBufferGeometry">A torus (donut)</div>
-<div id="Diagram-TorusKnotBufferGeometry" data-primitive="TorusKnotBufferGeometry">A torus knot</div>
-<div id="Diagram-TubeBufferGeometry" data-primitive="TubeBufferGeometry">A circle traced down a path</div>
+for <code>TextGeometry</code> and <code>TextGeometry</code> respectively.</div>
+<div id="Diagram-IcosahedronGeometry" data-primitive="IcosahedronGeometry">An icosahedron (20 sides)</div>
+<div id="Diagram-LatheGeometry" data-primitive="LatheGeometry">A shape generated by spinning a line. Examples would be: lamps, bowling pins, candles, candle holders, wine glasses, drinking glasses, etc... You provide the 2d silhouette as series of points and then tell three.js how many subdivisions to make as it spins the silhouette around an axis.</div>
+<div id="Diagram-OctahedronGeometry" data-primitive="OctahedronGeometry">An Octahedron (8 sides)</div>
+<div id="Diagram-ParametricGeometry" data-primitive="ParametricGeometry">A surface generated by providing a function that takes a 2D point from a grid and returns the corresponding 3d point.</div>
+<div id="Diagram-PlaneGeometry" data-primitive="PlaneGeometry">A 2D plane</div>
+<div id="Diagram-PolyhedronGeometry" data-primitive="PolyhedronGeometry">Takes a set of triangles centered around a point and projects them onto a sphere</div>
+<div id="Diagram-RingGeometry" data-primitive="RingGeometry">A 2D disc with a hole in the center</div>
+<div id="Diagram-ShapeGeometry" data-primitive="ShapeGeometry">A 2D outline that gets triangulated</div>
+<div id="Diagram-SphereGeometry" data-primitive="SphereGeometry">A sphere</div>
+<div id="Diagram-TetrahedronGeometry" data-primitive="TetrahedronGeometry">A tetrahedron (4 sides)</div>
+<div id="Diagram-TextGeometry" data-primitive="TextGeometry">3D text generated from a 3D font and a string</div>
+<div id="Diagram-TorusGeometry" data-primitive="TorusGeometry">A torus (donut)</div>
+<div id="Diagram-TorusKnotGeometry" data-primitive="TorusKnotGeometry">A torus knot</div>
+<div id="Diagram-TubeGeometry" data-primitive="TubeGeometry">A circle traced down a path</div>
<div id="Diagram-EdgesGeometry" data-primitive="EdgesGeometry">A helper object that takes another geometry as input and generates edges only if the angle between faces is greater than some threshold. For example if you look at the box at the top it shows a line going through each face showing every triangle that makes the box. Using an <code>EdgesGeometry</code> instead the middle lines are removed. Adjust the thresholdAngle below and you'll see the edges below that threshold disappear.</div>
<div id="Diagram-WireframeGeometry" data-primitive="WireframeGeometry">Generates geometry that contains one line segment (2 points) per edge in the given geometry. Without this you'd often be missing edges or get extra edges since WebGL generally requires 2 points per line segment. For example if all you had was a single triangle there would only be 3 points. If you tried to draw it using a material with <code>wireframe: true</code> you would only get a single line. Passing that triangle geometry to a <code>WireframeGeometry</code> will generate a new geometry that has 3 lines segments using 6 points..</div>
-You might notice of most of them come in pairs of `Geometry`
-or `BufferGeometry`. The difference between the 2 types is effectively flexibility
-vs performance.
-
-`BufferGeometry` based primitives are the performance oriented
-types. The vertices for the geometry are generated directly
-into an efficient typed array format ready to be uploaded to the GPU
-for rendering. This means they are faster to start up
-and take less memory but if you want to modify their
-data they take what is often considered more complex
-programming to manipulate.
-
-`Geometry` based primitives are the more flexible, easier to manipulate
-type. They are built from JavaScript based classes like `Vector3` for
-3D points, `Face3` for triangles.
-They take quite a bit of memory and before they can be rendered three.js will need to
-convert them to something similar to the corresponding `BufferGeometry` representation.
-
-If you know you are not going to manipulate a primitive or
-if you're comfortable doing the math to manipulate their
-internals then it's best to go with the `BufferGeometry`
-based primitives. If on the other hand you want to change
-a few things before rendering you might find the `Geometry`
-based primitives easier to deal with.
-
-As an simple example a `BufferGeometry`
-can not have new vertices easily added. The number of vertices used is
-decided at creation time, storage is created, and then data for vertices
-are filled in. Whereas for `Geometry` you can add vertices as you go.
-
-We'll go over creating custom geometry in [another article](threejs-custom-geometry.html). For now
+We'll go over creating custom geometry in [another article](threejs-custom-buffergeometry.html). For now
let's make an example creating each type of primitive. We'll start
with the [examples from the previous article](threejs-responsive.html).
@@ -158,7 +128,7 @@ that make up a shape. For a solid shape like a sphere
or a cube there's usually no reason to draw the
back sides of triangles as they all face inside the
shape. In our case though we are drawing a few things
-like the `PlaneBufferGeometry` and the `ShapeBufferGeometry`
+like the `PlaneGeometry` and the `ShapeGeometry`
which are 2 dimensional and so have no inside. Without
setting `side: THREE.DoubleSide` they would disappear
when looking at their back sides.
@@ -189,7 +159,7 @@ For example creating a box
const width = 8;
const height = 8;
const depth = 8;
- addSolidGeometry(-2, -2, new THREE.BoxBufferGeometry(width, height, depth));
+ addSolidGeometry(-2, -2, new THREE.BoxGeometry(width, height, depth));
}
```
@@ -200,7 +170,7 @@ Here's the result:
{{{example url="../threejs-primitives.html" }}}
There are a couple of notable exceptions to the pattern above.
-The biggest is probably the `TextBufferGeometry`. It needs to load
+The biggest is probably the `TextGeometry`. It needs to load
3D font data before it can generate a mesh for the text.
That data loads asynchronously so we need to wait for it
to load before trying to create the geometry. By promisifiying
@@ -222,7 +192,7 @@ And finally create the geometry and call `addObject` to add it the scene.
async function doit() {
const font = await loadFont('resources/threejs/fonts/helvetiker_regular.typeface.json'); /* threejsfundamentals: url */
- const geometry = new THREE.TextBufferGeometry('three.js', {
+ const geometry = new THREE.TextGeometry('three.js', {
font: font,
size: 3.0,
height: .2,
@@ -297,15 +267,15 @@ to take you directly to the docs for that shape.
There is one other pair of classes that doesn't really fit the patterns above. Those are
the `PointsMaterial` and the `Points` class. `Points` is like `LineSegments` above in that it takes a
-a `Geometry` or `BufferGeometry` but draws points at each vertex instead of lines.
+a `BufferGeometry` but draws points at each vertex instead of lines.
To use it you also need to pass it a `PointsMaterial` which
take a [`size`](PointsMaterial.size) for how large to make the points.
```js
const radius = 7;
const widthSegments = 12;
const heightSegments = 8;
-const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+const geometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
const material = new THREE.PointsMaterial({
color: 'red',
size: 0.2, // in world units
@@ -341,9 +311,9 @@ might be the sphere geometries. Spheres take parameters for
how many divisions to make around and how many top to bottom. For example
<div class="spread">
-<div data-diagram="SphereBufferGeometryLow"></div>
-<div data-diagram="SphereBufferGeometryMedium"></div>
-<div data-diagram="SphereBufferGeometryHigh"></div>
+<div data-diagram="SphereGeometryLow"></div>
+<div data-diagram="SphereGeometryMedium"></div>
+<div data-diagram="SphereGeometryHigh"></div>
</div>
The first sphere has 5 segments around and 3 high which is 15 segments
@@ -355,9 +325,9 @@ look like you need a high number of segments but remove the lines
and the flat shading and we get this
<div class="spread">
-<div data-diagram="SphereBufferGeometryLowSmooth"></div>
-<div data-diagram="SphereBufferGeometryMediumSmooth"></div>
-<div data-diagram="SphereBufferGeometryHighSmooth"></div>
+<div data-diagram="SphereGeometryLowSmooth"></div>
+<div data-diagram="SphereGeometryMediumSmooth"></div>
+<div data-diagram="SphereGeometryHighSmooth"></div>
</div>
It's now not so clear that the one on the right with 5000 triangles
@@ -374,8 +344,8 @@ Sometimes it's easy to choose. For example you can also choose
to subdivide a plane.
<div class="spread">
-<div data-diagram="PlaneBufferGeometryLow"></div>
-<div data-diagram="PlaneBufferGeometryHigh"></div>
+<div data-diagram="PlaneGeometryLow"></div>
+<div data-diagram="PlaneGeometryHigh"></div>
</div>
The plane on the left is 2 triangles. The plane on the right
@@ -392,8 +362,7 @@ tradeoff is for your particular situation.
If none of the shapes above fit your use case you can load
geometry for example from a [.obj file](threejs-load-obj.html)
or a [.gltf file](threejs-load-gltf.html).
-You can also create your own [custom Geometry](threejs-custom-geometry.html)
-or [custom BufferGeometry](threejs-custom-buffergeometry.html).
+You can also create your own [custom BufferGeometry](threejs-custom-buffergeometry.html).
Next up let's go over [how three's scene graph works and how
to use it](threejs-scenegraph.html). | true |
Other | mrdoob | three.js | fbac88d731b85fc9b25c69ce7161edd2566ed40c.json | remove references to XXXBufferGeometry | threejs/lessons/zh_cn/threejs-primitives.md | @@ -18,27 +18,27 @@ Three.js ๆๅพๅคๅพๅ
ใๅพๅ
ๅฐฑๆฏไธไบ 3D ็ๅฝข็ถ๏ผๅจ่ฟ่กๆถๆ นๆฎ
ไธ้ข็ๅพๅคๅพๅ
้ฝๆ้ป่ฎค็้จๅๆ่
ๅ
จ้จๅๆฐ๏ผๆไปฅๅฏไปฅๆ นๆฎไฝ ็้่ฆ้ๆฉไฝฟ็จใ
-<div id="Diagram-BoxBufferGeometry" data-primitive="BoxBufferGeometry">็ๅญ</div>
-<div id="Diagram-CircleBufferGeometry" data-primitive="CircleBufferGeometry">ๅนณ้ขๅ</div>
-<div id="Diagram-ConeBufferGeometry" data-primitive="ConeBufferGeometry">้ฅๅฝข</div>
-<div id="Diagram-CylinderBufferGeometry" data-primitive="CylinderBufferGeometry">ๅๆฑ</div>
-<div id="Diagram-DodecahedronBufferGeometry" data-primitive="DodecahedronBufferGeometry">ๅไบ้ขไฝ</div>
-<div id="Diagram-ExtrudeBufferGeometry" data-primitive="ExtrudeBufferGeometry">ๅๆคๅ็ 2D ๅฝข็ถ๏ผๅๅฏ้็ๆๅใ
-่ฟ้ๆไปฌๆคๅไบไธไธชๅฟๅใๆณจๆ๏ผ่ฟๅๅซๆฏ <code>TextBufferGeometry</code> ๅ <code>TextGeometry</code> ็ๅบ็กใ<div>
-<div id="Diagram-IcosahedronBufferGeometry" data-primitive="IcosahedronBufferGeometry">ไบๅ้ขไฝ</div>
-<div id="Diagram-LatheBufferGeometry" data-primitive="LatheBufferGeometry">็ป็ไธๆก็บฟๆ่ฝฌๅฝขๆ็ๅฝข็ถใไพๅฆ๏ผ็ฏๆณกใไฟ้พ็็ถใ่ก็ใ่ก็ๅฐใ้
็ถใ็ป็ๆฏ็ญใไฝ ๆไพไธ็ณปๅ็นไฝไธบ 2D ่ฝฎๅป๏ผๅนถๅ่ฏ Three.js ๆฒฟ็ๆๆก่ฝดๆ่ฝฌๆถ้่ฆๅฐไพง้ขๅๆๅคๅฐๅใ</div>
-<div id="Diagram-OctahedronBufferGeometry" data-primitive="OctahedronBufferGeometry">ๅ
ซ้ขไฝ</div>
-<div id="Diagram-ParametricBufferGeometry" data-primitive="ParametricBufferGeometry">้่ฟๆไพไธไธชๅฝๆฐ๏ผๅฐ็ฝๆ ผไธญ 2D ็็น่ฝฌๆๅฏนๅบ็ 3D ็น๏ผ็ๆ็่กจ้ขใ</div>
-<div id="Diagram-PlaneBufferGeometry" data-primitive="PlaneBufferGeometry">2D ๅนณ้ข</div>
-<div id="Diagram-PolyhedronBufferGeometry" data-primitive="PolyhedronBufferGeometry">ๅฐไธไบ็ฏ็ป็ไธญๅฟ็น็ไธ่งๅฝขๆๅฝฑๅฐ็ไฝไธ</div>
-<div id="Diagram-RingBufferGeometry" data-primitive="RingBufferGeometry">ไธญ้ดๆๆด็ 2D ๅ็</div>
-<div id="Diagram-ShapeBufferGeometry" data-primitive="ShapeBufferGeometry">2D ็ไธ่ง่ฝฎๅป</div>
-<div id="Diagram-SphereBufferGeometry" data-primitive="SphereBufferGeometry">็ไฝ</div>
-<div id="Diagram-TetrahedronBufferGeometry" data-primitive="TetrahedronBufferGeometry">ๅ้ขไฝ</div>
-<div id="Diagram-TextBufferGeometry" data-primitive="TextBufferGeometry">ๆ นๆฎ 3D ๅญไฝๅๅญ็ฌฆไธฒ็ๆ็ 3D ๆๅญ</div>
-<div id="Diagram-TorusBufferGeometry" data-primitive="TorusBufferGeometry">ๅ็ฏไฝ๏ผ็็ๅ๏ผ</div>
-<div id="Diagram-TorusKnotBufferGeometry" data-primitive="TorusKnotBufferGeometry">็ฏๅฝข่</div>
-<div id="Diagram-TubeBufferGeometry" data-primitive="TubeBufferGeometry">ๅ็ฏๆฒฟ็่ทฏๅพ</div>
+<div id="Diagram-BoxGeometry" data-primitive="BoxGeometry">็ๅญ</div>
+<div id="Diagram-CircleGeometry" data-primitive="CircleGeometry">ๅนณ้ขๅ</div>
+<div id="Diagram-ConeGeometry" data-primitive="ConeGeometry">้ฅๅฝข</div>
+<div id="Diagram-CylinderGeometry" data-primitive="CylinderGeometry">ๅๆฑ</div>
+<div id="Diagram-DodecahedronGeometry" data-primitive="DodecahedronGeometry">ๅไบ้ขไฝ</div>
+<div id="Diagram-ExtrudeGeometry" data-primitive="ExtrudeGeometry">ๅๆคๅ็ 2D ๅฝข็ถ๏ผๅๅฏ้็ๆๅใ
+่ฟ้ๆไปฌๆคๅไบไธไธชๅฟๅใๆณจๆ๏ผ่ฟๅๅซๆฏ <code>TextGeometry</code> ๅ <code>TextGeometry</code> ็ๅบ็กใ<div>
+<div id="Diagram-IcosahedronGeometry" data-primitive="IcosahedronGeometry">ไบๅ้ขไฝ</div>
+<div id="Diagram-LatheGeometry" data-primitive="LatheGeometry">็ป็ไธๆก็บฟๆ่ฝฌๅฝขๆ็ๅฝข็ถใไพๅฆ๏ผ็ฏๆณกใไฟ้พ็็ถใ่ก็ใ่ก็ๅฐใ้
็ถใ็ป็ๆฏ็ญใไฝ ๆไพไธ็ณปๅ็นไฝไธบ 2D ่ฝฎๅป๏ผๅนถๅ่ฏ Three.js ๆฒฟ็ๆๆก่ฝดๆ่ฝฌๆถ้่ฆๅฐไพง้ขๅๆๅคๅฐๅใ</div>
+<div id="Diagram-OctahedronGeometry" data-primitive="OctahedronGeometry">ๅ
ซ้ขไฝ</div>
+<div id="Diagram-ParametricGeometry" data-primitive="ParametricGeometry">้่ฟๆไพไธไธชๅฝๆฐ๏ผๅฐ็ฝๆ ผไธญ 2D ็็น่ฝฌๆๅฏนๅบ็ 3D ็น๏ผ็ๆ็่กจ้ขใ</div>
+<div id="Diagram-PlaneGeometry" data-primitive="PlaneGeometry">2D ๅนณ้ข</div>
+<div id="Diagram-PolyhedronGeometry" data-primitive="PolyhedronGeometry">ๅฐไธไบ็ฏ็ป็ไธญๅฟ็น็ไธ่งๅฝขๆๅฝฑๅฐ็ไฝไธ</div>
+<div id="Diagram-RingGeometry" data-primitive="RingGeometry">ไธญ้ดๆๆด็ 2D ๅ็</div>
+<div id="Diagram-ShapeGeometry" data-primitive="ShapeGeometry">2D ็ไธ่ง่ฝฎๅป</div>
+<div id="Diagram-SphereGeometry" data-primitive="SphereGeometry">็ไฝ</div>
+<div id="Diagram-TetrahedronGeometry" data-primitive="TetrahedronGeometry">ๅ้ขไฝ</div>
+<div id="Diagram-TextGeometry" data-primitive="TextGeometry">ๆ นๆฎ 3D ๅญไฝๅๅญ็ฌฆไธฒ็ๆ็ 3D ๆๅญ</div>
+<div id="Diagram-TorusGeometry" data-primitive="TorusGeometry">ๅ็ฏไฝ๏ผ็็ๅ๏ผ</div>
+<div id="Diagram-TorusKnotGeometry" data-primitive="TorusKnotGeometry">็ฏๅฝข่</div>
+<div id="Diagram-TubeGeometry" data-primitive="TubeGeometry">ๅ็ฏๆฒฟ็่ทฏๅพ</div>
<div id="Diagram-EdgesGeometry" data-primitive="EdgesGeometry">ไธไธชๅทฅๅ
ทๅฏน่ฑก๏ผๅฐไธไธชๅ ไฝไฝไฝไธบ่พๅ
ฅ๏ผ็ๆ้ขๅคน่งๅคงไบๆไธช้ๅผ็้ฃๆก่พนใไพๅฆ๏ผไฝ ไป้กถไธ็ไธไธช็ๅญ๏ผไฝ ไผ็ๅฐๆไธๆก็บฟ็ฉฟ่ฟ่ฟไธช้ข๏ผๅ ไธบๆฏไธช็ปๆ่ฟไธช็ๅญ็ไธ่งๅฝข้ฝๆพ็คบๅบๆฅไบใ่ๅฆๆไฝฟ็จ <code>EdgesGeometry</code> ไธญ้ด็็บฟๅฐฑไผ่ขซ็งป้คใ่ฐๆดไธ้ข็ thresholdAngle๏ผไฝ ๅฐฑไผ็ๅฐๅคน่งๅฐไบ่ฟไธชๅผ็่พนๆถๅคฑไบใ</div>
<div id="Diagram-WireframeGeometry" data-primitive="WireframeGeometry">ๅฏนไบ็ปๅฎ็ๅ ไฝไฝ๏ผ็ๆๆฏไธช่พนๅ
ๅซไธไธช็บฟๆฎต๏ผ2 ไธช็น๏ผ็ๅ ไฝไฝใๅฆๆไธ่ฟๆ ท๏ผ้ๅธธ็ผบ่พนๆ่
ๅค่พน๏ผๅ ไธบ WebGL ไธญๆฏๆก่พน้ๅธธ้่ฆ 2 ไธช็นใไพๅฆ๏ผๅฆๆไฝ ๅชๆไธไธชไธ่งๅฝข๏ผๅฐฑๅชๆ 3 ไธช็น ใๅฆๆไฝ ็จ <code>wireframe: true</code> ็ๆ่ดจๆฅ็ปๅถๅฎ๏ผไฝ ๅช่ฝๅพๅฐไธๆก็บฟใๅฐ่ฟไธชไธ่งๅฝขๅ ไฝไฝไผ ็ป <code>WireframeGeometry</code> ๅฐฑ่ฝ็ๆไธไธชๆฐ็ๅ ไฝไฝ๏ผ่ฟไธชๅ ไฝไฝ็จ 6 ไธช็น็ปๆ 3 ๆก็บฟๆฎตใ</div>
@@ -60,7 +60,7 @@ Three.js ๆๅพๅคๅพๅ
ใๅพๅ
ๅฐฑๆฏไธไบ 3D ็ๅฝข็ถ๏ผๅจ่ฟ่กๆถๆ นๆฎ
ไฝฟ็จ้กถ็น็ๆฐ้ๅจๅๅปบๆถๅฐฑๅฎๅฅฝไบ๏ผ็ธๅบ็ๅๅปบๅญๅจ๏ผๅกซๅ
้กถ็นๆฐๆฎใ
ไฝ็จ `Geometry` ไฝ ๅฐฑ่ฝ้ๆถๆทปๅ ้กถ็นใ
-ๆไปฌไผๅจ [ๅฆไธ็ฏๆ็ซ ](threejs-custom-geometry.html) ไธญๆฅ่ฎฒๅๅปบ่ชๅฎไนๅ ไฝไฝใ
+ๆไปฌไผๅจ [ๅฆไธ็ฏๆ็ซ ](threejs-custom-buffergeometry.html) ไธญๆฅ่ฎฒๅๅปบ่ชๅฎไนๅ ไฝไฝใ
็ฐๅจ๏ผๆไปฌๆฅไธบๅๅปบๆฏไธไธชๅพๅ
ไฝไธบไพๅญใ
ๆไปฌไป [ไธไธ็ฏๆ็ซ ็ไพๅญ](threejs-responsive.html) ๅผๅงใ
@@ -127,7 +127,7 @@ function createMaterial() {
ๅๆถ๏ผๆไปฌๅฐ `side: THREE.DoubleSide` ไผ ็ปๆ่ดจใ่ฟๅ่ฏ Three.js ็ปๅถ็ปๆๅฝข็ถ็ไธ่งๅฝข็ไธคไธช้ขใ
ๅฏนไบๅฎๅฟ็ๅฝข็ถ๏ผๅ็ไฝๆ็ซๆนไฝ๏ผ้ๅธธไธ้่ฆ็ปๅถไธ่งๅฝข็่้ข๏ผๅ ไธบๅฎไปฌๅ
จ้จๆๅๅ
้จใ
-ๅฏนไบๆไปฌ็ๆ
ๅต๏ผๆไปฌไผ็ปๅถไธไบๅ `PlaneBufferGeometry` ๅ `ShapeBufferGeometry` ่ฟๆ ท็ไบ็ปดๅพๅฝข๏ผๆฒกๆๅ
้จ,
+ๅฏนไบๆไปฌ็ๆ
ๅต๏ผๆไปฌไผ็ปๅถไธไบๅ `PlaneGeometry` ๅ `ShapeGeometry` ่ฟๆ ท็ไบ็ปดๅพๅฝข๏ผๆฒกๆๅ
้จ,
ๅฆๆไธ่ฎพ็ฝฎ `side: THREE.DoubleSide`๏ผๅฝไปๅ้ข็ๆถๅฎไปฌไผๆถๅคฑใ
้่ฆๆณจๆ็ๆฏ๏ผๅฆๆ **ไธ** ่ฎพ็ฝฎ `side: THREE.DoubleSide` ็ปๅถไผๆดๅฟซ๏ผๆไปฅๆๅฅฝๅชๅจ้่ฆ็ๆถๅ่ฎพ็ฝฎๅฎใ
@@ -151,7 +151,7 @@ function addSolidGeometry(x, y, geometry) {
const width = 8;
const height = 8;
const depth = 8;
- addSolidGeometry(-2, -2, new THREE.BoxBufferGeometry(width, height, depth));
+ addSolidGeometry(-2, -2, new THREE.BoxGeometry(width, height, depth));
}
```
@@ -161,7 +161,7 @@ function addSolidGeometry(x, y, geometry) {
{{{example url="../threejs-primitives.html" }}}
-ไธ้ข็ๆจกๅผๆไธไบๅผๅพๆณจๆ็ไพๅคใๆๅคง็ๅฏ่ฝๅฐฑๆฏ `TextBufferGeometry`ใๅจไธบๆๅญ็ๆ็ฝๆ ผๅ้่ฆๅ
ๅ ่ฝฝ 3D ๅญไฝๆฐๆฎใ
+ไธ้ข็ๆจกๅผๆไธไบๅผๅพๆณจๆ็ไพๅคใๆๅคง็ๅฏ่ฝๅฐฑๆฏ `TextGeometry`ใๅจไธบๆๅญ็ๆ็ฝๆ ผๅ้่ฆๅ
ๅ ่ฝฝ 3D ๅญไฝๆฐๆฎใ
ๆฐๆฎ็ๅ ่ฝฝๆฏๅผๆญฅ็๏ผๆไปฅๅจๅฐ่ฏๅๅปบๅ ไฝไฝๅ้่ฆ็ญๅพ
ใ้่ฟๅฐๅญไฝๅ ่ฝฝ Promise ๅ๏ผๆไปฌๅฏไปฅ่ฎฉ่ฟไธช่ฟ็จๆด็ฎๅใ
ๆไปฌๅๅปบไธไธช `FontLoader`๏ผ็ถๅ `loadFont` ๅฝๆฐ่ฟๅไธไธช `promise`๏ผ`promise` ็ `resolve` ไผ็ปๆไปฌๅญไฝใ
ๆฅ็ๆไปฌๅๅปบไธไธช `async` ๅฝๆฐ `doit`๏ผไฝฟ็จ `await` ๅ ่ฝฝๅญไฝใๆๅๅๅปบๅ ไฝไฝ๏ผ่ฐ็จ `addOjbect` ๅฐๅฎๆทปๅ ๅฐๅบๆฏไธญใ
@@ -178,7 +178,7 @@ function addSolidGeometry(x, y, geometry) {
async function doit() {
const font = await loadFont('resources/threejs/fonts/helvetiker_regular.typeface.json'); /* threejsfundamentals: url */
- const geometry = new THREE.TextBufferGeometry('three.js', {
+ const geometry = new THREE.TextGeometry('three.js', {
font: font,
size: 3.0,
height: .2,
@@ -243,7 +243,7 @@ function addLineGeometry(x, y, geometry) {
const radius = 7;
const widthSegments = 12;
const heightSegments = 8;
-const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+const geometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
const material = new THREE.PointsMaterial({
color: 'red',
size: 0.2, // in world units
@@ -276,9 +276,9 @@ const material = new THREE.PointsMaterial({
ไธไธชๅพๅฅฝ็ไพๅญๅฐฑๆฏ็ๅฝขๅ ไฝไฝใๅฎๅฏไปฅ่ฟไบๅๆฐ๏ผไธๅ็ปๆ็็ๆฐใไปไธๅฐไธ็ๆฐ้็ญใไพๅฆ๏ผ
<div class="spread">
-<div data-diagram="SphereBufferGeometryLow"></div>
-<div data-diagram="SphereBufferGeometryMedium"></div>
-<div data-diagram="SphereBufferGeometryHigh"></div>
+<div data-diagram="SphereGeometryLow"></div>
+<div data-diagram="SphereGeometryMedium"></div>
+<div data-diagram="SphereGeometryHigh"></div>
</div>
็ฌฌไธไธช็ไฝไธๅๆ 5 ๅ็๏ผ้ซๅบฆไธบ 3๏ผไธๅ
ฑ 15 ็๏ผๆ่
30 ไธชไธ่งๅฝขใ
@@ -288,9 +288,9 @@ const material = new THREE.PointsMaterial({
็ฑไฝ ๅณๅฎ้่ฆ็ปๅๆๅคๅฐใ็่ตทๆฅไฝ ๅฏ่ฝ้่ฆ่พๅคๆฐ้็ๅ็๏ผไฝๅป้ค็บฟ๏ผ่ฎพ็ฝฎๅนณ้ข็่ฒ๏ผๆไปฌๅฐฑๅพๅฐไบ๏ผ
<div class="spread">
-<div data-diagram="SphereBufferGeometryLowSmooth"></div>
-<div data-diagram="SphereBufferGeometryMediumSmooth"></div>
-<div data-diagram="SphereBufferGeometryHighSmooth"></div>
+<div data-diagram="SphereGeometryLowSmooth"></div>
+<div data-diagram="SphereGeometryMediumSmooth"></div>
+<div data-diagram="SphereGeometryHighSmooth"></div>
</div>
็ฐๅจๅนถไธๆๆพๆฏๅฆๅณ่พนๆ 5000 ไธชไธ่งๅฝข็ๆฏไธญ้ดๅชๆ 480 ไธชไธ่งๅฝข็ๅฅฝๆดๅคใ
@@ -301,8 +301,8 @@ const material = new THREE.PointsMaterial({
ๆๆถๅๅพๅฎนๆ้ๆฉใไพๅฆไฝ ๅฏไปฅ้ๆฉๅฐๅนณ้ข็ปๅใ
<div class="spread">
-<div data-diagram="PlaneBufferGeometryLow"></div>
-<div data-diagram="PlaneBufferGeometryHigh"></div>
+<div data-diagram="PlaneGeometryLow"></div>
+<div data-diagram="PlaneGeometryHigh"></div>
</div>
ๅทฆ่พน็ๅนณ้ขๆ 2 ไธชไธ่งๅฝข๏ผๅณ่พน็ๅนณ้ขๆ 200 ไธชไธ่งๅฝขใไธๅ็ไฝ๏ผๅจๅคๆฐๅนณ้ข็ๅบ็จๅบๆฏไธญ๏ผๅนถๆฒกๆไปไนๆไธญ็ๆนๆณใ
@@ -312,7 +312,7 @@ const material = new THREE.PointsMaterial({
ไฝ ้่ฆๆ นๆฎไฝ ็ๅ
ทไฝๆ
ๅต้ๆฉๅ้็ๆนๆกใ
ๅฆๆไธ้ข็ๅฝข็ถไธ็ฌฆๅไฝ ็ไฝฟ็จ้ๆฑ๏ผไฝ ๅฏไปฅไป [.obj ๆไปถ](threejs-load-obj.html) ๆ [.gltf ๆไปถ](threejs-load-gltf.html) ๅ ่ฝฝๅ ไฝไฝใ
-ไฝ ไนๅฏไปฅๅๅปบ [่ชๅฎไน Geometry](threejs-custom-geometry.html) ๆ [่ชๅฎไน BufferGeometry](threejs-custom-buffergeometry.html)ใ
+ไฝ ไนๅฏไปฅๅๅปบ [่ชๅฎไน Geometry](threejs-custom-buffergeometry.html)ใ
ๆฅไธๆฅๆฏ [Three.js ็ๅบๆฏๅพๆฏๅฆไฝๅทฅไฝ็ๅๅฆไฝไฝฟ็จๅฎ](threejs-scenegraph.html)ใ
| true |
Other | mrdoob | three.js | d3187f287817d1eeb05904ef762be9e3848e7a6d.json | translate threejs lights to zh-cn | threejs/lessons/zh_cn/threejs-lights.md | @@ -0,0 +1,488 @@
+Title: Three.js ๅ
็
ง
+Description: ่ฎพ็ฝฎๅ
็
ง
+TOC: ๅ
็
ง
+
+ๆฌๆๆฏๅ
ณไบ three.js ็ณปๅๆ็ซ ็ไธ้จๅใ็ฌฌไธ็ฏๆ็ซ ๆฏ [three.js ๅบ็ก](threejs-fundamentals.html)ใๅฆๆไฝ ่ฟๆฒก็่ฟ่ไธๅฏนthree.js ่ฟไธ็ๆ๏ผ้ฃๅบ่ฏฅไป้ฃ้ๅผๅง๏ผๅนถไธไบ่งฃๅฆไฝ[่ฎพ็ฝฎๅผๅ็ฏๅข](threejs-setup.html)ใไธไธ็ฏๆ็ซ ไป็ปไบ three.js ไธญ็ [็บน็](threejs-textures.html)ใ
+
+ๆฅไธๆฅๆไปฌๅญฆไน ๅฆไฝๅจ three.js ไธญไฝฟ็จๅ็งไธๅ็ฑปๅ็ๅ
็
งใ
+
+ๅจไธไธชๅบๆฌๅบๆฏ็ๅบ็กไธ๏ผๆไปฌ่ฐๆดไธไธ็ธๆบ็่ฎพ็ฝฎใๅฐ fov ่ฎพ็ฝฎไธบ 45๏ผ far ่ฎพ็ฝฎไธบ 100๏ผ็ถๅ็งปๅจ็ธๆบไฝ็ฝฎๅฐ (0, 10, 20)ใ
+
+```js
+*const fov = 45;
+const aspect = 2; // canvas ็้ป่ฎคๅฎฝ้ซ 300:150
+const near = 0.1;
+*const far = 100;
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
++camera.position.set(0, 10, 20);
+```
+
+็ถๅๆไปฌๆทปๅ ไธไธช `OrbitControls`ใ`OrbitControls` ่ฎฉๆไปฌๅฏไปฅๅด็ปๆไธไธช็นๆ่ฝฌๆงๅถ็ธๆบใ`OrbitControls` ๆฏ three.js ็ๅฏ้ๆจกๅ๏ผๆไปฅๆไปฌ้ฆๅ
้่ฆๅผๅ
ฅ่ฟไธชๆจกๅใ
+
+```js
+import * as THREE from './resources/three/r122/build/three.module.js';
++import {OrbitControls} from './resources/threejs/r122/examples/jsm/controls/OrbitControls.js';
+```
+
+็ถๅๆไปฌๅฐฑๅฏไปฅไฝฟ็จไบใๅๅปบ `OrbitControls` ๆถไผ ๅ
ฅไธคไธชๅๆฐ๏ผไธไธชๆฏ่ฆๆงๅถ็็ธๆบๅฏน่ฑก๏ผ็ฌฌไบไธชๆฏๆฃๆตไบไปถ็ DOM ๅ
็ด ใ
+
+```js
+const controls = new OrbitControls(camera, canvas);
+controls.target.set(0, 5, 0);
+controls.update();
+```
+
+ๆไปฌ่ฟๅฐ `OrbitControls` ็่งๅฏ็น่ฎพ็ฝฎไธบ (0, 5, 0) ็ไฝ็ฝฎ๏ผ่ฎพ็ฝฎๅฎ้่ฆ่ฐ็จไธไธ `controls.update`๏ผ่ฟๆ ทๆ็ๆญฃๆดๆฐ่งๅฏ็นไฝ็ฝฎใ
+
+ไธ้ขๆไปฌๅๅปบไธไบไธ่ฅฟๆฅๆๅ
ใ้ฆๅ
๏ผๅๅปบไธไธชๅฐๅนณ้ข๏ผๅนถ็จไธๆนๅฑ็คบ็ 2x2 ๅ็ด ็้ป็ฝๆ ผๅพ็ๆฅไฝไธบ็บน็ใ
+
+<div class="threejs_center">
+ <img src="../resources/images/checker.png" class="border" style="
+ image-rendering: pixelated;
+ width: 128px;
+ ">
+</div>
+
+้ฆๅ
ๅ ่ฝฝ่ฟไธช็บน็๏ผ่ฎพ็ฝฎ้ๅคๆจกๅผ๏ผ[`wrapS`](Texture.wrapS), [`wrapT`](Texture.wrapT)๏ผ๏ผ้ๆ ทๆจกๅผ๏ผ[`magFilter`](Texture.magFilter)๏ผไปฅๅ้ๅค็ๆฌกๆฐใๅ ไธบ่ดดๅพๆฏ 2x2 ๅคงๅฐ๏ผ้่ฟ่ฎพ็ฝฎๆๅนณ้บๆจกๅผ๏ผๅนถไธ้ๅคๆฌกๆฐๆฏ่พน้ฟ็ไธๅ๏ผๅฐฑๅฏไปฅ่ฎฉๆฏไธชๆ ผๅญๆญฃๅฅฝๆฏ1ไธชๅไฝ็ๅคงๅฐใ
+
+```js
+const planeSize = 40;
+
+const loader = new THREE.TextureLoader();
+const texture = loader.load('resources/images/checker.png');
+texture.wrapS = THREE.RepeatWrapping;
+texture.wrapT = THREE.RepeatWrapping;
+texture.magFilter = THREE.NearestFilter;
+const repeats = planeSize / 2;
+texture.repeat.set(repeats, repeats);
+```
+
+ๆฅ็ๆไปฌๅๅปบไธไธชๅนณ้ขๅ ไฝไฝ๏ผไธไธชๆ่ดจ๏ผๅ็จ่ฟไธคไธชไฝไธบๅๆฐ๏ผๅๅปบไธไธช `Mesh` ๅฏน่ฑกๅนถไธๆทปๅ ๅฐๅบๆฏไธญใๅ ไธบๅๅปบ็ๅนณ้ข้ป่ฎคๆฏๅจ XY ๅนณ้ขไธ๏ผ็ซ็ดๅนณ้ข๏ผ๏ผๆไปฌๅธๆๅพๅฐไธไธช XZ ๅนณ้ข๏ผๆฐดๅนณๅนณ้ข๏ผ๏ผๆไปฅๆไปฌๅฐไปๆ่ฝฌ 90ยฐใ
+
+```js
+const planeGeo = new THREE.PlaneBufferGeometry(planeSize, planeSize);
+const planeMat = new THREE.MeshPhongMaterial({
+ map: texture,
+ side: THREE.DoubleSide,
+});
+const mesh = new THREE.Mesh(planeGeo, planeMat);
+mesh.rotation.x = Math.PI * -.5;
+scene.add(mesh);
+```
+
+ๆฅ็ๅๆทปๅ ไธไธช็ซๆนไฝๅไธไธช็ไฝ๏ผ่ฟๆ ทๆไปฌๅฐฑๆไธไธช็ฉไฝๅฏไปฅๆๅ
ใ
+
+```js
+{
+ const cubeSize = 4;
+ const cubeGeo = new THREE.BoxBufferGeometry(cubeSize, cubeSize, cubeSize);
+ const cubeMat = new THREE.MeshPhongMaterial({color: '#8AC'});
+ const mesh = new THREE.Mesh(cubeGeo, cubeMat);
+ mesh.position.set(cubeSize + 1, cubeSize / 2, 0);
+ scene.add(mesh);
+}
+{
+ const sphereRadius = 3;
+ const sphereWidthDivisions = 32;
+ const sphereHeightDivisions = 16;
+ const sphereGeo = new THREE.SphereBufferGeometry(sphereRadius, sphereWidthDivisions, sphereHeightDivisions);
+ const sphereMat = new THREE.MeshPhongMaterial({color: '#CA8'});
+ const mesh = new THREE.Mesh(sphereGeo, sphereMat);
+ mesh.position.set(-sphereRadius - 1, sphereRadius + 2, 0);
+ scene.add(mesh);
+}
+```
+
+ไธๅๅๅคๅฐฑ็ปช๏ผๆไปฌๅผๅงๆทปๅ ๅ
ๆบใ
+
+## ็ฏๅขๅ
๏ผ`AmbientLight`๏ผ
+
+้ฆๅ
ๅๅปบไธไธช `AmbientLight`
+
+```js
+const color = 0xFFFFFF;
+const intensity = 1;
+const light = new THREE.AmbientLight(color, intensity);
+scene.add(light);
+```
+
+ๆไปฌๆทปๅ ไธไบๆงๅถไปฃ็ ๏ผไฝฟๆไปฌๅฏไปฅๅจๆๅฐๆนๅๅ
็
ง็ๅๆฐ๏ผ่ฟๆฏไฝฟ็จ [dat.GUI](https://github.com/dataarts/dat.gui) ๆฅๅฎ็ฐใไธบไบๅฏไปฅ้่ฟ `dat.GUI` ่ฐ่้ข่ฒ๏ผๆไปฌๅๅปบไธไธช่พ
ๅฉๅฏน่ฑกใๅฏน่ฑกๅ
ๆไธไธช `getter` ๅ `setter`๏ผๅฝ `dat.GUI` ไปๅฏน่ฑกๅ
่ทๅ `value` ๅผ็ๆถๅ๏ผ่งฆๅไบ `getter`๏ผไผๆ นๆฎๅๅปบๅฏน่ฑกๅฎไพๆถไผ ๅ
ฅ็ `object` ๅ `prop`๏ผ่ฟๅไธไธชๅๅ
ญ่ฟๅถ่ฒๅผ็ๅญ็ฌฆไธฒ๏ผๅฝ้่ฟ `dat.GUI` ๆงๅถๆนๅ่ฟไธช `value` ็ๆถๅ๏ผๅฐฑ่งฆๅไบ `setter`๏ผไผ็จๅๅ
ญ่ฟๅถ็่ฒๅผๅญ็ฌฆไธฒไฝไธบๅๆฐ่ฐ็จ `object.prop.set`ใ
+
+ไปฅไธๆฏ helper ็ฑป็ไปฃ็ ๏ผ
+
+```js
+class ColorGUIHelper {
+ constructor(object, prop) {
+ this.object = object;
+ this.prop = prop;
+ }
+ get value() {
+ return `#${this.object[this.prop].getHexString()}`;
+ }
+ set value(hexString) {
+ this.object[this.prop].set(hexString);
+ }
+}
+```
+
+ไปฅๅๅๅปบ dat.GUI ็ไปฃ็ ๏ผ
+
+```js
+const gui = new GUI();
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.add(light, 'intensity', 0, 2, 0.01);
+```
+
+็ปๆๅฆไธๆ็คบ๏ผ
+
+{{{example url="../threejs-lights-ambient.html" }}}
+
+ๅฏไปฅๅจๅบๆฏๅ
็นๅปๅๆๆฝ้ผ ๆ ๆฅๆนๅ็ธๆบ็ไฝ็ฝฎ๏ผ่งๅฏๅบๆฏใ
+
+ๅฏไปฅ็ๅฐๅบๆฏๅ
็็ฉไฝ็่ตทๆฅๆฒกๆ็ซไฝๆใ็ฏๅขๅ
๏ผ`AmbientLight`๏ผๅชๆฏ็ฎๅๅฐๅฐๆ่ดจ็้ข่ฒไธๅ
็
ง้ข่ฒ่ฟ่กๅ ๅ ๏ผPhotoShop ้็ๆญฃ็ๅ ๅบๆจกๅผ๏ผ๏ผๅไนไปฅๅ
็
งๅผบๅบฆใ
+
+ // ่ฟ้็้ข่ฒ่ฎก็ฎๆฏ RBG ้้ไธ็ๅผๅๅซๅฏนๅบ็ธไน
+ // ไพ: rgb(0.64,0.64,0.64) = rgb(0.8,0.8,0.8) * rgb(0.8,0.8,0.8) * 1
+ color = materialColor * light.color * light.intensity;
+
+่ฟๅฐฑๆฏ็ฏๅขๅ
๏ผๅฎๆฒกๆๆนๅ๏ผๆ ๆณไบง็้ดๅฝฑ๏ผๅบๆฏๅ
ไปปไฝไธ็นๅๅฐ็ๅ
็
งๅผบๅบฆ้ฝๆฏ็ธๅ็๏ผ้คไบๆนๅๅบๆฏๅ
ๆๆ็ฉไฝ็้ข่ฒไปฅๅค๏ผไธไผไฝฟ็ฉไฝไบง็ๆๆ็ๅๅ๏ผ็่ตทๆฅๅนถไธๅ็ๆญฃๆไนไธ็ๅ
็
งใ้ๅธธ็ไฝ็จๆฏๆไบฎๅบๆฏ๏ผ่ฎฉๆ้จไธ่ฆๅคชๆใ
+
+## ๅ็ๅ
๏ผ`HemisphereLight`๏ผ
+
+ๆฅไธๆฅไป็ปๅ็ๅ
๏ผ`HemisphereLight`๏ผใๅ็ๅ
๏ผ`HemisphereLight`๏ผ็้ข่ฒๆฏไปๅคฉ็ฉบๅฐๅฐ้ขไธคไธช้ข่ฒไน้ด็ๆธๅ๏ผไธ็ฉไฝๆ่ดจ็้ข่ฒไฝๅ ๅ ๅๅพๅฐๆ็ป็้ข่ฒๆๆใไธไธช็นๅๅฐ็ๅ
็
ง้ข่ฒๆฏ็ฑๆๅจๅนณ้ข็ๆๅ๏ผๆณๅ้๏ผๅณๅฎ็ โโ ้ขๅๆญฃไธๆนๅฐฑๅๅฐๅคฉ็ฉบ็ๅ
็
ง้ข่ฒ๏ผ้ขๅๆญฃไธๆนๅฐฑๅๅฐๅฐ้ข็ๅ
็
ง้ข่ฒ๏ผๅ
ถไป่งๅบฆๅๆฏไธคไธช้ข่ฒๆธๅๅบ้ด็้ข่ฒใ
+
+ไธ้ขๆฏไฟฎๆนๅ็ไปฃ็ ๏ผ
+
+```js
+-const color = 0xFFFFFF;
++const skyColor = 0xB1E1FF; // light blue
++const groundColor = 0xB97A20; // brownish orange
+const intensity = 1;
+-const light = new THREE.AmbientLight(color, intensity);
++const light = new THREE.HemisphereLight(skyColor, groundColor, intensity);
+scene.add(light);
+```
+
+ๅๆถไฟฎๆนไธไธ `dat.GUI` ้จๅ๏ผไฝฟๅพๅฏไปฅๆงๅถไธค็ง้ข่ฒ๏ผ
+
+```js
+const gui = new GUI();
+-gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
++gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('skyColor');
++gui.addColor(new ColorGUIHelper(light, 'groundColor'), 'value').name('groundColor');
+gui.add(light, 'intensity', 0, 2, 0.01);
+```
+
+็ปๆๅฆไธ๏ผ
+
+{{{example url="../threejs-lights-hemisphere.html" }}}
+
+ๅบๆฏๅบๆฌไธไนๆฒกๆๅคชๅคง็็ซไฝๆใๅ็ๅ
๏ผ`HemisphereLight`๏ผ ไธๅ
ถไป็ฑปๅๅ
็
ง็ปๅไฝฟ็จ๏ผๅฏไปฅๅพๅฅฝๅฐ่กจ็ฐๅคฉ็ฉบๅๅฐ้ข้ข่ฒ็
งๅฐๅฐ็ฉไฝไธๆถ็ๆๆใๆไปฅๆๅฅฝ็ไฝฟ็จๅบๆฏๅฐฑๆฏไธๅ
ถไปๅ
็
ง็ปๅไฝฟ็จ๏ผๆ่
ไฝไธบ็ฏๅขๅ
๏ผ`AmbientLight`๏ผ็ไธ็งๆฟไปฃๆนๆกใ
+
+## ๆนๅๅ
๏ผ`DirectionalLight`๏ผ
+
+ไธ้ขไป็ปๆนๅๅ
๏ผ`DirectionalLight`๏ผใ
+ๆนๅๅ
๏ผ`DirectionalLight`๏ผๅธธๅธธ็จๆฅ่กจ็ฐๅคช้ณๅ
็
ง็ๆๆใ
+
+```js
+const color = 0xFFFFFF;
+const intensity = 1;
+const light = new THREE.DirectionalLight(color, intensity);
+light.position.set(0, 10, 0);
+light.target.position.set(-5, 0, 0);
+scene.add(light);
+scene.add(light.target);
+```
+
+ๆณจๆ๏ผไธไป
`light` ๏ผๆไปฌ่ฟๆ [`light.target`](DirectionalLight.target) ไนๆทปๅ ๅฐไบๅบๆฏไธญใๆนๅๅ
๏ผ`DirectionalLight`๏ผ็ๆนๅๆฏไปๅฎ็ไฝ็ฝฎ็
งๅ็ฎๆ ็น็ไฝ็ฝฎใ
+
+ไธ้ขไปฃ็ ๆฏๅฐ็ฎๆ ็นๅๆ ๅฑๆงๆทปๅ ๅฐ `dat.GUI`๏ผไฝฟๅพๆไปฌๅฏไปฅๆงๅถ็ฎๆ ไฝ็ฝฎ
+
+```js
+const gui = new GUI();
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.add(light, 'intensity', 0, 2, 0.01);
+gui.add(light.target.position, 'x', -10, 10);
+gui.add(light.target.position, 'z', -10, 10);
+gui.add(light.target.position, 'y', 0, 10);
+```
+
+{{{example url="../threejs-lights-directional.html" }}}
+
+็ฎๅๆ็น้พไปฅ่งๅฏใThree.js ๆไพไบไธไบ่พ
ๅฉๅฏน่ฑก๏ผๆทปๅ ๅฐๅบๆฏไธญไนๅๅฐฑๅฏไปฅๆพ็คบๅบๅบๆฏไธญ็ไธๅฏ่งๅฏน่ฑก๏ผไพๅฆๅ
็
งใ็ธๆบ็ญ๏ผใๅจ่ฟ้ๆไปฌไฝฟ็จ `DirectionalLightHelper`๏ผๅฎไผ็ปๅถไธไธชๆนๅฝข็ๅฐๅนณ้ขไปฃ่กจๆนๅๅ
็ไฝ็ฝฎ๏ผไธๆก่ฟๆฅๅ
ๆบไธ็ฎๆ ็น็็ด็บฟ๏ผไปฃ่กจไบๅ
็ๆนๅใๅๅปบๅฏน่ฑกๆถ๏ผไผ ๅ
ฅๅ
ๆบๅฏน่ฑกไฝไธบๅๆฐ๏ผ็ถๅๆทปๅ ๅฐๅบๆฏไธญ๏ผๅฐฑๅฏไปฅๅ็ฐใ
+
+```js
+const helper = new THREE.DirectionalLightHelper(light);
+scene.add(helper);
+```
+
+ๆไปฌ้กบไพฟๅฎ็ฐไธไธๅฏนๅ
ๆบไฝ็ฝฎๅ็ฎๆ ็นไฝ็ฝฎ็ๆงๅถ้ป่พใๆไปฌๅๅปบไธไธช่พ
ๅฉๅฝๆฐ๏ผไฝฟๅพๅฏไปฅ้่ฟ `dat.GUI` ๆนๅไผ ๅ
ฅ็ `Vector3` ็ฑปๅๅฏน่ฑก็ `x`๏ผ`y`๏ผๅ `z` ็ๅผใ
+
+```js
+function makeXYZGUI(gui, vector3, name, onChangeFn) {
+ const folder = gui.addFolder(name);
+ folder.add(vector3, 'x', -10, 10).onChange(onChangeFn);
+ folder.add(vector3, 'y', 0, 10).onChange(onChangeFn);
+ folder.add(vector3, 'z', -10, 10).onChange(onChangeFn);
+ folder.open();
+}
+```
+
+ๆณจๆ๏ผๅฝ่พ
ๅฉๅฏน่ฑกๆ่กจ็คบ็ไธๅฏ่งๅฏน่ฑกๆๆๆนๅ็ๆถๅ๏ผๆไปฌๅฟ
้กป่ฐ็จ่พ
ๅฉๅฏน่ฑก็ `update` ๆนๆณๆฅๆดๆฐ่พ
ๅฉๅฏน่ฑกๆฌ่บซ็็ถๆใๅ ๆญคๆไปฌไผ ๅ
ฅไธไธช `onChangeFn` ๅฝๆฐ๏ผๆฏๅฝ `dat.GUI` ๆนๅไบๆไธชๅผ็ๆถๅ๏ผๅฐฑไผ่ขซ่ฐ็จใ
+
+ๅบ็จๅฐๅ
็
งไฝ็ฝฎไธ็ฎๆ ็นไฝ็ฝฎ็ๆงๅถ๏ผๅฐฑๅฆไธๆ็คบ๏ผ
+
+```js
++function updateLight() {
++ light.target.updateMatrixWorld();
++ helper.update();
++}
++updateLight();
+
+const gui = new GUI();
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.add(light, 'intensity', 0, 2, 0.01);
+
++makeXYZGUI(gui, light.position, 'position', updateLight);
++makeXYZGUI(gui, light.target.position, 'target', updateLight);
+```
+
+็ฐๅจๆไปฌๅฏไปฅๆงๅถๅ
ๆบไปฅๅ็ฎๆ ็นไฝ็ฝฎไบใ
+
+{{{example url="../threejs-lights-directional-w-helper.html" }}}
+
+ๆ่ฝฌ็ธๆบๅฏไปฅ็ๅพๆดๆธ
ๆฅใๆนๅฝข็ๅฐๅนณ้ขไปฃ่กจไบไธไธชๆนๅๅ
๏ผ`DirectionalLight`๏ผ๏ผๆนๅๅ
่กจ็คบ็ๆฏๆฅ่ชไธไธชๆนๅไธ็ๅ
๏ผๅนถไธๆฏไปๆไธช็นๅๅฐๅบๆฅ็๏ผ่ๆฏไปไธไธชๆ ้ๅคง็ๅนณ้ขๅ
๏ผๅๅฐๅบๅ
จ้จ็ธไบๅนณ่ก็ๅ
็บฟใ
+
+## ็นๅ
ๆบ๏ผ`PointLight`๏ผ
+
+็นๅ
ๆบ๏ผ`PointLight`๏ผ่กจ็คบ็ๆฏไปไธไธช็นๆๅไธชๆนๅๅๅฐๅบๅ
็บฟ็ไธ็งๅ
็
งๆๆใๆไปฌไฟฎๆนไธไธไปฃ็ ๏ผ
+
+```js
+const color = 0xFFFFFF;
+const intensity = 1;
+-const light = new THREE.DirectionalLight(color, intensity);
++const light = new THREE.PointLight(color, intensity);
+light.position.set(0, 10, 0);
+-light.target.position.set(-5, 0, 0);
+scene.add(light);
+-scene.add(light.target);
+```
+
+ๅๆถๆทปๅ ไธไธช `PointLightHelper`
+
+```js
+-const helper = new THREE.DirectionalLightHelper(light);
++const helper = new THREE.PointLightHelper(light);
+scene.add(helper);
+```
+
+ๅ ไธบ็นๅ
ๆบๆฒกๆ `target` ๅฑๆง๏ผๆไปฅ `onChange` ๅฝๆฐๅฏไปฅ็ฎๅใ
+
+```js
+function updateLight() {
+- light.target.updateMatrixWorld();
+ helper.update();
+}
+-updateLight();
+```
+
+`PointLightHelper` ไธๆฏไธไธช็น๏ผ่ๆฏๅจๅ
ๆบ็ไฝ็ฝฎ็ปๅถไบไธไธชๅฐๅฐ็็บฟๆกๅฎ็ณไฝๆฅไปฃ่กจ็นๅ
ๆบใไนๅฏไปฅไฝฟ็จๅ
ถไปๅฝข็ถๆฅ่กจ็คบ็นๅ
ๆบ๏ผๅช่ฆ็ป็นๅ
ๆบๆทปๅ ไธไธช่ชๅฎไน็ `Mesh` ๅญ่็นๅณๅฏใ
+
+็นๅ
ๆบ๏ผ`PointLight`๏ผๆ้ขๅค็ไธไธช่ๅด๏ผ[`distance`](PointLight.distance)๏ผๅฑๆงใ
+ๅฆๆ `distance` ่ฎพไธบ 0๏ผๅๅ
็บฟๅฏไปฅ็
งๅฐๅฐๆ ้่ฟๅคใๅฆๆๅคงไบ 0๏ผๅๅชๅฏไปฅ็
งๅฐๅฐๆๅฎ็่ๅด๏ผๅ
็
งๅผบๅบฆๅจ่ฟไธช่ฟ็จไธญ้ๆธ่กฐๅ๏ผๅจๅ
ๆบไฝ็ฝฎๆถ๏ผ`intensity` ๆฏ่ฎพๅฎ็ๅคงๅฐ๏ผๅจ่ท็ฆปๅ
ๆบ `distance` ไฝ็ฝฎ็ๆถๅ๏ผ`intensity` ไธบ 0ใ
+
+ไธ้ขๆฏๆทปๅ ๅฏน distance ๅๆฐๆงๅถ็ไปฃ็ ๏ผ
+
+```js
+const gui = new GUI();
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.add(light, 'intensity', 0, 2, 0.01);
++gui.add(light, 'distance', 0, 40).onChange(updateLight);
+
+makeXYZGUI(gui, light.position, 'position', updateLight);
+-makeXYZGUI(gui, light.target.position, 'target', updateLight);
+```
+
+ๆๆๅฆไธ๏ผ
+
+{{{example url="../threejs-lights-point.html" }}}
+
+ๆณจๆ `distance` > 0 ๆถๅ
็
งๅผบๅบฆ็่กฐๅ็ฐ่ฑกใ
+
+## ่ๅ
็ฏ๏ผ`SpotLight`๏ผ
+
+่ๅ
็ฏๅฏไปฅ็ๆๆฏไธไธช็นๅ
ๆบ่ขซไธไธชๅ้ฅไฝ้ๅถไฝไบๅ
็
ง็่ๅดใๅฎ้
ไธๆไธคไธชๅ้ฅ๏ผๅ
ๅ้ฅๅๅคๅ้ฅใๅ
็
งๅผบๅบฆๅจไธคไธช้ฅไฝไน้ดไป่ฎพๅฎ็ๅผบๅบฆ้ๅๅฐ 0๏ผๅ
ทไฝๅฏไปฅ็ไธๆน [`penumbra`](SpotLight.penumbra) ๅๆฐ๏ผใ
+
+่ๅ
็ฏ๏ผ`SpotLight`๏ผ็ฑปไผผๆนๅๅ
๏ผ`DirectionalLight`๏ผไธๆ ท้่ฆไธไธช็ฎๆ ็น๏ผๅ
ๆบ็ไฝ็ฝฎๆฏๅ้ฅ็้กถ็น๏ผ็ฎๆ ็นๅคไบๅ้ฅ็ไธญ่ฝด็บฟไธใ
+
+ไฟฎๆนไธ้ข `DirectionalLight` ็ไปฃ็ ๅฆไธ๏ผ
+
+```js
+const color = 0xFFFFFF;
+const intensity = 1;
+-const light = new THREE.DirectionalLight(color, intensity);
++const light = new THREE.SpotLight(color, intensity);
+scene.add(light);
+scene.add(light.target);
+
+-const helper = new THREE.DirectionalLightHelper(light);
++const helper = new THREE.SpotLightHelper(light);
+scene.add(helper);
+```
+
+่ๅ
็ฏ็ๅ้ฅ้กถ้จ่งๅบฆๅคงๅฐ้่ฟ [`angle`](SpotLight.angle) ๅฑๆง่ฎพ็ฝฎ๏ผไปฅๅผงๅบฆไฝๅไฝใๆไปฅๆไปฌ็จไป็ป [็บน็](threejs-textures.html) ๆถ็จๅฐ็ `DegRadHelper` ๆฅๆงๅถใ
+
+```js
+gui.add(new DegRadHelper(light, 'angle'), 'value', 0, 90).name('angle').onChange(updateLight);
+```
+
+ๅ
ๅ้ฅๆฏ้่ฟ่ฎพ็ฝฎ [`penumbra`](SpotLight.penumbra) ๅฑๆงๆฅๅฎไน็๏ผๅฑๆงๅผไปฃ่กจไบๅ
ๅ้ฅ็ธๅฏนๅคๅ้ฅๅคงๅฐๅๅ็็พๅๆฏใๅฝ `penumbra` ไธบ 0 ๆถ๏ผๅ
ๅ้ฅๅคงๅฐไธๅคๅ้ฅๅคงๅฐไธ่ด๏ผๅฝ `penumbra` ไธบ 1 ๆถ๏ผๅ
ๅ้ฅๅคงๅฐไธบ 0๏ผๅ
็
งๅผบๅบฆไปไธญ่ฝด็บฟๅฐฑๅผๅงๅพๅค้ๅ๏ผๅฝ `penumbra` ไธบ 0.5 ๆถ๏ผๅ
็
งๅผบๅบฆไปๅคๅ้ฅๅๅพ็ไธญ็นๅคๅผๅงๅพๅค้ๅใ
+
+```js
+gui.add(light, 'penumbra', 0, 1, 0.01);
+```
+
+{{{example url="../threejs-lights-spot-w-helper.html" }}}
+
+ๆณจๆ่งๅฏ๏ผๅฝ `penumbra` ไธบ้ป่ฎคๅผ 0 ็ๆถๅ๏ผ่ๅ
็ฏไผๆ้ๅธธๆธ
ๆฐ็่พน็ผ๏ผ่ๅฝๆ `penumbra` ๅ 1 ่ฐ่็ๆถๅ๏ผ่พน็ผไผๅผๅงๆจก็ณใ
+
+็คบไพไธญๆ็น้พไปฅ็ๅฐ่ๅ
็ฏ็ๆดไธชๅ้ฅไฝ๏ผๅ ไธบๅ้ฅๅบ้จๅจๅนณ้ขไธๆนใๅฐ `distance` ๅๅฐๅฐ 5 ๅทฆๅณ๏ผๅฐฑๅฏไปฅ็ๅฐๅ้ฅ็ๅบ้จใ
+
+## ็ฉๅฝขๅบๅๅ
๏ผ`RectAreaLight`๏ผ
+
+Three.js ไธญ่ฟๆไธ็ง็ฑปๅ็ๅ
็
ง๏ผ็ฉๅฝขๅบๅๅ
๏ผ`RectAreaLight`๏ผ, ้กพๅๆไน๏ผ่กจ็คบไธไธช็ฉๅฝขๅบๅ็ๅๅฐๅบๆฅ็ๅ
็
ง๏ผไพๅฆ้ฟๆก็ๆฅๅ
็ฏๆ่
ๅคฉ่ฑๆฟไธ็ฃจ็ ็ป็้่ฟๆฅ็่ช็ถๅ
ใ
+
+`RectAreaLight` ๅช่ฝๅฝฑๅ `MeshStandardMaterial` ๅ `MeshPhysicalMaterial`๏ผๆไปฅๆไปฌๆๆๆ็ๆ่ดจ้ฝๆนไธบ `MeshStandardMaterial`ใ
+
+```js
+ ...
+
+ const planeGeo = new THREE.PlaneBufferGeometry(planeSize, planeSize);
+- const planeMat = new THREE.MeshPhongMaterial({
++ const planeMat = new THREE.MeshStandardMaterial({
+ map: texture,
+ side: THREE.DoubleSide,
+ });
+ const mesh = new THREE.Mesh(planeGeo, planeMat);
+ mesh.rotation.x = Math.PI * -.5;
+ scene.add(mesh);
+}
+{
+ const cubeSize = 4;
+ const cubeGeo = new THREE.BoxBufferGeometry(cubeSize, cubeSize, cubeSize);
+- const cubeMat = new THREE.MeshPhongMaterial({color: '#8AC'});
++ const cubeMat = new THREE.MeshStandardMaterial({color: '#8AC'});
+ const mesh = new THREE.Mesh(cubeGeo, cubeMat);
+ mesh.position.set(cubeSize + 1, cubeSize / 2, 0);
+ scene.add(mesh);
+}
+{
+ const sphereRadius = 3;
+ const sphereWidthDivisions = 32;
+ const sphereHeightDivisions = 16;
+ const sphereGeo = new THREE.SphereBufferGeometry(sphereRadius, sphereWidthDivisions, sphereHeightDivisions);
+- const sphereMat = new THREE.MeshPhongMaterial({color: '#CA8'});
++ const sphereMat = new THREE.MeshStandardMaterial({color: '#CA8'});
+ const mesh = new THREE.Mesh(sphereGeo, sphereMat);
+ mesh.position.set(-sphereRadius - 1, sphereRadius + 2, 0);
+ scene.add(mesh);
+}
+```
+
+ไธบไบไฝฟ็จ `RectAreaLight`๏ผๆไปฌ้่ฆๅผๅ
ฅ three.js ็`RectAreaLightUniformsLib` ๆจกๅ๏ผๅๆถไฝฟ็จ `RectAreaLightHelper` ๆฅ่พ
ๅฉๆฅ็็ฏๅ
ๅฏน่ฑกใ
+
+```js
+import * as THREE from './resources/three/r122/build/three.module.js';
++import {RectAreaLightUniformsLib} from './resources/threejs/r122/examples/jsm/lights/RectAreaLightUniformsLib.js';
++import {RectAreaLightHelper} from './resources/threejs/r122/examples/jsm/helpers/RectAreaLightHelper.js';
+```
+
+ๆไปฌ้่ฆๅ
่ฐ็จ `RectAreaLightUniformsLib.init`
+
+```js
+function main() {
+ const canvas = document.querySelector('#c');
+ const renderer = new THREE.WebGLRenderer({canvas});
++ RectAreaLightUniformsLib.init();
+```
+
+ๅฆๆๅฟไบๅผๅ
ฅๅไฝฟ็จ `RectAreaLightUniformsLib`๏ผๅ
็
ง่ฟๆฏๅฏไปฅๆพ็คบ๏ผไฝๆฏไผ็่ตทๆฅๅพๅฅๆช๏ผ่ฏ่
ๆณจ๏ผๅจ็คบไพ็็ฎๅๅบๆฏไธญๆฒกๆๅ็ฐๅบๅซ๏ผ๏ผๆไปฅ่ฆ็กฎไฟๆไฝฟ็จใ
+
+็ถๅๆไปฌๅฏไปฅๅๅปบๅ
็
งไบ
+
+```js
+const color = 0xFFFFFF;
+*const intensity = 5;
++const width = 12;
++const height = 4;
+*const light = new THREE.RectAreaLight(color, intensity, width, height);
+light.position.set(0, 10, 0);
++light.rotation.x = THREE.MathUtils.degToRad(-90);
+scene.add(light);
+
+*const helper = new RectAreaLightHelper(light);
+*light.add(helper);
+```
+
+้่ฆๆณจๆ็ๆฏ๏ผไธๆนๅๅ
๏ผ`DirectionalLight`๏ผๅ่ๅ
็ฏ๏ผ`SpotLight`๏ผไธๅ๏ผ็ฉๅฝขๅ
ไธๆฏไฝฟ็จ็ฎๆ ็น๏ผ`target`๏ผ๏ผ่ๆฏไฝฟ็จ่ช่บซ็ๆ่ฝฌ่งๅบฆๆฅ็กฎๅฎๅ
็
งๆนๅใๅฆๅค๏ผ็ฉๅฝขๅ
็่พ
ๅฉๅฏน่ฑก๏ผ`RectAreaLightHelper`๏ผๅบ่ฏฅๆทปๅ ไธบๅ
็
ง็ๅญ่็น๏ผ่ไธๆฏๆทปๅ ไธบๅบๆฏ็ๅญ่็นใ
+
+ๅๆถๆไปฌไฟฎๆนไธไธ GUI ไปฃ็ ๏ผไฝฟๆไปฌๅฏไปฅๆ่ฝฌๅ
ๆบ๏ผ่ฐๆด `width` ๅ `height` ๅฑๆงใ
+
+```js
+const gui = new GUI();
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.add(light, 'intensity', 0, 10, 0.01);
+gui.add(light, 'width', 0, 20).onChange(updateLight);
+gui.add(light, 'height', 0, 20).onChange(updateLight);
+gui.add(new DegRadHelper(light.rotation, 'x'), 'value', -180, 180).name('x rotation').onChange(updateLight);
+gui.add(new DegRadHelper(light.rotation, 'y'), 'value', -180, 180).name('y rotation').onChange(updateLight);
+gui.add(new DegRadHelper(light.rotation, 'z'), 'value', -180, 180).name('z rotation').onChange(updateLight);
+
+makeXYZGUI(gui, light.position, 'position', updateLight);
+```
+
+ๅบๆฏๅฆไธๆ็คบ๏ผ
+
+{{{example url="../threejs-lights-rectarea.html" }}}
+
+ๅ
ณไบๅ
็
ง๏ผๆไปฌๅฐๆชๆๅ็ๆฏ `WebGLRenderer` ไธญๆไธไธช่ฎพ็ฝฎ้กน `physicallyCorrectLights`ใ่ฟไธช่ฎพ็ฝฎไผๅฝฑๅ๏ผ้็็ฆปๅ
ๆบ็่ท็ฆปๅขๅ ๏ผๅ
็
งๅฆไฝๅๅผฑใ่ฟไธช่ฎพ็ฝฎไผๅฝฑๅ็นๅ
ๆบ๏ผ`PointLight`๏ผๅ่ๅ
็ฏ๏ผ`SpotLight`๏ผ๏ผ็ฉๅฝขๅบๅๅ
๏ผ`RectAreaLight`๏ผไผ่ชๅจๅบ็จ่ฟไธช็นๆงใ
+
+ๅจ่ฎพ็ฝฎๅ
็
งๆถ๏ผๅบๆฌๆ่ทฏๆฏไธ่ฆ่ฎพ็ฝฎ `distance` ๆฅ่กจ็ฐๅ
็
ง็่กฐๅ๏ผไนไธ่ฆ่ฎพ็ฝฎ `intensity`ใ่ๆฏ่ฎพ็ฝฎๅ
็
ง็ [`power`](PointLight.power) ๅฑๆง๏ผไปฅๆตๆไธบๅไฝ๏ผthree.js ไผ่ฟ่ก็ฉ็่ฎก็ฎ๏ผไป่่กจ็ฐๅบๆฅ่ฟ็ๅฎ็ๅ
็
งๆๆใๅจ่ฟ็งๆ
ๅตไธ three.js ๅไธ่ฎก็ฎ็้ฟๅบฆๅไฝๆฏ็ฑณ๏ผไธไธช 60็ฆ ็็ฏๆณกๅคงๆฆๆฏ 800 ๆตๆๅผบๅบฆใๅนถไธๅ
ๆบๆไธไธช [`decay`](PointLight.decay) ๅฑๆง๏ผไธบไบๆจกๆ็ๅฎๆๆ๏ผๅบ่ฏฅ่ขซ่ฎพ็ฝฎไธบ `2`ใ
+
+ไธ้ข่ฎฉๆไปฌๆต่ฏ็็ใ
+
+้ฆๅ
ๅผๅฏ `physicallyCorrectLights` ๆจกๅผ
+
+```js
+const renderer = new THREE.WebGLRenderer({canvas});
++renderer.physicallyCorrectLights = true;
+```
+
+็ถๅๆไปฌ่ฎพ็ฝฎๅ
็
ง็ๅๆฐ๏ผ`power` ่ฎพ็ฝฎไธบ 800 ๆตๆ๏ผ`decay` ่ฎพ็ฝฎไธบ 2๏ผ`distance` ่ฎพ็ฝฎไธบ `Infinity`ใ
+
+```js
+const color = 0xFFFFFF;
+const intensity = 1;
+const light = new THREE.PointLight(color, intensity);
+light.power = 800;
+light.decay = 2;
+light.distance = Infinity;
+```
+
+ๅนถไธๆทปๅ gui ๆงๅถ `power` ๅ `decay`
+
+```js
+const gui = new GUI();
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.add(light, 'decay', 0, 4, 0.01);
+gui.add(light, 'power', 0, 2000);
+```
+
+{{{example url="../threejs-lights-point-physically-correct.html" }}}
+
+้่ฆๆณจๆ๏ผๆฏๆทปๅ ไธไธชๅ
ๆบๅฐๅบๆฏไธญ๏ผ้ฝไผ้ไฝ three.js ๆธฒๆๅบๆฏ็้ๅบฆ๏ผๆไปฅๅบ่ฏฅๅฐฝ้ไฝฟ็จๆๅฐ็่ตๆบๆฅๅฎ็ฐๆณ่ฆ็ๆๆใ
+
+ๆฅไธๆฅๆไปฌๅญฆไน three.js ไธญ็ [็ธๆบ](threejs-cameras.html)ใ
+
+<canvas id="c"></canvas>
+<script type="module" src="resources/threejs-lights.js"></script> | false |
Other | mrdoob | three.js | aec64e4f48dc806cf4bb21083ff3a60a3b056daf.json | Add userData property (issue #20621) | src/materials/Material.d.ts | @@ -53,6 +53,7 @@ export interface MaterialParameters {
stencilFail?: StencilOp;
stencilZFail?: StencilOp;
stencilZPass?: StencilOp;
+ userData?: any;
}
/** | false |
Other | mrdoob | three.js | 0fd9764f82ffe812768378ad268925992f2dc643.json | Fix improper SnakeCase. | src/math/Matrix3.d.ts | @@ -1,7 +1,7 @@
import { Matrix4 } from './Matrix4';
import { Vector3 } from './Vector3';
-type Matrix3tuple = [
+type Matrix3Tuple = [
number, number, number,
number, number, number,
number, number, number,
@@ -131,7 +131,7 @@ export class Matrix3 implements Matrix {
* @return The created or provided array.
*/
toArray( array?: number[], offset?: number ): number[];
- toArray( array?: Matrix3tuple, offset?: 0 ): Matrix3tuple;
+ toArray( array?: Matrix3Tuple, offset?: 0 ): Matrix3Tuple;
/**
* Copies he values of this matrix into the provided array-like. | true |
Other | mrdoob | three.js | 0fd9764f82ffe812768378ad268925992f2dc643.json | Fix improper SnakeCase. | src/math/Matrix4.d.ts | @@ -3,7 +3,7 @@ import { Euler } from './Euler';
import { Quaternion } from './Quaternion';
import { Matrix } from './Matrix3';
-type Matrix4tuple = [
+type Matrix4Tuple = [
number, number, number, number,
number, number, number, number,
number, number, number, number,
@@ -243,7 +243,7 @@ export class Matrix4 implements Matrix {
* @return The created or provided array.
*/
toArray( array?: number[], offset?: number ): number[];
- toArray( array?: Matrix4tuple, offset?: 0 ): Matrix4tuple;
+ toArray( array?: Matrix4Tuple, offset?: 0 ): Matrix4Tuple;
/**
* Copies he values of this matrix into the provided array-like. | true |
Other | mrdoob | three.js | 0fd9764f82ffe812768378ad268925992f2dc643.json | Fix improper SnakeCase. | src/math/Vector3.d.ts | @@ -9,7 +9,7 @@ import { BufferAttribute } from './../core/BufferAttribute';
import { InterleavedBufferAttribute } from './../core/InterleavedBufferAttribute';
import { Vector } from './Vector2';
-type Vector3tuple = [number, number, number];
+type Vector3Tuple = [number, number, number];
/**
* 3D vector.
@@ -287,7 +287,7 @@ export class Vector3 implements Vector {
* @return The created or provided array.
*/
toArray( array?: number[], offset?: number ): number[];
- toArray( array?: Vector3tuple, offset?: 0 ): Vector3tuple;
+ toArray( array?: Vector3Tuple, offset?: 0 ): Vector3Tuple;
/**
* Copies x, y and z into the provided array-like. | true |
Other | mrdoob | three.js | 0fd9764f82ffe812768378ad268925992f2dc643.json | Fix improper SnakeCase. | src/math/Vector4.d.ts | @@ -4,7 +4,7 @@ import { Matrix3 } from './Matrix3';
import { BufferAttribute } from './../core/BufferAttribute';
import { Vector } from './Vector2';
-type Vector4tuple = [number, number, number, number];
+type Vector4Tuple = [number, number, number, number];
/**
* 4D vector.
@@ -213,7 +213,7 @@ export class Vector4 implements Vector {
* @return The created or provided array.
*/
toArray( array?: number[], offset?: number ): number[];
- toArray( array?: Vector4tuple, offset?: 0 ): Vector4tuple;
+ toArray( array?: Vector4Tuple, offset?: 0 ): Vector4Tuple;
/**
* Copies x, y, z and w into the provided array-like. | true |
Other | mrdoob | three.js | 2f5fe01ba4444d11c605d546ed0839f3de0e96af.json | update rounded box uvs | examples/jsm/geometries/RoundedBoxBufferGeometry.js | @@ -28,6 +28,10 @@ class RoundedBoxBufferGeometry extends BoxBufferGeometry {
const uvs = this.attributes.uv.array;
const faceTris = positions.length / 6;
+ const arcLength = 2 * Math.PI * radius / 4;
+ const widthLength = Math.max( width - 2 * radius, 0 );
+ const heightLength = Math.max( height - 2 * radius, 0 );
+ const depthLength = Math.max( depth - 2 * radius, 0 );
for ( let i = 0, j = 0; i < positions.length; i += 3, j += 2 ) {
@@ -47,30 +51,81 @@ class RoundedBoxBufferGeometry extends BoxBufferGeometry {
switch ( side ) {
case 0: // right
- uvs[ j + 0 ] = 0.5 - ( positions[ i + 2 ] / ( depth - radius ) );
- uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
- break;
- case 1: // left
- uvs[ j + 0 ] = 0.5 + ( positions[ i + 2 ] / ( depth - radius ) );
- uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
- break;
- case 2: // top
- uvs[ j + 0 ] = 0.5 + ( positions[ i + 0 ] / ( width - radius ) );
- uvs[ j + 1 ] = 0.5 - ( positions[ i + 2 ] / ( depth - radius ) );
- break;
- case 3: // bottom
- uvs[ j + 0 ] = 0.5 + ( positions[ i + 0 ] / ( width - radius ) );
- uvs[ j + 1 ] = 0.5 + ( positions[ i + 2 ] / ( depth - radius ) );
- break;
- case 4: // front
- uvs[ j + 0 ] = 0.5 + ( positions[ i + 0 ] / ( width - radius ) );
- uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
- break;
- case 5: // back
- uvs[ j + 0 ] = 0.5 - ( positions[ i + 0 ] / ( width - radius ) );
- uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
+
+ const tempNormal = new Vector3();
+ const rightVector = new Vector3( 1, 0, 0 );
+ const totArcLength = 2 * Math.PI * radius / 4;
+
+ // length of the planes between the arcs on each axis
+ const heightLength = Math.max( height - 2 * radius, 0 );
+ const depthLength = Math.max( depth - 2 * radius, 0 );
+ const halfArc = Math.PI / 4;
+
+ // Get the vector projected onto the Y plane
+ tempNormal.copy( normal );
+ tempNormal.y = 0;
+ tempNormal.normalize();
+
+ // total amount of UV space alloted to a single arc
+ const arcUvRatioZ = 0.5 * totArcLength / ( totArcLength + depthLength );
+
+ // the distance along one arc the point is at
+ const arcAngleRatioZ = 1.0 - ( tempNormal.angleTo( rightVector ) / halfArc );
+
+ if ( Math.sign( tempNormal.z ) === 1 ) {
+
+ uvs[ j + 0 ] = arcAngleRatioZ * arcUvRatioZ;
+
+ } else {
+
+ // total amount of UV space alloted to the plane between the arcs
+ const lenUv = depthLength / ( totArcLength + depthLength );
+ uvs[ j + 0 ] = lenUv + arcUvRatioZ + arcUvRatioZ * ( 1.0 - arcAngleRatioZ );
+
+ }
+
+ tempNormal.copy( normal );
+ tempNormal.z = 0;
+ tempNormal.normalize();
+
+ const arcUvRatioY = 0.5 * totArcLength / ( totArcLength + heightLength );
+ const arcAngleRatioY = 1.0 - ( tempNormal.angleTo( rightVector ) / halfArc );
+
+ if ( Math.sign( tempNormal.y ) === - 1 ) {
+
+ uvs[ j + 1 ] = arcAngleRatioY * arcUvRatioY;
+
+ } else {
+
+ const lenUv = heightLength / ( totArcLength + heightLength );
+ uvs[ j + 1 ] = lenUv + arcUvRatioY + arcUvRatioY * ( 1.0 - arcAngleRatioY );
+
+ }
+
break;
+
+ // case 1: // left
+ // uvs[ j + 0 ] = 0.5 + ( positions[ i + 2 ] / ( depth - radius ) );
+ // uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
+ // break;
+ // case 2: // top
+ // uvs[ j + 0 ] = 0.5 + ( positions[ i + 0 ] / ( width - radius ) );
+ // uvs[ j + 1 ] = 0.5 - ( positions[ i + 2 ] / ( depth - radius ) );
+ // break;
+ // case 3: // bottom
+ // uvs[ j + 0 ] = 0.5 + ( positions[ i + 0 ] / ( width - radius ) );
+ // uvs[ j + 1 ] = 0.5 + ( positions[ i + 2 ] / ( depth - radius ) );
+ // break;
+ // case 4: // front
+ // uvs[ j + 0 ] = 0.5 + ( positions[ i + 0 ] / ( width - radius ) );
+ // uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
+ // break;
+ // case 5: // back
+ // uvs[ j + 0 ] = 0.5 - ( positions[ i + 0 ] / ( width - radius ) );
+ // uvs[ j + 1 ] = 0.5 + ( positions[ i + 1 ] / ( height - radius ) );
+ // break;
+
}
} | false |
Other | mrdoob | three.js | 48a6b71bc3212c22bf34267de7d0d5e030e80e28.json | Fix typo in threejs-scenegraph (#137) | threejs/lessons/threejs-scenegraph.md | @@ -226,7 +226,7 @@ objects.push(earthMesh);
Again we added more invisible scene graph nodes. The first, an `Object3D` called `earthOrbit`
and added both the `earthMesh` and the `moonOrbit` to it, also new. We then added the `mooMesh`
-to the `moonRobit`. The new scene graph looks like this.
+to the `moonOrbit`. The new scene graph looks like this.
<img src="resources/images/scenegraph-sun-earth-moon.svg" align="center">
| false |
Other | mrdoob | three.js | 9bf79c0c65f195cdeddaa4a72e217cf705187999.json | fix moonOrbit diagram/code | threejs/lessons/resources/images/scenegraph-sun-earth-moon.svg | @@ -1 +1 @@
-<svg version="1.1" viewBox="0.0 0.0 960.0 540.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="g33826f1ac4_0_49.0"><path d="m0 0l960.0 0l0 540.0l-960.0 0l0 -540.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#g33826f1ac4_0_49.0)"><path fill="#9fc5e8" d="m404.51837 48.492363l0 0c0 -6.540573 5.302185 -11.842758 11.842743 -11.842758l127.275116 0c3.1409302 0 6.153137 1.2477188 8.374084 3.468666c2.2209473 2.2209473 3.468689 5.2331963 3.468689 8.374092l0 47.369606c0 6.540573 -5.302185 11.842758 -11.842773 11.842758l-127.275116 0c-6.540558 0 -11.842743 -5.302185 -11.842743 -11.842758z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m404.51837 48.492363l0 0c0 -6.540573 5.302185 -11.842758 11.842743 -11.842758l127.275116 0c3.1409302 0 6.153137 1.2477188 8.374084 3.468666c2.2209473 2.2209473 3.468689 5.2331963 3.468689 8.374092l0 47.369606c0 6.540573 -5.302185 11.842758 -11.842773 11.842758l-127.275116 0c-6.540558 0 -11.842743 -5.302185 -11.842743 -11.842758z" fill-rule="evenodd"/><path fill="#000000" d="m424.8655 79.09716l0 -13.359375l5.6875 0q2.140625 0 3.109375 0.359375q0.96875 0.359375 1.546875 1.28125q0.578125 0.921875 0.578125 2.109375q0 1.5 -0.890625 2.484375q-0.875 0.96875 -2.625 1.234375q0.875 0.5 1.4375 1.125q0.578125 0.609375 1.53125 2.15625l1.640625 2.609375l-3.234375 0l-1.9375 -2.90625q-1.046875 -1.5625 -1.4375 -1.96875q-0.375 -0.40625 -0.8125 -0.546875q-0.421875 -0.15625 -1.34375 -0.15625l-0.546875 0l0 5.578125l-2.703125 0zm2.703125 -7.703125l2.0 0q1.9375 0 2.421875 -0.15625q0.484375 -0.171875 0.75 -0.578125q0.28125 -0.40625 0.28125 -1.0q0 -0.671875 -0.359375 -1.078125q-0.359375 -0.421875 -1.015625 -0.53125q-0.328125 -0.046875 -1.96875 -0.046875l-2.109375 0l0 3.390625zm10.160461 2.734375q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm8.770966 -0.125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm13.802246 -4.828125l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm11.192841 13.59375l-1.75 0q-1.390625 -2.09375 -2.125 -4.359375q-0.734375 -2.28125 -0.734375 -4.40625q0 -2.625 0.90625 -4.96875q0.78125 -2.046875 1.984375 -3.765625l1.75 0q-1.25 2.75 -1.71875 4.6875q-0.46875 1.9375 -0.46875 4.109375q0 1.5 0.28125 3.0625q0.28125 1.5625 0.765625 2.96875q0.3125 0.9375 1.109375 2.671875zm1.072052 -6.6875l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm19.719482 -4.046875l-2.53125 0.453125q-0.125 -0.75 -0.578125 -1.125q-0.453125 -0.390625 -1.171875 -0.390625q-0.953125 0 -1.53125 0.65625q-0.5625 0.65625 -0.5625 2.203125q0 1.734375 0.578125 2.4375q0.578125 0.703125 1.546875 0.703125q0.734375 0 1.203125 -0.40625q0.46875 -0.421875 0.65625 -1.421875l2.515625 0.421875q-0.390625 1.734375 -1.515625 2.625q-1.109375 0.875 -2.96875 0.875q-2.125 0 -3.390625 -1.328125q-1.25 -1.34375 -1.25 -3.71875q0 -2.390625 1.265625 -3.71875q1.265625 -1.34375 3.421875 -1.34375q1.765625 0 2.796875 0.765625q1.046875 0.75 1.515625 2.3125zm7.531952 3.734375l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm13.422577 5.671875l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.5468445 0l0 -9.671875l2.3749695 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm8.192871 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.9069824 9.59375q0.765625 -1.609375 1.0625 -2.484375q0.3125 -0.859375 0.578125 -1.984375q0.265625 -1.140625 0.390625 -2.15625q0.125 -1.015625 0.125 -2.078125q0 -2.171875 -0.46875 -4.109375q-0.453125 -1.9375 -1.703125 -4.6875l1.734375 0q1.375 1.953125 2.140625 4.15625q0.765625 2.1875 0.765625 4.453125q0 1.90625 -0.609375 4.078125q-0.671875 2.4375 -2.25 4.8125l-1.765625 0z" fill-rule="nonzero"/><path fill="#9fc5e8" d="m404.51837 173.30164l0 0c0 -6.540573 5.302185 -11.842758 11.842743 -11.842758l127.275116 0c3.1409302 0 6.153137 1.2477112 8.374084 3.4686584c2.2209473 2.2209473 3.468689 5.2332 3.468689 8.3741l0 47.3696c0 6.5405884 -5.302185 11.842758 -11.842773 11.842758l-127.275116 0c-6.540558 0 -11.842743 -5.30217 -11.842743 -11.842758z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m404.51837 173.30164l0 0c0 -6.540573 5.302185 -11.842758 11.842743 -11.842758l127.275116 0c3.1409302 0 6.153137 1.2477112 8.374084 3.4686584c2.2209473 2.2209473 3.468689 5.2332 3.468689 8.3741l0 47.3696c0 6.5405884 -5.302185 11.842758 -11.842773 11.842758l-127.275116 0c-6.540558 0 -11.842743 -5.30217 -11.842743 -11.842758z" fill-rule="evenodd"/><path fill="#000000" d="m424.9548 201.14081l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm10.688202 -2.203125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm9.364746 4.84375l0 -13.359375l2.5625 0l0 13.359375l-2.5625 0zm7.0895386 -6.71875l-2.328125 -0.421875q0.40625 -1.40625 1.359375 -2.078125q0.953125 -0.671875 2.84375 -0.671875q1.703125 0 2.546875 0.40625q0.84375 0.40625 1.171875 1.03125q0.34375 0.625 0.34375 2.28125l-0.015625 3.0q0 1.265625 0.109375 1.875q0.125 0.609375 0.46875 1.296875l-2.53125 0q-0.109375 -0.25 -0.25 -0.75q-0.0625 -0.234375 -0.09375 -0.3125q-0.65625 0.640625 -1.40625 0.96875q-0.734375 0.3125 -1.59375 0.3125q-1.484375 0 -2.34375 -0.8125q-0.859375 -0.8125 -0.859375 -2.046875q0 -0.828125 0.390625 -1.46875q0.390625 -0.640625 1.09375 -0.96875q0.703125 -0.34375 2.03125 -0.609375q1.796875 -0.328125 2.484375 -0.625l0 -0.25q0 -0.75 -0.359375 -1.0625q-0.359375 -0.3125 -1.375 -0.3125q-0.6875 0 -1.078125 0.28125q-0.375 0.265625 -0.609375 0.9375zm3.421875 2.078125q-0.484375 0.15625 -1.5625 0.390625q-1.0625 0.21875 -1.390625 0.4375q-0.5 0.359375 -0.5 0.90625q0 0.53125 0.40625 0.9375q0.40625 0.390625 1.015625 0.390625q0.703125 0 1.328125 -0.46875q0.46875 -0.34375 0.609375 -0.84375q0.09375 -0.328125 0.09375 -1.25l0 -0.5zm7.5007324 4.640625l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm4.135254 -4.34375l2.625 -0.25q0.234375 1.3125 0.953125 1.9375q0.734375 0.609375 1.96875 0.609375q1.296875 0 1.953125 -0.546875q0.671875 -0.546875 0.671875 -1.28125q0 -0.484375 -0.28125 -0.8125q-0.28125 -0.328125 -0.96875 -0.578125q-0.484375 -0.15625 -2.171875 -0.578125q-2.15625 -0.546875 -3.03125 -1.328125q-1.234375 -1.09375 -1.234375 -2.6875q0 -1.015625 0.578125 -1.90625q0.578125 -0.890625 1.65625 -1.34375q1.09375 -0.46875 2.640625 -0.46875q2.515625 0 3.78125 1.109375q1.28125 1.09375 1.34375 2.9375l-2.703125 0.109375q-0.171875 -1.03125 -0.75 -1.46875q-0.5625 -0.453125 -1.703125 -0.453125q-1.171875 0 -1.84375 0.46875q-0.421875 0.3125 -0.421875 0.84375q0 0.46875 0.40625 0.796875q0.5 0.4375 2.46875 0.90625q1.96875 0.453125 2.90625 0.953125q0.953125 0.5 1.484375 1.359375q0.53125 0.859375 0.53125 2.125q0 1.15625 -0.640625 2.15625q-0.640625 1.0 -1.8125 1.484375q-1.15625 0.484375 -2.890625 0.484375q-2.53125 0 -3.890625 -1.171875q-1.359375 -1.171875 -1.625 -3.40625zm11.896698 -5.328125l2.71875 0l2.328125 6.859375l2.25 -6.859375l2.65625 0l-3.421875 9.3125l-0.609375 1.6875q-0.328125 0.84375 -0.640625 1.28125q-0.3125 0.453125 -0.703125 0.71875q-0.390625 0.28125 -0.96875 0.4375q-0.578125 0.15625 -1.3125 0.15625q-0.734375 0 -1.453125 -0.15625l-0.21875 -2.0q0.59375 0.125 1.078125 0.125q0.890625 0 1.3125 -0.53125q0.4375 -0.515625 0.671875 -1.328125l-3.6875 -9.703125zm10.688232 6.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm15.719452 -6.90625l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm7.3689575 6.59375l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.5156555 0 -3.7344055 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875305 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.4062805 0q0.03125 1.140625 0.6094055 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.5469055 0.609375 -0.5312805 1.65625l3.8281555 0zm4.4225464 -4.0l2.359375 0l0 1.3125q1.265625 -1.53125 3.015625 -1.53125q0.9375 0 1.609375 0.390625q0.6875 0.375 1.125 1.140625q0.640625 -0.765625 1.375 -1.140625q0.75 -0.390625 1.578125 -0.390625q1.0625 0 1.796875 0.4375q0.75 0.421875 1.109375 1.265625q0.265625 0.625 0.265625 2.0l0 6.1875l-2.5625 0l0 -5.53125q0 -1.4375 -0.265625 -1.859375q-0.34375 -0.546875 -1.09375 -0.546875q-0.53125 0 -1.015625 0.328125q-0.46875 0.328125 -0.671875 0.96875q-0.203125 0.625 -0.203125 2.0l0 4.640625l-2.5625 0l0 -5.296875q0 -1.421875 -0.140625 -1.828125q-0.140625 -0.40625 -0.421875 -0.609375q-0.28125 -0.203125 -0.78125 -0.203125q-0.59375 0 -1.0625 0.328125q-0.46875 0.3125 -0.6875 0.921875q-0.203125 0.59375 -0.203125 1.984375l0 4.703125l-2.5625 0l0 -9.671875z" fill-rule="nonzero"/><path fill="#9fc5e8" d="m311.7743 298.1109l0 0c0 -6.540558 5.3021545 -11.842743 11.842743 -11.842743l127.275116 0c3.1408997 0 6.153137 1.2477112 8.374084 3.4686584c2.2209473 2.2209473 3.4686584 5.233185 3.4686584 8.374084l0 47.36963c0 6.540558 -5.3021545 11.842743 -11.842743 11.842743l-127.275116 0c-6.5405884 0 -11.842743 -5.302185 -11.842743 -11.842743z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m311.7743 298.1109l0 0c0 -6.540558 5.3021545 -11.842743 11.842743 -11.842743l127.275116 0c3.1408997 0 6.153137 1.2477112 8.374084 3.4686584c2.2209473 2.2209473 3.4686584 5.233185 3.4686584 8.374084l0 47.36963c0 6.540558 -5.3021545 11.842743 -11.842743 11.842743l-127.275116 0c-6.5405884 0 -11.842743 -5.302185 -11.842743 -11.842743z" fill-rule="evenodd"/><path fill="#000000" d="m330.67575 325.95007l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm17.641327 2.765625l0 -1.453125q-0.53125 0.78125 -1.390625 1.234375q-0.859375 0.4375 -1.8125 0.4375q-0.96875 0 -1.75 -0.421875q-0.765625 -0.4375 -1.125 -1.203125q-0.34375 -0.78125 -0.34375 -2.140625l0 -6.125l2.5625 0l0 4.4375q0 2.046875 0.140625 2.515625q0.140625 0.453125 0.515625 0.71875q0.375 0.265625 0.953125 0.265625q0.65625 0 1.171875 -0.359375q0.515625 -0.359375 0.703125 -0.890625q0.203125 -0.53125 0.203125 -2.609375l0 -4.078125l2.546875 0l0 9.671875l-2.375 0zm13.833496 0l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.546875 0l0 -9.671875l2.375 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm2.5834656 0l0 -13.359375l4.03125 0l2.421875 9.109375l2.390625 -9.109375l4.046875 0l0 13.359375l-2.5 0l0 -10.515625l-2.65625 10.515625l-2.59375 0l-2.640625 -10.515625l0 10.515625l-2.5 0zm21.150177 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.7194824 2.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm13.828827 -10.59375l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0zm13.083496 17.28125l-1.75 0q-1.390625 -2.09375 -2.125 -4.359375q-0.734375 -2.28125 -0.734375 -4.40625q0 -2.625 0.90625 -4.96875q0.78125 -2.046875 1.984375 -3.765625l1.75 0q-1.25 2.75 -1.71875 4.6875q-0.46875 1.9375 -0.46875 4.109375q0 1.5 0.28125 3.0625q0.28125 1.5625 0.765625 2.96875q0.3125 0.9375 1.109375 2.671875zm1.462677 -7.359375l2.546875 -0.265625q0.109375 0.875 0.640625 1.375q0.546875 0.5 1.25 0.5q0.796875 0 1.34375 -0.640625q0.5625 -0.65625 0.5625 -1.96875q0 -1.234375 -0.546875 -1.84375q-0.546875 -0.609375 -1.4375 -0.609375q-1.09375 0 -1.96875 0.96875l-2.078125 -0.296875l1.3125 -6.953125l6.765625 0l0 2.390625l-4.828125 0l-0.40625 2.265625q0.859375 -0.421875 1.75 -0.421875q1.703125 0 2.890625 1.25q1.1875 1.234375 1.1875 3.203125q0 1.65625 -0.953125 2.9375q-1.3125 1.78125 -3.625 1.78125q-1.84375 0 -3.015625 -1.0q-1.15625 -1.0 -1.390625 -2.671875zm9.656952 3.4375l3.484375 -4.984375l-3.34375 -4.6875l3.125 0l1.71875 2.65625l1.796875 -2.65625l3.015625 0l-3.28125 4.578125l3.578125 5.09375l-3.140625 0l-1.96875 -3.0l-1.984375 3.0l-3.0 0zm10.891357 3.921875q0.765625 -1.609375 1.0625 -2.484375q0.3125 -0.859375 0.578125 -1.984375q0.265625 -1.140625 0.390625 -2.15625q0.125 -1.015625 0.125 -2.078125q0 -2.171875 -0.46875 -4.109375q-0.453125 -1.9375 -1.703125 -4.6875l1.734375 0q1.375 1.953125 2.140625 4.15625q0.765625 2.1875 0.765625 4.453125q0 1.90625 -0.609375 4.078125q-0.671875 2.4375 -2.25 4.8125l-1.765625 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m479.9987 107.70473c0 13.438522 0.01574707 20.156578 0.03149414 26.877045c0.01574707 6.7204742 0.03149414 13.443375 0.03149414 26.886734" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m479.9987 107.70473c0 13.438522 0.01574707 20.156578 0.03149414 26.877045l0.01763916 8.886749" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m475.09262 143.47234l4.9656677 13.610458l4.944702 -13.618103z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m479.9987 232.51399l0 26.87706l-92.75592 0l0 26.886719" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m479.9987 232.514l0 26.877045l-92.75592 0l0 8.886719" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m382.2876 268.27777l4.9551697 13.614319l4.9552 -13.614319z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m497.26248 298.1109l0 0c0 -6.540558 5.3021545 -11.842743 11.842743 -11.842743l127.27515 0c3.1408691 0 6.153137 1.2477112 8.374084 3.4686584c2.2209473 2.2209473 3.468628 5.233185 3.468628 8.374084l0 47.36963c0 6.540558 -5.302185 11.842743 -11.842712 11.842743l-127.27515 0c-6.5405884 0 -11.842743 -5.302185 -11.842743 -11.842743z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m497.26248 298.1109l0 0c0 -6.540558 5.3021545 -11.842743 11.842743 -11.842743l127.27515 0c3.1408691 0 6.153137 1.2477112 8.374084 3.4686584c2.2209473 2.2209473 3.468628 5.233185 3.468628 8.374084l0 47.36963c0 6.540558 -5.302185 11.842743 -11.842712 11.842743l-127.27515 0c-6.5405884 0 -11.842743 -5.302185 -11.842743 -11.842743z" fill-rule="evenodd"/><path fill="#000000" d="m534.58826 325.63757l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm6.5319824 -1.046875l-2.328125 -0.421875q0.40625 -1.40625 1.359375 -2.078125q0.953125 -0.671875 2.84375 -0.671875q1.703125 0 2.546875 0.40625q0.84375 0.40625 1.171875 1.03125q0.34375 0.625 0.34375 2.28125l-0.015625 3.0q0 1.265625 0.109375 1.875q0.125 0.609375 0.46875 1.296875l-2.53125 0q-0.109375 -0.25 -0.25 -0.75q-0.0625 -0.234375 -0.09375 -0.3125q-0.65625 0.640625 -1.40625 0.96875q-0.734375 0.3125 -1.59375 0.3125q-1.484375 0 -2.34375 -0.8125q-0.859375 -0.8125 -0.859375 -2.046875q0 -0.828125 0.390625 -1.46875q0.390625 -0.640625 1.09375 -0.96875q0.703125 -0.34375 2.03125 -0.609375q1.796875 -0.328125 2.484375 -0.625l0 -0.25q0 -0.75 -0.359375 -1.0625q-0.359375 -0.3125 -1.375 -0.3125q-0.6875 0 -1.078125 0.28125q-0.375 0.265625 -0.609375 0.9375zm3.421875 2.078125q-0.484375 0.15625 -1.5625 0.390625q-1.0625 0.21875 -1.390625 0.4375q-0.5 0.359375 -0.5 0.90625q0 0.53125 0.40625 0.9375q0.40625 0.390625 1.015625 0.390625q0.703125 0 1.328125 -0.46875q0.46875 -0.34375 0.609375 -0.84375q0.09375 -0.328125 0.09375 -1.25l0 -0.5zm7.5007324 4.640625l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm9.244629 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm4.3220215 -3.6875l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0zm8.317871 6.765625q0 -2.046875 0.609375 -3.421875q0.453125 -1.03125 1.234375 -1.828125q0.796875 -0.8125 1.734375 -1.203125q1.25 -0.53125 2.875 -0.53125q2.953125 0 4.71875 1.828125q1.78125 1.828125 1.78125 5.09375q0 3.234375 -1.765625 5.0625q-1.75 1.828125 -4.6875 1.828125q-2.984375 0 -4.75 -1.8125q-1.75 -1.828125 -1.75 -5.015625zm2.78125 -0.09375q0 2.265625 1.046875 3.4375q1.046875 1.171875 2.65625 1.171875q1.609375 0 2.640625 -1.15625q1.046875 -1.171875 1.046875 -3.484375q0 -2.296875 -1.015625 -3.421875q-1.0 -1.140625 -2.671875 -1.140625q-1.671875 0 -2.6875 1.15625q-1.015625 1.140625 -1.015625 3.4375zm14.714539 6.6875l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm4.697815 0l0 -13.359375l2.5625 0l0 4.8125q1.171875 -1.34375 2.796875 -1.34375q1.765625 0 2.921875 1.28125q1.15625 1.28125 1.15625 3.671875q0 2.484375 -1.1875 3.828125q-1.171875 1.328125 -2.859375 1.328125q-0.828125 0 -1.640625 -0.40625q-0.796875 -0.421875 -1.375 -1.234375l0 1.421875l-2.375 0zm2.53125 -5.046875q0 1.5 0.484375 2.21875q0.65625 1.03125 1.765625 1.03125q0.84375 0 1.4375 -0.71875q0.59375 -0.734375 0.59375 -2.296875q0 -1.65625 -0.609375 -2.390625q-0.59375 -0.734375 -1.53125 -0.734375q-0.921875 0 -1.53125 0.71875q-0.609375 0.71875 -0.609375 2.171875zm8.97406 -5.9375l0 -2.375l2.5625 0l0 2.375l-2.5625 0zm0 10.984375l0 -9.671875l2.5625 0l0 9.671875l-2.5625 0zm9.62085 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m479.9987 232.51399l0 26.87706l92.75589 0l0 26.886719" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m479.9987 232.514l0 26.877045l92.75589 0l0 8.886719" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m567.7994 268.27777l4.9552 13.614319l4.9552 -13.614319z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m404.51706 428.34976l0 0c0 -6.5405884 5.302185 -11.842773 11.842743 -11.842773l127.27515 0c3.1408691 0 6.153137 1.2477112 8.374084 3.468689c2.2209473 2.2209473 3.468628 5.233185 3.468628 8.374084l0 47.3696c0 6.5405884 -5.302124 11.842743 -11.842712 11.842743l-127.27515 0c-6.540558 0 -11.842743 -5.3021545 -11.842743 -11.842743z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m404.51706 428.34976l0 0c0 -6.5405884 5.302185 -11.842773 11.842743 -11.842773l127.27515 0c3.1408691 0 6.153137 1.2477112 8.374084 3.468689c2.2209473 2.2209473 3.468628 5.233185 3.468628 8.374084l0 47.3696c0 6.5405884 -5.302124 11.842743 -11.842712 11.842743l-127.27515 0c-6.540558 0 -11.842743 -5.3021545 -11.842743 -11.842743z" fill-rule="evenodd"/><path fill="#000000" d="m440.28058 455.87643l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm6.5319824 -1.046875l-2.328125 -0.421875q0.40625 -1.40625 1.359375 -2.078125q0.953125 -0.671875 2.84375 -0.671875q1.703125 0 2.546875 0.40625q0.84375 0.40625 1.171875 1.03125q0.34375 0.625 0.34375 2.28125l-0.015625 3.0q0 1.265625 0.109375 1.875q0.125 0.609375 0.46875 1.296875l-2.53125 0q-0.109375 -0.25 -0.25 -0.75q-0.0625 -0.234375 -0.09375 -0.3125q-0.65625 0.640625 -1.40625 0.96875q-0.734375 0.3125 -1.59375 0.3125q-1.484375 0 -2.34375 -0.8125q-0.859375 -0.8125 -0.859375 -2.046875q0 -0.828125 0.390625 -1.46875q0.390625 -0.640625 1.09375 -0.96875q0.703125 -0.34375 2.03125 -0.609375q1.796875 -0.328125 2.484375 -0.625l0 -0.25q0 -0.75 -0.359375 -1.0625q-0.359375 -0.3125 -1.375 -0.3125q-0.6875 0 -1.078125 0.28125q-0.375 0.265625 -0.609375 0.9375zm3.421875 2.078125q-0.484375 0.15625 -1.5625 0.390625q-1.0625 0.21875 -1.390625 0.4375q-0.5 0.359375 -0.5 0.90625q0 0.53125 0.40625 0.9375q0.40625 0.390625 1.015625 0.390625q0.703125 0 1.328125 -0.46875q0.46875 -0.34375 0.609375 -0.84375q0.09375 -0.328125 0.09375 -1.25l0 -0.5zm7.500702 4.640625l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm9.244659 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm4.322052 -3.6875l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0zm8.833466 13.359375l0 -13.359375l4.03125 0l2.421875 9.109375l2.390625 -9.109375l4.046875 0l0 13.359375l-2.5 0l0 -10.515625l-2.65625 10.515625l-2.59375 0l-2.640625 -10.515625l0 10.515625l-2.5 0zm21.150177 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.7194824 2.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.9530945 0.65625q0.96875 0.640625 1.328125 1.90625l-2.4062195 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.0468445 0.453125 2.8593445 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.2812195 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm13.828827 -10.59375l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m572.7428 357.32327l0 29.591736l-92.75592 0l0 29.589355" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m572.7428 357.32327l0 29.591766l-92.75592 0l0 11.589355" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m475.03168 398.5044l4.9552 13.614288l4.9552 -13.614288z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m590.00525 428.34976l0 0c0 -6.5405884 5.302185 -11.842773 11.842773 -11.842773l127.275085 0c3.1409302 0 6.153137 1.2477112 8.374084 3.468689c2.2209473 2.2209473 3.468689 5.233185 3.468689 8.374084l0 47.3696c0 6.5405884 -5.302185 11.842743 -11.842773 11.842743l-127.275085 0c-6.5405884 0 -11.842773 -5.3021545 -11.842773 -11.842743z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m590.00525 428.34976l0 0c0 -6.5405884 5.302185 -11.842773 11.842773 -11.842773l127.275085 0c3.1409302 0 6.153137 1.2477112 8.374084 3.468689c2.2209473 2.2209473 3.468689 5.233185 3.468689 8.374084l0 47.3696c0 6.5405884 -5.302185 11.842743 -11.842773 11.842743l-127.275085 0c-6.5405884 0 -11.842773 -5.3021545 -11.842773 -11.842743z" fill-rule="evenodd"/><path fill="#000000" d="m617.3939 449.28268l2.359375 0l0 1.3125q1.265625 -1.53125 3.015625 -1.53125q0.9375 0 1.609375 0.390625q0.6875 0.375 1.125 1.140625q0.640625 -0.765625 1.375 -1.140625q0.75 -0.390625 1.578125 -0.390625q1.0625 0 1.796875 0.4375q0.75 0.421875 1.109375 1.265625q0.265625 0.625 0.265625 2.0l0 6.1875l-2.5625 0l0 -5.53125q0 -1.4375 -0.265625 -1.859375q-0.34375 -0.546875 -1.09375 -0.546875q-0.53125 0 -1.015625 0.328125q-0.46875 0.328125 -0.671875 0.96875q-0.203125 0.625 -0.203125 2.0l0 4.640625l-2.5625 0l0 -5.296875q0 -1.421875 -0.140625 -1.828125q-0.140625 -0.40625 -0.421875 -0.609375q-0.28125 -0.203125 -0.78125 -0.203125q-0.59375 0 -1.0625 0.328125q-0.46875 0.3125 -0.6875 0.921875q-0.203125 0.59375 -0.203125 1.984375l0 4.703125l-2.5625 0l0 -9.671875zm16.197754 4.703125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm8.770996 -0.125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm18.161621 4.84375l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.546875 0l0 -9.671875l2.375 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm2.583435 0l0 -13.359375l4.03125 0l2.421875 9.109375l2.390625 -9.109375l4.046875 0l0 13.359375l-2.5 0l0 -10.515625l-2.65625 10.515625l-2.59375 0l-2.640625 -10.515625l0 10.515625l-2.5 0zm21.150208 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.7194824 2.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm13.828796 -10.59375l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m572.7428 357.32327l0 29.591736l92.75586 0l0 29.589355" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m572.7428 357.32327l0 29.591766l92.75586 0l0 11.589355" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m660.5435 398.5044l4.955139 13.614288l4.9552 -13.614288z" fill-rule="evenodd"/></g></svg>
\ No newline at end of file
+<svg version="1.1" viewBox="0.0 0.0 960.0 540.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="g33826f1ac4_0_49.0"><path d="m0 0l960.0 0l0 540.0l-960.0 0l0 -540.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#g33826f1ac4_0_49.0)"><path fill="#9fc5e8" d="m389.85565 47.055325l0 0c0 -5.746193 4.6582336 -10.4044075 10.404419 -10.4044075l120.82898 0c2.7593994 0 5.4058228 1.0961761 7.3570557 3.0473824c1.9511719 1.9512062 3.0473633 4.5976067 3.0473633 7.357025l0 41.616383c0 5.746193 -4.658203 10.404411 -10.404419 10.404411l-120.82898 0c-5.7461853 0 -10.404419 -4.6582184 -10.404419 -10.404411z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m389.85565 47.055325l0 0c0 -5.746193 4.6582336 -10.4044075 10.404419 -10.4044075l120.82898 0c2.7593994 0 5.4058228 1.0961761 7.3570557 3.0473824c1.9511719 1.9512062 3.0473633 4.5976067 3.0473633 7.357025l0 41.616383c0 5.746193 -4.658203 10.404411 -10.404419 10.404411l-120.82898 0c-5.7461853 0 -10.404419 -4.6582184 -10.404419 -10.404411z" fill-rule="evenodd"/><path fill="#000000" d="m405.54138 74.783516l0 -13.359375l5.6875 0q2.140625 0 3.109375 0.359375q0.96875 0.359375 1.546875 1.28125q0.578125 0.921875 0.578125 2.109375q0 1.5 -0.890625 2.484375q-0.875 0.96875 -2.625 1.234375q0.875 0.5 1.4375 1.125q0.578125 0.609375 1.53125 2.15625l1.640625 2.609375l-3.234375 0l-1.9375 -2.90625q-1.046875 -1.5625 -1.4375 -1.96875q-0.375 -0.40625 -0.8125 -0.546875q-0.421875 -0.15625 -1.34375 -0.15625l-0.546875 0l0 5.578125l-2.703125 0zm2.703125 -7.703125l2.0 0q1.9375 0 2.421875 -0.15625q0.484375 -0.171875 0.75 -0.578125q0.28125 -0.40625 0.28125 -1.0q0 -0.671875 -0.359375 -1.078125q-0.359375 -0.421875 -1.015625 -0.53125q-0.328125 -0.046875 -1.96875 -0.046875l-2.109375 0l0 3.390625zm10.160461 2.734375q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm8.770966 -0.125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm13.802246 -4.828125l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm11.192841 13.59375l-1.75 0q-1.390625 -2.09375 -2.125 -4.359375q-0.734375 -2.28125 -0.734375 -4.40625q0 -2.625 0.90625 -4.96875q0.78125 -2.046875 1.984375 -3.765625l1.75 0q-1.25 2.75 -1.71875 4.6875q-0.46875 1.9375 -0.46875 4.109375q0 1.5 0.28125 3.0625q0.28125 1.5625 0.765625 2.96875q0.3125 0.9375 1.109375 2.671875zm1.072052 -6.6875l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm19.719482 -4.046875l-2.53125 0.453125q-0.125 -0.75 -0.578125 -1.125q-0.453125 -0.390625 -1.171875 -0.390625q-0.953125 0 -1.53125 0.65625q-0.5625 0.65625 -0.5625 2.203125q0 1.734375 0.578125 2.4375q0.578125 0.703125 1.546875 0.703125q0.734375 0 1.203125 -0.40625q0.46875 -0.421875 0.65625 -1.421875l2.515625 0.421875q-0.390625 1.734375 -1.515625 2.625q-1.109375 0.875 -2.96875 0.875q-2.125 0 -3.390625 -1.328125q-1.25 -1.34375 -1.25 -3.71875q0 -2.390625 1.265625 -3.71875q1.265625 -1.34375 3.421875 -1.34375q1.765625 0 2.796875 0.765625q1.046875 0.75 1.515625 2.3125zm7.531952 3.734375l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm13.422607 5.671875l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.546875 0l0 -9.671875l2.375 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm8.192841 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.9069824 9.59375q0.7655945 -1.609375 1.0624695 -2.484375q0.3125 -0.859375 0.578125 -1.984375q0.265625 -1.140625 0.390625 -2.15625q0.125 -1.015625 0.125 -2.078125q0 -2.171875 -0.46875 -4.109375q-0.453125 -1.9375 -1.7030945 -4.6875l1.7343445 0q1.375 1.953125 2.140625 4.15625q0.765625 2.1875 0.765625 4.453125q0 1.90625 -0.609375 4.078125q-0.671875 2.4375 -2.25 4.8125l-1.7655945 0z" fill-rule="nonzero"/><path fill="#9fc5e8" d="m389.85568 156.69574l0 0c0 -5.7461853 4.658203 -10.404404 10.404388 -10.404404l120.82898 0c2.7593994 0 5.4058228 1.0961761 7.3570557 3.0473785c1.9511719 1.9512024 3.0473633 4.5976105 3.0473633 7.357025l0 41.616394c0 5.7461853 -4.658203 10.404404 -10.404419 10.404404l-120.82898 0c-5.7461853 0 -10.404388 -4.6582184 -10.404388 -10.404404z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m389.85568 156.69574l0 0c0 -5.7461853 4.658203 -10.404404 10.404388 -10.404404l120.82898 0c2.7593994 0 5.4058228 1.0961761 7.3570557 3.0473785c1.9511719 1.9512024 3.0473633 4.5976105 3.0473633 7.357025l0 41.616394c0 5.7461853 -4.658203 10.404404 -10.404419 10.404404l-120.82898 0c-5.7461853 0 -10.404388 -4.6582184 -10.404388 -10.404404z" fill-rule="evenodd"/><path fill="#000000" d="m405.63068 181.65831l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm10.688202 -2.203125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm9.364746 4.84375l0 -13.359375l2.5625 0l0 13.359375l-2.5625 0zm7.0895386 -6.71875l-2.328125 -0.421875q0.40625 -1.40625 1.359375 -2.078125q0.953125 -0.671875 2.84375 -0.671875q1.703125 0 2.546875 0.40625q0.84375 0.40625 1.171875 1.03125q0.34375 0.625 0.34375 2.28125l-0.015625 3.0q0 1.265625 0.109375 1.875q0.125 0.609375 0.46875 1.296875l-2.53125 0q-0.109375 -0.25 -0.25 -0.75q-0.0625 -0.234375 -0.09375 -0.3125q-0.65625 0.640625 -1.40625 0.96875q-0.734375 0.3125 -1.59375 0.3125q-1.484375 0 -2.34375 -0.8125q-0.859375 -0.8125 -0.859375 -2.046875q0 -0.828125 0.390625 -1.46875q0.390625 -0.640625 1.09375 -0.96875q0.703125 -0.34375 2.03125 -0.609375q1.796875 -0.328125 2.484375 -0.625l0 -0.25q0 -0.75 -0.359375 -1.0625q-0.359375 -0.3125 -1.375 -0.3125q-0.6875 0 -1.078125 0.28125q-0.375 0.265625 -0.609375 0.9375zm3.421875 2.078125q-0.484375 0.15625 -1.5625 0.390625q-1.0625 0.21875 -1.390625 0.4375q-0.5 0.359375 -0.5 0.90625q0 0.53125 0.40625 0.9375q0.40625 0.390625 1.015625 0.390625q0.703125 0 1.328125 -0.46875q0.46875 -0.34375 0.609375 -0.84375q0.09375 -0.328125 0.09375 -1.25l0 -0.5zm7.5007324 4.640625l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm4.135254 -4.34375l2.625 -0.25q0.234375 1.3125 0.953125 1.9375q0.734375 0.609375 1.96875 0.609375q1.2969055 0 1.9531555 -0.546875q0.671875 -0.546875 0.671875 -1.28125q0 -0.484375 -0.28125 -0.8125q-0.28125 -0.328125 -0.96875 -0.578125q-0.48440552 -0.15625 -2.1719055 -0.578125q-2.15625 -0.546875 -3.03125 -1.328125q-1.234375 -1.09375 -1.234375 -2.6875q0 -1.015625 0.578125 -1.90625q0.578125 -0.890625 1.65625 -1.34375q1.09375 -0.46875 2.640625 -0.46875q2.5156555 0 3.7812805 1.109375q1.28125 1.09375 1.34375 2.9375l-2.703125 0.109375q-0.171875 -1.03125 -0.75 -1.46875q-0.5625 -0.453125 -1.7031555 -0.453125q-1.171875 0 -1.84375 0.46875q-0.421875 0.3125 -0.421875 0.84375q0 0.46875 0.40625 0.796875q0.5 0.4375 2.46875 0.90625q1.9687805 0.453125 2.9062805 0.953125q0.953125 0.5 1.484375 1.359375q0.53125 0.859375 0.53125 2.125q0 1.15625 -0.640625 2.15625q-0.640625 1.0 -1.8125 1.484375q-1.15625 0.484375 -2.8906555 0.484375q-2.53125 0 -3.890625 -1.171875q-1.359375 -1.171875 -1.625 -3.40625zm11.8967285 -5.328125l2.71875 0l2.328125 6.859375l2.25 -6.859375l2.65625 0l-3.421875 9.3125l-0.609375 1.6875q-0.328125 0.84375 -0.640625 1.28125q-0.3125 0.453125 -0.703125 0.71875q-0.390625 0.28125 -0.96875 0.4375q-0.578125 0.15625 -1.3125 0.15625q-0.734375 0 -1.453125 -0.15625l-0.21875 -2.0q0.59375 0.125 1.078125 0.125q0.890625 0 1.3125 -0.53125q0.4375 -0.515625 0.671875 -1.328125l-3.6875 -9.703125zm10.688202 6.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm15.719482 -6.90625l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm7.368927 6.59375l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm4.422577 -4.0l2.359375 0l0 1.3125q1.265625 -1.53125 3.015625 -1.53125q0.9375 0 1.609375 0.390625q0.6875 0.375 1.125 1.140625q0.640625 -0.765625 1.375 -1.140625q0.75 -0.390625 1.578125 -0.390625q1.0625 0 1.796875 0.4375q0.75 0.421875 1.109375 1.265625q0.265625 0.625 0.265625 2.0l0 6.1875l-2.5625 0l0 -5.53125q0 -1.4375 -0.265625 -1.859375q-0.34375 -0.546875 -1.09375 -0.546875q-0.53125 0 -1.015625 0.328125q-0.46875 0.328125 -0.671875 0.96875q-0.203125 0.625 -0.203125 2.0l0 4.640625l-2.5625 0l0 -5.296875q0 -1.421875 -0.140625 -1.828125q-0.140625 -0.40625 -0.421875 -0.609375q-0.28125 -0.203125 -0.78125 -0.203125q-0.59375 0 -1.0625 0.328125q-0.46875 0.3125 -0.6875 0.921875q-0.203125 0.59375 -0.203125 1.984375l0 4.703125l-2.5625 0l0 -9.671875z" fill-rule="nonzero"/><path fill="#9fc5e8" d="m286.88977 266.33615l0 0c0 -5.7461853 4.658203 -10.404388 10.404388 -10.404388l131.1597 0c2.75943 0 5.4058228 1.0961609 7.357025 3.0473633c1.9512024 1.9512329 3.0473938 4.5976257 3.0473938 7.357025l0 41.616394c0 5.7461853 -4.6582336 10.404419 -10.404419 10.404419l-131.1597 0l0 0c-5.7461853 0 -10.404388 -4.6582336 -10.404388 -10.404419z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m286.88977 266.33615l0 0c0 -5.7461853 4.658203 -10.404388 10.404388 -10.404388l131.1597 0c2.75943 0 5.4058228 1.0961609 7.357025 3.0473633c1.9512024 1.9512329 3.0473938 4.5976257 3.0473938 7.357025l0 41.616394c0 5.7461853 -4.6582336 10.404419 -10.404419 10.404419l-131.1597 0l0 0c-5.7461853 0 -10.404388 -4.6582336 -10.404388 -10.404419z" fill-rule="evenodd"/><path fill="#000000" d="m306.29517 291.29874l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm17.641357 2.765625l0 -1.453125q-0.53125 0.78125 -1.390625 1.234375q-0.859375 0.4375 -1.8125 0.4375q-0.96875 0 -1.75 -0.421875q-0.765625 -0.4375 -1.125 -1.203125q-0.34375 -0.78125 -0.34375 -2.140625l0 -6.125l2.5625 0l0 4.4375q0 2.046875 0.140625 2.515625q0.140625 0.453125 0.515625 0.71875q0.375 0.265625 0.953125 0.265625q0.65625 0 1.171875 -0.359375q0.515625 -0.359375 0.703125 -0.890625q0.203125 -0.53125 0.203125 -2.609375l0 -4.078125l2.546875 0l0 9.671875l-2.375 0zm13.833466 0l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.546875 0l0 -9.671875l2.375 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm2.583496 0l0 -13.359375l4.03125 0l2.421875 9.109375l2.390625 -9.109375l4.046875 0l0 13.359375l-2.5 0l0 -10.515625l-2.65625 10.515625l-2.59375 0l-2.640625 -10.515625l0 10.515625l-2.5 0zm21.150177 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.719452 2.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm13.828857 -10.59375l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0zm13.083466 17.28125l-1.75 0q-1.390625 -2.09375 -2.125 -4.359375q-0.734375 -2.28125 -0.734375 -4.40625q0 -2.625 0.90625 -4.96875q0.78125 -2.046875 1.984375 -3.765625l1.75 0q-1.25 2.75 -1.71875 4.6875q-0.46875 1.9375 -0.46875 4.109375q0 1.5 0.28125 3.0625q0.28125 1.5625 0.765625 2.96875q0.3125 0.9375 1.109375 2.671875zm1.462677 -7.359375l2.546875 -0.265625q0.109375 0.875 0.640625 1.375q0.546875 0.5 1.25 0.5q0.796875 0 1.34375 -0.640625q0.5625 -0.65625 0.5625 -1.96875q0 -1.234375 -0.546875 -1.84375q-0.546875 -0.609375 -1.4375 -0.609375q-1.09375 0 -1.96875 0.96875l-2.078125 -0.296875l1.3125 -6.953125l6.765625 0l0 2.390625l-4.828125 0l-0.40625 2.265625q0.859375 -0.421875 1.75 -0.421875q1.703125 0 2.890625 1.25q1.1875 1.234375 1.1875 3.203125q0 1.65625 -0.953125 2.9375q-1.3125 1.78125 -3.625 1.78125q-1.84375 0 -3.015625 -1.0q-1.15625 -1.0 -1.390625 -2.671875zm9.656982 3.4375l3.484375 -4.984375l-3.34375 -4.6875l3.125 0l1.71875 2.65625l1.796875 -2.65625l3.015625 0l-3.28125 4.578125l3.578125 5.09375l-3.140625 0l-1.96875 -3.0l-1.984375 3.0l-3.0 0zm10.891327 3.921875q0.765625 -1.609375 1.0625 -2.484375q0.3125 -0.859375 0.578125 -1.984375q0.265625 -1.140625 0.390625 -2.15625q0.125 -1.015625 0.125 -2.078125q0 -2.171875 -0.46875 -4.109375q-0.453125 -1.9375 -1.703125 -4.6875l1.734375 0q1.375 1.953125 2.140625 4.15625q0.765625 2.1875 0.765625 4.453125q0 1.90625 -0.609375 4.078125q-0.671875 2.4375 -2.25 4.8125l-1.765625 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m460.67456 99.07612c0 11.803856 0.01574707 17.706139 0.03149414 23.607712c0.01574707 5.901573 0.03149414 11.802437 0.03149414 23.604881" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m460.6746 99.07612c0 11.803856 0.01574707 17.706139 0.03149414 23.607712l0.012664795 5.6048965" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m455.76355 128.29391l4.9694214 13.6091l4.9409485 -13.619476z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m460.67456 208.71654l0 23.607712l-97.79526 0l0 23.604889" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m460.6746 208.71654l0 23.607712l-97.79529 0l0 5.604889" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m357.9241 237.92914l4.9552 13.614288l4.9552 -13.614288z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m467.93658 266.33743l0 0c0 -5.7461853 4.658203 -10.404404 10.404419 -10.404404l106.27777 0c2.7594604 0 5.4058228 1.0961761 7.3570557 3.0473785c1.9511719 1.9512024 3.0473633 4.597595 3.0473633 7.357025l0 41.616394c0 5.7461853 -4.658203 10.404388 -10.404419 10.404388l-106.27777 0l0 0c-5.746216 0 -10.404419 -4.658203 -10.404419 -10.404388z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m467.93658 266.33743l0 0c0 -5.7461853 4.658203 -10.404404 10.404419 -10.404404l106.27777 0c2.7594604 0 5.4058228 1.0961761 7.3570557 3.0473785c1.9511719 1.9512024 3.0473633 4.597595 3.0473633 7.357025l0 41.616394c0 5.7461853 -4.658203 10.404388 -10.404419 10.404388l-106.27777 0l0 0c-5.746216 0 -10.404419 -4.658203 -10.404419 -10.404388z" fill-rule="evenodd"/><path fill="#000000" d="m493.32538 290.9875l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm6.5319824 -1.046875l-2.328125 -0.421875q0.40625 -1.40625 1.359375 -2.078125q0.953125 -0.671875 2.84375 -0.671875q1.703125 0 2.546875 0.40625q0.84375 0.40625 1.171875 1.03125q0.34375 0.625 0.34375 2.28125l-0.015625 3.0q0 1.265625 0.109375 1.875q0.125 0.609375 0.46875 1.296875l-2.53125 0q-0.109375 -0.25 -0.25 -0.75q-0.0625 -0.234375 -0.09375 -0.3125q-0.65625 0.640625 -1.40625 0.96875q-0.734375 0.3125 -1.59375 0.3125q-1.484375 0 -2.34375 -0.8125q-0.859375 -0.8125 -0.859375 -2.046875q0 -0.828125 0.390625 -1.46875q0.390625 -0.640625 1.09375 -0.96875q0.703125 -0.34375 2.03125 -0.609375q1.796875 -0.328125 2.484375 -0.625l0 -0.25q0 -0.75 -0.359375 -1.0625q-0.359375 -0.3125 -1.375 -0.3125q-0.6875 0 -1.078125 0.28125q-0.375 0.265625 -0.609375 0.9375zm3.421875 2.078125q-0.484375 0.15625 -1.5625 0.390625q-1.0625 0.21875 -1.390625 0.4375q-0.5 0.359375 -0.5 0.90625q0 0.53125 0.40625 0.9375q0.40625 0.390625 1.015625 0.390625q0.703125 0 1.328125 -0.46875q0.46875 -0.34375 0.609375 -0.84375q0.09375 -0.328125 0.09375 -1.25l0 -0.5zm7.500702 4.640625l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.48440552 -0.3125 1.1094055 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.9062805 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm9.244659 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm4.3220215 -3.6875l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0zm8.317871 6.765625q0 -2.046875 0.609375 -3.421875q0.453125 -1.03125 1.234375 -1.828125q0.796875 -0.8125 1.734375 -1.203125q1.25 -0.53125 2.875 -0.53125q2.953125 0 4.71875 1.828125q1.78125 1.828125 1.78125 5.09375q0 3.234375 -1.765625 5.0625q-1.75 1.828125 -4.6875 1.828125q-2.984375 0 -4.75 -1.8125q-1.75 -1.828125 -1.75 -5.015625zm2.78125 -0.09375q0 2.265625 1.046875 3.4375q1.046875 1.171875 2.65625 1.171875q1.609375 0 2.640625 -1.15625q1.046875 -1.171875 1.046875 -3.484375q0 -2.296875 -1.015625 -3.421875q-1.0 -1.140625 -2.671875 -1.140625q-1.671875 0 -2.6875 1.15625q-1.015625 1.140625 -1.015625 3.4375zm14.714539 6.6875l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm4.697815 0l0 -13.359375l2.5625 0l0 4.8125q1.171875 -1.34375 2.796875 -1.34375q1.765625 0 2.921875 1.28125q1.15625 1.28125 1.15625 3.671875q0 2.484375 -1.1875 3.828125q-1.171875 1.328125 -2.859375 1.328125q-0.828125 0 -1.640625 -0.40625q-0.796875 -0.421875 -1.375 -1.234375l0 1.421875l-2.375 0zm2.53125 -5.046875q0 1.5 0.484375 2.21875q0.65625 1.03125 1.765625 1.03125q0.84375 0 1.4375 -0.71875q0.59375 -0.734375 0.59375 -2.296875q0 -1.65625 -0.609375 -2.390625q-0.59375 -0.734375 -1.53125 -0.734375q-0.921875 0 -1.53125 0.71875q-0.609375 0.71875 -0.609375 2.171875zm8.97406 -5.9375l0 -2.375l2.5625 0l0 2.375l-2.5625 0zm0 10.984375l0 -9.671875l2.5625 0l0 9.671875l-2.5625 0zm9.62085 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m460.67456 208.71654l0 23.608185l70.80316 0l0 23.604416" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m460.6746 208.71654l0 23.608185l70.80313 0l0 5.604416" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m526.5225 237.92914l4.9552 13.614288l4.9552 -13.614288z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m389.85434 380.7483l0 0c0 -5.746216 4.658203 -10.404419 10.404388 -10.404419l106.2778 0c2.75943 0 5.4058228 1.0961609 7.357025 3.0473938c1.9512329 1.9512024 3.0473633 4.597595 3.0473633 7.357025l0 41.616364c0 5.746216 -4.658203 10.404419 -10.404388 10.404419l-106.2778 0l0 0c-5.7461853 0 -10.404388 -4.658203 -10.404388 -10.404419z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m389.85434 380.7483l0 0c0 -5.746216 4.658203 -10.404419 10.404388 -10.404419l106.2778 0c2.75943 0 5.4058228 1.0961609 7.357025 3.0473938c1.9512329 1.9512024 3.0473633 4.597595 3.0473633 7.357025l0 41.616364c0 5.746216 -4.658203 10.404419 -10.404388 10.404419l-106.2778 0l0 0c-5.7461853 0 -10.404388 -4.658203 -10.404388 -10.404419z" fill-rule="evenodd"/><path fill="#000000" d="m413.68085 405.39835l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm6.531952 -1.046875l-2.328125 -0.421875q0.40625 -1.40625 1.359375 -2.078125q0.953125 -0.671875 2.84375 -0.671875q1.703125 0 2.546875 0.40625q0.84375 0.40625 1.171875 1.03125q0.34375 0.625 0.34375 2.28125l-0.015625 3.0q0 1.265625 0.109375 1.875q0.125 0.609375 0.46875 1.296875l-2.53125 0q-0.109375 -0.25 -0.25 -0.75q-0.0625 -0.234375 -0.09375 -0.3125q-0.65625 0.640625 -1.40625 0.96875q-0.734375 0.3125 -1.59375 0.3125q-1.484375 0 -2.34375 -0.8125q-0.859375 -0.8125 -0.859375 -2.046875q0 -0.828125 0.390625 -1.46875q0.390625 -0.640625 1.09375 -0.96875q0.703125 -0.34375 2.03125 -0.609375q1.796875 -0.328125 2.484375 -0.625l0 -0.25q0 -0.75 -0.359375 -1.0625q-0.359375 -0.3125 -1.375 -0.3125q-0.6875 0 -1.078125 0.28125q-0.375 0.265625 -0.609375 0.9375zm3.421875 2.078125q-0.484375 0.15625 -1.5625 0.390625q-1.0625 0.21875 -1.390625 0.4375q-0.5 0.359375 -0.5 0.90625q0 0.53125 0.40625 0.9375q0.40625 0.390625 1.015625 0.390625q0.703125 0 1.328125 -0.46875q0.46875 -0.34375 0.609375 -0.84375q0.09375 -0.328125 0.09375 -1.25l0 -0.5zm7.5007324 4.640625l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm9.244629 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0zm4.322052 -3.6875l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0zm8.833496 13.359375l0 -13.359375l4.03125 0l2.421875 9.109375l2.390625 -9.109375l4.046875 0l0 13.359375l-2.5 0l0 -10.515625l-2.65625 10.515625l-2.59375 0l-2.640625 -10.515625l0 10.515625l-2.5 0zm21.150177 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.7194824 2.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm13.828827 -10.59375l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m531.4799 318.35822l0 26.001038l-78.078766 0l0 25.998962" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m531.4799 318.35822l0 26.001038l-78.078766 0l0 7.9989624" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m448.44595 352.35822l4.9552 13.614319l4.9552 -13.614319z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m546.01666 380.7483l0 0c0 -5.746216 4.658203 -10.404419 10.404358 -10.404419l106.27783 0c2.7593994 0 5.4058228 1.0961609 7.3569946 3.0473938c1.9512329 1.9512024 3.0474243 4.597595 3.0474243 7.357025l0 41.616364c0 5.746216 -4.658203 10.404419 -10.404419 10.404419l-106.27783 0l0 0c-5.746155 0 -10.404358 -4.658203 -10.404358 -10.404419z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m546.01666 380.7483l0 0c0 -5.746216 4.658203 -10.404419 10.404358 -10.404419l106.27783 0c2.7593994 0 5.4058228 1.0961609 7.3569946 3.0473938c1.9512329 1.9512024 3.0474243 4.597595 3.0474243 7.357025l0 41.616364c0 5.746216 -4.658203 10.404419 -10.404419 10.404419l-106.27783 0l0 0c-5.746155 0 -10.404358 -4.658203 -10.404358 -10.404419z" fill-rule="evenodd"/><path fill="#000000" d="m563.0306 398.8046l2.359375 0l0 1.3125q1.265625 -1.53125 3.015625 -1.53125q0.9375 0 1.609375 0.390625q0.6875 0.375 1.125 1.140625q0.640625 -0.765625 1.375 -1.140625q0.75 -0.390625 1.578125 -0.390625q1.0625 0 1.796875 0.4375q0.75 0.421875 1.109375 1.265625q0.265625 0.625 0.265625 2.0l0 6.1875l-2.5625 0l0 -5.53125q0 -1.4375 -0.265625 -1.859375q-0.34375 -0.546875 -1.09375 -0.546875q-0.53125 0 -1.015625 0.328125q-0.46875 0.328125 -0.671875 0.96875q-0.203125 0.625 -0.203125 2.0l0 4.640625l-2.5625 0l0 -5.296875q0 -1.421875 -0.140625 -1.828125q-0.140625 -0.40625 -0.421875 -0.609375q-0.28125 -0.203125 -0.78125 -0.203125q-0.59375 0 -1.0625 0.328125q-0.46875 0.3125 -0.6875 0.921875q-0.203125 0.59375 -0.203125 1.984375l0 4.703125l-2.5625 0l0 -9.671875zm16.197754 4.703125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm8.770996 -0.125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm18.161621 4.84375l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.546875 0l0 -9.671875l2.375 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm2.06781 -6.59375q0 -2.046875 0.609375 -3.421875q0.453125 -1.03125 1.234375 -1.828125q0.796875 -0.8125 1.734375 -1.203125q1.25 -0.53125 2.875 -0.53125q2.953125 0 4.71875 1.828125q1.78125 1.828125 1.78125 5.09375q0 3.234375 -1.765625 5.0625q-1.75 1.828125 -4.6875 1.828125q-2.984375 0 -4.75 -1.8125q-1.75 -1.828125 -1.75 -5.015625zm2.78125 -0.09375q0 2.265625 1.046875 3.4375q1.046875 1.171875 2.65625 1.171875q1.609375 0 2.640625 -1.15625q1.046875 -1.171875 1.046875 -3.484375q0 -2.296875 -1.015625 -3.421875q-1.0 -1.140625 -2.671875 -1.140625q-1.671875 0 -2.6875 1.15625q-1.015625 1.140625 -1.015625 3.4375zm14.7146 6.6875l-2.5625 0l0 -9.671875l2.375 0l0 1.375q0.609375 -0.984375 1.09375 -1.28125q0.484375 -0.3125 1.109375 -0.3125q0.875 0 1.6875 0.484375l-0.796875 2.234375q-0.640625 -0.421875 -1.203125 -0.421875q-0.53125 0 -0.90625 0.296875q-0.375 0.296875 -0.59375 1.078125q-0.203125 0.765625 -0.203125 3.234375l0 2.984375zm4.697754 0l0 -13.359375l2.5625 0l0 4.8125q1.171875 -1.34375 2.796875 -1.34375q1.765625 0 2.921875 1.28125q1.15625 1.28125 1.15625 3.671875q0 2.484375 -1.1875 3.828125q-1.171875 1.328125 -2.859375 1.328125q-0.828125 0 -1.640625 -0.40625q-0.796875 -0.421875 -1.375 -1.234375l0 1.421875l-2.375 0zm2.53125 -5.046875q0 1.5 0.484375 2.21875q0.65625 1.03125 1.765625 1.03125q0.84375 0 1.4375 -0.71875q0.59375 -0.734375 0.59375 -2.296875q0 -1.65625 -0.609375 -2.390625q-0.59375 -0.734375 -1.53125 -0.734375q-0.921875 0 -1.53125 0.71875q-0.609375 0.71875 -0.609375 2.171875zm8.974121 -5.9375l0 -2.375l2.5625 0l0 2.375l-2.5625 0zm0 10.984375l0 -9.671875l2.5625 0l0 9.671875l-2.5625 0zm9.620789 -9.671875l0 2.03125l-1.75 0l0 3.90625q0 1.1875 0.046875 1.390625q0.046875 0.1875 0.21875 0.3125q0.1875 0.125 0.4375 0.125q0.359375 0 1.03125 -0.25l0.21875 2.0q-0.890625 0.375 -2.015625 0.375q-0.703125 0 -1.265625 -0.234375q-0.546875 -0.234375 -0.8125 -0.59375q-0.25 -0.375 -0.34375 -1.0q-0.09375 -0.453125 -0.09375 -1.8125l0 -4.21875l-1.171875 0l0 -2.03125l1.171875 0l0 -1.921875l2.578125 -1.5l0 3.421875l1.75 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m531.4799 318.35822l0 26.001038l78.078735 0l0 25.998962" fill-rule="evenodd"/><path stroke="#000000" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m531.4799 318.35822l0 26.001038l78.078735 0l0 7.9989624" fill-rule="evenodd"/><path fill="#000000" stroke="#000000" stroke-width="3.0" stroke-linecap="butt" d="m604.60345 352.35822l4.9552 13.614319l4.9552 -13.614319z" fill-rule="evenodd"/><path fill="#9fc5e8" d="m546.01666 479.4097l0 0c0 -5.7461853 4.658203 -10.404419 10.404358 -10.404419l106.27783 0c2.7593994 0 5.4058228 1.0961914 7.3569946 3.0473938c1.9512329 1.9512024 3.0474243 4.597595 3.0474243 7.357025l0 41.616364c0 5.746216 -4.658203 10.404419 -10.404419 10.404419l-106.27783 0l0 0c-5.746155 0 -10.404358 -4.658203 -10.404358 -10.404419z" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m546.01666 479.4097l0 0c0 -5.7461853 4.658203 -10.404419 10.404358 -10.404419l106.27783 0c2.7593994 0 5.4058228 1.0961914 7.3569946 3.0473938c1.9512329 1.9512024 3.0474243 4.597595 3.0474243 7.357025l0 41.616364c0 5.746216 -4.658203 10.404419 -10.404419 10.404419l-106.27783 0l0 0c-5.746155 0 -10.404358 -4.658203 -10.404358 -10.404419z" fill-rule="evenodd"/><path fill="#000000" d="m561.4683 497.466l2.359375 0l0 1.3125q1.265625 -1.53125 3.015625 -1.53125q0.9375 0 1.609375 0.390625q0.6875 0.375 1.125 1.140625q0.640625 -0.765625 1.375 -1.140625q0.75 -0.390625 1.578125 -0.390625q1.0625 0 1.796875 0.4375q0.75 0.421875 1.109375 1.265625q0.265625 0.625 0.265625 2.0l0 6.1875l-2.5625 0l0 -5.53125q0 -1.4375 -0.265625 -1.859375q-0.34375 -0.546875 -1.09375 -0.546875q-0.53125 0 -1.015625 0.328125q-0.46875 0.328125 -0.671875 0.96875q-0.203125 0.625 -0.203125 2.0l0 4.640625l-2.5625 0l0 -5.296875q0 -1.421875 -0.140625 -1.828125q-0.140625 -0.40625 -0.421875 -0.609375q-0.28125 -0.203125 -0.78125 -0.203125q-0.59375 0 -1.0625 0.328125q-0.46875 0.3125 -0.6875 0.921875q-0.203125 0.59375 -0.203125 1.984375l0 4.703125l-2.5625 0l0 -9.671875zm16.197754 4.703125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm8.770996 -0.125q0 -1.28125 0.625 -2.46875q0.625 -1.203125 1.78125 -1.828125q1.15625 -0.625 2.578125 -0.625q2.1875 0 3.59375 1.421875q1.40625 1.421875 1.40625 3.609375q0 2.1875 -1.421875 3.640625q-1.421875 1.4375 -3.5625 1.4375q-1.328125 0 -2.546875 -0.59375q-1.203125 -0.609375 -1.828125 -1.765625q-0.625 -1.171875 -0.625 -2.828125zm2.625 0.125q0 1.453125 0.671875 2.21875q0.6875 0.75 1.6875 0.75q1.0 0 1.671875 -0.75q0.6875 -0.765625 0.6875 -2.234375q0 -1.421875 -0.6875 -2.1875q-0.671875 -0.765625 -1.671875 -0.765625q-1.0 0 -1.6875 0.765625q-0.671875 0.765625 -0.671875 2.203125zm18.16156 4.84375l-2.5625 0l0 -4.9375q0 -1.5625 -0.171875 -2.015625q-0.15625 -0.46875 -0.53125 -0.71875q-0.359375 -0.265625 -0.875 -0.265625q-0.671875 0 -1.203125 0.375q-0.53125 0.359375 -0.734375 0.96875q-0.1875 0.59375 -0.1875 2.21875l0 4.375l-2.546875 0l0 -9.671875l2.375 0l0 1.421875q1.265625 -1.640625 3.1875 -1.640625q0.84375 0 1.546875 0.3125q0.703125 0.296875 1.0625 0.78125q0.359375 0.46875 0.5 1.078125q0.140625 0.59375 0.140625 1.703125l0 6.015625zm2.583496 0l0 -13.359375l4.03125 0l2.421875 9.109375l2.390625 -9.109375l4.046875 0l0 13.359375l-2.5 0l0 -10.515625l-2.65625 10.515625l-2.59375 0l-2.640625 -10.515625l0 10.515625l-2.5 0zm21.150208 -3.078125l2.546875 0.421875q-0.484375 1.40625 -1.546875 2.140625q-1.0625 0.734375 -2.65625 0.734375q-2.515625 0 -3.734375 -1.65625q-0.953125 -1.3125 -0.953125 -3.328125q0 -2.40625 1.25 -3.765625q1.265625 -1.359375 3.1875 -1.359375q2.15625 0 3.40625 1.421875q1.25 1.421875 1.1875 4.375l-6.40625 0q0.03125 1.140625 0.609375 1.78125q0.59375 0.625 1.484375 0.625q0.59375 0 1.0 -0.328125q0.421875 -0.328125 0.625 -1.0625zm0.15625 -2.59375q-0.03125 -1.109375 -0.578125 -1.6875q-0.546875 -0.578125 -1.328125 -0.578125q-0.84375 0 -1.390625 0.609375q-0.546875 0.609375 -0.53125 1.65625l3.828125 0zm3.7194214 2.90625l2.5625 -0.390625q0.171875 0.75 0.671875 1.140625q0.5 0.390625 1.40625 0.390625q0.984375 0 1.484375 -0.375q0.34375 -0.25 0.34375 -0.671875q0 -0.296875 -0.1875 -0.484375q-0.1875 -0.1875 -0.859375 -0.34375q-3.09375 -0.6875 -3.921875 -1.25q-1.140625 -0.78125 -1.140625 -2.171875q0 -1.265625 0.984375 -2.109375q1.0 -0.859375 3.078125 -0.859375q1.984375 0 2.953125 0.65625q0.96875 0.640625 1.328125 1.90625l-2.40625 0.4375q-0.15625 -0.5625 -0.59375 -0.859375q-0.421875 -0.296875 -1.234375 -0.296875q-1.0 0 -1.4375 0.28125q-0.296875 0.203125 -0.296875 0.515625q0 0.265625 0.25 0.46875q0.34375 0.25 2.390625 0.71875q2.046875 0.453125 2.859375 1.140625q0.796875 0.671875 0.796875 1.890625q0 1.34375 -1.109375 2.296875q-1.109375 0.953125 -3.28125 0.953125q-1.984375 0 -3.140625 -0.796875q-1.140625 -0.8125 -1.5 -2.1875zm13.828857 -10.59375l0 4.921875q1.234375 -1.453125 2.953125 -1.453125q0.890625 0 1.59375 0.328125q0.71875 0.328125 1.078125 0.84375q0.359375 0.5 0.484375 1.125q0.140625 0.609375 0.140625 1.921875l0 5.671875l-2.5625 0l0 -5.109375q0 -1.515625 -0.15625 -1.921875q-0.140625 -0.421875 -0.515625 -0.65625q-0.359375 -0.25 -0.90625 -0.25q-0.640625 0 -1.140625 0.3125q-0.5 0.3125 -0.734375 0.9375q-0.234375 0.625 -0.234375 1.84375l0 4.84375l-2.5625 0l0 -13.359375l2.5625 0z" fill-rule="nonzero"/><path fill="#000000" fill-opacity="0.0" d="m609.55994 432.76907l0 36.251953" fill-rule="evenodd"/><path stroke="#595959" stroke-width="3.0" stroke-linejoin="round" stroke-linecap="butt" d="m609.55994 432.76907l0 18.251953" fill-rule="evenodd"/><path fill="#595959" stroke="#595959" stroke-width="3.0" stroke-linecap="butt" d="m604.60474 451.02103l4.9552 13.614319l4.9552 -13.614319z" fill-rule="evenodd"/></g></svg>
\ No newline at end of file | true |
Other | mrdoob | three.js | 9bf79c0c65f195cdeddaa4a72e217cf705187999.json | fix moonOrbit diagram/code | threejs/lessons/threejs-scenegraph.md | @@ -224,9 +224,9 @@ objects.push(earthMesh);
+objects.push(moonMesh);
```
-Again we added another invisible scene graph node, an `Object3D` called `earthOrbit`
-and added both the `earthMesh` and the `moonMesh` to it. The new scene graph looks like
-this.
+Again we added more invisible scene graph nodes. The first, an `Object3D` called `earthOrbit`
+and added both the `earthMesh` and the `moonOrbit` to it, also new. We then added the `mooMesh`
+to the `moonRobit`. The new scene graph looks like this.
<img src="resources/images/scenegraph-sun-earth-moon.svg" align="center">
@@ -305,6 +305,7 @@ some function to add the helpers for each node
+makeAxisGrid(sunMesh, 'sunMesh');
+makeAxisGrid(earthOrbit, 'earthOrbit');
+makeAxisGrid(earthMesh, 'earthMesh');
++makeAxisGrid(moonOrbit, 'moonOrbit');
+makeAxisGrid(moonMesh, 'moonMesh');
```
| true |
Other | mrdoob | three.js | 9bf79c0c65f195cdeddaa4a72e217cf705187999.json | fix moonOrbit diagram/code | threejs/threejs-scenegraph-sun-earth-moon-axes-grids.html | @@ -150,6 +150,7 @@
makeAxisGrid(sunMesh, 'sunMesh');
makeAxisGrid(earthOrbit, 'earthOrbit');
makeAxisGrid(earthMesh, 'earthMesh');
+ makeAxisGrid(moonOrbit, 'moonOrbit');
makeAxisGrid(moonMesh, 'moonMesh');
function resizeRendererToDisplaySize(renderer) { | true |
Other | mrdoob | three.js | db4b9fe0938e533c2793f31234221664f4d97708.json | translate ja of texture | threejs/lessons/ja/threejs-textures.md | @@ -0,0 +1,607 @@
+Title: Three.jsใฎใใฏในใใฃ
+Description: Three.jsใฎใใฏในใใฃใฎไฝฟใๆน
+TOC: ใใฏในใใฃ
+
+ใใฎ่จไบใฏthree.jsใซใคใใฆใฎใทใชใผใบ่จไบใฎไธใคใงใใ
+ๆๅใฎ่จไบใฏ[Three.jsใฎๅบ็ค็ฅ่ญ](threejs-fundamentals.html)ใงใใ
+ใพใ ่ชญใใงใชใไบบใฏใใใกใใใๅ
ใซ่ชญใใงใฟใใจใใใใใใใพใใใ
+
+ใใฏในใใฃใฏThree.jsใฎๅคงใใชใใใใฏใฎไธใคใงใใ
+ใฉใฎใฌใใซใง่ชฌๆใใใจใใใ100%ๆฟ็ฅใใฆใฏใใพใใใใใใฃใฆใฟใใใจๆใใพใใ
+Three.jsใซใฏใใใใใฎใใใใฏใใใใไบใใซ้ขไฟใใฆใใใฎใงใไธๅบฆใซ่ชฌๆใใใฎใ้ฃใใใฎใงใใ
+ใใใใใฎ่จไบใฎๅ
ๅฎนใฎๆฉ่ฆ่กจใงใใ
+
+<ul>
+<li><a href="#hello">ใใญใผใปใใฏในใใฃ</a></li>
+<li><a href="#six">็ซๆนไฝใฎๅ้ขใซ็ฐใชใ6ใคใฎใใฏในใใฃใ่ฒผใไปใใ</a></li>
+<li><a href="#loading">ใใฏในใใฃใฎ่ชญใฟ่พผใฟ</a></li>
+<ul>
+ <li><a href="#easy">็ฐกๅใชๆนๆณ</a></li>
+ <li><a href="#wait1">ใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใค</a></li>
+ <li><a href="#waitmany">่คๆฐใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใค</a></li>
+ <li><a href="#cors">็ฐใชใใชใชใธใณใใใฎใใฏในใใฃใฎ่ชญใฟ่พผใฟ</a></li>
+</ul>
+<li><a href="#memory">ใกใขใชไฝฟ็จ</a></li>
+<li><a href="#format">JPG vs PNG</a></li>
+<li><a href="#filtering-and-mips">ใใฃใซใฟใชใณใฐใจMIP</a></li>
+<li><a href="#uvmanipulation">ใใฏในใใฃใฎ็นฐใ่ฟใใใชใใปใใใๅ่ปขใใฉใใใณใฐ</a></li>
+</ul>
+
+## <a name="hello"></a> ใใญใผใปใใฏในใใฃ
+
+ใใฏในใใฃใฏ*ไธ่ฌ็ใซ*PhotoshopใGIMPใฎใใใช3rdใใผใใฃใผใฎใใญใฐใฉใ ใงๆใใใไฝใใใ็ปๅใงใใ
+ไพใใฐใใใฎ็ปๅใ็ซๆนไฝใซไนใใฆใฟใพใใใใ
+
+<div class="threejs_center">
+ <img src="../resources/images/wall.jpg" style="width: 600px;" class="border" >
+</div>
+
+ๆๅใฎไพใไฟฎๆญฃใใฆใฟใพใใใใ`TextureLoader`ใไฝใใใจใงใๅฟ
่ฆใชใใจใฏใในใฆใงใใพใใ
+[`load`](TextureLoader.load)ใ็ปๅใฎURLใๅผๆฐใซใใฆๅผใณใ`color`ใ่จญๅฎใใไปฃใใใซใ
+ใใใชใขใซใฎ`map`ๅฑๆงใซใใฎ็ตๆใๆธกใใฆใใ ใใใ
+
+```js
++const loader = new THREE.TextureLoader();
+
+const material = new THREE.MeshBasicMaterial({
+- color: 0xFF8844,
++ map: loader.load('resources/images/wall.jpg'),
+});
+```
+
+`MeshBasicMaterial`ใไฝฟใฃใฆใใใฎใงใๅ
ๆบใๅฟ
่ฆใชใใใจใซๆณจๆใใฆใใ ใใใ
+
+{{{example url="../threejs-textured-cube.html" }}}
+
+## <a name="six"></a> ็ซๆนไฝใฎๅ้ขใซ็ฐใชใ6ใคใฎใใฏในใใฃใ่ฒผใไปใใ
+
+็ซๆนไฝใฎๅ้ขใซ่ฒผใไปใใใ6ใคใฎใใฏในใใฃใฏใฉใฎใใใชใใฎใงใใใใใ
+
+<div class="threejs_center">
+ <div>
+ <img src="../resources/images/flower-1.jpg" style="width: 100px;" class="border" >
+ <img src="../resources/images/flower-2.jpg" style="width: 100px;" class="border" >
+ <img src="../resources/images/flower-3.jpg" style="width: 100px;" class="border" >
+ </div>
+ <div>
+ <img src="../resources/images/flower-4.jpg" style="width: 100px;" class="border" >
+ <img src="../resources/images/flower-5.jpg" style="width: 100px;" class="border" >
+ <img src="../resources/images/flower-6.jpg" style="width: 100px;" class="border" >
+ </div>
+</div>
+
+`Mesh`ใไฝใใจใใซใๅใซ6ใคใฎใใใชใขใซใไฝใใ้
ๅใจใใฆๆธกใใพใใ
+
+```js
+const loader = new THREE.TextureLoader();
+
+-const material = new THREE.MeshBasicMaterial({
+- map: loader.load('resources/images/wall.jpg'),
+-});
++const materials = [
++ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-1.jpg')}),
++ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-2.jpg')}),
++ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-3.jpg')}),
++ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-4.jpg')}),
++ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-5.jpg')}),
++ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-6.jpg')}),
++];
+-const cube = new THREE.Mesh(geometry, material);
++const cube = new THREE.Mesh(geometry, materials);
+```
+
+ๅใใพใใ๏ผ
+
+{{{example url="../threejs-textured-cube-6-textures.html" }}}
+
+ใใ ใใๅ
จใฆใฎ็จฎ้กใฎใธใชใกใใชใ่คๆฐใฎใใใชใขใซใซๅฏพๅฟใใฆใใใใใงใฏใชใใใจใซๆณจๆใใฆใใ ใใใ
+`BoxGeometry`ใจ`BoxBufferGeometry`ใฏใใใใใใฎ้ขใซ6ใคใฎใใใชใขใซใไฝฟใใพใใ
+`ConeGeometry`ใจ`ConeBufferGeometry`ใฏ2ใคใฎใใใชใขใซใไฝฟใใใจใใงใใไธใคใฏๅบ้ขใไธใคใฏๅ้้ขใซ้ฉ็จใใใพใใ
+`CylinderGeometry`ใจ`CylinderBufferGeometry`ใฏ3ใคใฎใใใชใขใซใไฝฟใใใจใใงใใไธใคใฏๅบ้ขใไธใคใฏไธ้ขใไธใคใฏๅด้ขใซ้ฉ็จใใใพใใ
+ใใฎไปใฎใฑใผในใงใฏใใซในใฟใ ใธใชใกใใชใฎใใซใใ่ชญใฟ่พผใฟใใใฏในใใฃใฎๅบงๆจใฎไฟฎๆญฃใๅฟ
่ฆใซใชใใพใใ
+
+
+1ใคใฎใธใชใกใใชใซ่คๆฐใฎ็ปๅใ้ฉ็จใใใใชใใ
+[ใใฏในใใฃใขใใฉใน](https://en.wikipedia.org/wiki/Texture_atlas)ใไฝฟใใฎใใใปใใฎ3Dใจใณใธใณใงใฏใฏใใใซไธ่ฌ็ใงใใฏใใใซ้ซๆง่ฝใงใใ
+ใใฏในใใฃใขใใฉในใฏใไธใคใฎใใฏในใใฃใซ่คๆฐใฎ็ปๅใ้
็ฝฎใใใธใชใกใใชใฎ้ ็นใฎๅบงๆจใไฝฟใฃใฆ
+ใใฏในใใฃใฎใฉใฎ้จๅใใธใชใกใใชใฎใใฎใใฎใฎไธ่งๅฝขใซไฝฟใใใใใ้ธๆใใใใฎใงใใ
+
+ใใฏในใใฃใฎๅบงๆจใจใฏใชใใงใใใใ๏ผใธใชใกใใช้ ็นใซไธใใใใใใผใฟใฎใใจใงใ
+ใใฏในใใฃใฎใฉใฎ้จๅใใใฎ้ ็นใซๅฏพๅฟใใใๆๅฎใใใใฎใงใใ
+[ใซในใฟใ ใธใชใกใใชใฎๆง็ฏ](threejs-custom-geometry.html)ใๅงใใใจใใซ่ชฌๆใใพใใ
+
+## <a name="loading"></a> ใใฏในใใฃใฎ่ชญใฟ่พผใฟ
+
+### <a name="easy"></a> ็ฐกๅใชๆนๆณ
+
+ใใฎใตใคใใฎใณใผใใฎใปใจใใฉใฏใใใฃใจใ็ฐกๅใชใใฏในใใฃใฎ่ชญใฟ่พผใฟๆนใไฝฟใฃใฆใใพใใ
+`TextureLoader`ใไฝใใใใฎ[`load`](TextureLoader.load)ใกใฝใใใๅผใณใพใใ
+ใใใฏ`Texture`ใชใใธใงใฏใใ่ฟใใพใใ
+
+
+```js
+const texture = loader.load('resources/images/flower-1.jpg');
+```
+
+ใใฎใกใฝใใใไฝฟใใจใ็ปๅใthree.jsใซใใฃใฆ้ๅๆ็ใซ่ชญใฟ่พผใพใใใพใงใใใฏในใใฃใ้ๆใซใชใใพใใ่ชญใฟ่พผใพใใๆ็นใงใใใฏในใใฃใใใฆใณใญใผใใใ็ปๅใซๆดๆฐใใพใใ
+
+
+ใใฎๆนๆณใงใฏใใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใคๅฟ
่ฆใใชใใใใผใธใใใใซใฌใณใใชใณใฐใๅงใใใใจใใงใใใจใใใๅคงใใชๅฉ็นใใใใพใใ
+ๅคใใฎใฑใผในใงใใฎๆนๆณใงๅ้กใใใพใใใใใใฏในใใฃใใใฆใณใญใผใใ็ตใใใจใใซthree.jsใซ้็ฅใใฆใใใใใจใใงใใพใใ
+
+### <a name="wait1"></a> ใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใค
+
+ใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใคใใใซใใใฏในใใฃใญใผใใผใฎ`load`ใกใฝใใใฏใใใฏในใใฃใฎ่ชญใฟ่พผใฟใ็ตไบใใใจใใซๅผใฐใใใณใผใซใใใฏใๅใใพใใ
+ๅ้ ญใฎไพใซๆปใใใใฎใใใซใ`Mesh`ใไฝใใทใผใณใซ่ฟฝๅ ใใๅใซใใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใคใใจใใงใใพใใ
+
+
+```js
+const loader = new THREE.TextureLoader();
+loader.load('resources/images/wall.jpg', (texture) => {
+ const material = new THREE.MeshBasicMaterial({
+ map: texture,
+ });
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+ cubes.push(cube); // add to our list of cubes to rotate
+});
+```
+
+ใใฉใฆใถใฎใญใฃใใทใฅใใฏใชใขใใๆฅ็ถใ้
ใใชใใชใ้ใใ้ใใๅใใใใจใฏใชใใจๆใใพใใใ
+ใกใใใจใใฏในใใฃใ่ชญใฟ่พผใพใใใฎใๅพ
ใฃใฆใใใฎใงใๅฎๅฟใใฆใใ ใใใ
+
+{{{example url="../threejs-textured-cube-wait-for-texture.html" }}}
+
+### <a name="waitmany"></a> ่คๆฐใใฏในใใฃใฎ่ชญใฟ่พผใฟใๅพ
ใค
+
+
+ๅ
จใฆใฎใใฏในใใฃใ่ชญใฟ่พผใพใใใใจใๅพ
ใคใใใซใ`LoadingManager`ใไฝฟใใใจใใงใใพใใ
+`TextureLoader`ใๆธกใใจใ[`onLoad`](LoadingManager.onLoad)ๅฑๆงใใณใผใซใใใฏใซ่จญๅฎใใใพใใ
+
+```js
++const loadManager = new THREE.LoadingManager();
+*const loader = new THREE.TextureLoader(loadManager);
+
+const materials = [
+ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-1.jpg')}),
+ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-2.jpg')}),
+ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-3.jpg')}),
+ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-4.jpg')}),
+ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-5.jpg')}),
+ new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-6.jpg')}),
+];
+
++loadManager.onLoad = () => {
++ const cube = new THREE.Mesh(geometry, materials);
++ scene.add(cube);
++ cubes.push(cube); // add to our list of cubes to rotate
++};
+```
+
+`LoadingManager`ใฏ[`onProgress`](LoadingManager.onProgress)ๅฑๆงใใใใ
+ใใญใฐใฌในใคใณใธใฑใผใฟใผใ่กจ็คบใใใใใฎใณใผใซใใใฏใ่จญๅฎใงใใพใใ
+
+ใพใใHTMLใซใใญใฐใฌในใใผใ่ฟฝๅ ใใพใใใใ
+
+```html
+<body>
+ <canvas id="c"></canvas>
++ <div id="loading">
++ <div class="progress"><div class="progressbar"></div></div>
++ </div>
+</body>
+```
+
+ใใใฆCSSใซใ่ฟฝๅ ใใพใใ
+
+```css
+#loading {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+#loading .progress {
+ margin: 1.5em;
+ border: 1px solid white;
+ width: 50vw;
+}
+#loading .progressbar {
+ margin: 2px;
+ background: white;
+ height: 1em;
+ transform-origin: top left;
+ transform: scaleX(0);
+}
+```
+
+ใใใใใจใใณใผใๅ
ใง`onProgress`ใณใผใซใใใฏใฎ`progressbar`ใฎในใฑใผใซใๆดๆฐใงใใพใใ
+ใใใฏใๆๅพใฎใขใคใใ ใ่ชญใฟ่พผใพใใURLใใใพ่ชญใฟ่พผใพใใฆใใใขใคใใ ใฎๆฐใใขใคใใ ใฎๅ่จๆฐใๆธกใใฆๅผใฐใใพใใ
+
+```js
++const loadingElem = document.querySelector('#loading');
++const progressBarElem = loadingElem.querySelector('.progressbar');
+
+loadManager.onLoad = () => {
++ loadingElem.style.display = 'none';
+ const cube = new THREE.Mesh(geometry, materials);
+ scene.add(cube);
+ cubes.push(cube); // add to our list of cubes to rotate
+};
+
++loadManager.onProgress = (urlOfLastItemLoaded, itemsLoaded, itemsTotal) => {
++ const progress = itemsLoaded / itemsTotal;
++ progressBarElem.style.transform = `scaleX(${progress})`;
++};
+```
+
+ใญใฃใใทใฅใๅ้คใใฆไฝ้ใชใณใใฏใทใงใณใไฝใใชใ้ใใฏใใใญใฐใฌในใใผใ่ฆใใใจใงใใชใใใใใใพใใใ
+
+{{{example url="../threejs-textured-cube-wait-for-all-textures.html" }}}
+
+## <a name="cors"></a> ็ฐใชใใชใชใธใณใใใฎใใฏในใใฃใฎ่ชญใฟ่พผใฟ
+
+็ฐใชใใตใผใใผใฎ็ปๅใไฝฟใใใใใใฎใตใผใใผใฏๆญฃใใใใใใผใ้ใๅฟ
่ฆใใใใพใใ
+ใใใใชใใจใthree.jsใงใใฎ็ปๅใไฝฟใใใจใใงใใใใจใฉใผใๅใๅใใงใใใใ
+ใใ็ใใใ็ปๅใๆไพใใใตใผใใผใ้็จใใฆใใใชใใ
+[ๆญฃใใใใใใผใ้ใ](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)ใ็ขบ่ชใใฆใใ ใใใ
+็ปๅใใในใใฃใณใฐใใฆใใใตใผใใผใซๆใๅ
ฅใใใใใๆจฉ้็จใฎใใใใผใ้ใใใจใใงใใชใใชใใ
+ใใฎใตใผใใผใใใฎ็ปๅใไฝฟใใใจใฏใงใใพใใใ
+
+
+ไพใใฐใ[imgur](https://imgur.com)ใ[flickr](https://flickr.com)ใใใใฆ
+[github](https://github.com)ใฏๅ
จใฆใใในใใใฆใใ็ปๅใ
+three.jsใงไฝฟใใใจใใงใใใใใชใใใใผใ้ใฃใฆใใพใใ
+
+## <a name="memory"></a>ใกใขใชไฝฟ็จ
+
+ๅคใใฎๅ ดๅใใใฏในใใฃใฏthree.jsใขใใชใฎไธญใงๆใใกใขใชใไฝฟใฃใฆใใพใใ
+*ไธ่ฌ็ใซ*ใใฏในใใฃใฏ`ๅน
* ้ซใ * 4 * 1.33`ใใคใใฎใกใขใชใๆถ่ฒปใใฆใใใใจใ็่งฃใใใฎใฏ้่ฆใงใใ
+
+ๅง็ธฎใซใคใใฆใฏ่จๅใใฆใใชใใใจใซๆณจๆใใฆใใ ใใใ.jpgใคใกใผใธใไฝใใ่ถ
้ซๅง็ธฎใใใใจใใงใใพใใ
+ไพใใฐใๅฎถใฎใทใผใณใไฝใฃใฆใใใจใใพใใใใๅฎถใฎไธญใซใฏใใใผใใซใใใใไธ้ขใซๆจ็ฎใฎใใฏในใใฃใ็ฝฎใใใจใซๆฑบใใพใใใ
+
+<div class="threejs_center"><img class="border" src="resources/images/compressed-but-large-wood-texture.jpg" align="center" style="width: 300px"></div>
+
+
+ใใฎใคใกใผใธใฏใใฃใ157kใชใฎใงใๆฏ่ผ็้ใใใฆใณใญใผใใใใใจใใงใใพใใใใใใ
+[ใใฏใปใซใ ใจ3024 x 3761ใฎๅคงใใ](resources/images/compressed-but-large-wood-texture.jpg)ใงใใ
+ๅ่ฟฐใใๅผใซใใใจใ
+
+ 3024 * 3761 * 4 * 1.33 = 60505764.5
+
+
+ใจใชใใthree.jsใฎ**60ใกใฌใฎใกใขใช๏ผ**ใๆถ่ฒปใใใงใใใใ
+ใใฎใใใชใใฏในใใฃใใใใคใใใใ ใใงใใกใขใชใชใผใฏใใฆใใพใใงใใใใ
+
+
+ใใฎไพใๆใกๅบใใใฎใฏใใใฏในใใฃใไฝฟ็จใใใใจใฎ้ ใใใณในใใ็ฅใฃใฆใใใฎใ้่ฆใ ใใใงใใ
+three.jsใงใใฏในใใฃใไฝฟใใใใซใฏใใใฏในใใฃใฎใใผใฟใGPUใซๆธกใใ*ไธ่ฌ็ใซ*้ๅง็ธฎใซใใฆใใๅฟ
่ฆใใใใพใใ
+
+ใใฎ่ฉฑใฎๆ่จใฏใใใฏในใใฃใใใกใคใซใตใคใบใ ใใงใชใใๆฌกๅ
ใๅฐใใใใใใจใงใใ
+ใใกใคใซใตใคใบใฎๅฐใใ = ้ซ้ใชใใฆใณใญใผใใงใใๆฌกๅ
ใฎๅฐใใ = ็ใกใขใชใงใใ
+ใงใฏใใฉใฎใใใซๅฐใใใงใใใฎใงใใใใ๏ผ
+ใงใใใ ใๅฐใใใใใใฆๅๅ่ฆใใใใใใงใใ
+
+## <a name="format"></a> JPG vs PNG
+
+ใใใฏ้ๅธธใฎHTMLใจใปใผๅใใงใPNGใฏใญในใฌในๅง็ธฎใชใฎใงใlossyๅง็ธฎใฎJPGใใใ
+ไธ่ฌ็ใซใใฆใณใญใผใใ้
ใใชใใพใใ
+ใใใใPNGใฏ้้ๆงใใใใพใใPNGใฏๆณ็ทใใใใๅพใปใฉ่ชฌๆใใ้็ปๅใใใใฎใใใช้็ปๅใใผใฟใซใ้ฉใใใใฉใผใใใใงใใ
+
+WebGLใซใใใฆใJPGใPNGใใใ็ใกใขใชใงใฏใชใใใจใ่ฆใใฆใใใฆใใ ใใใไธ่จใๅ็
งใใฆใใ ใใใ
+
+## <a name="filtering-and-mips"></a> ใใฃใซใฟใชใณใฐใจMIP
+
+ใใฎ16x16ใฎใใฏในใใฃใ
+
+<div class="threejs_center"><img src="resources/images/mip-low-res-enlarged.png" class="nobg" align="center"></div>
+
+็ซๆนไฝใซ้ฉ็จใใฆใฟใพใใ
+
+<div class="spread"><div data-diagram="filterCube"></div></div>
+
+ใใฎ็ซๆนไฝใใจใฆใๅฐใใๆ็ปใใฆใฟใพใใใใ
+
+<div class="spread"><div data-diagram="filterCubeSmall"></div></div>
+
+ใตใผใใ่ฆใใซใใใงใใๅฐใใช็ซๆนไฝใๆกๅคงใใฆใฟใพใใใใ
+
+<div class="spread"><div data-diagram="filterCubeSmallLowRes"></div></div>
+
+GPUใฏๅฐใใช็ซๆนไฝใฎใฉใฎใใฏใปใซใซใฉใฎ่ฒใไฝฟใใใใฉใใใฃใฆ็ฅใใฎใงใใใใ๏ผ
+็ซๆนไฝใๅฐใใใใฆ1ใ2ใใฏใปใซใใใชใใจใใใใฉใใงใใใใ๏ผ
+
+ใใฃใซใฟใชใณใฐใจใฏใใใใใใฎใงใใ
+
+ใใใใฉใใทใงใใใชใ่ฟใใฎๅ
จใฆใฎใใฏใปใซใๅนณๅใใฆใ1ใ2ใใฏใปใซใฎ่ฒใ่ฆใคใใพใใ
+ใใใฏใจใฆใ้
ใๆไฝใงใใGPUใฏใใใใใใใไฝฟใฃใฆใใฎๅ้กใ่งฃๆฑบใใพใใ
+
+MIPใฏใใฏในใใฃใฎใณใใผใงใใใฏใปใซใใใฌใณใใใใฆๆฌกใฎๅฐใใMIPใไฝใใใพใใใใฎใใใๅใฎMIPใฎๅๅใฎๅน
ใจๅๅใฎ้ซใใซใชใฃใฆใใพใใ
+MIPใฏ1x1ใใฏใปใซใฎMIPใๅพใใใใพใงไฝใใใพใใ
+ๅ
จใฆใฎMIPไธใฎ็ปๅใฏใใฎใใใซใชใใพใใ
+
+<div class="threejs_center"><img src="resources/images/mipmap-low-res-enlarged.png" class="nobg" align="center"></div>
+
+ใใฆใ็ซๆนไฝใ1ใ2ใใฏใปใซใฎๅฐใใใซๆใใใใจใใใฉใใช่ฒใซใใใๆฑบใใใใใGPUใฏๆใๅฐใใชMIPใฌใใซใๆฌกใซๅฐใใMIPใ้ธใถใใจใใงใใพใใ
+
+
+three.jsใงใฏใใใฏในใใฃใๅ
ใฎๅคงใใใใๅคงใใๆใใใใจใใจใๅฐใใๆใใใใจใใฎไธกๆนใงใๅฆ็ใฎ่จญๅฎใ้ธใถใใจใใงใใพใใ
+
+
+ใใฏในใใฃใๅ
ใฎๅคงใใใใๅคงใใๆใใใใจใใฎใใฃใซใฟ่จญๅฎใจใใฆใ[`texture.magFilter`](Texture.magFilter)ๅฑๆงใซ`THREE.NearestFilter`ใ`THREE.LinearFilter`ใ่จญๅฎใใใใจใใงใใพใใ
+`NearestFilter`ใฏๅ
ใฎใใฏในใใฃใใๆใ่ฟใ1ใใฏใปใซใไฝฟ็จใใใจใใใใจใงใใ
+ไฝ่งฃๅๅบฆใฎใใฏในใใฃใงใฏใใใคใณใฏใฉใใใฎใใใซใใฏใปใซๅใใใ่ฆใ็ฎใซใชใใพใใ
+
+`LinearFilter`ใฏใใฏในใใฃใใใ่ฒใๆฑบใใใใใฏใปใซใซๆใ่ฟใ4ใใฏใปใซใ้ธใณใ
+ๅฎ้ใฎ็นใ4ใคใฎใใฏใปใซใใใฉใใ ใ้ขใใฆใใใใซๅฟใใฆ้ฉๅใชๆฏ็ใงๆททใๅใใใพใใ
+
+<div class="spread">
+ <div>
+ <div data-diagram="filterCubeMagNearest" style="height: 250px;"></div>
+ <div class="code">Nearest</div>
+ </div>
+ <div>
+ <div data-diagram="filterCubeMagLinear" style="height: 250px;"></div>
+ <div class="code">Linear</div>
+ </div>
+</div>
+
+ๅ
ใฎๅคงใใใใใใใฏในใใฃใๅฐใใๆ็ปใใใๆใฎใใฃใซใฟ่จญๅฎใงใฏใ
+[`texture.minFilter`](Texture.minFilter)ๅฑๆงใ6ใคใฎๅคใใไธใค่จญๅฎใงใใพใใ
+
+* `THREE.NearestFilter`
+
+ ไธใจๅๆงใซใใใฏในใใฃใฎๆใ่ฟใใใฏใปใซใ้ธใถใ
+
+* `THREE.LinearFilter`
+
+ ไธใจๅๆงใซใใใฏในใใฃใใ4ใใฏใปใซใ้ธใใงๆททใๅใใใใ
+
+* `THREE.NearestMipmapNearestFilter`
+
+ ้ฉๅใชMIPใ้ธใณใใใฏใปใซใไธใค้ธใถใ
+
+* `THREE.NearestMipmapLinearFilter`
+
+ 2ใคMIPใ้ธใณใใใใใใใใใฏใปใซใ้ธใใงใใใฎ2ใคใๆททใใใ
+
+* `THREE.LinearMipmapNearestFilter`
+
+ ้ฉๅใชMIPใ้ธใณใ4ใใฏใปใซใ้ธใใงๆททใๅใใใใ
+
+* `THREE.LinearMipmapLinearFilter`
+
+ 2ใคMIPใ้ธใณใใใใใใใ4ใใฏใปใซใ้ธใใงใ8ใคๅ
จ้จใๆททใๅใใใฆ1ใใฏใปใซใซใใใ
+
+ใใใง6ใคๅ
จใฆใฎ่จญๅฎใฎไพใ่ฆใใพใใใใ
+
+<div class="spread">
+ <div data-diagram="filterModes" style="
+ height: 450px;
+ position: relative;
+ ">
+ <div style="
+ width: 100%;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: flex-start;
+ ">
+ <div style="
+ background: rgba(255,0,0,.8);
+ color: white;
+ padding: .5em;
+ margin: 1em;
+ font-size: small;
+ border-radius: .5em;
+ line-height: 1.2;
+ user-select: none;"
+ >click to<br/>change<br/>texture</div>
+ </div>
+ <div class="filter-caption" style="left: 0.5em; top: 0.5em;">nearest</div>
+ <div class="filter-caption" style="width: 100%; text-align: center; top: 0.5em;">linear</div>
+ <div class="filter-caption" style="right: 0.5em; text-align: right; top: 0.5em;">nearest<br/>mipmap<br/>nearest</div>
+ <div class="filter-caption" style="left: 0.5em; text-align: left; bottom: 0.5em;">nearest<br/>mipmap<br/>linear</div>
+ <div class="filter-caption" style="width: 100%; text-align: center; bottom: 0.5em;">linear<br/>mipmap<br/>nearest</div>
+ <div class="filter-caption" style="right: 0.5em; text-align: right; bottom: 0.5em;">linear<br/>mipmap<br/>linear</div>
+ </div>
+</div>
+
+ๆณจๆใใใใจใฏใๅทฆไธใจไธญๅคฎไธใฏ`NearestFilter`ใไฝฟใฃใฆใใฆใ`LinearFilter`ใฏMIPใไฝฟใฃใฆใใชใใใจใงใใGPUใๅ
ใฎใใฏในใใฃใใใใฏใปใซใ้ธใถใฎใงใ้ ใใฏใกใใคใใฆ่ฆใใพใใ
+ๅทฆๅดใฏใใฃใไธใคใฎใใฏใปใซใ้ธใฐใใไธญๅคฎใฏ4ใคใฎใใฏใปใซใ้ธใฐใใฆๆททใๅใใใใพใใใใใใ
+่ฏใ่ฒใฎ่กจ็พใซใฏ่ณใฃใฆใใพใใใ
+ใปใใฎ4ใคใฎไธญใงใฏใๅณไธใฎ`LinearMipmapLinearFilter`ใไธ็ช่ฏใใงใใ
+
+ไธใฎ็ปๅใใฏใชใใฏใใใจใไธใงไฝฟ็จใใฆใใใใฏในใใฃใจใMIPใฌใใซใใจใซ่ฒใ็ฐใชใใใฏในใใฃใๅใๆฟใใใพใใ
+
+<div class="threejs_center">
+ <div data-texture-diagram="differentColoredMips"></div>
+</div>
+
+ใใใงใ่ตทใใฆใใใใจใๅใใใใใใงใใใใ
+ๅทฆไธใจไธญๅคฎไธใฏใๆๅใฎMIPใใใฃใจ้ ใใพใงไฝฟใใใฆใใใฎใๅใใใพใใ
+ๅณไธใจไธญๅคฎไธใฏใๅฅใฎMIPใไฝฟใใใฆใใใฎใใใๅใใใพใใ
+
+
+ๅ
ใฎใใฏในใใฃใซๅใๆฟใใใจใๅณไธใๆปใใใใคใพใ้ซๅ่ณชใงใใใใจใๅใใใพใใ
+ใชใๅธธใซใใฎใขใผใใซใใชใใฎใ่ใใใใใใใใพใใใ
+ๆใๆใใใช็็ฑใฏใใฌใใญๆใๅบใใใใซใใใฏใปใซๅใใฆใปใใใจใใงใใ
+ๆฌกใฎ็็ฑใฏใ8ใใฏใปใซใ่ชญใฟ่พผใใงๆททใๅใใใใใจใฏใ1ใใฏใปใซใ่ชญใใงๆททใๅใใใใใใ้
ใใใจใงใใ
+1ใคใฎใใฏในใใฃใฎ้ๅบฆใงใฏ้ใใๅบใใใใซๆใใชใใใใใใพใใใใ
+่จไบใ้ฒใใซใคใใฆใๆ็ต็ใซ4ใ5ใฎใใฏในใใฃใไธๅบฆใซๆใคใใใชใขใซใๅบใฆใใใงใใใใ
+4ใใฏในใใฃ * 8ใใฏใปใซ๏ผใใฏในใใฃใใจ๏ผใฏใใฉใฎใใฏใปใซใๆ็ปใใใซใ32ใใฏใปใซๆขใใใจใซใชใใพใใ
+ใใใฏใขใใคใซใใใคในใง่ใใใจใใซ็นใซ้่ฆใซใชใใพใใ
+
+## <a name="uvmanipulation"></a> ใใฏในใใฃใฎ็นฐใ่ฟใใใชใใปใใใๅ่ปขใใฉใใใณใฐ
+
+ใใฏในใใฃใฏใ็นฐใ่ฟใใใชใใปใใใๅ่ปขใฎ่จญๅฎใใใใพใใ
+
+three.jsใฎใใใฉใซใใฎใใฏในใใฃใฏ็นฐใ่ฟใใใพใใใ
+ใใฏในใใฃใ็นฐใ่ฟใใใใใฉใใใฎ่จญๅฎใซใฏใ2ใคใฎๅฑๆงใใใใพใใ
+ๆฐดๅนณๆนๅใฎใฉใใใณใฐใซ[`wrapS`](Texture.wrapS)ใจใๅ็ดๆนๅใฎใฉใใใณใฐใซ[`wrapT`](Texture.wrapT)ใงใใ
+
+ไปฅไธใฎใฉใใใ่จญๅฎใใใพใ๏ผ
+
+* `THREE.ClampToEdgeWrapping`
+
+ ใใใใใฎ่งใฎๆๅพใฎใใฏใปใซใๆฐธ้ ใซ็นฐใ่ฟใใใพใใ
+
+* `THREE.RepeatWrapping`
+
+ ใใฏในใใฃใ็นฐใ่ฟใใใพใใ
+
+* `THREE.MirroredRepeatWrapping`
+
+ ใใฏในใใฃใฎ้กๅใๅใใใ็นฐใ่ฟใใใพใใ
+
+ไพใใฐใไธกๆนๅใซใฉใใใณใฐใใใจใ
+
+```js
+someTexture.wrapS = THREE.RepeatWrapping;
+someTexture.wrapT = THREE.RepeatWrapping;
+```
+
+็นฐใ่ฟใใฏ`repeat`ๅฑๆงใง่จญๅฎใใใพใใ
+
+```js
+const timesToRepeatHorizontally = 4;
+const timesToRepeatVertically = 2;
+someTexture.repeat.set(timesToRepeatHorizontally, timesToRepeatVertically);
+```
+
+ใใฏในใใฃใฎใชใใปใใใฏ`offset`ๅฑๆงใงใงใใพใใ
+ใใฏในใใฃใฏ1ๅไฝ = 1ใใฏในใใฃใฎๅคงใใใซใชใใปใใใใใพใใ
+่จใๆใใใจใ0 = ใชใใปใใใชใใ1 = ใใฏในใใฃๅ
จไฝใฎๅคงใใใจใใใใจใงใใ
+
+```js
+const xOffset = .5; // offset by half the texture
+const yOffset = .25; // offset by 1/4 the texture
+someTexture.offset.set(xOffset, yOffset);
+```
+
+ใใฏในใใฃใฎๅ่ปขใฏใ`rotation`ๅฑๆงใงใใฉใธใขใณใงๆๅฎใใพใใ
+ๅๆงใซ `center`ๅฑๆงใงๅ่ปขใฎไธญๅฟใๆๅฎใใพใใ
+ใใใฉใซใใฏ0,0ใงใๅทฆไธใฎ่งใงๅ่ปขใใพใใ
+ใชใใปใใใจๅใใใใซใๅไฝใฏใใฏในใใฃใฎๅคงใใใชใฎใงใ`.5, .5`ใซ่จญๅฎใใใจใ
+ใใฏในใใฃใฎไธญๅฟใงใฎๅ่ปขใซใชใใพใใ
+
+```js
+someTexture.center.set(.5, .5);
+someTexture.rotation = THREE.MathUtils.degToRad(45);
+```
+
+ๆๅใซๅใไธใใใตใณใใซใงใใใใฎๅคใ่ฉฆใใฆใฟใพใใใใ
+
+ๆๅใซใใใฏในใใฃใๆไฝใงใใใใใซๅ็
งใไฟๆใใฆใใใพใใ
+
+```js
++const texture = loader.load('resources/images/wall.jpg');
+const material = new THREE.MeshBasicMaterial({
+- map: loader.load('resources/images/wall.jpg');
++ map: texture,
+});
+```
+
+ใใใงใใ็ฐกๅใชใคใณใฟใผใใงใผในใๆไพใใใใใซ[dat.GUI](https://github.com/dataarts/dat.gui)ใไฝฟใใพใใ
+
+```js
+import {GUI} from '../3rdparty/dat.gui.module.js';
+```
+
+ไปฅๅใฎdat.GUIใฎไพใงใใใใใซใdat.GUIใซๅบฆๆฐใงๆไฝใงใใใชใใธใงใฏใใไธใใ
+ใฉใธใขใณๅไฝใงใใญใใใฃใ่จญๅฎใใ็ฐกๅใชใฏใฉในใไฝฟใใพใใ
+
+```js
+class DegRadHelper {
+ constructor(obj, prop) {
+ this.obj = obj;
+ this.prop = prop;
+ }
+ get value() {
+ return THREE.MathUtils.radToDeg(this.obj[this.prop]);
+ }
+ set value(v) {
+ this.obj[this.prop] = THREE.MathUtils.degToRad(v);
+ }
+}
+```
+
+`"123"`ใจใใฃใๆๅญๅใใ`123`ใจใใฃใๆฐๅคใซๅคๆใใใฏใฉในใๅฟ
่ฆใงใใ
+ใใใฏใthree.jsใฏ`wrapS`ใ`wrapT`ใฎใใใชenumใฎ่จญๅฎใจใใฆๆฐๅคใๅฟ
่ฆใงใใใ
+dat.GUIใฏenumใซๆๅญๅใฎใฟใไฝฟใใใใงใใ
+
+```js
+class StringToNumberHelper {
+ constructor(obj, prop) {
+ this.obj = obj;
+ this.prop = prop;
+ }
+ get value() {
+ return this.obj[this.prop];
+ }
+ set value(v) {
+ this.obj[this.prop] = parseFloat(v);
+ }
+}
+```
+
+ใใฎใฏใฉในใไฝฟใฃใฆใไธ่จ่จญๅฎใฎใใใฎ็ฐกๅใชGUIใใปใใใขใใใงใใพใใ
+
+```js
+const wrapModes = {
+ 'ClampToEdgeWrapping': THREE.ClampToEdgeWrapping,
+ 'RepeatWrapping': THREE.RepeatWrapping,
+ 'MirroredRepeatWrapping': THREE.MirroredRepeatWrapping,
+};
+
+function updateTexture() {
+ texture.needsUpdate = true;
+}
+
+const gui = new GUI();
+gui.add(new StringToNumberHelper(texture, 'wrapS'), 'value', wrapModes)
+ .name('texture.wrapS')
+ .onChange(updateTexture);
+gui.add(new StringToNumberHelper(texture, 'wrapT'), 'value', wrapModes)
+ .name('texture.wrapT')
+ .onChange(updateTexture);
+gui.add(texture.repeat, 'x', 0, 5, .01).name('texture.repeat.x');
+gui.add(texture.repeat, 'y', 0, 5, .01).name('texture.repeat.y');
+gui.add(texture.offset, 'x', -2, 2, .01).name('texture.offset.x');
+gui.add(texture.offset, 'y', -2, 2, .01).name('texture.offset.y');
+gui.add(texture.center, 'x', -.5, 1.5, .01).name('texture.center.x');
+gui.add(texture.center, 'y', -.5, 1.5, .01).name('texture.center.y');
+gui.add(new DegRadHelper(texture, 'rotation'), 'value', -360, 360)
+ .name('texture.rotation');
+```
+
+ๆๅพใซ็น่จใใใใจใฏใใใใใฏในใใฃใฎ`wrapS`ใ`wrapT`ใๅคใใใชใใ
+three.jsใ่จญๅฎใฎ้ฉ็จใ็ฅใใใใซใ[`texture.needsUpdate`](Texture.needsUpdate)ใ่จญๅฎใใชใใใฐใชใใชใใใจใงใใใปใใฎ่จญๅฎใฏ่ชๅ็ใซ้ฉ็จใใใพใใ
+
+
+{{{example url="../threejs-textured-cube-adjust.html" }}}
+
+ใใใฏใใฏในใใฃใฎใใใใฏใธใฎ็ฌฌไธๆญฉใซใใใพใใใ
+ใใๆ็นใงใใใฏในใใฃใฎๅบงๆจใใใใใชใขใซใ้ฉ็จใงใใๅฅใฎ9็จฎใฎใใฏในใใฃใซใคใใฆใ่ชฌๆใใพใใ
+
+ไปใฎใจใใใฏใ[ๅ
ๆบ](threejs-lights.html)ใซ้ฒใฟใพใใใใ
+
+<!--
+alpha
+ao
+env
+light
+specular
+bumpmap ?
+normalmap ?
+metalness
+roughness
+-->
+
+<link rel="stylesheet" href="resources/threejs-textures.css">
+<script type="module" src="resources/threejs-textures.js"></script> | false |
Other | mrdoob | three.js | 20cf0fb9fabf5fe8fbe57929452303d79106d235.json | fix blank png in firefox issue | threejs/threejs-postprocessing-adobe-lut-to-png-converter.html | @@ -234,6 +234,7 @@ <h1>Adobe LUT to PNG converter</h1>
}());
document.querySelector('button').addEventListener('click', () => {
+ render();
renderer.domElement.toBlob((blob) => {
saveData(blob, `${name}-s${renderer.domElement.height}.png`);
}); | false |
Other | mrdoob | three.js | 339ae6a38ce912d4b7ad807dddccc838ddc82a62.json | add csp support to lut-reader | threejs/lessons/kr/threejs-post-processing-3dlut.md | @@ -441,10 +441,16 @@ import * as dragAndDrop from './resources/drag-and-drop.js';
dragAndDrop.setup({ msg: 'Drop LUT File here' });
dragAndDrop.onDropFile(readLUTFile);
+function ext(s) {
+ const period = s.lastIndexOf('.');
+ return s.substr(period + 1);
+}
+
function readLUTFile(file) {
const reader = new FileReader();
reader.onload = (e) => {
- const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result));
+ const type = ext(file.name);
+ const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result, type));
const {size, data, name} = lut;
const texture = new THREE.DataTexture(data, size * size, size, THREE.RGBFormat);
texture.minFilter = THREE.LinearFilter; | true |
Other | mrdoob | three.js | 339ae6a38ce912d4b7ad807dddccc838ddc82a62.json | add csp support to lut-reader | threejs/lessons/threejs-post-processing-3dlut.md | @@ -433,10 +433,16 @@ Then we can use them like this
dragAndDrop.setup({msg: 'Drop LUT File here'});
dragAndDrop.onDropFile(readLUTFile);
+function ext(s) {
+ const period = s.lastIndexOf('.');
+ return s.substr(period + 1);
+}
+
function readLUTFile(file) {
const reader = new FileReader();
reader.onload = (e) => {
- const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result));
+ const type = ext(file.name);
+ const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result, type));
const {size, data, name} = lut;
const texture = new THREE.DataTexture(data, size * size, size, THREE.RGBFormat);
texture.minFilter = THREE.LinearFilter; | true |
Other | mrdoob | three.js | 339ae6a38ce912d4b7ad807dddccc838ddc82a62.json | add csp support to lut-reader | threejs/resources/lut-reader.js | @@ -43,7 +43,83 @@ function splitOnSpaceHandleQuotesWithEscapes(str, splits = ' \t\n\r') {
return strings;
}
-export function parse(str) {
+const startWhitespaceRE = /^\s/;
+const intRE = /^\d+$/;
+const isNum = s => intRE.test(s);
+
+const quotesRE = /^".*"$/;
+function trimQuotes(s) {
+ return quotesRE.test(s) ? s.substr(s, s.length - 2) : s;
+}
+
+const splitToNumbers = s => s.split(' ').map(parseFloat);
+
+export function parseCSP(str) {
+ const data = [];
+ const lut = {
+ name: 'unknown',
+ type: '1D',
+ size: 0,
+ data,
+ min: [0, 0, 0],
+ max: [1, 1, 1],
+ };
+
+ const lines = str.split('\n').map(s => s.trim()).filter(s => s.length > 0 && !startWhitespaceRE.test(s));
+
+ // check header
+ lut.type = lines[1];
+ if (lines[0] !== 'CSPLUTV100' ||
+ (lut.type !== '1D' && lut.type !== '3D')) {
+ throw new Error('not CSP');
+ }
+
+ // skip meta (read to first number)
+ let lineNdx = 2;
+ for (; lineNdx < lines.length; ++lineNdx) {
+ const line = lines[lineNdx];
+ if (isNum(line)) {
+ break;
+ }
+ if (line.startsWith('TITLE ')) {
+ lut.name = trimQuotes(line.substr(6).trim());
+ }
+ }
+
+ // read ranges
+ const ranges = [];
+ for (let i = 0; i < 3; ++i) {
+ ++lineNdx;
+ const input = splitToNumbers(lines[lineNdx++]);
+ const output = splitToNumbers(lines[lineNdx++]);
+ ranges.push({input, output});
+ if (input.length !== 2 || output.length !== 2 ||
+ input[0] !== 0 || input[1] !== 1 ||
+ output[0] !== 0 || output[1] !== 1) {
+ throw new Error('mapped ranges not support');
+ }
+ }
+
+ // read sizes
+ const sizes = splitToNumbers(lines[lineNdx++]);
+ if (sizes[0] !== sizes[1] || sizes[0] !== sizes[2]) {
+ throw new Error('only cubic sizes supported');
+ }
+ lut.size = sizes[0];
+
+ // read data
+ for (; lineNdx < lines.length; ++lineNdx) {
+ const parts = splitToNumbers(lines[lineNdx]);
+ if (parts.length !== 3) {
+ throw new Error('malformed file');
+ }
+ data.push(...parts);
+ }
+
+ return lut;
+}
+
+export function parseCUBE(str) {
const data = [];
const lut = {
name: 'unknown',
@@ -85,13 +161,10 @@ export function parse(str) {
}
}
- if (!lut.min) {
- lut.min = data.slice(0, 3);
- lut.max = data.slice(data.length - 3, data.length);
- }
-
if (!lut.size) {
- lut.size = data.length / 3;
+ lut.size = lut.type === '1D'
+ ? (data.length / 3)
+ : Math.cbrt(data.length / 3);
}
return lut;
@@ -124,6 +197,20 @@ function lut1Dto3D(lut) {
return {...lut, data};
}
+const parsers = {
+ 'cube': parseCUBE,
+ 'csp': parseCSP,
+};
+
+// for backward compatibility
+export function parse(str, format = 'cube') {
+ const parser = parsers[format.toLowerCase()];
+ if (!parser) {
+ throw new Error(`no parser for format: ${format}`);
+ }
+ return parser(str);
+}
+
export function lutTo2D3Drgb8(lut) {
if (lut.type === '1D') {
lut = lut1Dto3D(lut); | true |
Other | mrdoob | three.js | 339ae6a38ce912d4b7ad807dddccc838ddc82a62.json | add csp support to lut-reader | threejs/threejs-postprocessing-3dlut-w-loader.html | @@ -391,10 +391,16 @@
dragAndDrop.setup({msg: 'Drop LUT File here'});
dragAndDrop.onDropFile(readLUTFile);
+ function ext(s) {
+ const period = s.lastIndexOf('.');
+ return s.substr(period + 1);
+ }
+
function readLUTFile(file) {
const reader = new FileReader();
reader.onload = (e) => {
- const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result));
+ const type = ext(file.name);
+ const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result, type));
const {size, data, name} = lut;
const texture = new THREE.DataTexture(data, size * size, size, THREE.RGBFormat);
texture.magFilter = THREE.LinearFilter; | true |
Other | mrdoob | three.js | 339ae6a38ce912d4b7ad807dddccc838ddc82a62.json | add csp support to lut-reader | threejs/threejs-postprocessing-adobe-lut-to-png-converter.html | @@ -194,10 +194,16 @@ <h1>Adobe LUT to PNG converter</h1>
dragAndDrop.setup({msg: 'Drop LUT File here'});
dragAndDrop.onDropFile(readLUTFile);
+ function ext(s) {
+ const period = s.lastIndexOf('.');
+ return s.substr(period + 1);
+ }
+
function readLUTFile(file) {
const reader = new FileReader();
reader.onload = (e) => {
- const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result));
+ const type = ext(file.name);
+ const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result, type));
effectLUT.uniforms.lutMapSize.value = lut.size;
| true |
Other | mrdoob | three.js | b0778d0ce5bc2bba07c42918a50cb7680abf0f40.json | translate ja of scenegraph | threejs/lessons/ja/threejs-scenegraph.md | @@ -0,0 +1,487 @@
+Title: Three.jsใฎใทใผใณใฐใฉใ
+Description: ใทใผใณใฐใฉใใจใฏใชใซใ๏ผ
+TOC: ใทใผใณใฐใฉใ
+
+ใใฎ่จไบใฏthree.jsใซใคใใฆใฎใทใชใผใบ่จไบใฎไธใคใงใใ
+ๆๅใฎ่จไบใฏ[Three.jsใฎๅบ็ค](threejs-fundamentals.html)ใงใใ
+ใพใ ่ชญใใงใชใไบบใฏใใใกใใใๅ
ใซ่ชญใใงใฟใใจใใใใใใใพใใใ
+
+Three.jsใฎๆ ธๅฟใฏ้้ใใชใใทใผใณใฐใฉใใงใใ
+3Dใจใณใธใณใฎใทใผใณใฐใฉใใฏใๅใใผใใใญใผใซใซใช็ฉบ้ใ่กจ็พใใฆใใใใฐใฉใๅ
ใฎใใผใใฎ้ๅฑคใงใใ
+
+<img src="resources/images/scenegraph-generic.svg" align="center">
+
+ๆฝ่ฑก็ใชใฎใงใไพใใใใคใๆใใฆใฟใพใใใใ
+
+ไพใฎไธใคใฏๅคช้ฝ็ณปใๅคช้ฝใปๅฐ็ใปๆใงใใใใใ
+
+<img src="resources/images/scenegraph-solarsystem.svg" align="center">
+
+ๅฐ็ใฏๅคช้ฝใๅใฃใฆใใพใใๆใฏๅฐ็ใๅใฃใฆใใพใใ
+ๆใฏๅฐ็ใฎๅจใใๅใๆใใฆ็งปๅใใฆใใพใใๆใใ่ฆใใจใๅฐ็ใฎ"ใญใผใซใซใช็ฉบ้"ใๅใฃใฆใใใใจใซใชใใพใใ
+ๅคช้ฝใจใฎ็ธๅฏพ็ใชๅใใฏใๆใฎ่ฆ็นใใ่ฆใใจใฏใฌใคใธใผใช่บๆใฎใใใชๆฒ็ทใซ่ฆใใพใใใๅใซๅฐ็ใฎใญใผใซใซใช็ฉบ้ใๅจๅใใฆใใใจๆใใๅฟ
่ฆใใใใพใใ
+
+{{{diagram url="resources/moon-orbit.html" }}}
+
+ๅฅใฎ่ใๆนใใใฆใฟใพใใๅฐ็ใๅฐ่ปธใฎๅจใใ่ช่ปขใใฆใใใใจใใๅคช้ฝใฎๅจใใๅ
ฌ่ปขใใฆใใใใจใใ
+ๅฐ็ใซไฝใใงใใใใชใใ่ใใๅฟ
่ฆใฏใใใพใใใ
+็ใใใฏๅ
จใใใฃใฆๅฐ็ใๅใใๅใใใใฆใใชใใใฎใใใซใ
+ๆญฉใใใใใใฉใคใใใใใๆณณใใ ใใ่ตฐใฃใใใใใ ใใงใใ
+ๅฐ็ใฎ"ใญใผใซใซใช็ฉบ้"ใงๆญฉใใใใใใฉใคใใใใใๆณณใใ ใใ่ตฐใฃใใใใใใฆ็ๆดปใใใใใฆใใฆใใใฟใชใใใฏๅคช้ฝใจ็ธๅฏพ็ใซใๅฐ็ใฎไธใง1,600km/hใฎ้ใใงๅ่ปขใใๅคช้ฝใฎๅจใใ107,200km/hใฎ้ๅบฆใงๅใฃใฆใใพใใ
+ๅคช้ฝ็ณปไธใฎใฟใชใใใฎไฝ็ฝฎใฏใๅ่ฟฐใใๆใจๅใใใใชใใฎใงใใใๆฐใซใใๅฟ
่ฆใฏใใใพใใใ
+ใฟใชใใใฏๅฐ็ใฎ"ใญใผใซใซใช็ฉบ้"ใงใๅฐ็ใจใฎ็ธๅฏพ็ใชไฝ็ฝฎใ ใใๅฟ้
ใใฆใใใฐใใใฎใงใใ
+
+ไธๆญฉ้ฒใฟใพใใใใ็งใใกใฏๅคช้ฝใจๅฐ็ใจๆใฎๅณใไฝใใใใจๆณๅใใฆใฟใฆใใ ใใใ
+ใพใใๅคช้ฝใใๅงใใพใใใใใใ ็ไฝใไฝใๅ็นใซ็ฝฎใใ ใใงใใ
+ใทใผใณใฐใฉใใไฝฟใๆนๆณใฎๆผ็ฟใจใใฆใๅคช้ฝใๅฐ็ใๆใไฝฟใใใจใใๆฐใซ็ใใฆใใใฆใใ ใใใ
+ใใกใใใ็พๅฎใฎๅคช้ฝใๅฐ็ใๆใฏ็ฉ็ๅญฆใซๅพใใพใใใๆผ็ฟ็ฎ็ใชใฎใงใใทใผใณใฐใฉใใงไปฃ็จใใพใใ
+
+
+```js
+// an array of objects whose rotation to update
+const objects = [];
+
+// use just one sphere for everything
+const radius = 1;
+const widthSegments = 6;
+const heightSegments = 6;
+const sphereGeometry = new THREE.SphereBufferGeometry(
+ radius, widthSegments, heightSegments);
+
+const sunMaterial = new THREE.MeshPhongMaterial({emissive: 0xFFFF00});
+const sunMesh = new THREE.Mesh(sphereGeometry, sunMaterial);
+sunMesh.scale.set(5, 5, 5); // make the sun large
+scene.add(sunMesh);
+objects.push(sunMesh);
+```
+
+ใจใฆใๅฐใชใใใชใดใณใใใงใใ็ไฝใไฝฟใใพใใ็ทฏๅบฆๆนๅใซใใฃใ6ๅๅฒใงใใ
+ใใใงใๅ่ปขใใฆใใใใจใ่ฆใใใใชใใพใใ
+
+ๅใ็ไฝใๅ
จใฆใฎ็ไฝใซไฝฟใใพใใใคใใใชใฎใงใๅคช้ฝใฎใกใใทใฅใฎๅคงใใใ5ๅใซใใฆใใใพใใ
+
+ใพใใphong materialใฎ`emissive`ๅฑๆงใ้ป่ฒใซ่จญๅฎใใพใใ
+phong materialใฎemissiveๅฑๆงใฏใๅบๆฌ็ใซใๅ
ใๅฝใใฃใฆใใชใ่กจ้ขใซๆใใใ่ฒใงใใ
+ๅ
ๆบใฏใใฎ่ฒใซไปใๅ ใใใใพใใ
+
+ๆฌกใซใใทใผใณใฎ็ใไธญใซ1ใค็นๅ
ๆบใ็ฝฎใใพใใใใๅพใปใฉใใใ่ฉณ็ดฐใซ็นๅ
ๆบใซใคใใฆ่ชฌๆใใพใใใ
+ไธ็นใใ็บใใใใๆใใใจใใใฎใใใจใใใใใฎ็ฐกๅใช่ชฌๆใงใใ
+
+```js
+{
+ const color = 0xFFFFFF;
+ const intensity = 3;
+ const light = new THREE.PointLight(color, intensity);
+ scene.add(light);
+}
+```
+
+่ฆใใใใใใใใซใ็ดๆฅๅ็นใ่ฆไธใใใใใซใซใกใฉใ็ฝฎใใพใใใใ
+ๆใ็ฐกๅใชๆนๆณใฏ `lookAt`้ขๆฐใไฝฟใใใจใงใใ
+`lookAt`้ขๆฐใฏใๅผๆฐใซๆธกใใไฝ็ฝฎใใ่ฆใใใใใซใซใกใฉใๅใใพใใ
+ใใฎๅใซใใซใกใฉใฎไธ้จใใฉใฎๆนๅใๅใใฆใใใใใใใใฏใ
+ใซใกใฉใซใจใฃใฆใฉใฎๆนๅใ"ไธ"ใชใฎใใใใซใกใฉใซไผใใๅฟ
่ฆใใใใพใใ
+ใปใจใใฉใฎๅ ดๅใY่ปธใฎๆญฃใไธใงๅๅใงใใใ
+ไปใฏ่ฆไธใใใฆใใใฎใงใZ่ปธใฎๆญฃใไธใ ใจใซใกใฉใซไผใใๅฟ
่ฆใใใใพใใ
+
+```js
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+camera.position.set(0, 50, 0);
+camera.up.set(0, 0, 1);
+camera.lookAt(0, 0, 0);
+```
+
+ใฌใณใใชใณใฐใซใผใใฎไธญใงใๅใฎไพใๅ่ใซใใฆใไปฅไธใฎใณใผใใงใ`objects`้
ๅๅ
ใฎๅ
จใฆใฎใชใใธใงใฏใใๅ่ปขใใใฆใใพใใ
+
+```js
+objects.forEach((obj) => {
+ obj.rotation.y = time;
+});
+```
+
+`sunMesh`ใ`objects`้
ๅใซ่ฟฝๅ ใใใฎใงใๅ่ปขใใพใใ
+
+{{{example url="../threejs-scenegraph-sun.html" }}}
+
+ใใฆใๅฐ็ใ่ฟฝๅ ใใฆใฟใพใใใใ
+
+```js
+const earthMaterial = new THREE.MeshPhongMaterial({color: 0x2233FF, emissive: 0x112244});
+const earthMesh = new THREE.Mesh(sphereGeometry, earthMaterial);
+earthMesh.position.x = 10;
+scene.add(earthMesh);
+objects.push(earthMesh);
+```
+
+้ใใใใชใขใซใไฝใฃใฆใใพใใใ้ป่ๆฏใซๅฏพใใฆ็ฎ็ซใคใใใ
+*emissive*ใซๅฐใ้่ฒใ่จญๅฎใใพใใ
+
+`earthMesh`ใไฝใใใใๆฐใใไฝใฃใ้่ฒใฎ`earthMaterial`ใจใๅ
ใจๅใ`sphereGeometry`ใไฝฟใใพใใ
+ใใใๅคช้ฝใฎ10ใฆใใใๅทฆๅดใซ็ฝฎใใใทใผใณใซ่ฟฝๅ ใใพใใ
+ใใใฏ`objects`้
ๅใซใใใ่ฟฝๅ ใใใใฎใงใๅๆงใซๅ่ปขใใพใใ
+
+
+{{{example url="../threejs-scenegraph-sun-earth.html" }}}
+
+ๅคช้ฝใจๅฐ็ใฎไธกๆนใๅ่ปขใใฆ่ฆใใพใใใๅฐ็ใฏๅคช้ฝใฎๅจใใๅ
ฌ่ปขใใฆใใพใใใ
+ๅฐ็ใๅคช้ฝใฎๅญ่ฆ็ด ใซใใฆใฟใพใใใใ
+
+```js
+-scene.add(earthMesh);
++sunMesh.add(earthMesh);
+```
+
+ใใใฆ...
+
+{{{example url="../threejs-scenegraph-sun-earth-orbit.html" }}}
+
+ใชใซใ่ตทใใพใใใ๏ผใชใๅฐ็ใๅคช้ฝใจๅใๅคงใใใงใใใใชใซ้ขใใฆใใใฎใงใใใใใ
+ๅฐ็ใ่ฆใใใใซใฏใๅฎ้ใฎใจใใใใซใกใฉใ50ใฆใใใไธใใใ150ใฆใใใไธใซๅใใๅฟ
่ฆใใใใพใใใ
+
+`earthMesh`ใ`sunMesh`ใฎๅญ่ฆ็ด ใจใใพใใใ
+`sunMesh`ใฏ`sunMesh.scale.set(5, 5, 5)`ใซใใฃใฆ5ๅใซๅคงใใใ่จญๅฎใใฆใใพใใ
+ใใฃใฆใ`sunMesh`ใฎใญใผใซใซใช็ฉบ้ใฏ5ๅๅคงใใใชใใพใใใ
+ใใฎ็ฉบ้ใซใใใใใใใใใใฎใฏ5ๅใใใใฎใงใใ
+ใคใพใใๅฐ็ใ5ๅๅคงใใใชใใๅคช้ฝใใใฎ่ท้ขใ5ๅ๏ผ`earthMesh.position.x = 10`๏ผใซใชใฃใใฎใงใใ
+
+ ใทใผใณใฐใฉใใฏใใใฎใใใซใชใใพใใ
+
+<img src="resources/images/scenegraph-sun-earth.svg" align="center">
+
+ใใใไฟฎๆญฃใใใใใใทใผใณใฐใฉใใซ็ฉบใฎใใผใใ่ฟฝๅ ใใพใใใใ
+ใใใฆใๅคช้ฝใจๅฐ็ใฎไธกๆนใใใฎใใผใใฎๅญ่ฆ็ด ใซใใพใใใใ
+
+```js
++const solarSystem = new THREE.Object3D();
++scene.add(solarSystem);
++objects.push(solarSystem);
+
+const sunMaterial = new THREE.MeshPhongMaterial({emissive: 0xFFFF00});
+const sunMesh = new THREE.Mesh(sphereGeometry, sunMaterial);
+sunMesh.scale.set(5, 5, 5);
+-scene.add(sunMesh);
++solarSystem.add(sunMesh);
+objects.push(sunMesh);
+
+const earthMaterial = new THREE.MeshPhongMaterial({color: 0x2233FF, emissive: 0x112244});
+const earthMesh = new THREE.Mesh(sphereGeometry, earthMaterial);
+earthMesh.position.x = 10;
+-sunMesh.add(earthMesh);
++solarSystem.add(earthMesh);
+objects.push(earthMesh);
+```
+
+ใใใง`Object3D`ใไฝใใพใใใ`Mesh`ใฎใใใซใใทใผใณใฐใฉใใฎใใผใใงใใใ`Mesh`ใจใฏ็ฐใชใใใใใชใขใซใใธใชใกใใชใๆใกใพใใใ
+ใใ ใญใผใซใซใช็ฉบ้ใ่กจ็พใใใ ใใงใใ
+
+ๆฐใใใทใผใณใฐใฉใใฏใใใฎใใใซใชใใพใใ
+
+<img src="resources/images/scenegraph-sun-earth-fixed.svg" align="center">
+
+`sunMesh`ใจ`earthMesh`ใฏๅ
ฑใซ`solarSystem`ใฎๅญ่ฆ็ด ใงใใ3ใคๅ
จ้จใๅ่ปขใใฆใใพใใใ
+ใใพ`earthMesh`ใฏ`sunMesh`ใฎๅญ่ฆ็ด ใงใฏใชใใฎใงใ5ๅใซๆกๅคงใใใพใใใ
+
+{{{example url="../threejs-scenegraph-sun-earth-orbit-fixed.html" }}}
+
+ใจใฆใใใใชใใพใใใๅฐ็ใฏๅคช้ฝใใใๅฐใใใๅคช้ฝใฎๅจใใๅ
ฌ่ปขใใคใคใ่ช่ปขใใฆใใพใใ
+
+็ถใใฆใๅๆงใฎๆนๆณใงๆใ่ฟฝๅ ใใฆใฟใพใใใใ
+
+```js
++const earthOrbit = new THREE.Object3D();
++earthOrbit.position.x = 10;
++solarSystem.add(earthOrbit);
++objects.push(earthOrbit);
+
+const earthMaterial = new THREE.MeshPhongMaterial({color: 0x2233FF, emissive: 0x112244});
+const earthMesh = new THREE.Mesh(sphereGeometry, earthMaterial);
+-solarSystem.add(earthMesh);
++earthOrbit.add(earthMesh);
+objects.push(earthMesh);
+
++const moonOrbit = new THREE.Object3D();
++moonOrbit.position.x = 2;
++earthOrbit.add(moonOrbit);
+
++const moonMaterial = new THREE.MeshPhongMaterial({color: 0x888888, emissive: 0x222222});
++const moonMesh = new THREE.Mesh(sphereGeometry, moonMaterial);
++moonMesh.scale.set(.5, .5, .5);
++moonOrbit.add(moonMesh);
++objects.push(moonMesh);
+```
+
+ๅใณใๆ็ปใใใชใใทใผใณใฐใฉใใฎใใผใใ่ฟฝๅ ใใพใใใใใใฏใ`earthOrbit`ใจๅผใฐใใ`Object3D`ใงใใ
+ใใใฆใใใฎใใผใใซ`earthMesh`ใจ`moonMesh`ใฎไธกๆนใ่ฟฝๅ ใใพใใใ
+ๆฐใใใทใผใณใฐใฉใใฏใใใฎใใใซใชใใพใใ
+
+<img src="resources/images/scenegraph-sun-earth-moon.svg" align="center">
+
+ใใใฆใใใฎใใใซๆ็ปใใใพใใ
+
+{{{example url="../threejs-scenegraph-sun-earth-moon.html" }}}
+
+่จไบใฎไธ้จใงใ่ฆใใใ่บๆใฎใใฟใผใณใซๆฒฟใฃใๆใ่ฆใใพใใ
+ใใใใๆๅใงๆไฝใใๅฟ
่ฆใฏใใใพใใใงใใใ
+ใใ ใใทใผใณใฐใฉใใ่จญๅฎใใใ ใใงใใ
+
+ใทใผใณใฐใฉใใฎใใผใใๅใใใใใชใใชใซใใๆๅใใใจใไพฟๅฉใชใใจใใใใพใใ
+Three.jsใฏใใใใใใใใซใhelpfulใจใใhelpersใจใใใใใพใใ
+
+ไธใคใฏ`AxesHelper`ใงใใ
+ใญใผใซใซใช<span style="color:red">X</span>ใ<span style="color:green">Y</span>ใ<span style="color:blue">Z</span>่ปธใ่กจใ
+3ใคใฎ็ทใๆ็ปใใพใใ
+็งใใกใไฝใฃใๅ
จใฆใฎใใผใใซๅ ใใพใใใใ
+
+```js
+// add an AxesHelper to each node
+objects.forEach((node) => {
+ const axes = new THREE.AxesHelper();
+ axes.material.depthTest = false;
+ axes.renderOrder = 1;
+ node.add(axes);
+});
+```
+
+็งใใกใฎๅ ดๅใใใจใ็ไฝใฎๅ
้จใงใใฃใใจใใฆใใ่ปธใ่กจ็คบใใใใใงใใ
+ใใใใใใใใซใใใใชใขใซใฎ`depthTest`ใfalseใซใใพใใ
+ใใใซใใฃใฆใ่ปธใใชใซใใฎๅ
้จใซๆ็ปใใใฆใใใใฉใใใใงใใฏใใชใใชใใพใใ
+ๅ
จใฆใฎ็ไฝใฎๅพใซๆ็ปใใใใใใซใ`renderOrder`ใ1ใซ่จญๅฎใใพใ๏ผใใใฉใซใๅคใฏ0ใงใ๏ผใ
+ใใใใชใใจใ็ไฝใ่ปธใฎไธใซๆ็ปใใใ่ปธใ่ฆใฃใฆใใพใๅฏ่ฝๆงใใใใพใใ
+
+{{{example url="../threejs-scenegraph-sun-earth-moon-axes.html" }}}
+
+<span style="color:red">x (่ตค)</span> ใจ<span style="color:blue">z (้)</span>ใฎ
+่ปธใ่ฆใใพใใ็งใใกใฏใชใใธใงใฏใใใพใฃใใ่ฆไธใใใฆใใฆใใชใใธใงใฏใใฏy่ปธใไธญๅฟใซ
+ๅ่ปขใใฆใใใฎใงใ<span style="color:green">y (็ท)</span>่ปธใใใพใ่ฆใใพใใใ
+
+ไฝ็ฝฎใ้ใชใฃใ่ปธใ2็ตใใใฎใงใ่ฆใฅใใใใใใใพใใใ
+`sunMesh`ใจ`solarSystem`ใฏๅใๅ ดๆใซใใใพใใ
+ๅๆงใซใ`earthMesh`ใจ`earthOrbit`ใฏๅใๅ ดๆใซใใใพใใ
+ๅใใผใใซๅฏพใใฆใชใณ/ใชใใงใใใใใซใ็ฐกๅใชๆไฝใๅ ใใฆใฟใพใใใใ
+ใใฎใคใใงใซใ`GridHelper` ใจใใใใซใใผ้ขๆฐใ่ฟฝๅ ใใฆใใใพใใใใ
+ใใใฏX,Zๅนณ้ขใซ2ๆฌกๅ
ใฐใชใใใไฝใใพใใใใใฉใซใใงใฏใใฐใชใใใฏ10x10ใฆใใใใงใใ
+
+[dat.GUI](https://github.com/dataarts/dat.gui)ใไฝฟใใพใใ
+ใใใฏthree.jsใใญใธใงใฏใใงใจใฆใไธ่ฌ็ใชUIใฉใคใใฉใชใงใใ
+dat.GUIใฏใชใใธใงใฏใใจใใฎใชใใธใงใฏใใฎๅฑๆงๅใๅใๅใใ
+ๅฑๆงใฎๅใซๅบใฅใใฆใ่ชๅ็ใซใใฎๅฑๆงใๆไฝใใUIใไฝๆใใพใใ
+
+ใใใใใฎใใผใใซๅฏพใใฆใ`GridHelper`ใจ`AxesHelper`ใฎไธกๆนใไฝใใใใงใใ
+ใใใใใฎใใผใใซใฉใใซใๅฟ
่ฆใชใฎใงใๅคใใซใผใใๅ้คใใ
+ๅใใผใใซhelperใๅ ใใ้ขๆฐใๅผใถๅฝขๅผใซใใพใใ
+
+```js
+-// add an AxesHelper to each node
+-objects.forEach((node) => {
+- const axes = new THREE.AxesHelper();
+- axes.material.depthTest = false;
+- axes.renderOrder = 1;
+- node.add(axes);
+-});
+
++function makeAxisGrid(node, label, units) {
++ const helper = new AxisGridHelper(node, units);
++ gui.add(helper, 'visible').name(label);
++}
++
++makeAxisGrid(solarSystem, 'solarSystem', 25);
++makeAxisGrid(sunMesh, 'sunMesh');
++makeAxisGrid(earthOrbit, 'earthOrbit');
++makeAxisGrid(earthMesh, 'earthMesh');
++makeAxisGrid(moonMesh, 'moonMesh');
+```
+
+`makeAxisGrid`ใฏใdat.GUIใใใใใผใซใใ`AxisGridHelper`ใฏใฉในใไฝใใพใใ
+ๅ่ฟฐใใใใใซใdat.GUIใฏใใชใใธใงใฏใใฎๅๅใไปใใๅฑๆงใๆไฝใใUIใ่ชๅ็ใซ็ๆใใพใใ
+ๅฑๆงใฎๅใซๅฟใใฆ็ฐใชใUIใไฝๆใใใพใใ
+ใใงใใฏใใใฏในใไฝใฃใฆๆฌฒใใใฎใงใ`bool`ๅฑๆงใๆๅฎใใๅฟ
่ฆใใใใพใใ
+ใใใใ่ปธใจใฐใชใใใฎไธกๆนใไธใคใฎๅฑๆงใง่กจ็คบ/้่กจ็คบใซใใใใฎใงใ
+ๅฑๆงใฎgetterใจsetterใๆใฃใใฏใฉในใไฝๆใใพใใ
+ใใฎๆนๆณใงใdat.GUIใซไธใคใฎๅฑๆงใๆไฝใใใใใซๆใใใใใจใใงใใพใใใ
+ๅ
้จ็ใซใฏๅใใผใใซ`AxesHelper`ใจ`GridHelper`ใฎไธกๆนใฎvisibleๅฑๆงใ่จญๅฎใใใใจใใงใใพใใ
+
+
+```js
+// Turns both axes and grid visible on/off
+// dat.GUI requires a property that returns a bool
+// to decide to make a checkbox so we make a setter
+// and getter for `visible` which we can tell dat.GUI
+// to look at.
+class AxisGridHelper {
+ constructor(node, units = 10) {
+ const axes = new THREE.AxesHelper();
+ axes.material.depthTest = false;
+ axes.renderOrder = 2; // after the grid
+ node.add(axes);
+
+ const grid = new THREE.GridHelper(units, units);
+ grid.material.depthTest = false;
+ grid.renderOrder = 1;
+ node.add(grid);
+
+ this.grid = grid;
+ this.axes = axes;
+ this.visible = false;
+ }
+ get visible() {
+ return this._visible;
+ }
+ set visible(v) {
+ this._visible = v;
+ this.grid.visible = v;
+ this.axes.visible = v;
+ }
+}
+```
+
+ๆณจๆใใใใจใฏใ`AxesHelper`ใฎ`renderOrder`ใ2ใซ่จญๅฎใใ`GridHelper`ใซใฏ1ใ่จญๅฎใใใใจใงใใ
+ใใใใใใจใงใ่ปธใฏใฐใชใใใฎๅพใซๆ็ปใใใพใใ
+ใใใใชใใจใใฐใชใใใ่ปธใไธๆธใใใฆใใพใใใใใใพใใใ
+
+{{{example url="../threejs-scenegraph-sun-earth-moon-axes-grids.html" }}}
+
+`solarSystem`ใฎใใงใใฏใใชใณใซใใใจใไธใง่จญๅฎใใใใใซใ
+ใฉใฎใใใซๅฐ็ใไธญๅฟใใใกใใใฉ10ใฆใใใใซใใใๅใใใงใใใใ
+ๅฐ็ใ`solarSystem`ใฎ*ใญใผใซใซใช็ฉบ้*ใซใฉใฎใใใซๅญๅจใใใๅใใใพใใ
+ๅๆงใซใใใ`earthOrbit`ใฎใใงใใฏใใชใณใซใใใจใ
+ใฉใฎใใใซๆใ`earthOrbit`ใฎ*ใญใผใซใซใช็ฉบ้*ใฎไธญๅฟใใใใกใใใฉ2ใฆใใใใใใๅใใใงใใใใ
+
+ใใๅฐใใทใผใณใฐใฉใใฎไพใ็ดนไปใใพใใ
+็ฐกๅใชใฒใผใ ใฎไธ็ใฎ่ชๅ่ปใฏใใใฎใใใชใทใผใณใฐใฉใใ ใจใใพใใใใ
+
+<img src="resources/images/scenegraph-car.svg" align="center">
+
+ใใ่ปใฎbodyๅ
จไฝใๅใใใจใใใใซไผดใฃใฆwheelsใๅใใงใใใใ
+ใใbodyใซwheelsใจใฏๅฅใซใใฆใณใใใฆๆฌฒใใใจใใใจใ
+bodyใจwheelsใใ่ปใฎใใฌใผใ ใ่กจใ"frame"ใใผใใฎๅญ่ฆ็ด ใซใงใใพใใ
+
+ๅฅใฎไพใฏใฒใผใ ใฎไธ็ใฎไบบ้ใงใใ
+
+<img src="resources/images/scenegraph-human.svg" align="center">
+
+ใจใฆใ่ค้ใชไบบ้ใฎใทใผใณใฐใฉใใ่ฆใฆใใ ใใใ
+ๅฎ้ใฏใไธ่จใฎใทใผใณใฐใฉใใฏๅ็ดๅใใใฆใใพใใ
+ไพใใฐใๅ
จใฆใฎๆใฎๆ(ๅฐใชใใจใ28ใใผใ)ใๅ
จใฆใฎ่ถณใฎๆ(ใใใซ28ใใผใ)ใ
+ๅ ใใฆ้กใจ้กใ็ฎใใใใฆใใฃใจๆงใ
ใช้จไฝใใซใใผใใใใใซใใฐใฉใใๆกๅผตใงใใใใใใใพใใใ
+
+
+ใใๅฐใ่ค้ใชใทใผใณใฐใฉใใไฝใใพใใใใๆฆ่ปใไฝใใพใใ
+ๆฆ่ปใฏ6ใคใฎ่ป่ผชใจ็ ฒๅกใใใใพใใใใฎๆฆ่ปใฏใใ้็ญใซๆฒฟใฃใฆ่ตฐใใพใใ
+ใใใไธญใ็งปๅใใ็ไฝใใใใๆฆ่ปใฏใใฎ็ไฝใ็ใใจใใพใใใใ
+
+ใใใใทใผใณใฐใฉใใงใใใกใใทใฅใฏ็ท่ฒใ`Object3D`ใฏ้่ฒใๆใใใฏ้่ฒใใซใกใฉใฏ็ดซ่ฒใงใใ
+ใทใผใณใฐใฉใใซ่ฟฝๅ ใใใฆใใชใใซใกใฉใไธใคใใใพใใ
+
+<div class="threejs_center"><img src="resources/images/scenegraph-tank.svg" style="width: 800px;"></div>
+
+ใณใผใใ่ฆใฆใใใใใฎใใผใใฎ่จญๅฎใ็ขบ่ชใใฆใใ ใใใ
+
+ใฟใผใฒใใใใคใพใๆฆ่ปใ็ใฃใฆใใใใฎใจใใฆใ`targetOrbit`(`Object3D`) ใใใใพใใ
+ใใใฏใกใใใฉๅ่ฟฐใฎ`earthOrbit`ใจๅใใใใซๅ่ปขใใพใใ
+`targetOrbit`ใฎๅญ่ฆ็ด ใงใใ`targetElevation` (`Object3D`)ใฏใ
+`targetOrbit`ใใใฎใชใใปใใใจๅบๆบใจใชใ้ซใใๆไพใใพใใ
+ใใฎๅญ่ฆ็ด ใซใฏใ`targetElevation`ใซๅฏพใใฆ็ธๅฏพ็ใซๆตฎใๆฒใฟใใใ`targetBob`ใจๅผใฐใใ`Object3D`ใใใใพใใ
+ๆๅพใซใ`targetMesh`ใใใใพใใๅ่ปขใใใฆ่ฒใๅคใใใใจใใงใใใใใ ใฎ็ซๆนไฝใงใใ
+
+
+```js
+// move target
+targetOrbit.rotation.y = time * .27;
+targetBob.position.y = Math.sin(time * 2) * 4;
+targetMesh.rotation.x = time * 7;
+targetMesh.rotation.y = time * 13;
+targetMaterial.emissive.setHSL(time * 10 % 1, 1, .25);
+targetMaterial.color.setHSL(time * 10 % 1, 1, .25);
+```
+
+ๆฆ่ปใซใฏใ`tank`ใจๅผใฐใใ`Object3D`ใใใใพใใ
+ใใใไฝฟใฃใฆๆฆ่ปใฎๅญ่ฆ็ด ใใในใฆ็งปๅใใใใใจใใงใใพใใ
+ใณใผใใงใฏ`SplineCurve`ใไฝฟใฃใฆใใพใใใใใฏๆฒ็ทใซๆฒฟใฃใไฝ็ฝฎใๆฑใใใใจใใงใใพใใ
+0.0ใฏๆฒ็ทใฎๅง็นใงใใ1.0ใฏๆฒ็ทใฎ็ต็นใงใใใใใซใใใๆฆ่ปใใใ็พๅจๅฐใๆฑใใพใใ
+ๆฌกใซใใซใผใใฎๅฐใไธใฎไฝ็ฝฎใๆฑใใฆใ`Object3D.lookAt`ใไฝฟใใๆฆ่ปใใใฎๆนๅใซๅใใพใใ
+
+
+```js
+const tankPosition = new THREE.Vector2();
+const tankTarget = new THREE.Vector2();
+
+...
+
+// move tank
+const tankTime = time * .05;
+curve.getPointAt(tankTime % 1, tankPosition);
+curve.getPointAt((tankTime + 0.01) % 1, tankTarget);
+tank.position.set(tankPosition.x, 0, tankPosition.y);
+tank.lookAt(tankTarget.x, 0, tankTarget.y);
+```
+
+ๆฆ่ปใฎใฆใฃใบใใซไปใใฆใใ็ ฒๅกใฏใๆฆ่ปใฎๅญ่ฆ็ด ใชใฎใง่ชๅ็ใซๅใใพใใ
+ใฟใผใฒใใใฎๆนใๅใใใใฎใซใใฟใผใฒใใใฎไฝ็ฝฎใๆฑใใๆฌกใซๅใณ`Object3D.lookAt`ใไฝฟใใ ใใงใใ
+
+```js
+const targetPosition = new THREE.Vector3();
+
+...
+
+// face turret at target
+targetMesh.getWorldPosition(targetPosition);
+turretPivot.lookAt(targetPosition);
+```
+
+`turretCamera`ใฏ`turretMesh`ใฎๅญ่ฆ็ด ใชใฎใงใ็ ฒๅกใจไธ็ทใซไธไธใซๅใใๅ่ปขใใพใใ
+
+
+```js
+// make the turretCamera look at target
+turretCamera.lookAt(targetPosition);
+```
+
+`targetBob`ใฎๅญ่ฆ็ด ใงใใ`targetCameraPivot`ใใใใพใใใใใฏใฟใผใฒใใใจไธ็ทใซๆตฎ้ใใพใใ
+ๆฆ่ปใซ็ใใๅฎใใพใใใใ`targetCamera`ใซใฟใผใฒใใ่ช่บซใซ้ซใใๅใใใใใใงใใ
+ใใใซใกใฉใ`targetBob`ใฎๅญ่ฆ็ด ใซใใฆใใซใกใฉ่ช่บซใซ็ใใๅฎใใใใใ ใใ ใจใ
+ใซใกใฉใใฟใผใฒใใใฎๅ
ๅดใซๅ
ฅใ่พผใใงใใพใใงใใใใ
+
+```js
+// make the targetCameraPivot look at the tank
+tank.getWorldPosition(targetPosition);
+targetCameraPivot.lookAt(targetPosition);
+```
+
+ๆๅพใซใๅ
จใฆใฎ่ป่ผชใๅ่ปขใใใพใใ
+
+```js
+wheelMeshes.forEach((obj) => {
+ obj.rotation.x = time * 3;
+});
+```
+
+ๅๆๅๆใซใ4ใคๅ
จใฆใฎใซใกใฉใฎ้
ๅใ่จญๅฎใใพใใ
+
+```js
+const cameras = [
+ { cam: camera, desc: 'detached camera', },
+ { cam: turretCamera, desc: 'on turret looking at target', },
+ { cam: targetCamera, desc: 'near target looking at tank', },
+ { cam: tankCamera, desc: 'above back of tank', },
+];
+
+const infoElem = document.querySelector('#info');
+```
+
+ๆ็ปๆใซใซใกใฉใๅจๅใใใพใใ
+
+```js
+const camera = cameras[time * .25 % cameras.length | 0];
+infoElem.textContent = camera.desc;
+```
+
+{{{example url="../threejs-scenegraph-tank.html"}}}
+
+ใทใผใณใฐใฉใใฎๅไฝใจใไฝฟใๆนใฎใขใคใใขใใใใฎไพใใๅพใใใใฐใจๆใใพใใ
+`Object3D`ใใผใใไฝใใ็ฉไฝใใใฎๅญ่ฆ็ด ใซใใใใจใฏใthree.jsใฎใใใช3Dใจใณใธใณใไธๆใไฝฟใใใใซ
+้่ฆใชในใใใใงใใ
+ๆใ้ใใซใชใซใใๅใใใใๅ่ปขใใใใใใใใจใฏใใใฐใใฐ่ค้ใชๆฐๅญฆใๅฟ
่ฆใซ่ฆใใใใใใใพใใใ
+ไพใใฐใทใผใณใฐใฉใใชใใงใๆใฎๅใใๆไฝใใใใ่ปใฎ่ปไฝใซๅฏพใใฆๅฃฎๅคช็ฅ็ใซ่ป่ผชใ็ฝฎใใใใใใใจใฏใ
+ใจใฆใ้ฃใใใใใใใพใใใใใใใใทใผใณใฐใฉใใไฝฟใใใจใงใใจใฆใ็ฐกๅใซใชใใฎใงใใ
+
+[ๆฌกใฏใใใชใขใซใ่ชฌๆใใพใ](threejs-materials.html)ใ
\ No newline at end of file | false |
Other | mrdoob | three.js | b4910892bfa32c0fdc25d72d1336d8b34aec8fe1.json | fix voxel diagram | threejs/lessons/resources/threejs-voxel-geometry.js | @@ -10,7 +10,7 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
wire: '#DDD',
};
const lightColors = {
- wore: '#000',
+ wire: '#000',
};
const colors = isDarkMode ? darkColors : lightColors;
| false |
Other | mrdoob | three.js | 03d33279e4d3cde6273be59c5f6693346ebfab42.json | remove superfluous slashes | build/templates/index.template | @@ -37,14 +37,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
-<meta name="description" content="Three.js tutorials and solutions" />
-<meta name="keywords" content="webgl graphics three.js" />
-<meta name="thumbnail" content="https://threejsfundamentals.org/threejs/lessons/resources/threejsfundamentals.jpg" />
+<meta name="description" content="Three.js tutorials and solutions">
+<meta name="keywords" content="webgl graphics three.js">
+<meta name="thumbnail" content="https://threejsfundamentals.org/threejs/lessons/resources/threejsfundamentals.jpg">
-<meta property="og:title" content="{{title}}" />
-<meta property="og:type" content="website" />
-<meta property="og:image" content="https://threejsfundamentals.org/threejs/lessons/resources/threejsfundamentals.jpg" />
-<meta property="og:description" content="{{templateOptions.description}}" />
+<meta property="og:title" content="{{title}}">
+<meta property="og:type" content="website">
+<meta property="og:image" content="https://threejsfundamentals.org/threejs/lessons/resources/threejsfundamentals.jpg">
+<meta property="og:description" content="{{templateOptions.description}}">
<meta property="og:url" content="https://threejsfundamentals.org">
<meta name="twitter:card" content="summary_large_image">
@@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<meta name="twitter:domain" content="threejsfundamentals.org">
<meta name="twitter:title" content="threejsfundamentals.org">
<meta name="twitter:url" content="https://threejsfundamentals.org">
-<meta name="twitter:description" content="{{templateOptions.description}}" />
+<meta name="twitter:description" content="{{templateOptions.description}}">
<meta name="twitter:image:src" content="https://threejsfundamentals.org/threejs/lessons/resources/threejsfundamentals.jpg">
<title>{{title}}</title>
@@ -73,12 +73,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<link rel="apple-touch-icon" href="/threejs/lessons/resources/threejsfundamentals-icon.png">
<link rel="icon" href="/threejs/lessons/resources/threejsfundamentals-icon.png">
-<link rel="stylesheet" href="/threejs/lessons/lang.css" />
+<link rel="stylesheet" href="/threejs/lessons/lang.css">
{{#ifexists filename="/threejs/lessons/{{langCode}}/lang.css" langCode=langInfo.baseDirname}}
-<link rel="stylesheet" href="/threejs/lessons/{{langInfo.baseDirname}}/lang.css" />
+<link rel="stylesheet" href="/threejs/lessons/{{langInfo.baseDirname}}/lang.css">
{{/ifexists}}
-<link rel="stylesheet" href="/threejs/lessons/resources/lesson.css" />
-<link rel="stylesheet" href="/threejs/lessons/resources/index.css" />
+<link rel="stylesheet" href="/threejs/lessons/resources/lesson.css">
+<link rel="stylesheet" href="/threejs/lessons/resources/index.css">
</head>
<body>
<div id="canvas"> | true |
Other | mrdoob | three.js | 03d33279e4d3cde6273be59c5f6693346ebfab42.json | remove superfluous slashes | build/templates/lesson.template | @@ -37,24 +37,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
-<meta name="description" content="{{description}}" />
-<meta name="keywords" content="webgl graphics three.js" />
-<meta name="thumbnail" content="{{screenshot}}" />
-
-<meta property="og:title" content="{{title}}" />
-<meta property="og:type" content="website" />
-<meta property="og:image" content="{{screenshot}}" />
-<meta property="og:description" content="{{description}}" />
-<meta property="og:url" content="{{url}}" />
-
-<meta name="twitter:card" content="summary_large_image" />
-<meta name="twitter:site" content="@greggman" />
-<meta name="twitter:creator" content="@greggman" />
-<meta name="twitter:domain" content="threejsfundamentals.org" />
-<meta name="twitter:title" content="{{title}}" />
-<meta name="twitter:url" content="{{url}}" />
-<meta name="twitter:description" content="{{description}}" />
-<meta name="twitter:image:src" content="{{screenshot}}" />
+<meta name="description" content="{{description}}">
+<meta name="keywords" content="webgl graphics three.js">
+<meta name="thumbnail" content="{{screenshot}}">
+
+<meta property="og:title" content="{{title}}">
+<meta property="og:type" content="website">
+<meta property="og:image" content="{{screenshot}}">
+<meta property="og:description" content="{{description}}">
+<meta property="og:url" content="{{url}}">
+
+<meta name="twitter:card" content="summary_large_image">
+<meta name="twitter:site" content="@greggman">
+<meta name="twitter:creator" content="@greggman">
+<meta name="twitter:domain" content="threejsfundamentals.org">
+<meta name="twitter:title" content="{{title}}">
+<meta name="twitter:url" content="{{url}}">
+<meta name="twitter:description" content="{{description}}">
+<meta name="twitter:image:src" content="{{screenshot}}">
<script type="application/ld+json">
{
@@ -96,11 +96,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<link rel="apple-touch-icon" href="/threejs/lessons/resources/threejsfundamentals-icon.png">
<link rel="icon" href="/threejs/lessons/resources/threejsfundamentals-icon.png">
-<link rel="stylesheet" href="/threejs/lessons/lang.css" />
+<link rel="stylesheet" href="/threejs/lessons/lang.css">
{{#ifexists filename="/threejs/lessons/{{langCode}}/lang.css" langCode=langInfo.baseDirname}}
-<link rel="stylesheet" href="/threejs/lessons/{{langInfo.baseDirname}}/lang.css" />
+<link rel="stylesheet" href="/threejs/lessons/{{langInfo.baseDirname}}/lang.css">
{{/ifexists}}
-<link rel="stylesheet" href="/threejs/lessons/resources/lesson.css" />
+<link rel="stylesheet" href="/threejs/lessons/resources/lesson.css">
</head>
<body>
{{{include "build/templates/header.template"}}} | true |
Other | mrdoob | three.js | cdb5482850b4dc7dcbfffc3c541a046959d566bd.json | fix example threejs-prerequisites.md | threejs/lessons/threejs-prerequisites.md | @@ -165,14 +165,14 @@ Destructuring works with arrays too. Assume an array `const position = [1, 2, 3,
old code
```js
-const x = position[2];
-const y = position[1];
+const x = position[2]; // 3
+const y = position[1]; // 2
```
new code
```js
-const [x, y] = position;
+const [, y, x] = position; // x = 3, y = 2
```
Destructuring also works in function arguments | false |
Other | mrdoob | three.js | a9a96cfb8af23788ac97d77176ca1842daf2e865.json | add translation kr/threejs-tips.md | threejs/lessons/kr/threejs-tips.md | @@ -0,0 +1,361 @@
+Title: Three.js ํ
+Description: Three.js๋ฅผ ์ธ ๋ ํ์ํ ์๋ ์๋ ๊ฒ๋ค
+TOC: #
+
+์ด ๊ธ์ Three.js์ ํ์ ๊ดํ ๊ธ๋ค ์ค ๋๋ฌด ์งง์ ๋ณ๋์ ๊ธ๋ก ๋ถ๋ฆฌํ๊ธฐ ์ ๋งคํ ๊ธ๋ค์ ๋ฌถ์ ๊ฒ์
๋๋ค.
+
+---
+
+<a id="screenshot" data-toc="์คํฌ๋ฆฐ์ท ์ฐ๊ธฐ"></a>
+
+# ์บ๋ฒ์ค์ ์คํฌ๋ฆฐ์ท ์ฐ๊ธฐ
+
+๋ธ๋ผ์ฐ์ ์์ ์คํฌ๋ฆฐ์ท์ ์ฐ์ ์ ์๋ ๋ฐฉ๋ฒ์ 2๊ฐ์ง ์ ๋๊ฐ ์์ต๋๋ค. ์์ ๋ถํฐ ์ฌ์ฉํ๋ [`canvas.toDataURL`](https://developer.mozilla.org/ko/docs/Web/API/HTMLCanvasElement/toDataURL)๊ณผ, ์๋ก ๋ฑ์ฅํ [`canvas.toBlob`](https://developer.mozilla.org/ko/docs/Web/API/HTMLCanvasElement/toBlob)์ด ์์ฃ .
+
+๊ทธ๋ฅ ๋ฉ์๋ง ํธ์ถํ๋ฉด ๋๋ ๊ฑฐ๋ผ๋, ์ผํ ์ฌ์ ๋ณด์
๋๋ค. ์๋ ์ ๋์ ์ฝ๋๋ฉด ์์ฝ๊ฒ ์คํฌ๋ฆฐ์ท์ ์ฐ์ ์ ์์ ๊ฒ ๊ฐ๋ค์.
+
+```html
+<canvas id="c"></canvas>
++<button id="screenshot" type="button">Save...</button>
+```
+
+```js
+const elem = document.querySelector('#screenshot');
+elem.addEventListener('click', () => {
+ canvas.toBlob((blob) => {
+ saveBlob(blob, `screencapture-${ canvas.width }x${ canvas.height }.png`);
+ });
+});
+
+const saveBlob = (function() {
+ const a = document.createElement('a');
+ document.body.appendChild(a);
+ a.style.display = 'none';
+ return function saveData(blob, fileName) {
+ const url = window.URL.createObjectURL(blob);
+ a.href = url;
+ a.download = fileName;
+ a.click();
+ };
+}());
+```
+
+์๋๋ [๋ฐ์ํ ๋์์ธ](threejs-responsive.html)์ ์์ ์ ๋ฒํผ๊ณผ ๋ฒํผ์ ๊พธ๋ฐ CSS๋ฅผ ์ถ๊ฐํ ์์ ์
๋๋ค.
+
+{{{example url="../threejs-tips-screenshot-bad.html"}}}
+
+ํ์ง๋ง ๋ง์ ์คํฌ๋ฆฐ์ท์ ์ฐ์ด๋ณด๋ ์๋์ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ ๋์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/screencapture-413x313.png"></div>
+
+๊ทธ๋ฅ ํ
๋น ์ด๋ฏธ์ง๋ค์.
+
+๋ฌผ๋ก ๋ธ๋ผ์ฐ์ ๋/OS์ ๋ฐ๋ผ ์ ๋์ค๋ ๊ฒฝ์ฐ๋ ์์ ์ ์์ง๋ง ๋๊ฒ์ ๊ฒฝ์ฐ ํ
๋น ์ด๋ฏธ์ง๊ฐ ๋์ฌ ๊ฒ๋๋ค.
+
+์ด๊ฑด ์ฑ๋ฅ ๊ด๋ จ ๋ฌธ์ ์
๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ๋ธ๋ผ์ฐ์ ๋ ํ๋ฉด์ ๋ ๋๋งํ ํ WebGL ์บ๋ฒ์ค์ ๋๋ก์ ๋ฒํผ๋ฅผ ๋ฐ๋ก ๋น์๋๋ค.
+
+์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ํ๋ฉด์ ์บก์ณํ๊ธฐ ์ง์ ์ ํ๋ฉด์ ๋ ๋๋งํ๋ ํจ์๋ฅผ ํธ์ถํด์ผ ํฉ๋๋ค.
+
+์์ ์์ ๋ช ๊ฐ์ง๋ฅผ ์์ ํด์ผ ํฉ๋๋ค. ๋จผ์ ๋ ๋๋ง ํจ์๋ฅผ ๋ถ๋ฆฌํฉ์๋ค.
+
+```js
++const state = {
++ time: 0,
++};
+
+-function render(time) {
+- time *= 0.001;
++function render() {
+ if (resizeRendererToDisplaySize(renderer)) {
+ const canvas = renderer.domElement;
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
+ camera.updateProjectionMatrix();
+ }
+
+ cubes.forEach((cube, ndx) => {
+ const speed = 1 + ndx * .1;
+- const rot = time * speed;
++ const rot = state.time * speed;
+ cube.rotation.x = rot;
+ cube.rotation.y = rot;
+ });
+
+ renderer.render(scene, camera);
+
+- requestAnimationFrame(render);
+}
+
++function animate(time) {
++ state.time = time * 0.001;
++
++ render();
++
++ requestAnimationFrame(animate);
++}
++requestAnimationFrame(animate);
+```
+
+์ด์ `render` ํจ์๋ ์ค์ง ํ๋ฉด์ ๋ ๋๋งํ๋ ์ญํ ๋ง ํ๊ธฐ์, ํ๋ฉด์ ์บก์ณํ๊ธฐ ์ง์ ์ `render` ํจ์๋ฅผ ํธ์ถํ๋ฉด ๋ฉ๋๋ค.
+
+```js
+const elem = document.querySelector('#screenshot');
+elem.addEventListener('click', () => {
++ render();
+ canvas.toBlob((blob) => {
+ saveBlob(blob, `screencapture-${ canvas.width }x${ canvas.height }.png`);
+ });
+});
+```
+
+์ด์ ๋ฌธ์ ์์ด ์ ์๋ํ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-tips-screenshot-good.html" }}}
+
+๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ํด์๋ ๋ค์ ๊ธ์ ๋ณด๊ธฐ ๋ฐ๋๋๋ค.
+
+---
+
+<a id="preservedrawingbuffer" data-toc="์บ๋ฒ์ค ์ด๊ธฐํ ๋ฐฉ์งํ๊ธฐ"></a>
+
+# ์บ๋ฒ์ค ์ด๊ธฐํ ๋ฐฉ์งํ๊ธฐ
+
+์์ง์ด๋ ๋ฌผ์ฒด๋ก ์ฌ์ฉ์๊ฐ ๊ทธ๋ฆผ์ ๊ทธ๋ฆฌ๊ฒ ํ๋ค๊ณ ํด๋ด
์๋ค. ์ด๊ฑธ ๊ตฌํํ๋ ค๋ฉด `WebGLRenderer`๋ฅผ ์์ฑํ ๋ `preserveDrawingBuffer: true`๋ฅผ ์ค์ ํด์ผ ํฉ๋๋ค. ๋ํ Three.js๊ฐ ์บ๋ฒ์ค๋ฅผ ์ด๊ธฐํํ์ง ์๋๋ก ํด์ฃผ์ด์ผ ํ์ฃ .
+
+```js
+const canvas = document.querySelector('#c');
+-const renderer = new THREE.WebGLRenderer({ canvas });
++const renderer = new THREE.WebGLRenderer({
++ canvas,
++ preserveDrawingBuffer: true,
++ alpha: true,
++});
++renderer.autoClearColor = false;
+```
+
+{{{example url="../threejs-tips-preservedrawingbuffer.html" }}}
+
+๋ง์ฝ ์ง์ง ๋๋ก์ ํ๋ก๊ทธ๋จ์ ๋ง๋ค ๊ณํ์ด๋ผ๋ฉด ์ด ๋ฐฉ๋ฒ์ ์ฐ์ง ์๋ ๊ฒ ์ข์ต๋๋ค. ํด์๋๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ๋ธ๋ผ์ฐ์ ๊ฐ ์บ๋ฒ์ค๋ฅผ ์ด๊ธฐํํ ํ
๋๊น์. ํ์ฌ ์์ ์์๋ ํด์๋๋ฅผ ์บ๋ฒ์ค ํฌ๊ธฐ์ ๋ง์ถฐ ๋ณ๊ฒฝํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์บ๋ฒ์ค ํฌ๊ธฐ๋ ํ๋ฉด ํฌ๊ธฐ์ ๋ง์ถฐ ์กฐ์ ๋์ฃ . ํ์ผ์ ๋ค์ด๋ฐ๊ฑฐ๋, ํญ์ ๋ฐ๊พธ๊ฑฐ๋, ์ํํ์์ค์ด ์ถ๊ฐ๋๋ ๋ฑ ํ๋ฉด ํฌ๊ธฐ๊ฐ ๋ฐ๋๋ ๊ฒฝ์ฐ๋ ๋ค์ํฉ๋๋ค. ๋ชจ๋ฐ์ผ ํ๊ฒฝ์ด๋ผ๋ฉด ํ๋ฉด์ ํ์ ์ํค๋ ๊ฒฝ์ฐ๋ ํฌํจ๋๊ฒ ์ฃ .
+
+๋๋ก์ ํ๋ก๊ทธ๋จ์ ๋ง๋ค๋ ค๋ฉด [๋ ๋ ํ๊ฒ์ ์ด์ฉํด ํ
์ค์ฒ๋ก ํ๋ฉด์ ๋ ๋๋ง](threejs-rendertargets.html)ํ๋ ๊ฒ ์ข์ ๊ฒ๋๋ค.
+
+---
+
+<a id="tabindex" data-toc="์บ๋ฒ์ค์์ ํค ์
๋ ฅ ๋ฐ๊ธฐ"></a>
+
+# ํค ์
๋ ฅ ๋ฐ๊ธฐ
+
+์ด ์๋ฆฌ์ฆ์์๋ ๋๋ถ๋ถ์ ์ด๋ฒคํธ ๋ฆฌ์ค๋๋ฅผ `canvas`์ ์ถ๊ฐํ์ต๋๋ค. ๋ค๋ฅธ ์ด๋ฒคํธ๋ ๋ฌธ์ ์์ด ์๋ํ์ง๋ง, ๋ฑ ํ๋, ํค๋ณด๋ ์ด๋ฒคํธ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๊ทธ๋ฅ ๋์ํ์ง ์์์ต๋๋ค.
+
+ํค๋ณด๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ผ๋ ค๋ฉด ํด๋น ์์์ [`tabindex`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex)๋ฅผ 0 ์ด์์ ๊ฐ์ผ๋ก ์ค์ ํด์ผ ํฉ๋๋ค.
+
+```html
+<canvas tabindex="0"></canvas>
+```
+
+ํ์ง๋ง ์ด ์์ฑ์ ์ ์ฉํ๋ฉด ์๋ก์ด ๋ฌธ์ ๊ฐ ์๊น๋๋ค. `tabindex`๊ฐ ์๋ ์์๋ focus ์ํ์ผ ๋ ๊ฐ์กฐ ํ์๊ฐ ์ ์ฉ๋๊ฑฐ๋ ์. ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด CSS์ `outline` ์์ฑ์ `none`์ผ๋ก ์ค์ ํด์ผ ํฉ๋๋ค.
+
+```css
+canvas:focus {
+ outline: none;
+}
+```
+
+๊ฐ๋จํ ํ
์คํธ๋ฅผ ์ํด ์บ๋ฒ์ค 3๊ฐ๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```html
+<canvas id="c1"></canvas>
+<canvas id="c2" tabindex="0"></canvas>
+<canvas id="c3" tabindex="1"></canvas>
+```
+
+๋ง์ง๋ง ์บ๋ฒ์ค์๋ง CSS๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```css
+#c3:focus {
+ outline: none;
+}
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ชจ๋ ์บ๋ฒ์ค์ ์ด๋ฒคํธ ๋ฆฌ์ค๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+document.querySelectorAll('canvas').forEach((canvas) => {
+ const ctx = canvas.getContext('2d');
+
+ function draw(str) {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText(str, canvas.width / 2, canvas.height / 2);
+ }
+ draw(canvas.id);
+
+ canvas.addEventListener('focus', () => {
+ draw('has focus press a key');
+ });
+
+ canvas.addEventListener('blur', () => {
+ draw('lost focus');
+ });
+
+ canvas.addEventListener('keydown', (e) => {
+ draw(`keyCode: ${e.keyCode}`);
+ });
+});
+```
+
+์ฒซ ๋ฒ์งธ ์บ๋ฒ์ค์๋ ์๋ฌด๋ฆฌ ํด๋ ํค๋ณด๋ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ง ์์ ๊ฒ๋๋ค. ๋ ๋ฒ์งธ ์บ๋ฒ์ค๋ ํค๋ณด๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ๊ธด ํ์ง๋ง ๊ฐ์กฐ ํ์๊ฐ ์๊ธฐ์ฃ . ๋์ ์ธ ๋ฒ์งธ ์บ๋ฒ์ค์์๋ ๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค.
+
+{{{example url="../threejs-tips-tabindex.html"}}}
+
+---
+
+<a id="transparent-canvas" data-toc="์บ๋ฒ์ค๋ฅผ ํฌ๋ช
ํ๊ฒ ๋ง๋ค๊ธฐ"></a>
+
+# ์บ๋ฒ์ค๋ฅผ ํฌ๋ช
ํ๊ฒ ๋ง๋ค๊ธฐ
+
+์๋ฌด๋ฐ ์ค์ ์ ํ์ง ์๋๋ค๋ฉด Three.js๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์บ๋ฒ์ค๋ฅผ ๋ถํฌ๋ช
ํ๊ฒ ๋ ๋๋งํฉ๋๋ค. ์บ๋ฒ์ค๋ฅผ ํฌ๋ช
ํ๊ฒ ๋ง๋ค๋ ค๋ฉด `WebGLRenderer`๋ฅผ ์์ฑํ ๋ [`alpha: true`](WebGLRenderer.alpha)๋ฅผ ๋๊ฒจ์ค์ผ ํ์ฃ .
+
+```js
+const canvas = document.querySelector('#c');
+-const renderer = new THREE.WebGLRenderer({ canvas });
++const renderer = new THREE.WebGLRenderer({
++ canvas,
++ alpha: true,
++});
+```
+
+๋ํ ์บ๋ฒ์ค๊ฐ premultiplied ์ํ(๋ฏธ๋ฆฌ ๊ณ์ฐ๋ alpha ๊ฐ, straight alpha ๋๋ associated alpha๋ผ๊ณ ๋ ๋ถ๋ฆผ)๋ฅผ ์ฌ์ฉํ์ง **์๋๋ก** ํ๊ฒ๋ ํ๋ ค๋ฉด ์๋์ฒ๋ผ ๊ฐ์ ์ค์ ํด์ค์ผ ํฉ๋๋ค.
+
+```js
+const canvas = document.querySelector('#c');
+const renderer = new THREE.WebGLRenderer({
+ canvas,
+ alpha: true,
++ premultipliedAlpha: false,
+});
+```
+
+Three.js๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์บ๋ฒ์ค์๋ [`premultipliedAlpha: true`](WebGLRenderer.premultipliedAlpha)๋ฅผ ์ฌ์ฉํ์ง๋ง ์ฌ์ง(material)์๋ [`premultipliedAlpha: false`](Material.premultipliedAlpha)๋ฅผ ์ฌ์ฉํฉ๋๋ค.
+
+premultiplied alpha๋ฅผ ์ด๋ป๊ฒ ์ฌ์ฉํด์ผ ํ๋์ง ์๊ณ ์ถ๋ค๋ฉด [์ฌ๊ธฐ ์ด ๊ธ](https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre)\*์ ์ฐธ๊ณ ํ๊ธฐ ๋ฐ๋๋๋ค.
+
+
+โป ์์ด์ด๋ ์ฝ๊ธฐ๊ฐ ์ด๋ ต๋ค๋ฉด ๊ทธ๋ฅ ๊ตฌ๊ธ์ premultiplied alpha๋ฅผ ๊ฒ์ํ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค. ์ญ์ฃผ.
+
+์ด์จ๋ ์ด์ ํ ๋ฒ ํฌ๋ช
์บ๋ฒ์ค ์์ ๋ฅผ ๋ง๋ค์ด๋ณด์ฃ .
+
+[๋ฐ์ํ ๋์์ธ](threejs-responsive.html)์์ ๊ฐ์ ธ์จ ์์ ์ ์ ์ค์ ์ ์ ์ฉํ์ต๋๋ค. ์ถ๊ฐ๋ก ์ฌ์ง๋ ๋๊ฐ์ด ํฌ๋ช
ํ๊ฒ ๋ง๋ค์ด๋ณด์ฃ .
+
+```js
+function makeInstance(geometry, color, x) {
+- const material = new THREE.MeshPhongMaterial({ color });
++ const material = new THREE.MeshPhongMaterial({
++ color,
++ opacity: 0.5,
++ });
+
+...
+
+```
+
+์ฌ๊ธฐ์ HTML๋ก ํ
์คํธ๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```html
+<body>
+ <canvas id="c"></canvas>
++ <div id="content">
++ <div>
++ <h1>Cubes-R-Us!</h1>
++ <p>We make the best cubes!</p>
++ </div>
++ </div>
+</body>
+```
+
+์บ๋ฒ์ค๋ฅผ ์์ ๋ฌ์ผ ํ๋ CSS๋ ์ถ๊ฐํฉ๋๋ค.
+
+```css
+body {
+ margin: 0;
+}
+#c {
+ width: 100vw;
+ height: 100vh;
+ display: block;
++ position: fixed;
++ left: 0;
++ top: 0;
++ z-index: 2;
++ pointer-events: none;
+}
++#content {
++ font-size: 7vw;
++ font-family: sans-serif;
++ text-align: center;
++ width: 100vw;
++ height: 100vh;
++ display: flex;
++ justify-content: center;
++ align-items: center;
++}
+```
+
+`pointer-events: none`์ ์บ๋ฒ์ค๊ฐ ๋ง์ฐ์ค๋ ํฐ์น ์ด๋ฒคํธ์ ์ํฅ์ ๋ฐ์ง ์๋๋ก ํด์ค๋๋ค. ์๋์ ์๋ ํ
์คํธ๋ฅผ ๋ฐ๋ก ์ ํํ ์ ์๋๋ก ์ค์ ํ ๊ฒ์ด์ฃ .
+
+{{{example url="../threejs-tips-transparent-canvas.html" }}}
+
+---
+
+<a id="html-background" data-toc="Three.js๋ฅผ HTML ์์์ ๋ฐฐ๊ฒฝ์ผ๋ก ์ฌ์ฉํ๊ธฐ"></a>
+
+# ๋ฐฐ๊ฒฝ์ Three.js ์ ๋๋ฉ์ด์
๋ฃ๊ธฐ
+
+๋ง์ด ๋ฐ์ ์ง๋ฌธ ์ค์ ํ๋๊ฐ Three.js ์ ๋๋ฉ์ด์
์ ์น ํ์ด์ง์ ๋ฐฐ๊ฒฝ์ผ๋ก ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด์์ต๋๋ค.
+
+๊ฐ๋ฅํ ๋ฐฉ๋ฒ์ 2๊ฐ์ง ์ ๋๊ฒ ๋ค์.
+
+* ์บ๋ฒ์ค ์์์ CSS `position`์ `fixed`๋ก ์ค์ ํ๋ค.
+
+```css
+#c {
+ position: fixed;
+ left: 0;
+ top: 0;
+ ...
+}
+```
+
+์ด์ ์์ ์์ ์ผ๋ ๋ฐฉ๋ฒ๊ณผ ๋๊ฐ์ ๋ฐฉ๋ฒ์ ์ ์ฉํ ์ ์์ต๋๋ค. `z-index`๋ฅผ -1 ๋ก ์ค์ ํ๋ฉด ์ ์ก๋ฉด์ฒด๋ค์ด ํ
์คํธ ๋ค๋ก ์ฌ๋ผ์ง ๊ฒ๋๋ค.
+
+์ด ๋ฐฉ๋ฒ์ ๋จ์ ์ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋๊ฐ ๋ฐ๋์ ํ์ด์ง์ ํตํฉ๋์ผ ํ๋ค๋ ๊ฒ๋๋ค. ํนํ ๋ณต์กํ ํ์ด์ง๋ผ๋ฉด Three.js๋ฅผ ๋ ๋๋งํ๋ ์ฝ๋๊ฐ ๋ค๋ฅธ ์ฝ๋์ ์ถฉ๋ํ์ง ์๋๋ก ํน๋ณํ ์ ๊ฒฝ์ ์จ์ผ ํ๊ฒ ์ฃ .
+
+* `iframe`์ ์ด๋ค.
+
+์ด ๋ฐฉ๋ฒ์ ์ด ์ฌ์ดํธ์ [๋ฉ์ธ ํ์ด์ง](/threejs/lessons/kr/)์์ ์ฌ์ฉํ ๋ฐฉ๋ฒ์
๋๋ค.
+
+ํด๋น ์น ํ์ด์ง์ iframe๋ง ์ถ๊ฐํ๋ฉด ๋์ฃ .
+
+```html
+<iframe id="background" src="threejs-responsive.html">
+<div>
+ ๋ด์ฉ ๋ด์ฉ ๋ด์ฉ ๋ด์ฉ
+</div>
+```
+
+๊ทธ๋ฐ ๋ค์ ์บ๋ฒ์ค ์์๋ฅผ ํ์ฉํ์ ๋์ ๋ง์ฐฌ๊ฐ์ง๋ก iframe์ด ์ฐฝ ์ ์ฒด๋ฅผ ์ฑ์ฐ๋๋ก ํ ๋ค, `z-index`๋ฅผ ์ด์ฉํด ๋ฐฐ๊ฒฝ์ผ๋ก ์ง์ ํฉ๋๋ค. iframe์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์ค๊ณฝ์ ์ด ์์ผ๋ ์ถ๊ฐ๋ก `border`๋ง `none`์ผ๋ก ์ค์ ํด์ฃผ๋ฉด ๋ฉ๋๋ค.
+
+```css
+#background {
+ position: fixed;
+ width: 100vw;
+ height: 100vh;
+ left: 0;
+ top: 0;
+ z-index: -1;
+ border: none;
+ pointer-events: none;
+}
+```
+
+{{{example url="../threejs-tips-html-background.html"}}}
\ No newline at end of file | false |
Other | mrdoob | three.js | 7d378eeaa05faf9242027a6037af43ad8b89c920.json | add translation kr/threejs-debugging-glsl | threejs/lessons/kr/threejs-debugging-glsl.md | @@ -0,0 +1,64 @@
+Title: Three.js GLSL ๋๋ฒ๊น
+Description: GLSL ์์ด๋ ๋๋ฒ๊น
์ ๋ํด ์์๋ด
๋๋ค
+TOC: GLSL ๋๋ฒ๊น
+
+์ด ์ฌ์ดํธ์์ ์๋ฐ์คํฌ๋ฆฝํธ ์์ฒด์ ๋ํด ๋ค๋ฃจ์ง ์๋ฏ, ์์ง๊น์ง ์ด ์ฌ์ดํธ์๋ GLSL์ ๋ํ ๊ธ์ด ์์ต๋๋ค. GLSL์ ๊ฐ๋จํ ๋ค๋ฃจ๊ธฐ ์ด๋ ค์ด ์ฃผ์ ์ด๊ธฐ์ GLSL์ ๋ฐฐ์ฐ๊ณ ์ถ๋ค๋ฉด [์ด ์๋ฆฌ์ฆ](https://webglfundamentals.org/webgl/lessons/ko/)๋ฅผ ์ฐธ๊ณ ํ๊ธฐ ๋ฐ๋๋๋ค.
+
+GLSL์ ๋ํด ์ด๋ ์ ๋ ์๋ค๋ฉด ์ด ๊ธ์ด GLSL ๋๋ฒ๊น
์ ๋์์ด ๋ ๊ฒ๋๋ค.
+
+GLSL ์์ด๋๋ฅผ ๋ง๋ค์๋๋ฐ ์๋ฌด๊ฒ๋ ๋ํ๋์ง ์์ ๋, ์ ๋ ๋ณดํต ์์ด๋๋ฅผ fragment ์์ด๋๋ก ๋ฐ๊พผ ๋ค ํน์ ์์๋ง ๋ฐํํ๊ฒ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ์์ด๋์ ๊ฐ์ฅ ๋ง์ง๋ง์ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ฅผ ๋ฃ๋ ๊ฒ์ด์ฃ .
+
+```glsl
+void main() {
+
+ ...
+
+ gl_FragColor = vec4(1, 0, 0, 1); // ๋นจ๊ฐ
+}
+```
+
+๋ง์ฝ ์ ๋ ๊ฒ ํด์ ์์๊ฐ ๋ณด์ธ๋ค๋ฉด fragment ์์ด๋์ ๋ฌธ์ ๊ฐ ์๋ ๊ฒ๋๋ค. ํ
์ค์ฒ๊ฐ ๊นจ์ง ๊ฑด์ง, ๊ท ๋ฑ ๋ณ์(uniform)๋ฅผ ์ง์ ํ์ง ์์ ๊ฑด์ง, ๊ท ๋ฑ ๋ณ์์ ์๋ชป๋ ๊ฐ์ ์ง์ ํ ๊ฑด์ง๋ ์ ์ ์์ง๋ง ์ ์ด๋ ์ด๋์ ๋ฌธ์ ๋ฅผ ์ฐพ์์ผ ํ ์ง๋ ์ ์ ์์ฃ .
+
+์ด๋๊ฐ ํ๋ ธ๋์ง ํ์ธํ๊ธฐ ์ํด ๋ช ๊ฐ์ง ์์๋ฅผ ์ค์ ๋ก ๋ ๋๋งํด๋ณผ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด fragment ์์ด๋์ ๋ฒ์ (normal)์ ์ฌ์ฉํ๋ค๋ฉด ์ ๋ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋๋ฅผ ์ถ๊ฐํ ๊ฒ๋๋ค.
+
+```glsl
+gl_FragColor = vec4(vNormal * 0.5 + 0.5, 1);
+```
+
+๋ฒ์ ์ ๊ฐ์ -1 ์์ +1 ์ฌ์ด์ด๊ธฐ์ 0.5๋ฅผ ๊ณฑํ ๋ค 0.5๋ฅผ ๋ํ๋ฉด ๊ฐ์ 0.0 ์์ 0.1๋ก ๋ง๋ค์ด ์์ผ๋ก ํํํ ์ ์์ต๋๋ค.
+
+์คํ์ด ์ ๋ ์์ ์ ์ด ์์ด๋๋ฅผ ์ ์ฉํด๋ณด๋ฉด ๋ฒ์ ์ด *๋ณดํต(normally)* ์ด๋ป๊ฒ ์๊ฒผ๋์ง ์ ์ ์์ต๋๋ค. ๋ง์ฝ ๋ฒ์ ์ด ์ ์์ ์ผ๋ก ๋ณด์ด์ง ์๋๋ค๋ฉด ๊ทธ๊ฒ ๋ค์ ๋ฌธ์ ๋ฅผ ์ฐพ์ ๋จ์๊ฐ ๋๊ฒ ์ฃ . fragment ์์ด๋์์ ๋ฒ์ ์ ๊ฐ์ ๋ณ๊ฒฝํ๋ ๊ฒฝ์ฐ ๊ฐ์ ๋ฐฉ๋ฒ์ ์ด์ฉํด ๊ฒฐ๊ณผ๊ฐ์ ๋ ๋๋งํ ์ ์์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/standard-primitive-normals.jpg" style="width: 650px;"></div>
+
+๋ง์ฐฌ๊ฐ์ง๋ก ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์๋ ํ
์ค์ฒ ์ขํ๊ฐ ์์ผ๋ ๊ทธ๊ฑธ๋ก ๋ค์๊ณผ ๊ฐ์ด ํ์ฉํ ์ ์์ต๋๋ค.
+
+```glsl
+gl_FragColor = vec4(fract(vUv), 0, 1);
+```
+
+ํ
์ค์ฒ ์ขํ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ, `fract`๋ฅผ ์คํํ ๊ฐ์ 0๋ถํฐ 1 ์ฌ์ด์ ๊ฐ์ด ์๋ ์ ์์ต๋๋ค. ๋์ ๋ฌผ์ฒด๊ฐ ํ
์ค์ฒ๋ณด๋ค ํฌ๊ณ `texture.repeat`์ ์ฌ์ฉํ ๊ฒฝ์ฐ 1๋ณด๋ค ํฐ ์ซ์๊ฐ ๋์ฌ ์ ์๊ฒ ์ฃ .
+
+<div class="threejs_center"><img src="resources/images/standard-primitive-uvs.jpg" style="width: 650px;"></div>
+
+fragment ์์ด๋์ ๋ค๋ฅธ ๊ฐ์ผ๋ก๋ ๋น์ทํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ํด๋น ๊ฐ์ ๋ฒ์๋ฅผ ์์๋ธ ๋ค ํด๋น ๊ฐ์ 0.0๋ถํฐ 1.0 ์ฌ์ด์ ๊ฐ์ผ๋ก ๋ณํํด `gl_FragColor`์ ์ง์ ํ๋ ๊ฑฐ์ฃ .
+
+ํ
์ค์ฒ๋ฅผ ํ์ธํ๋ ค๋ฉด `CanvasTexture`๋ `DataTexture`๋ฅผ ์ฌ์ฉํด๋ณด๊ธฐ ๋ฐ๋๋๋ค.
+
+๋ง์ฝ `gl_FragColor`์ ๋นจ๊ฐ์์ ์ง์ ํ๋๋ฐ๋ ์๋ฌด๊ฒ๋ ๋ณด์ด์ง ์๋๋ค๋ฉด, vertex ์์ด๋ ๊ด๋ จ ๋ฌผ์ฒด์ ๋ฐฉํฅ ๋ฌธ์ ์ผ ์ ์์ต๋๋ค. ํน์ ํ๋ ฌ ์ขํ(matrix)๊ฐ ์๋ชป๋์๊ฑฐ๋ ์ด๋ค ์์ฑ์ ๊ฐ์ด ์๋ชป๋์๊ฑฐ๋ ์ค์ ์ด ์ด์ํ ์ ์์ฃ .
+
+๊ทธ๋ผ ๋จผ์ ํ๋ ฌ ์ขํ๋ฅผ ์ดํด๋ด์ผ ํฉ๋๋ค. `renderer.render(scene, camera)`๋ฅผ ํ ๋ฒ๋ง ํธ์ถํ ๋ค ์ฝ์์์ ๊ฐ์ฒด๋ฅผ ํผ์ณ ๋ณด๋ ๊ฒ์ด์ฃ . ์นด๋ฉ๋ผ์ ์ ์ญ ํ๋ ฌ ์ขํ๋ ํฌ์ฌ ํ๋ ฌ ์ขํ์ `NaN`์ด ์๋ ๊ฑธ๊น์? ์ฅ๋ฉด ๊ฐ์ฒด๋ฅผ ํผ์ณ `children` ์์ฑ์ ํ์ธํ๋ ์ ์ญ ํ๋ ฌ ์ขํ๋ ๋ฉ์ฉกํด ๋ณด์
๋๋ค(`NaN`์ด ์์). ๋ํ ๋ค๋ฅธ ํ๋ ฌ ์ขํ์ 4๊ฐ์ง ๊ฐ๋ค๋ ๋ชจ๋ ๋ฉ์ฉกํด ๋ณด์
๋๋ค. ๋ง์ฝ ์ฅ๋ฉด์ ํฌ๊ธฐ๊ฐ 50x50x50์ธ๋ฐ ์ด๋ค ์ขํ๊ฐ์ด 552352623.123์ด๋ผ๋ฉด ํ์คํ ๋ญ๊ฐ ์๋ชป๋ ๊ฒ๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/inspect-matrices.gif"></div>
+
+fragment ์์ด๋์ ๋ง์ฐฌ๊ฐ์ง๋ก vertex ์์ด๋์์๋ ๊ฐ์ fragment ์์ด๋์ ๋๊ฒจ์ฃผ๋ ๋ฐฉ์์ผ๋ก ๊ฐ์ ์๊ฐํํ ์ ์์ต๋๋ค. ์ ์์ด๋์ ๋์ผํ๊ฒ ๋ณ์๋ฅผ ์์ฑํ ๋ค, ์์ฌ๋๋ ๊ฐ์ ๋๊ฒจ์ฃผ๋ ๊ฑฐ์ฃ . ์ ๋ผ๋ฉด fragment ์์ด๋๊ฐ ๊ทธ ๊ฐ์ ํ์ํ๋๋ก ์์ฌ๋๋ ๊ฐ์ `vNormal`์ 0.0์์ 1.0 ์ฌ์ด์ ๊ฐ์ผ๋ก ๋ฐ๊ฟ ์ง์ ํ ๊ฒ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ์์๊ณผ ์ผ์นํ๋์ง ํ์ธํ๋ ๊ฒ์ด์ฃ .
+
+์ด ๋ฐฉ๋ฒ์ด ํตํ์ง ์๋๋ค๋ฉด ์ด๋ค vertex ์์ด๋๊ฐ geometry๋ฅผ ๊ฐ์ฅ ๊ฐ๋จํ๊ฒ ํ์ํ ์ ์์๊น์? ์์ฃผ ๊ฐ๋จํ๊ฒ ๋ค์์ฒ๋ผ ํ ์ ์์ ๊ฒ๋๋ค.
+
+```glsl
+gl_Position = projection * modelView * vec4(position.xyz, 1);
+```
+
+์ ์ฝ๋๊ฐ ์ ์๋ํ๋ค๋ฉด ๋ณ๊ฒฝ์ฌํญ์ ์กฐ๊ธ์ฉ ์ ์ฉํด๋ณด๊ธฐ ๋ฐ๋๋๋ค.
+
+์ถ๊ฐ๋ก [ํฌ๋กฌ์ ํ์ฅ ํ๋ก๊ทธ๋จ ์ค ์์ด๋ ์๋ํฐ](https://chrome.google.com/webstore/detail/shader-editor/ggeaidddejpbakgafapihjbgdlbbbpob?hl=ko)๋ ๋ค๋ฅธ ๋ธ๋ผ์ฐ์ ์ ๋น์ทํ ํ๋ก๊ทธ๋จ์ ์ฐพ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ๋ ์์ต๋๋ค. ์ด๋ ๋ค๋ฅธ ์์ด๋๊ฐ ์ด๋ป๊ฒ ์๋ํ๋์ง ๋ณผ ๋๋ ์ ์ฉํ์ฃ . ๋ํ ์ ๋ณ๊ฒฝ ์ฌํญ์ ๋ฐ๋ก ์ ์ฉํด๋ณผ ์ ์๋ค๋ ๊ฒ๋ ์ฅ์ ์
๋๋ค. | false |
Other | mrdoob | three.js | dc8aa5fc60a999eeb29118735d4e899850e82fc3.json | add translation kr/threejs-debugging-javascript.md | threejs/lessons/kr/threejs-debugging-javascript.md | @@ -0,0 +1,447 @@
+Title: Three.js ์๋ฐ์คํฌ๋ฆฝํธ ๋๋ฒ๊น
+Description: Three.js์์ ์๋ฐ์คํฌ๋ฆฝํธ ๋๋ฒ๊น
ํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ์๋ฐ์คํฌ๋ฆฝํธ ๋๋ฒ๊น
+
+์ด ๊ธ์ Three.js์ ํ์ ๋ ๊ธ์ด ์๋๋๋ค. ๋ณด๋ค๋ ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ๋๋ฒ๊น
ํ๋ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ํ๋ ํธ์ด ์ ๋นํ์ฃ . Three.js๋ฅผ ๋ฐฐ์ฐ๋ ค๋ ๋ถ๋ค ์ค์๋ ์๋ฐ์คํฌ๋ฆฝํธ๋ ์ฒ์ ์ ํ๋ ๋ถ๋ค์ด ๋๋ฌ ์๋๋ฐ, ์ด ๊ธ์ด ๊ทธ๋ฐ ๋ถ๋ค์๊ฒ ๋์์ด ๋์์ผ๋ฉด ์ข๊ฒ ๋ค์.
+
+๋๋ฒ๊น
์ ๋ฐฉ๋ํ ์ฃผ์ ๋ผ ์ฌ๊ธฐ์ ๋ชจ๋ ๋ถ๋ถ์ ๋ค๋ฃจ๊ธฐ๋ ์ด๋ ต์ต๋๋ค. ์ด ๊ธ์์๋ ์๋ฐ์คํฌ๋ฆฝํธ ์
๋ฌธ์์ ๊ฒฝ์ฐ๋ฅผ ๊ฐ์ ํด ๋ช ๊ฐ์ง ์ค์ํ ๋ถ๋ถ์ ์ง๊ณ ๋์ด๊ฐ ๊ฒ๋๋ค. ๋๋ฒ๊น
์ ๋์ค์ ๋ฌด์์ ๋ฐฐ์ฐ๋ ๋์์ด ๋๋ ์๊ฐ์ ๋ค์ฌ ๊ผญ ์ดํด๋ณด๊ธฐ ๋ฐ๋๋๋ค.
+
+## ๋ธ๋ผ์ฐ์ ๊ฐ๋ฐ์ ๋๊ตฌ
+
+[ํฌ๋กฌ](https://developers.google.com/web/tools/chrome-devtools/), [ํ์ด์ดํญ์ค](https://developer.mozilla.org/ko/docs/Tools), [์ฌํ๋ฆฌ](https://developer.apple.com/safari/tools/), [์ฃ์ง](https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide) ๋ฑ ๋ชจ๋ ๋ธ๋ผ์ฐ์ ์๋ ๊ฐ๋ฐ์ ๋๊ตฌ๊ฐ ์์ต๋๋ค.
+
+ํฌ๋กฌ์์๋ `โฎ` ์์ด์ฝ์ ํด๋ฆญํด "๋๊ตฌ ๋๋ณด๊ธฐ -> ๊ฐ๋ฐ์ ๋๊ตฌ"๋ฅผ ์ ํํ๋ฉด ๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ์ด ์ ์์ต๋๋ค. ๊ธฐ๋ณธ ๋จ์ถํค๋ ๊ฑฐ๊ธฐ์ ๊ฐ์ด ํ์๋์ฃ .
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-chrome.jpg" style="width: 789px;"></div>
+
+ํ์ด์ดํญ์ค์์๋ `โฐ` ์์ด์ฝ์ ํด๋ฆฐํ ๋ค "์น ๊ฐ๋ฐ์ -> ๋๊ตฌ ํ์/์จ๊ธฐ๊ธฐ"๋ฅผ ์ ํํ๋ฉด ๋ฉ๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-firefox.jpg" style="width: 786px;"></div>
+
+์ฌํ๋ฆฌ๋ ๋จผ์ ๊ณ ๊ธ ์ค์ ์์ ๊ฐ๋ฐ์ ๋ฉ๋ด๋ฅผ ํ์ฑํํด์ผ ํฉ๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-enable-safari.jpg" style="width: 775px;"></div>
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ๋ฐ์ ๋ฉ๋ด์์ "Show/Connect Web Inspector"๋ฅผ ์ ํํ๋ฉด ๋์ฃ .
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-safari.jpg" style="width: 777px;"></div>
+
+ํฌ๋กฌ์ ๊ฒฝ์ฐ๋ [PC ๋ฒ์ ผ ํฌ๋กฌ์ ์ด์ฉํด ์๋๋ก์ด๋ ๊ธฐ๊ธฐ์ ํฌ๋กฌ์ ๋๋ฒ๊น
](https://developers.google.com/web/tools/chrome-devtools/remote-debugging/)ํ ์ ์์ต๋๋ค. ์ฌํ๋ฆฌ์์๋ [macOS ์ปดํจํฐ์์ ์์ดํฐ์ด๋ ์์ดํจ๋์ ์ฌํ๋ฆฌ๋ฅผ ๋๋ฒ๊น
](https://www.google.com/search?q=safari+remote+debugging+ios)ํ ์ ์์ฃ .
+
+์ ๋ ํฌ๋กฌ์ด ๋ ์ต์ํ๊ธฐ์ ํฌ๋กฌ์ ๊ธฐ์ค์ผ๋ก ์ค๋ช
ํ๊ฒ ์ต๋๋ค. ๋ค๋ฅธ ๋ธ๋ผ์ฐ์ ๋ค๋ ๋ค ๋น์ทํ ๊ธฐ๋ฅ์ด ์์ผ๋ ๊ทธ๋ค์ง ์ด๋ ต์ง ์๊ฒ ๋ฐฐ์ด ๊ฑธ ์จ๋จน์ ์ ์์ ๊ฑฐ์์.
+
+## ์บ์ ๋๊ธฐ
+
+๋ธ๋ผ์ฐ์ ๋ ๋ด๋ ค ๋ฐ์ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฌ์ฉํฉ๋๋ค. ์ฌ์ฉ์ ์
์ฅ์์๋ ์ฌ์ดํธ๋ฅผ ๋ ๋ฒ ์ด์ ๋ฐฉ๋ฌธํ์ ๋ ํ์ผ์ ๋ค์ ๋ค์ด ๋ฐ์ง ์์๋ ๋๋ ํ์ํ ์ผ์ด์ฃ .
+
+ํ์ง๋ง ๊ฐ๋ฐ์์ ์
์ฅ์์๋ ์ด ๊ธฐ๋ฅ์ด ๋ถํธํ ์ ์์ต๋๋ค. ํ์ผ์ ์์ ํ ๋ค ํ์ด์ง๋ฅผ ์๋ก๊ณ ์นจํด๋ ๋ธ๋ผ์ฐ์ ๊ฐ ์บ์๋ก ์ ์ฅ๋ ํ์ผ์ ์ฌ์ฉํด ์์ ๋ ๋ด์ฉ์ด ๋ฐ์๋์ง ์๊ธฐ ๋๋ฌธ์ด์ฃ .
+
+์น ๊ฐ๋ฐ์ ํ๋ ๋์ ์บ์ฑ์ ๋นํ์ฑํ ํ๋ฉด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. ์ด๋ฌ๋ฉด ๋ธ๋ผ์ฐ์ ๊ฐ ํญ์ ํ์ผ์ ์ต์ ๋ฒ์ ผ์ ๋ฐ์ ์ฌ์ฉํ์ฃ .
+
+๋จผ์ ๊ฐ๋ฐ์ ๋๊ตฌ์ ๋ฉ๋ด์์ ์ค์ ์ ์ ํํ ๋ค
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-chrome-settings.jpg" style="width: 778px"></div>
+
+"Disable Cache (while DevTools is open)"์ ์ ํํฉ๋๋ค(๊ฐ๋ฐ์ ๋๊ตฌ๊ฐ ์ด๋ ธ์ ๋ ์บ์ ๋นํ์ฑํ).
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-chrome-disable-cache.jpg" style="width: 779px"></div>
+
+## ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ์
+
+๊ฐ๋ฐ์ ๋๊ตฌ์๋ **console**์ด๋ผ๋ ํญ์ด ์์ต๋๋ค. ์ฌ๊ธฐ์ ๊ฐ์ข
๊ฒฝ๊ณ ๋ ์ค๋ฅ ๋ฉ์์ง๊ฐ ์ถ๋ ฅ๋์ฃ .
+
+Three.js๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ 1๊ฐ ๋ด์ง 2๊ฐ์ ๋ฉ์์ง๊ฐ ๋ณด์ด๋ ๊ฒ ์ ์์
๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-no-errors.jpg" style="width: 779px"></div>
+
+๋ค๋ฅธ ๋ฉ์์ง๊ฐ ๋ณด์ธ๋ค๋ฉด ์ด๋ฅผ ํ์ธํด๋ด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ์๋์ ๊ฐ์ ๊ฒฝ์ฐ
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-errors.jpg" style="width: 779px"></div>
+
+์คํ๊ฐ ๋ฌ์ต๋๋ค. "three"๋ฅผ "threee"๋ก ์๋ชป ์ผ์ฃ .
+
+๋ฟ๋ง ์๋๋ผ `console.log`๋ก ์ง์ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํ ์๋ ์์ต๋๋ค.
+
+```js
+console.log(someObject.position.x, someObject.position.y, someObject.position.z);
+```
+
+์ดํด๋ณด๊ณ ์ถ์ ๊ฐ์ฒด๋ฅผ ์ถ๋ ฅํ ์๋ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด [glTF ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html)์ ์์ ์์ root ์ฅ๋ฉด(scene) ์์๋ฅผ ์ถ๋ ฅํด๋ณด์ฃ .
+
+```js
+ {
+ const gltfLoader = new GLTFLoader();
+ gltfLoader.load('resources/models/cartoon_lowpoly_small_city_free_pack/scene.gltf', (gltf) => {
+ const root = gltf.scene;
+ scene.add(root);
++ console.log(root);
+```
+
+์ด์ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ์์์ ํด๋น ๊ฐ์ฒด๋ฅผ ํผ์ณ ๋ณผ ์ ์์ต๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/devtools-console-object.gif"></div>
+
+์ด์ธ์๋ `console.error`๋ฅผ ์ด์ฉํด ๋นจ๊ฐ ์๋ฌ ๋ฉ์์ง, `console.warn`์ ์ด์ฉํด ๋
ธ๋ ๊ฒฝ๊ณ ๋ฉ์์ง ๋ฑ์ ๋์ธ ์ ์์ต๋๋ค.
+
+## ํ๋ฉด์ ๋ฐ์ดํฐ ๋์ฐ๊ธฐ
+
+์ด๋ ์์ฃผ ๊ฐ๋จํ์ง๋ง ์ฌ๋๋ค์ด ์ฝ๊ฒ ๋ ์ฌ๋ฆฌ์ง ๋ชปํ๋ ๋ฐฉ๋ฒ์
๋๋ค. `<div>`์ `<pre>` ํ๊ทธ๋ฅผ ์ด์ฉํด ๋ฐ์ดํฐ๋ฅผ ํ๋ฉด์ ์ถ๋ ฅํ๋ ๊ฒ์ด์ฃ .
+
+๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ HTML ์์๋ฅผ ๋ช ๊ฐ ๋ง๋ค๊ณ
+
+```html
+<canvas id="c"></canvas>
++<div id="debug">
++ <div>x:<span id="x"></span></div>
++ <div>y:<span id="y"></span></div>
++ <div>z:<span id="z"></span></div>
++</div>
+```
+
+์บ๋ฒ์ค ์์ ์ฌ๋ผ๊ฐ๋๋ก ์คํ์ผ์ ์ง์ ํ๋ ๊ฒ๋๋ค(์บ๋ฒ์ค๊ฐ ํ๋ฉด์ ๊ฝ ์ฑ์ ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค).
+
+```html
+<style>
+#debug {
+ position: absolute;
+ left: 1em;
+ top: 1em;
+ padding: 1em;
+ background: rgba(0, 0, 0, 0.8);
+ color: white;
+ font-family: monospace;
+}
+</style>
+```
+
+๊ทธ๋ฐ ๋ค์ ์์๋ค์ ์ฐธ์กฐํด ๊ฐ ์์์ ํ
์คํธ๋ฅผ ์ง์ ํฉ๋๋ค.
+
+```js
+// ์ด๊ธฐํ ์
+const xElem = document.querySelector('#x');
+const yElem = document.querySelector('#y');
+const zElem = document.querySelector('#z');
+
+// ๋ ๋๋ง ๋ฃจํ๋ ์
๋ฐ์ดํธ ์
+xElem.textContent = someObject.position.x.toFixed(3);
+yElem.textContent = someObject.position.y.toFixed(3);
+zElem.textContent = someObject.position.z.toFixed(3);
+```
+
+๋ฐํ์์ ๊ฐ์ ์ฒดํฌํ ๋ ์ ์ฉํฉ๋๋ค.
+
+{{{example url="../threejs-debug-js-html-elements.html" }}}
+
+์ผํ์ฉ ๋ก๊ทธ ๋ฒํผ(one-time log buffer)\*๋ฅผ ๋ง๋๋ ๊ฒ๋ ํ ๋ฐฉ๋ฒ์
๋๋ค. ์ผํ์ฉ ๋ก๊ทธ ๋ฒํผ๋ผ๋ ์ด๋ฆ์ ์ ๊ฐ ๋์ถฉ ์ง์ ๊ฒ์ด์ง๋ง, ๋ง์ ๊ฒ์๋ค์ด ์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํฉ๋๋ค. ์ผํ์ฉ์ด๋ผ๋ ๋ง์ฒ๋ผ ์ด ๋ฐฉ๋ฒ์ ์ง์ ํ ๋ฉ์์ง๋ฅผ ํ ํ๋ ์ ๋์๋ง ๋ณด์ฌ์ค๋๋ค. ๋ฐ์ดํฐ๋ฅผ ์ถ๋ ฅํ ๋ถ๋ถ์์ ์ง์ ๋งค ํ๋ ์๋ง๋ค ๋ฉ์์ง๋ฅผ ๋ฒํผ์ ์ถ๊ฐํด์ผ ํ์ฃ . ๋ฉ์์ง๋ง๋ค HTML ์์๋ฅผ ๋ฐ๋ก ๋ง๋ค์๋ ์ ๋ฐฉ๋ฒ์ ๋นํ๋ฉด ํจ์ฌ ๊ฒฝ์ ์ ์
๋๋ค.
+
+โป ์ผํ์ฉ ๋ก๊ทธ ๋ฒํผ: ์๋ฌธ์์๋ clearing logger๋ผ๊ณ ์ผ์ต๋๋ค. ์ญ์ฃผ.
+
+๋จผ์ ์ HTML ์์ ๋ฅผ ์๋์ฒ๋ผ ์์ ํฉ๋๋ค.
+
+```html
+<canvas id="c"></canvas>
+<div id="debug">
+ <pre></pre>
+</div>
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ฒํผ์ *์ถ๊ฐ/์ด๊ธฐํ*๋ฅผ ๊ด๋ฆฌํ๋ ๊ฐ๋จํ ํด๋์ค๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+class ClearingLogger {
+ constructor(elem) {
+ this.elem = elem;
+ this.lines = [];
+ }
+ log(...args) {
+ this.lines.push([...args].join(' '));
+ }
+ render() {
+ this.elem.textContent = this.lines.join('\n');
+ this.lines = [];
+ }
+}
+```
+
+๊ฐ๋จํ ์์ ๋ฅผ ํ๋ ๋ง๋ค์ด๋ด
์๋ค. ํ๋ฉด์ ํด๋ฆญํ์ ๋ ํฌ์ธํฐ ์์น์ mesh๋ฅผ ๋ง๋ค๊ณ 2์ด ๋์ ๋ฌด์์ ๋ฐฉํฅ์ผ๋ก ์์ง์ธ ํ ์ฌ๋ผ์ง๋๋ก ํ๊ฒ ์ต๋๋ค. ๋จผ์ [๋ฐ์ํ ๋์์ธ](threejs-responsive.html)์์ ์ผ๋ ์์ ๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
+
+์๋๋ ํ๋ฉด์ ํด๋ฆญํ ๋๋ง๋ค `Mesh`๋ฅผ ์ถ๊ฐํ๋ ์ฝ๋์
๋๋ค.
+
+```js
+const geometry = new THREE.SphereBufferGeometry();
+const material = new THREE.MeshBasicMaterial({ color: 'red' });
+
+const things = [];
+
+function rand(min, max) {
+ if (max === undefined) {
+ max = min;
+ min = 0;
+ }
+ return Math.random() * (max - min) + min;
+}
+
+function createThing() {
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ things.push({
+ mesh,
+ timer: 2,
+ velocity: new THREE.Vector3(rand(-5, 5), rand(-5, 5), rand(-5, 5)),
+ });
+}
+
+canvas.addEventListener('click', createThing);
+```
+
+์๋๋ ์์ฑํ mesh๋ฅผ ์์ง์ด๊ณ , ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํ ๋ค ์ผ์ ์๊ฐ์ด ์ง๋ฌ์ ๋ ํด๋น ์์๋ฅผ ์ ๊ฑฐํ๋ ์ฝ๋์
๋๋ค.
+
+```js
+const logger = new ClearingLogger(document.querySelector('#debug pre'));
+
+let then = 0;
+function render(now) {
+ now *= 0.001; // ์ด ๋จ์๋ก ๋ณํ
+ const deltaTime = now - then;
+ then = now;
+
+ ...
+
+ logger.log('fps:', (1 / deltaTime).toFixed(1));
+ logger.log('num things:', things.length);
+ for (let i = 0; i < things.length;) {
+ const thing = things[i];
+ const mesh = thing.mesh;
+ const pos = mesh.position;
+ logger.log(
+ 'timer:', thing.timer.toFixed(3),
+ 'pos:', pos.x.toFixed(3), pos.y.toFixed(3), pos.z.toFixed(3));
+ thing.timer -= deltaTime;
+ if (thing.timer <= 0) {
+ // ํด๋น ์์๋ฅผ ์ ๊ฑฐํฉ๋๋ค. i๋ฅผ ์ฆ๊ฐ์ํค์ง ์์๋ค๋ ์ ์ ์ ์ํ์ธ์.
+ things.splice(i, 1);
+ scene.remove(mesh);
+ } else {
+ mesh.position.addScaledVector(thing.velocity, deltaTime);
+ ++i;
+ }
+ }
+
+ renderer.render(scene, camera);
+ logger.render();
+
+ requestAnimationFrame(render);
+}
+```
+
+์์ ๋ฅผ ๋น ๋ฅด๊ฒ ํด๋ฆญํ๋ฉด ๋ง์ ๋ฐ์ดํฐ๊ฐ ํ ๋ฒ์ ๋ํ๋ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-debug-js-clearing-logger.html" }}}
+
+## ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ(Query Parameters)
+
+์น์์๋ ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ(?, &)๋ ์ต์ปค(#)๋ก ๋ฐ์ดํฐ๋ฅผ ๋๊ฒจ์ค ์ ์์ต๋๋ค. ์ด๋ค์ search, ํด์(hash)๋ผ๊ณ ๋ถ๋ฆฌ๊ธฐ๋ ํ์ฃ .
+
+```text
+ https://domain/path/?query#anchor
+```
+
+์๋ฅผ ๋ค์ด ์ด์ ์์ ๋ฅผ URL์ `?debug=true`๊ฐ ์์ ๋๋ง ๋๋ฒ๊น
์์๊ฐ ๋ณด์ด๋๋ก ํด๋ณด๊ฒ ์ต๋๋ค.
+
+๋จผ์ ์ฟผ๋ฆฌ๋ฅผ ํ์ฑํ๋ ์ฝ๋๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+/**
+ * ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ๋ฅผ ํค/๊ฐ ๊ฐ์ฒด๋ก ๋ฐํํฉ๋๋ค.
+ * ์๋ฅผ ๋ค์ด ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ๊ฐ ๋ค์๊ณผ ๊ฐ๋ค๋ฉด
+ *
+ * abc=123&def=456&name=gman
+ *
+ * `getQuery()`๋ ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค.
+ *
+ * {
+ * abc: '123',
+ * def: '456',
+ * name: 'gman',
+ * }
+ */
+function getQuery() {
+ return Object.fromEntries(new URLSearchParams(window.location.search).entries());
+}
+```
+
+๋ค์์ผ๋ก ๋๋ฒ๊น
์์๊ฐ ๋ฏธ๋ฆฌ ๋ณด์ด์ง ์๋๋ก ํฉ๋๋ค.
+
+```html
+<canvas id="c"></canvas>
++<div id="debug" style="display: none;">
+ <pre></pre>
+</div>
+```
+
+์์ ์์ฑํ๋ ์์ ์์ ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ๋ฅผ ์ฝ์ด `?debug=true`์ผ ๋๋ง ๋๋ฒ๊น
์์๊ฐ ๋ณด์ด๋๋ก ํฉ๋๋ค.
+
+```js
+const query = getQuery();
+const debug = query.debug === 'true';
+const logger = debug
+ ? new ClearingLogger(document.querySelector('#debug pre'))
+ : new DummyLogger();
+if (debug) {
+ document.querySelector('#debug').style.display = '';
+}
+```
+
+`?debug=true`๊ฐ ์๋ ๋ ์ฌ์ฉํ `DummyLogger`๋ ๋ง๋ญ๋๋ค.
+
+```js
+class DummyLogger {
+ log() {}
+ render() {}
+}
+```
+
+์๋์ ๊ฐ์ url๋ก ์ ๊ทผํ๋ฉด ์๋ฌด๊ฒ๋ ๋ณด์ด์ง ์์ต๋๋ค.
+
+<a target="_blank" href="../threejs-debug-js-params.html">threejs-debug-js-params.html</a>
+
+๋์ ์๋ url์ ์ฐ๋ฉด
+
+<a target="_blank" href="../threejs-debug-js-params.html?debug=true">threejs-debug-js-params.html?debug=true</a>
+
+๋๋ฒ๊น
์์๊ฐ ์ ๋๋ก ๋ณด์
๋๋ค.
+
+ํ๋ผ๋ฏธํฐ๋ฅผ ์ฌ๋ฌ ๊ฐ ์ ๋ฌํ ๋๋ `์๋ฌดํ์ด์ง.html?ํค=๊ฐ&๋ค๋ฅธํค=๋ค๋ฅธ๊ฐ`์ฒ๋ผ ๊ฐ ํญ๋ชฉ์ '&'๋ก ๊ตฌ๋ถํ๋ฉด ๋ฉ๋๋ค. ํ๋ผ๋ฏธํฐ๋ฅผ ์ฌ์ฉํ๋ฉด ๋ค์ํ ๊ฐ์ ์ง์ ํ ์ ์์ต๋๋ค. `speed=0.01`์ ๋๊ฒจ ๋ฐ์ ์ฑ์ ์๋๋ฅผ ๋๋ฆฌ๊ฒ ํ ์๋ ์๊ณ `showHelpers=true` ๊ฐ์ ๊ฐ์ ๋๊ฒจ ๋ฐ์ ๋ค๋ฅธ ๊ธ์์ ๋ค๋ค๋ ์กฐ๋ช
, ๊ทธ๋ฆผ์, ์นด๋ฉ๋ผ์ ์ ๋์ฒด ๋ฑ์ ํฌํผ ๊ฐ์ฒด๋ฅผ ๋ณด์ด๊ฒ ํ ์๋ ์์ฃ .
+
+## ๋๋ฒ๊ฑฐ ์ฌ์ฉ๋ฒ์ ์ตํ๋ผ
+
+๋ธ๋ผ์ฐ์ ์๋ ์ ๋ถ ๋๋ฒ๊ฑฐ๊ฐ ์์ด ํ๋ก๊ทธ๋จ์ ์ค ๋จ์๋ก ์คํํ๋ฉฐ ๋ชจ๋ ๋ณ์๋ฅผ ๊ฒ์ฌํ ์ ์์ต๋๋ค.
+
+๋๋ฒ๊ฑฐ์ ์ฌ์ฉ๋ฒ์ ๋๋ฌด ํฐ ์ฃผ์ ์ด๊ธฐ์ ์ด ๊ธ์์ ์ ๋ถ ์ค๋ช
ํ๊ธฐ ์ด๋ ค์ฐ๋ ์๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค.
+
+* [ํฌ๋กฌ ๊ฐ๋ฐ์๋๊ตฌ์์ ์๋ฐ์คํฌ๋ฆฝํธ ๋๋ฒ๊น
ํ๊ธฐ](https://developers.google.com/web/tools/chrome-devtools/javascript/)
+* [Debugging in Chrome](https://javascript.info/debugging-chrome)
+* [Tips and Tricks for Debugging in Chrome Developer Tools](https://hackernoon.com/tips-and-tricks-for-debugging-in-chrome-developer-tools-458ade27c7ab)
+
+## ๋๋ฒ๊ฑฐ ๋ฑ์์ `NaN`์ ํ์ธํด๋ผ
+
+`NaN`์ Not a Number(์ซ์๊ฐ ์๋)์ ์ค์๋ง์
๋๋ค. ์๋ฐ์คํฌ๋ฆฝํธ๊ฐ ์ํ์ ์ผ๋ก ์ฐ์ฐํ ์ ์๋ ์์ด ์ฃผ์ด์ก์ ๋ ๋ฐํํ๋ ๊ฐ์ด์ฃ .
+
+์๋๋ ๊ฐ๋จํ ์์
๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/nan-banana.png" style="width: 180px;"></div>
+
+์ ๋ ๋ฌด์ธ๊ฐ๋ฅผ ๋ง๋ค๋ค ํ๋ฉด์ ์๋ฌด๊ฒ๋ ๋ณด์ด๋ ๊ฒ ์์ผ๋ฉด `NaN`์ด ์๋์ง ํ์ธํฉ๋๋ค. ๋ง์ฝ `NaN`์ด ์๋ค๋ฉด ํด๋น ๋ถ๋ถ๋ถํฐ ๋ค์ ์ดํด ๋ณด๊ธฐ ์์ํ์ฃ .
+
+[glTF ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html)์์ ์ฒ์ ํจ์ค๋ฅผ ๊ทธ๋ ธ์ ๋ `SplineCurve` ํด๋์ค๋ก 2D ๊ณก์ ์ ๋ง๋ค์๋ ๊ฒ, ๊ธฐ์ตํ๋์?
+
+์ฒ์์ ์ด ๊ณก์ ์ ์ด์ฉํด ์๋์ฐจ๋ฅผ ์์ง์์์ฃ .
+
+```js
+curve.getPointAt(zeroToOnePointOnCurve, car.position);
+```
+
+์ด๋ `curve.getPointAt`์ ๋ด๋ถ์ ์ผ๋ก ๋ ๋ฒ์งธ ์ธ์๋ก ๋๊ฒจ์ค ๊ฐ์ฒด์ `set` ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค. ์ด ๊ฒฝ์ฐ ์ธ์๋ก ๋๊ฒจ์ค ๊ฐ์ฒด๋ `car.position`, `Vector3`์ด์ฃ . `Vector3`์ `set` ๋ฉ์๋์๋ x, y, z ์ธ ๊ฐ์ง ์ธ์๋ฅผ ๋๊ฒจ์ค์ผ ํฉ๋๋ค. ํ์ง๋ง `SplineCurve`๋ 2D์ด๊ธฐ์ `car.position.set` ๋ฉ์๋์ x์ y ๊ฐ๋ง ๋๊ฒจ์ค๋๋ค.
+
+์ด๋ฌ๋ฉด x, y์ ๊ฐ์ ๋๊ฒจ ๋ฐ์ ๊ฐ์ผ๋ก ์ง์ ๋๋, z๋ `undefined`๋ก ์ง์ ๋ ๊ฒ๋๋ค.
+
+๋๋ฒ๊ฑฐ์์ ์๋์ฐจ์ `matrixWorld`๋ฅผ ์ดํด ๋ณด๋ `NaN`์ผ๋ก ์ง์ ๋ ๊ฐ์ด ๋ง์ด ๋ณด์
๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/debugging-nan.gif" style="width: 476px;"></div>
+
+ํ๋ ฌ ์ขํ(matrix)์ `NaN`์ด ์๋ค๋ ๊ฒ์ `position`, `rotation`, `scale` ๋ฑ์ ์์ฑ์ด๋ ํ๋ ฌ ์ขํ์ ์ํฅ์ ๋ฏธ์น๋ ํจ์์ ์๋ชป๋ ๋ฐ์ดํฐ๊ฐ ์ง์ ๋์๋ค๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. ์ฌ๊ธฐ์๋ถํฐ ์ถ์ ํด ์ฌ๋ผ๊ฐ๋ฉด ์ด๋๊ฐ ๋ฌธ์ ์ธ์ง ์ฝ๊ฒ ์ฐพ์ ์ ์๊ฒ ์ฃ .
+
+์๋ฐ์คํฌ๋ฆฝํธ ์ซ์์๋ `NaN`๋ฟ๋ง ์๋๋ผ `Infinity`๋ผ๋ ๊ฐ๋ ์์ต๋๋ค. ์ด ์ญ์ ๋ง์ ๋ฒ๊ทธ์ ์ฃผ๋ฒ์ด ๋ ์ ์์ฃ .
+
+## ์ฝ๋๋ฅผ ๊น๋ด๋ผ!
+
+Three.js๋ ์คํ ์์ค์
๋๋ค. ๋๋ ค์ ๋ง๊ณ ์ฝ๋๋ฅผ ํ ๋ฒ ๊น๋ณด์ธ์! [๊นํ๋ธ](https://github.com/mrdoob/three.js)์์ ์์ค ์ฝ๋๋ฅผ ์ดํด ๋ณด๊ฑฐ๋, ๋๋ฒ๊ฑฐ์์ ํจ์๋ฅผ ์ฐจ๋ก๋๋ก ์ถ์ ํด ๋ณผ ์๋ ์์ต๋๋ค. ์ด๋ ๊ฐ๋ฐ ๋จ๊ณ์์๋ `three.min.js`๊ฐ ์๋ `three.js`๋ฅผ ์ฐ๋ ๊ฒ์ ์ถ์ฒํฉ๋๋ค. ์๋ํ๋ฉด `three.min.js`๋ ์ฉ๋์ ์ค์ด๊ธฐ ์ํด ๋๋
ํ์ ์์ถ์ด ์ ์ฉ๋ ํํ๊ฑฐ๋ ์. `three.js`๊ฐ ์ฉ๋์ด ๋ ํฌ๊ธด ํ์ง๋ง ๋๋ฒ๊น
์๋ ํจ์ฌ ์ ๋ฆฌํฉ๋๋ค. ์ ๋ ๋ฌธ์ ๊ฐ ์์ ๋๋ ๋๋ถ๋ถ `three.js`๋ฅผ ์ฌ์ฉํด ์ฝ๋๋ฅผ ๋จ๊ณ๋ณ๋ก ์ดํด๋ณด๋ ํธ์
๋๋ค.
+
+## `requestAnimationFrame`์ ๋ ๋๋ง ๊ฐ์ฅ ๋ง์ง๋ง์ ๋ฃ์ด๋ผ
+
+๋ค๋ฅธ ์ฌ๋์ ์ฝ๋๋ฅผ ๋ณด๋ค๋ณด๋ฉด ์๋์ ๊ฐ์ ํ์์ ์์ฃผ ๋ด
๋๋ค.
+
+```js
+function render() {
+ requestAnimationFrame(render);
+
+ // -- ์ฃผ์ ์ฃผ์ --
+
+ renderer.render(scene, camera);
+}
+requestAnimationFrame(render);
+```
+
+ํ์ง๋ง ์ ๋ ์ด ์๋ฆฌ์ฆ์ ์ฒ์์์๋ถํฐ `requestAnimationFrame`์ ์๋์ ๋ฐฐ์นํ์ต๋๋ค.
+
+```js
+function render() {
+ // -- ์ฃผ์ ์ฃผ์ --
+
+ renderer.render(scene, camera);
+
+ requestAnimationFrame(render);
+}
+requestAnimationFrame(render);
+```
+
+์ด๋ฐ ๋ฐฉ์์ ์ฌ์ฉํ ๊ฐ์ฅ ์ค์ํ ์ด์ ๋, ์ด๋์ผ ์๋ฌ๊ฐ ๋ฌ์ ๋ ์ฝ๋๋ฅผ ๋ฉ์ถ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค. `requestAnimationFrame`์ ์๋จ์์ ์คํํ๋ฉด ์๋ฌ๊ฐ ๋๊ธฐ ์ ์ ์ด๋ฏธ ๋ค๋ฅธ ํ๋ ์์ ์์ฒญํ ๊ฒ์ด๋ฏ๋ก, ์๋ฌ๊ฐ ๋ฐ๋ณตํด ๋ํ๋ ์ ์์ต๋๋ค. ๊ฐ์ธ์ ์ธ ์๊ฐ์ด๊ธด ํ์ง๋ง, ์๋ฌ๋ฅผ ๋จ์ํ ๋ฌด์ํด๋ฒ๋ฆฌ๋ ๊ฒ๋ณด๋ค ๋ฌธ์ ๋ฅผ ์ฐพ์ ๊ณ ์น๋ ๊ฒ ํจ์ฌ ๋์ ๊ฒ๋๋ค. ์๋ฌ ๋๋ฌธ์ ๋ญ๊ฐ ์ ๋๋ก ์คํ๋์ง ์๋๋ฐ ํ๋ก๊ทธ๋จ์ด ๋ฉ์ถ์ง ์๋๋ค๋ฉด ๋ฌธ์ ๊ฐ ์๋์ง์กฐ์ฐจ ๋ชจ๋ฅผ ์ ์์ผ๋๊น์.
+
+## ๋จ์๋ฅผ ํ์ธํ๋ผ!
+
+์ด๋ ์๋ฅผ ๋ค์ด ์ธ์ ๋(degree)๋ฅผ ์ฌ์ฉํด์ผ ํ๋์ง, ์ธ์ ๋ผ๋์(ํธ๋, radian)์ ์ฌ์ฉํด์ผ ํ๋์ง ์์์ผ ํ๋ค๋ ์๋ฏธ์
๋๋ค. ์์ฝ๊ฒ๋ Three.js๋ ๋ชจ๋ ๋ถ๋ถ์์ ๊ฐ์ ๋จ์๋ฅผ ์ฌ์ฉํ์ง ์์ต๋๋ค. ๋น์ฅ ์๊ฐ๋๊ธฐ๋ก๋ ์นด๋ฉ๋ผ์ ์์ผ๊ฐ(fov, field of view)์ด ๋๋ฅผ ์ฌ์ฉํ๋๊ตฐ์. ๋๋จธ์ง ๊ฐ๋๋ ์ ๋ถ ๋ผ๋์์ ์ฌ์ฉํฉ๋๋ค.
+
+๊ธธ์ด ๋จ์๋ ์ค์ํ ์์์
๋๋ค. ์ต๊ทผ๊น์ง๋ 3D ์ฑ์ ๊ธธ์ด ๋จ์๋ฅผ ์์ ๋กญ๊ฒ ์ ํํ ์ ์์์ต๋๋ค. ์ด๋ค ์ฑ์ 1์นธ = 1cm๋ฅผ ์ผ๊ณ ์ด๋ค ์ฑ์ 1์นธ = 1ํผํธ๋ฅผ ์ผ์ฃ . ๋ฌผ๋ก ์ง๊ธ๋ ๊ธธ์ด ๋จ์๋ฅผ ์ผ๋ง๋ ์ง ์์ ๋กญ๊ฒ ์ค์ ํ ์ ์์ต๋๋ค. Three.js๋ ๊ธฐ๋ณธ์ ์ผ๋ก 1์นธ = 1๋ฏธํฐ๋ก ๊ฐ์ ํ๋๋ฐ, ๋ฌผ๋ฆฌ ๊ธฐ๋ฐ ๋ ๋๋ง ๊ฐ์ ๊ฒฝ์ฐ๋ ์กฐ๋ช
์ ์ธ๊ธฐ๋ฅผ ๋ฏธํฐ๋ก ์ค์ ํ๋ ํนํ ๋ ์ ๊ฒฝ์ ์จ์ผ ํฉ๋๋ค. ์ฆ๊ฐํ์ค(AR)์ด๋ ๊ฐ์ํ์ค(VR) ๊ฐ์ ๊ฒฝ์ฐ์๋ ์ฌ์ฉ์์ ์ปจํธ๋กค๋ฌ ์ฌ์ด์ ๊ฑฐ๋ฆฌ๋ฅผ ์์์ผ ํ๋ ์ค์ ์ธ๊ณ์ ๋จ์๋ฅผ ์ ์ ์ฉํด์ผ ํ์ฃ .
+
+## ์ง๋ฌธํ ๋ *์ต์ํ์ผ๋ก, ์์ฑ๋, ํ
์คํธํ ์ ์๋ ์์ *๋ฅผ ๋ง๋ค์ด๋ผ
+
+Three.js์ ๊ดํด ์ง๋ฌธํ ๋๋ MCVE์ ๋ง์ถฐ ์ต์ํ์ผ๋ก(Minimal), ์์ฑ๋(Complete), ํ
์คํธํ ์ ์๋(Verifiable) ์์ (Example)๋ฅผ ํฌํจํด์ผ ํฉ๋๋ค.
+
+**์ต์ํ์ผ๋ก** ๋ง๋๋ ๊ฒ ๊ฐ์ฅ ์ค์ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ์ฌ๋ฌ๋ถ์ด [glTF ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html)์์ ๊ฒฝ๋ก๋ฅผ ์๋์ฐจ๋ฅผ ๋ฐ๋ผ๊ฐ๊ฒ ํ๋ ๋ฐ ์ด๋ ค์์ ๊ฒช๋๋ค๊ณ ํด๋ณด์ฃ . ์ด ์์ ์๋ ์์ฃผ ๋ง์ ์์๊ฐ ์์ต๋๋ค. ๋์ถฉ ๋ชฉ๋ก์ ๋ง๋ค์ด๋ณด์ฃ .
+
+1. HTML ํ ๋ฌถ์
+2. CSS ์ฝ๊ฐ
+3. ์กฐ๋ช
+4. ๊ทธ๋ฆผ์
+5. ๊ทธ๋ฆผ์๋ฅผ ์กฐ์ํ๋ dat.GUI
+6. .gltf ํ์ผ์ ๋ถ๋ฌ์ค๋ ์ฝ๋
+7. ์บ๋ฒ์ค๋ฅผ ๋ฆฌ์ฌ์ด์งํ๋ ์ฝ๋
+8. ์๋์ฐจ๊ฐ ๊ฒฝ๋ก๋ฅผ ๋ฐ๋ผ ์์ง์ด๋๋ก ํ๋ ์ฝ๋
+
+๊ฝค ๋ง์ ์์ ์ฝ๋๋ค์. ๋ง์ฝ ์ค๋ก์ง ๊ฒฝ๋ก๋ฅผ ๋ฐ๋ผ๊ฐ๋ ๋ถ๋ถ์ ๋ํด์๋ง ์ง๋ฌธํ ๊ฑฐ๋ผ๋ฉด `<canvas>`์ `<script>`๋ฅผ ์ ์ธํ ๋๋จธ์ง HTML์ ์์ด๋ ๋ ๊ฒ๋๋ค. .gltf ํ์ผ๋ ๋ง์ฐฌ๊ฐ์ง๋ก ๋ถํ์ํ์ฃ . ์กฐ๋ช
๊ณผ ๊ทธ๋ฆผ์๋ฅผ ์์ ๊ณ `MeshBasicMaterial`์ ์ฌ์ฉํ ์๋, dat.GUI๋ฅผ ์ ๊ฑฐํ ์๋ ์์ต๋๋ค. ์ฐจ๋ผ๋ฆฌ `GridHelper`๋ฅผ ์ฐ๋ ๊ฒ ํจ์ฌ ๊ฐ๋จํ๊ฒ ๋ค์. ๋ง์ง๋ง์ผ๋ก ๋ฌผ์ฒด๊ฐ ๊ฒฝ๋ก๋ฅผ ๋ฐ๋ผ ์์ง์ด๋ ๋ถ๋ถ๋ง ์ง๋ฌธํ๋ ์๋์ฐจ ๋์ ์ก๋ฉด์ฒด๋ฅผ ์จ๋ ๋ ๊ฒ๋๋ค.
+
+์๋๋ ์ ์์๋ฅผ ๋ชจ๋ ๊ณ ๋ คํ ์์ ์
๋๋ค. ์๋ 271์ค์ด์๋ ์ฝ๋๋ฅผ 135์ค๋ก ์ค์์ฃ . 21๊ฐ ์ ์ผ๋ก ์ด๋ฃจ์ด์ง ๋ณต์กํ ๊ฒฝ๋ก ๋์ 3๊ฐ ํน์ 4๊ฐ์ ์ ๋ง ์ฌ์ฉํ๋ ๊ฐ๋จํ ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํด ์ฝ๋๋ฅผ ๋ ์ค์ผ ์๋ ์์ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-debugging-mcve.html" }}}
+
+`OrbitController`๋ฅผ ๊ทธ๋๋ก ๋ ๊ฑด ์นด๋ฉ๋ผ๋ฅผ ์์ง์ด๋ ๋ฑ ๋จ์ํ ๋ค๋ฅธ ์ฌ๋์ ํธ์๋ฅผ ์ํด์์ง๋ง, ๊ฒฝ์ฐ์ ๋ฐ๋ผ์๋ ์ ๊ฒ๋ ์ ๊ฑฐํ ์ ์์ ๊ฒ๋๋ค.
+
+MCVE์ ์ฅ์ ์ ์ด๋ ๊ฒ ์์ ๋ฅผ ๋ง๋ค๋ค ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๊ธฐ๋ ํ๋ค๋ ๊ฒ๋๋ค. ๋ถํ์ํ ์์๋ฅผ ์ ๊ฑฐํ๊ณ ์๋ฌ๋ฅผ ์ฌํํ ์ ์๋ ๊ฐ์ฅ ์์ ์ฝ๋๋ฅผ ์ง๋ค ๋ณด๋ฉด ๋ฌธ์ ์ ์์ธ์ด ๋ฐํ์ง๋ ๊ฒฝ์ฐ๊ฐ ๊ฝค ๋ง๊ฑฐ๋ ์.
+
+๊ฑฐ๊ธฐ๋ค MCVE๋ ๋ต๋ณ์์ ๋ํ ์์์ด๊ธฐ๋ ํฉ๋๋ค. ์ต์ํ์ ์์ ๋ฅผ ๋ง๋ค์ด ๋ค๋ฅธ ์ฌ๋์ด ์ฌ๋ฌ๋ถ์ ๋ฌธ์ ํด๊ฒฐ์ ๋๊ธฐ ์ฝ๋๋ก ๋ฐฐ๋ คํ๋ ๊ฒ์ด์ฃ . ์ด ๊ณผ์ ์์ ๋ฐฐ์ฐ๋ ๊ฒ๋ ๋ง๊ณ ์.
+
+๋ํ ์คํ ์ค๋ฒํ๋ก์ฐ์์ ์ง๋ฌธ๊ธ์ ์ฌ๋ฆด ๋ **[์ฝ๋์ ์ผ๋ถ๋ถ(snippet)](https://stackoverflow.blog/2014/09/16/introducing-runnable-javascript-css-and-html-code-snippets/)์ ์ฌ๋ฆฌ๋ ๊ฒ**๋ ๊ต์ฅํ ์ค์ํฉ๋๋ค. ๋ฌผ๋ก JSFiddle์ด๋ Codepen ๋๋ ๋น์ทํ ์ฌ์ดํธ๋ฅผ ์จ ์ฌ๋ฌ๋ถ์ด ๋ง๋ MVCE๋ฅผ ํ
์คํธํ๊ฒ๋ ํ ์๋ ์์ฃ . ํ์ง๋ง ์คํ ์ค๋ฒํ๋ก์ฐ์์ ๊ธ ์ฐ๊ธฐ๋ฅผ ๋๋ฌ๋ณด๋ฉด **์ง๋ฌธ ์์ฒด**์ ์ฝ๋ ์ผ๋ถ๋ฅผ ๋ถ์ฌ๋ฃ๋ ๊ฒ ํ์ ์กฐ๊ฑด๋ผ๋ ๊ฒ์ ์ ์ ์์ต๋๋ค. ์ฝ๋์ ์ผ๋ถ๋ถ์ ์ง์ด ๋ฃ์ด์ผ๋ง ํด๋น ์กฐ๊ฑด์ด ๋ง์กฑ๋์ฃ .
+
+ํน์๋ ํด์ ๋งํด๋์ง๋ง, ์ด ์ฌ์ดํธ์ ์์ ๋ค๋ก ์ง๋ฌธํ ๋๋ ์ฝ๋์ ๋ชจ๋ ๋ถ๋ถ์ ํ์ธํด์ผ ํฉ๋๋ค. HTML, CSS, ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ์ ๋ถ [์ค๋ํซ(snippet) ์๋ํฐ](https://stackoverflow.blog/2014/09/16/introducing-runnable-javascript-css-and-html-code-snippets/)์ ๋ฃ์ผ๋ฉด ๋์ฃ . ์ถ๊ฐ๋ก ๊ถ๊ธํ ๋ถ๋ถ๊ณผ ๊ด๋ จ๋ ์ฝ๋๋ง ๋จ๊ธฐ๊ณ ๋๋จธ์ง๋ ์์ ์ฝ๋๋ฅผ ์ต์ํ์ผ๋ก ๋ง๋๋ ๊ฒ๋ง ๊ธฐ์ตํ๊ธฐ ๋ฐ๋๋๋ค.
+
+์ด ์ ๋๋ง ๋ฐ๋ฅด๋ฉด ์ง๋ฌธ์ ๋ํ ๋ต๋ณ์ ๋ฐ๋ ๊ฒ ๊ทธ๋ค์ง ์ด๋ ต์ง ์์ ๊ฒ๋๋ค.
+
+## `MeshBasicMaterial`์ ์ฌ์ฉํ๋ผ
+
+`MeshBasicMaterial`์ ์กฐ๋ช
์ ์ํฅ์ ๋ฐ์ง ์์ต๋๋ค. ๋๋ฌธ์ ์ฌ์ง(material)์ ์ด๊ฑธ๋ก ๋ฐ๊พธ๋ฉด ๋ณด์ด์ง ์์๋ ๋ฌผ์ฒด๊ฐ ๋ณด์ด๋ ๊ฒฝ์ฐ๊ฐ ์์ฃ . ๋ง์ฝ ์ด๋ค ๋ฌผ์ฒด๊ฐ `MeshBasicMaterial`์ ์ ์ฉํ์ ๋๋ ์ ๋ํ๋๋๋ฐ ๋ค๋ฅธ ์ฌ์ง๋ก ๋ฐ๊พธ๋ฉด ๋ํ๋์ง ์๋๋ค๋ฉด, ํด๋น ๋ฌธ์ ๋ ์ฌ์ง์ด๋ ์กฐ๋ช
๋๋ ๋ค๋ฅธ ์ธ๋ถ ์์ ๋๋ฌธ์ผ ๊ฒ๋๋ค.
+
+## ์นด๋ฉ๋ผ์ `near`์ `far` ์ค์ ์ ํ์ธํ๋ผ
+
+[์นด๋ฉ๋ผ์ ๊ดํ ๊ธ](threejs-cameras.html)์์ ๋ค๋ค๋ฏ, `PerspectiveCamera`์๋ `near`์ `far` ์ค์ ์ด ์์ต๋๋ค. ๋ค๋ฅธ ๊ฒ๋ณด๋ค ๋จผ์ ์ฅ๋ฉด ์์๋ฅผ ์ ๋ถ ๋ด์ ์ ์๋๋ก ์ด ๊ฐ๋ค์ ์ค์ ํ์ธ์. **์์๋ก๋ผ๋** `near`๋ฅผ 0.001, `far`๋ฅผ 1000000 ๋ฑ ์์์ ํฐ ๊ฐ์ผ๋ก ์ค์ ํ๋ค๋ฉด ๊น์ด์ ๋ฐ๋ฅธ ํด์๋ ๋ฌธ์ ๊ฐ ๋ํ๋ ๊ฒ๋๋ค. ์ค์ง ์นด๋ฉ๋ผ์ ๊ฐ๊น์ด ๋ฌผ์ฒด๋ง ์ ๋๋ก ๋ณด์ด๊ฒ ์ฃ .
+
+## ์ฅ๋ฉด์ด ์นด๋ฉ๋ผ ์์ ์๋์ง ํ์ธํ๋ผ
+
+์ฅ๋ฉด์ด ํ๋ฉด์ ๋ํ๋์ง ์๋ ๊ฒฝ์ฐ, ์ฅ๋ฉด์ด ์นด๋ฉ๋ผ ์์ ์๋ ๊ฒ ์์ธ์ผ ๋๋ ์์ต๋๋ค. ๋ง์ฝ ์นด๋ฉ๋ผ๋ฅผ ์กฐ์ํ ์ ์๋ค๋ฉด `OrbitController` ๊ฐ์ ์ก์
์ ์ถ๊ฐํด ์นด๋ฉ๋ผ๋ฅผ ๋๋ ค ๋ณด๊ธฐ ๋ฐ๋๋๋ค. ๋๋ ์ ๊ฐ [์ด ๊ธ](threejs-load-obj.html)์์ ๋ค๋ค๋ ๊ฒ์ฒ๋ผ ์นด๋ฉ๋ผ๊ฐ ์ฅ๋ฉด ์ ์ฒด๋ฅผ ๋ด๋๋ก ํด๋ณด์ธ์. ์ ๊ฐ ์ ๊ธ์์ ์ด ์ฝ๋๋ ์ฅ๋ฉด์ ์์๋ฅผ ์ฐพ์ ํด๋น ์์๋ฅผ ์ ๋ถ ๋ด๋๋ก ์นด๋ฉ๋ผ์ ์์น์ `near`, `far` ๊ฐ์ ์กฐ์ ํฉ๋๋ค. ์ ์ฝ๋์์ ๋๋ฒ๊ฑฐ๋ฅผ ์ฌ์ฉํ๊ฑฐ๋, `console.log`๋ฅผ ์ถ๊ฐํด ์์์ ํฌ๊ธฐ๋ ์ฅ๋ฉด์ ์ค์ ์ ์ถ๋ ฅํด ๋ณผ ์๋ ์์ฃ .
+
+## ๋ญ๋ ์นด๋ฉ๋ผ ์์ ๋ฐฐ์นํด๋ด๋ผ
+
+์ด๊ฑด ๋ฌธ์ ๊ฐ ์๊ฒผ๋๋ฐ ์ด๋ค ์ ์ด ๋ฌธ์ ์ผ์ง ๋ชจ๋ฅผ ๋, ํ๋์ฉ ์ฒ์ฒํ ์์๋ฅผ ์ถ๊ฐํด๋ณด๋ผ๋ ๋ง์
๋๋ค. ๋ง์ฝ ์ฝ๋๋ฅผ ์คํํ๋๋ฐ ์ฅ๋ฉด์ ์๋ฌด๊ฒ๋ ๋ณด์ด์ง ์๋๋ค๋ฉด ์นด๋ฉ๋ผ ๋ฐ๋ก ์์ ๊ฐ๋จํ ์์๋ฅผ ๋ฐฐ์นํด๋ณด์ธ์. ๊ตฌ์ฒด๋ ์ก๋ฉด์ฒด๋ฅผ ๋ง๋ค์ด `MeshBasicMaterial` ๊ฐ์ด ๋จ์ํ ์ฌ์ง์ ์ง์ ํด ํ๋ฉด์ ์ ๋๋ก ๋จ๋์ง ํ์ธํ๋ ๊ฒ๋๋ค. ๊ทธ๋ฐ ๋ค์ ์๊ฐ์ ๋ค์ฌ ๋ค๋ฅธ ์์๋ค์ ํ๋ํ๋ ์ถ๊ฐํด ๋๊ฐ๋ ๊ฑฐ์ฃ . ์ด๋ฌ๋ค๋ณด๋ฉด ๋ฒ๊ทธ๊ฐ ๋ค์ ๋ํ๋๊ฑฐ๋ ์ด๋ค ๊ฒ ๋ฌธ์ ์ธ์ง ์ ์ ์์ ๊ฒ๋๋ค.
+
+---
+
+์ฌ๊ธฐ๊น์ง ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ๋๋ฒ๊น
ํ๋ ๋ช ๊ฐ์ง ํ์ ์ดํด๋ดค์ต๋๋ค. ๋ค์ ๊ธ์์๋ [GLSL์ ๋๋ฒ๊น
ํ๋ ๋ช ๊ฐ์ง ํ](threejs-debugging-glsl.html)์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค. | false |
Other | mrdoob | three.js | 7be4e4279a6f2cf549bc7eaba9b346cdc6b4a223.json | add translation kr/threejs-material-table.md | threejs/lessons/kr/threejs-material-table.md | @@ -0,0 +1,12 @@
+Title: ์ฌ์ง(Material) ์์ฑํ
+Description: Three.js์ ๊ฐ ์ฌ์ง์ด ์ง์ํ๋ ์์ฑ์ ๋ํ ํ์
๋๋ค
+TOC: ์ฌ์ง(Material) ์์ฑํ
+
+Three.js์์ ์ฃผ๋ก ์ฐ๋ ์ฌ์ง(material)์ Mesh ์ฌ์ง์
๋๋ค. ์๋๋ ๊ฐ ์ฌ์ง์ด ์ง์ํ๋ ์์ฑ์ ํ๋ก ๋ํ๋ธ ๊ฒ์
๋๋ค.
+
+<div>
+<div id="material-table" class="threejs_center"></div>
+<script type="module" src="../resources/threejs-material-table.js"></script>
+<link rel="stylesheet" href="../resources/threejs-material-table.css">
+</div>
+ | false |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | Gruntfile.js | @@ -166,9 +166,7 @@ module.exports = function(grunt) {
});
});
const buildStuff = require('@gfxfundamentals/lesson-builder');
- const settings = Object.assign({}, buildSettings, {
- filenames,
- });
+ const settings = {...buildSettings, filenames};
const finish = this.async();
buildStuff(settings).finally(finish);
}); | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/kr/threejs-optimize-lots-of-objects-animated.md | @@ -80,11 +80,7 @@ function makeDiffFile(baseFile, otherFile, compareFn) {
return value;
});
// baseFile์ ๋ณต์ฌํ ๋ค min, max, data๋ฅผ ์ ๊ฐ์ผ๋ก ๊ต์ฒดํฉ๋๋ค.
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
```
| true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/kr/threejs-post-processing-3dlut.md | @@ -148,7 +148,7 @@ const lutShader = {
};
const lutNearestShader = {
- uniforms: Object.assign( {}, lutShader.uniforms ),
+ uniforms: {...lutShader.uniforms},
vertexShader: lutShader.vertexShader,
fragmentShader: lutShader.fragmentShader.replace('#define FILTER_LUT', '//'),
}; | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/resources/threejs-materials.js | @@ -32,9 +32,10 @@ import {threejsLessonUtils} from './threejs-lesson-utils.js';
function basicLambertPhongExample(MaterialCtor, lowPoly, params = {}) {
const geometry = lowPoly ? lowPolySphereGeometry : highPolySphereGeometry;
- const material = new MaterialCtor(Object.assign({
+ const material = new MaterialCtor({
color: 'hsl(210,50%,50%)',
- }, params));
+ ...params,
+ });
return {
obj3D: new THREE.Mesh(geometry, material),
trackball: lowPoly, | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/resources/threejs-primitives.js | @@ -785,7 +785,7 @@ const geometry = new THREE.WireframeGeometry(
addElem(base, 'pre', 'prettyprint showmods', trimmedLines.join('\n'));
- createLiveImage(elem, Object.assign({}, info, {create: createFn}), name);
+ createLiveImage(elem, {...info, create: createFn}, name);
}
makeExample(elem, info.create, info.src); | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/ru/threejs-optimize-lots-of-objects-animated.md | @@ -97,11 +97,7 @@ function makeDiffFile(baseFile, otherFile, compareFn) {
});
// make a copy of baseFile and replace min, max, and data
// with the new data
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
```
| true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/threejs-optimize-lots-of-objects-animated.md | @@ -101,11 +101,7 @@ function makeDiffFile(baseFile, otherFile, compareFn) {
});
// make a copy of baseFile and replace min, max, and data
// with the new data
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
```
| true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/lessons/threejs-post-processing-3dlut.md | @@ -147,7 +147,7 @@ const lutShader = {
};
const lutNearestShader = {
- uniforms: Object.assign( {}, lutShader.uniforms ),
+ uniforms: {...lutShader.uniforms},
vertexShader: lutShader.vertexShader,
fragmentShader: lutShader.fragmentShader.replace('#define FILTER_LUT', '//'),
}; | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/resources/lessons-helper.js | @@ -545,9 +545,10 @@
setupLesson(this);
}
const args = [].slice.apply(arguments);
- args[1] = Object.assign({
+ args[1] = {
powerPreference: 'low-power',
- }, args[1]);
+ ...args[1],
+ };
const ctx = oldFn.apply(this, args);
if (!ctx && isWebGL) {
showNeedWebGL(this); | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/resources/lessons-worker-helper.js | @@ -119,9 +119,10 @@
setupLesson(this);
}
const args = [].slice.apply(arguments);
- args[1] = Object.assign({
+ args[1] = {
powerPreference: 'low-power',
- }, args[1]);
+ ...args[1],
+ };
return oldFn.apply(this, args);
};
}(OffscreenCanvas.prototype.getContext)); | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/resources/lut-reader.js | @@ -121,7 +121,7 @@ function lut1Dto3D(lut) {
for (let i = 0; i < lut.size * lut.size; ++i) {
data.push(...src);
}
- return Object.assign({}, lut, {data});
+ return {...lut, data};
}
export function lutTo2D3Drgb8(lut) {
@@ -140,5 +140,5 @@ export function lutTo2D3Drgb8(lut) {
data[i + 1] = (src[i + 1] - min[1]) / range[1] * 255;
data[i + 2] = (src[i + 2] - min[2]) / range[2] * 255;
}
- return Object.assign({}, lut, {data});
+ return {...lut, data};
} | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/resources/webgl-debug-helper.js | @@ -517,7 +517,7 @@
ext = wrapped.apply(ctx, arguments);
if (ext) {
const origExt = ext;
- ext = makeDebugContext(ext, Object.assign({}, options, {errCtx: ctx}));
+ ext = makeDebugContext(ext, {...options, errCtx: ctx});
sharedState.wrappers[extensionName] = { wrapper: ext, orig: origExt };
addEnumsForContext(origExt, extensionName);
} | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-lots-of-objects-animated.html | @@ -264,11 +264,7 @@
});
// make a copy of baseFile and replace min, max, and data
// with the new data
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
// generate a new set of data | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-lots-of-objects-morphtargets-w-colors.html | @@ -265,11 +265,7 @@
});
// make a copy of baseFile and replace min, max, and data
// with the new data
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
// generate a new set of data | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-lots-of-objects-morphtargets.html | @@ -265,11 +265,7 @@
});
// make a copy of baseFile and replace min, max, and data
// with the new data
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
// generate a new set of data | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-lots-of-objects-multiple-data-sets.html | @@ -229,11 +229,7 @@
});
// make a copy of baseFile and replace min, max, and data
// with the new data
- return Object.assign({}, baseFile, {
- min,
- max,
- data,
- });
+ return {...baseFile, min, max, data};
}
// generate a new set of data | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-postprocessing-3dlut-identity.html | @@ -223,7 +223,7 @@
};
const lutNearestShader = {
- uniforms: Object.assign( {}, lutShader.uniforms ),
+ uniforms: {...lutShader.uniforms},
vertexShader: lutShader.vertexShader,
fragmentShader: lutShader.fragmentShader.replace('#define FILTER_LUT', '//'),
}; | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-postprocessing-3dlut-w-loader.html | @@ -311,7 +311,7 @@
};
const lutNearestShader = {
- uniforms: Object.assign( {}, lutShader.uniforms ),
+ uniforms: {...lutShader.uniforms},
vertexShader: lutShader.vertexShader,
fragmentShader: lutShader.fragmentShader.replace('#define FILTER_LUT', '//'),
}; | true |
Other | mrdoob | three.js | d93f63f821a3f0d4b00d52262e582654f43c9162.json | prefer object spread | threejs/threejs-postprocessing-3dlut.html | @@ -294,7 +294,7 @@
};
const lutNearestShader = {
- uniforms: Object.assign( {}, lutShader.uniforms ),
+ uniforms: {...lutShader.uniforms},
vertexShader: lutShader.vertexShader,
fragmentShader: lutShader.fragmentShader.replace('#define FILTER_LUT', '//'),
}; | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/fr/threejs-primitives.md | @@ -406,5 +406,5 @@ ou votre [BufferGeometry](threejs-custom-buffergeometry.html).
Voyons maintenant l'article traitant sur [comment fonctionne un graphe de scรจne three.js et comment l'utiliser](threejs-scenegraph.html).
-<link rel="stylesheet" href="../resources/threejs-primitives.css">
-<script type="module" src="../resources/threejs-primitives.js"></script>
+<link rel="stylesheet" href="resources/threejs-primitives.css">
+<script type="module" src="resources/threejs-primitives.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ja/threejs-primitives.md | @@ -352,6 +352,6 @@ const material = new THREE.PointsMaterial({
ๆฌกใฏใ[threeใฎใทใผใณใฐใฉใใฎๅใๆนใจไฝฟใๆน](threejs-scenegraph.html)ใ่ชฌๆใใพใใ
-<link rel="stylesheet" href="../resources/threejs-primitives.css">
-<script type="module" src="../resources/threejs-primitives.js"></script>
+<link rel="stylesheet" href="resources/threejs-primitives.css">
+<script type="module" src="resources/threejs-primitives.js"></script>
| true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-align-html-elements-to-3d.md | @@ -702,5 +702,5 @@ function updateLabels() {
๋ค์ ๊ธ์์๋ ๋ ๋์๊ฐ [์ง๊ตฌ๋ณธ ์์ ๋๋ผ๋ฅผ ์ ํํ๊ณ ๊ฐ์กฐ](threejs-indexed-textures.html)ํด๋ณด๊ฒ ์ต๋๋ค.
-<link rel="stylesheet" href="../resources/threejs-align-html-elements-to-3d.css">
-<script type="module" src="../resources/threejs-align-html-elements-to-3d.js"></script>
+<link rel="stylesheet" href="resources/threejs-align-html-elements-to-3d.css">
+<script type="module" src="resources/threejs-align-html-elements-to-3d.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-cameras.md | @@ -581,4 +581,4 @@ function render(time) {
๋ํด ๋จผ์ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-cameras.js"></script>
\ No newline at end of file
+<script type="module" src="resources/threejs-cameras.js"></script>
\ No newline at end of file | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-custom-buffergeometry.md | @@ -446,4 +446,4 @@ positionAttribute.needsUpdate = true;
๋ฐ ๋์์ด ๋์์ผ๋ฉด ์ข๊ฒ ๋ค์.
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-custom-buffergeometry.js"></script>
+<script type="module" src="resources/threejs-custom-buffergeometry.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-fog.md | @@ -261,4 +261,4 @@ class FogGUIHelper {
</div>
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-fog.js"></script>
+<script type="module" src="resources/threejs-fog.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-lights.md | @@ -552,4 +552,4 @@ gui.add(light, 'power', 0, 2000);
๋ค์ ์ฅ์์๋ [์นด๋ฉ๋ผ ์กฐ์๋ฒ](threejs-cameras.html)์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค.
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-lights.js"></script>
+<script type="module" src="resources/threejs-lights.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-materials.md | @@ -319,4 +319,4 @@ Three.js๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฒ์ ํ ๋ฒ๋ง ์ฌ์ง์ ์ค์ ์ ์ ์ฉํฉ๋
</div>
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-materials.js"></script>
\ No newline at end of file
+<script type="module" src="resources/threejs-materials.js"></script>
\ No newline at end of file | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-optimize-lots-of-objects.md | @@ -464,4 +464,4 @@ geometry๋ฅผ ํฉ์น๋ ๊ฑด ๊ฝค ์์ฃผ ์ฌ์ฉํ๋ ์ต์ ํ ๊ธฐ๋ฒ์
๋๋ค. ์
ํ์ง๋ง ์์๋ฅผ ํ๋์ mesh๋ก ํฉ์ณ๋ฒ๋ฆฌ๋ฉด ๋ณ๋์ ์์์๋ ํน์ ๋ถ๋ถ์ ์กฐ์ํ๊ธฐ๊ฐ ์ด๋ ต์ต๋๋ค. ์ํฉ์ ๋ฐ๋ผ ์ข์ ๋ฐฉ๋ฒ๋ ๋ค ๋ค๋ฅผ ํ
์ฃ . [๋ค์ ๊ธ](threejs-optimize-lots-of-objects-animated.html)์์๋ ๊ทธ ๋ฐฉ๋ฒ ์ค ํ๋๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-lots-of-objects.js"></script>
\ No newline at end of file
+<script type="module" src="resources/threejs-lots-of-objects.js"></script>
\ No newline at end of file | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-post-processing-3dlut.md | @@ -499,4 +499,4 @@ updateGUI();
์ด ๊ธ์์๋ ์์ด๋๊ฐ ์ด๋ป๊ฒ ์๋ํ๋์ง์ ๋ํด์๋ ์์ ์ค๋ช
ํ์ง ์์์ต๋๋ค. ๋์ค์ GLSL์ ๋ํด ๋ ๋ค๋ฃฐ ๊ธฐํ๊ฐ ์์์ผ๋ฉด ์ข๊ฒ ๋ค์. ์์ด๋์ ์๋ ๋ฐฉ์์ ์๊ณ ์ถ๋ค๋ฉด [ํ์ฒ๋ฆฌ์ ๊ดํ ๊ธ](threejs-post-processing.html)์ ์๋ ๋งํฌ ๋๋ [์ด ์ ํ๋ธ ์์](https://www.youtube.com/watch?v=rfQ8rKGTVlg#t=24m30s)์ ์ฐธ๊ณ ํ๊ธฐ ๋ฐ๋๋๋ค.
-<script type="module" src="../resources/threejs-post-processing-3dlut.js"></script>
+<script type="module" src="resources/threejs-post-processing-3dlut.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-primitives.md | @@ -366,6 +366,6 @@ const material = new THREE.PointsMaterial({
๋ค์ ์ฅ์์๋ [์ฌ ๊ทธ๋ํ์ ๊ทธ ์ฌ์ฉ๋ฒ](threejs-scenegraph.html)์ ๋ํด
์์๋ณด๊ฒ ์ต๋๋ค.
-<link rel="stylesheet" href="../resources/threejs-primitives.css">
-<script type="module" src="../resources/threejs-primitives.js"></script>
+<link rel="stylesheet" href="resources/threejs-primitives.css">
+<script type="module" src="resources/threejs-primitives.js"></script>
| true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-textures.md | @@ -613,5 +613,5 @@ metalness
roughness
-->
-<link rel="stylesheet" href="../resources/threejs-textures.css">
-<script type="module" src="../resources/threejs-textures.js"></script>
\ No newline at end of file
+<link rel="stylesheet" href="resources/threejs-textures.css">
+<script type="module" src="resources/threejs-textures.js"></script>
\ No newline at end of file | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/kr/threejs-voxel-geometry.md | @@ -1085,4 +1085,4 @@ function updateCellGeometry(x, y, z) {
์ด ๊ธ์ด Three.js๋ก ๋ง์ธํฌ๋ํํธ ๊ฐ์ ๊ทธ๋ํฝ์ ๊ตฌํํ ๋ ์ข์ ์์์ ์ ๋ง๋ จํ๊ณ , geometry๋ฅผ ์ต์ ํํ๋ ๋ฐ ๋์์ด ๋์์ผ๋ฉด ํฉ๋๋ค.
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-voxel-geometry.js"></script>
+<script type="module" src="resources/threejs-voxel-geometry.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-cameras.md | @@ -600,4 +600,4 @@ function render(time) {
ะ ะฟะพะบะฐ ะดะฐะฒะฐะนัะต ะฟะตัะตะนะดะตะผ ะบ [ัะตะฝัะผ](threejs-shadows.html).
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-cameras.js"></script>
+<script type="module" src="resources/threejs-cameras.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-custom-buffergeometry.md | @@ -430,5 +430,5 @@ positionAttribute.needsUpdate = true;
ะดะตะนััะฒะธัะตะปัะฝะพ ะทะฐะฒะธัะธั ะพั ะฒะฐัะธั
ะฟะพััะตะฑะฝะพััะตะน.
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-custom-buffergeometry.js"></script>
+<script type="module" src="resources/threejs-custom-buffergeometry.js"></script>
| true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-fog.md | @@ -241,4 +241,4 @@ class FogGUIHelper {
</div>
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-fog.js"></script>
+<script type="module" src="resources/threejs-fog.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-lights.md | @@ -573,4 +573,4 @@ gui.add(light, 'power', 0, 2000);
ะะฐะปะตะต ะดะฐะฒะฐะนัะต ะฟะตัะตะนะดะตะผ ะบ [ัะฐะฑะพัะต ั ะบะฐะผะตัะฐะผะธ](threejs-cameras.html).
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-lights.js"></script>
+<script type="module" src="resources/threejs-lights.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-material-table.md | @@ -7,6 +7,6 @@ Mesh. ะะพั ัะฐะฑะปะธัะฐ, ะฟะพะบะฐะทัะฒะฐััะฐั, ะบะฐะบะธะต ััะฝะบัะธะธ
<div>
<div id="material-table" class="threejs_center"></div>
-<script type="module" src="../resources/threejs-material-table.js"></script>
-<link rel="stylesheet" href="../resources/threejs-material-table.css">
+<script type="module" src="resources/threejs-material-table.js"></script>
+<link rel="stylesheet" href="resources/threejs-material-table.css">
</div> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-materials.md | @@ -318,5 +318,5 @@ flat shaded
</div>
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-materials.js"></script>
+<script type="module" src="resources/threejs-materials.js"></script>
| true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-optimize-lots-of-objects.md | @@ -519,4 +519,4 @@ scene.add(mesh);
[ะดััะณะพะน ััะฐััะต](threejs-optimize-lots-of-objects-animated.html).
<canvas id="c"></canvas>
-<script type="module" src="../resources/threejs-lots-of-objects.js"></script>
+<script type="module" src="resources/threejs-lots-of-objects.js"></script> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-primitives.md | @@ -329,5 +329,5 @@ function addLineGeometry(x, y, geometry) {
ะะฐะปะตะต ะดะฐะฒะฐะนัะต ัะฐััะผะพััะธะผ [ะบะฐะบ ัะฐะฑะพัะฐะตั ะณัะฐั ััะตะฝั ะธ ะบะฐะบ ะตะณะพ ะธัะฟะพะปัะทะพะฒะฐัั](threejs-scenegraph.html).
-<script type="module" src="../resources/threejs-primitives.js"></script>
-<link rel="stylesheet" href="../resources/threejs-primitives.css">
+<script type="module" src="resources/threejs-primitives.js"></script>
+<link rel="stylesheet" href="resources/threejs-primitives.css"> | true |
Other | mrdoob | three.js | b98e8ff2d9dbfe261f7320749a825410a306545e.json | use lesson-builder v1.7.0 | threejs/lessons/ru/threejs-textures.md | @@ -615,5 +615,5 @@ metalness
roughness
-->
-<script type="module" src="../resources/threejs-textures.js"></script>
-<link rel="stylesheet" href="../resources/threejs-textures.css">
+<script type="module" src="resources/threejs-textures.js"></script>
+<link rel="stylesheet" href="resources/threejs-textures.css"> | true |
Other | mrdoob | three.js | 43b860a8728facf8efe16bb145060a152c929bf7.json | fix script link | threejs/lessons/ru/threejs-optimize-lots-of-objects.md | @@ -519,4 +519,4 @@ scene.add(mesh);
[ะดััะณะพะน ััะฐััะต](threejs-optimize-lots-of-objects-animated.html).
<canvas id="c"></canvas>
-<script type="module" src="resources/threejs-lots-of-objects.js"></script>
+<script type="module" src="../resources/threejs-lots-of-objects.js"></script> | false |
Other | mrdoob | three.js | 32c7c3244ab6c84747ca055a244f111c8390c29c.json | fix version references | threejs/lessons/fr/threejs-fundamentals.md | @@ -97,7 +97,7 @@ Tout d'abord, chargeons three.js :
```html
<script type="module">
-import * as THREE from './resources/threejs/r114/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
</script>
```
@@ -121,7 +121,7 @@ dans le document html :
```html
<script type="module">
-import * as THREE from './resources/threejs/r114/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
+function main() {
+ const canvas = document.querySelector('#c');
@@ -415,7 +415,7 @@ par le biais d'une balise <code><script type="module"></code>. Voici un ex
</p>
<pre class=prettyprint>
<script type="module">
-import * as THREE from './resources/threejs/r114/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
...
| true |
Other | mrdoob | three.js | 32c7c3244ab6c84747ca055a244f111c8390c29c.json | fix version references | threejs/lessons/fr/threejs-prerequisites.md | @@ -25,7 +25,7 @@ ou en ligne via une balise `<script type="module">`. Voici un exemple des deux
```html
<script type="module">
-import * as THREE from './resources/threejs/r114/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
...
| true |
Other | mrdoob | three.js | 32c7c3244ab6c84747ca055a244f111c8390c29c.json | fix version references | threejs/lessons/ja/threejs-fundamentals.md | @@ -33,7 +33,7 @@ Three.jsใฏcanvasใซๆ็ปใใใใใcanvasใthree.jsใซๆธกใๅฟ
่ฆใใ
```html
<script type="module">
-import * as THREE from './resources/threejs/r110/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
function main() {
const canvas = document.querySelector('#c');
@@ -292,7 +292,7 @@ es6ใขใธใฅใผใซใฏในใฏใชใใใฎใญใผใใซ <code>import</code> ใไฝฟ
</p>
<pre class=prettyprint>
<script type="module">
-import * as THREE from './resources/threejs/r110/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
...
| true |
Other | mrdoob | three.js | 32c7c3244ab6c84747ca055a244f111c8390c29c.json | fix version references | threejs/lessons/ja/threejs-prerequisites.md | @@ -20,7 +20,7 @@ es6ใขใธใฅใผใซใฏในใฏใชใใใฎไธญใง `import` ใญใผใฏใผใใใพใ
```html
<script type="module">
-import * as THREE from './resources/threejs/r110/build/three.module.js';
+import * as THREE from './resources/threejs/r119/build/three.module.js';
...
| true |
Other | mrdoob | three.js | 87e8946694297c8751a3941160f513b1cb4227e2.json | add ja translation with orginal script | threejs/lessons/ja/threejs-primitives.md | @@ -0,0 +1,546 @@
+Title: Three.js ใฎใใชใใใฃใใ
+Description: three.js ใใชใใใฃใใฎๆ
ใ
+TOC: ใใชใใใฃใ
+
+This article is one in a series of articles about three.js.
+The first article was [about fundamentals](threejs-fundamentals.html).
+If you haven't read that yet you might want to start there.
+ใใฎ่จไบใฏthree.jsใซใคใใฆใฎใทใชใผใบ่จไบใฎไธใคใงใใ
+ๆๅใฎ่จไบใฏ[about fundamentals](threejs-fundamentals.html)ใงใใ
+ใใใพใ ่ชญใพใใฆใใชใๅ ดๅใฏใใใกใใๅ
ใซๅงใใใฎใ่ฏใใงใใใใ
+
+Three.js has a large number of primitives. Primitives
+are generally 3D shapes that are generated at runtime
+with a bunch of parameters.
+Three.jsใฏๅคใใฎใใชใใใฃใใใใใพใใ
+ใใชใใใฃใใฏใไธ่ฌ็ใซๅฎ่กๆใซใใฉใกใผใฟ็พคใๆๅฎใใฆ็ๆใใใใ3Dๅฝข็ถใฎใใจใงใใ
+
+
+It's common to use primitives for things like a sphere
+for a globe or a bunch of boxes to draw a 3D graph. It's
+especially common to use primitives to experiment
+and get started with 3D. For the majority of 3D apps
+it's more common to have an artist make 3D models
+in a 3D modeling program like [Blender](https://blender.org)
+or [Maya](https://www.autodesk.com/products/maya/) or [Cinema 4D](https://www.maxon.net/en-us/products/cinema-4d/). Later in this series we'll
+cover making and loading data from several 3D modeling
+programs. For now let's go over some of the available
+primitives.
+ๅฐ็ๅใฎ็ไฝใใ3Dใฐใฉใใๆใใใใฎ็ฎฑใฎ้ใพใใฎใใใชใใฎใซใใใชใใใฃใใไฝฟใใฎใฏไธ่ฌ็ใงใใ
+ๅฎ้จใใใ3Dใๅงใใใใใใใใซใใใชใใใฃใใไฝฟใใใจใฏใใจใฆใๆฎ้ใงใใ
+3Dใขใใชใฑใผใทใงใณใฎๅคใใฏใ3Dใขใใซใ[Blender](https://blender.org)ใ
+[Maya](https://www.autodesk.com/products/maya/)ใ
+[Cinema 4D](https://www.maxon.net/en-us/products/cinema-4d/)ใจใใฃใ
+3Dใขใใชใณใฐใใญใฐใฉใ ใงใไฝฟใฃใฆใใขใผใใฃในใใซไฝใฃใฆใใใๆนใไธ่ฌ็ใงใใ
+ใใฎใทใชใผใบใฎๅพๅใงใฏใใใใคใใฎ3Dใขใใชใณใฐใใญใฐใฉใ ใใใใผใฟใไฝใฃใฆ
+่ชญใฟ่พผใๆนๆณใซใ่จๅใใใคใใใงใใ
+ใงใฏใๅฉ็จใงใใใใชใใใฃใใซใคใใฆ่ชฌๆใใพใใใใ
+
+
+Many of the primitives below have defaults for some or all of their
+parameters so you can use more or less depending on your needs.
+ไปฅไธใฎใใชใใใฃใใฎๅคใใฏใไธ้จใพใใฏๅ
จใฆใฎใใฉใกใผใฟใผใฎใใใฉใซใๅคใใใใ
+ๅฟ
่ฆใซๅฟใใฆใๅคใใๅฐใชใใไฝฟใใใจใใงใใใงใใใใ
+
+
+<div id="Diagram-BoxBufferGeometry" data-primitive="BoxBufferGeometry">็ซๆนไฝ</div>
+<div id="Diagram-CircleBufferGeometry" data-primitive="CircleBufferGeometry">2ๆฌกๅ
ใฎๅ</div>
+<div id="Diagram-ConeBufferGeometry" data-primitive="ConeBufferGeometry">A Coneๅ้</div>
+<div id="Diagram-CylinderBufferGeometry" data-primitive="CylinderBufferGeometry">A Cylinderๅ็ญ</div>
+<div id="Diagram-DodecahedronBufferGeometry" data-primitive="DodecahedronBufferGeometry">A dodecahedron (12 sides)ๅไบ้ขไฝ๏ผ12้ข๏ผ</div>
+<div id="Diagram-ExtrudeBufferGeometry" data-primitive="ExtrudeBufferGeometry">An extruded 2d shape with optional bevelling.
+Here we are extruding a heart shape. Note this is the basis
+for <code>TextBufferGeometry</code> and <code>TextGeometry</code> respectively.
+ใใใซใฎใชใใทใงใณไปใใฎใๆผใๅบใใใ2ๆฌกๅ
ๅฝข็ถใ
+ใใใฏ<code>TextBufferGeometry</code>ใจ<code>TextGeometry</code>ใฎใใใใใฎๅบ็คใซใชใใใจใซๆณจๆใใฆใใ ใใใ</div>
+<div id="Diagram-IcosahedronBufferGeometry" data-primitive="IcosahedronBufferGeometry">An icosahedron (20 sides)ไบๅ้ขไฝ๏ผ20้ข๏ผ</div>
+<div id="Diagram-LatheBufferGeometry" data-primitive="LatheBufferGeometry">A shape generated by spinning a line. Examples would be: lamps, bowling pins, candles, candle holders, wine glasses, drinking glasses, etc... You provide the 2d silhouette as series of points and then tell three.js how many subdivisions to make as it spins the silhouette around an axis.ใใ่ปธใฎๅจใใๅ่ปขใใฆใงใใๅฝข็ถใไพใจใใฆใฏใใใชใจใใใงใใใใ๏ผใฉใณใใใใผใชใณใฐใฎใใณใใใใใใใใใใ็ซใฆใใฏใคใณใฐใฉในใใใชใณใฏใฐใฉในใใชใฉใชใฉ...ใ็นใฎ้ฃ็ถใจใใฆ2ๆฌกๅ
ใฎ่ผช้ญใไธใใใใฎ่ผช้ญใ่ปธใฎๅจใใงๅ่ปขใใใ้ใซใใฉใฎใใใ็ดฐใใใใใthree.jsใซๆ็คบใใใใจใใงใใพใใ</div>
+<div id="Diagram-OctahedronBufferGeometry" data-primitive="OctahedronBufferGeometry">An Octahedron (8 sides)ๅ
ซ้ขไฝ๏ผ8้ข๏ผ</div>
+<div id="Diagram-ParametricBufferGeometry" data-primitive="ParametricBufferGeometry">A surface generated by providing a function that takes a 2D point from a grid and returns the corresponding 3d point.ใฐใชใใใใ2ๆฌกๅ
ใฎ็นใๅๅพใใๅฏพๅฟใใ3ๆฌกๅ
ใฎ็นใ่ฟใ้ขๆฐใไฝใใใจใงใงใใ่กจ้ขใ</div>
+<div id="Diagram-PlaneBufferGeometry" data-primitive="PlaneBufferGeometry">A 2D plane 2ๆฌกๅ
ใฎๅ่งๅฝข</div>
+<div id="Diagram-PolyhedronBufferGeometry" data-primitive="PolyhedronBufferGeometry">Takes a set of triangles centered around a point and projects them onto a sphereใใ็นใฎๅจใใซไธ่งๅฝขใฎ้ใพใใ้ใใฆ็ใซใใ</div>
+<div id="Diagram-RingBufferGeometry" data-primitive="RingBufferGeometry">A 2D disc with a hole in the centerใ็ใไธญใซ็ฉดใฎใใใๅ็ค</div>
+<div id="Diagram-ShapeBufferGeometry" data-primitive="ShapeBufferGeometry">A 2D outline that gets triangulatedใไธ่งๅฝขๅๅฒใใใ2ๆฌกๅ
ใฎ่ผช้ญ</div>
+<div id="Diagram-SphereBufferGeometry" data-primitive="SphereBufferGeometry">A sphereใ็</div>
+<div id="Diagram-TetrahedronBufferGeometry" data-primitive="TetrahedronBufferGeometry">A tetrahedron (4 sides)ใๅ้ขไฝ๏ผ4้ข๏ผ</div>
+<div id="Diagram-TextBufferGeometry" data-primitive="TextBufferGeometry">3D text generated from a 3D font and a string 3Dใใฉใณใใจๆๅญใซใใ3Dใใญในใ</div>
+<div id="Diagram-TorusBufferGeometry" data-primitive="TorusBufferGeometry">A torus (donut)ใๅ็ฐ๏ผใใผใใ๏ผ</div>
+<div id="Diagram-TorusKnotBufferGeometry" data-primitive="TorusKnotBufferGeometry">A torus knotใๅ็ฐ๏ผ็ตใณ็ฎ๏ผ</div>
+<div id="Diagram-TubeBufferGeometry" data-primitive="TubeBufferGeometry">A circle traced down a pathใ็ต่ทฏใใชใใฃใๅ</div>
+<div id="Diagram-EdgesGeometry" data-primitive="EdgesGeometry">A helper object that takes another geometry as input and generates edges only if the angle between faces is greater than some threshold. For example if you look at the box at the top it shows a line going through each face showing every triangle that makes the box. Using an <code>EdgesGeometry</code> instead the middle lines are removed. Adjust the thresholdAngle below and you'll see the edges below that threshold disappear.็ฐใชใใธใชใกใใชใๅ
ฅๅใจใใฆใใใฎ้ขๅๅฃซใฎ่งๅบฆใ้พๅคไปฅไธใชใ่งใไฝใๅบใใ่ฃๅฉใชใใธใงใฏใใไพใใฐใ่จไบใฎๆๅใฎๆนใง็ดนไปใใ็ซๆนไฝใ่ฆใฆใฟใใจใใใใใใฎ้ขใซใ็ซๆนไฝใไฝใฃใฆใใๅ
จใฆใฎไธ่งๅฝขใฎ็ทใ่กจ็คบใใใฆใใพใใ<code>EdgesGeometry</code>ใไปฃใใใซไฝฟใใใจใงใ้ขๅ
ใฎ็ทใฏใๅ
จใฆ้คๅปใใใพใใไธ่จใฎthresholdAngleใ่ชฟๆดใใฆใฟใฆใใ ใใใ้พๅคไปฅไธใฎ่งใๆถใใฆ่ฆใใใงใใใใ</div>
+<div id="Diagram-WireframeGeometry" data-primitive="WireframeGeometry">Generates geometry that contains one line segment (2 points) per edge in the given geometry. Without this you'd often be missing edges or get extra edges since WebGL generally requires 2 points per line segment. For example if all you had was a single triangle there would only be 3 points. If you tried to draw it using a material with <code>wireframe: true</code> you would only get a single line. Passing that triangle geometry to a <code>WireframeGeometry</code> will generate a new geometry that has 3 lines segments using 6 points..
+1ใคใฎ่งใใจใซ1ใคใฎ็ทๅ๏ผ2็น๏ผใๆใคใธใชใกใใชใ็ๆใใใWebGLใฏ็ทๅใไฝใใฎใซ2็นใๅฟ
่ฆใชใฎใงใใใฎๆฉ่ฝใใชใใจใใใฐใใฐ่งใๅฟใใใใไฝๅใช่งใไฝใฃใฆใใพใใงใใใใไพใใฐใใใฃใ3็นใใใชใ1ใคใฎไธ่งๅฝขใใใจใใพใใ<code>wireframe: true</code>ใฎใใใชใขใซใไฝฟใฃใฆใใใๆใใใจใใๅ ดๅใ1ๆฌใฎ็ทๅใใๅพใใใพใใใ<code>WireframeGeometry</code>ใซใใฎไธ่งๅฝขใฎใธใชใกใใชใๆธกใใจใ6็นใใใชใ3ใคใฎ็ทๅใๆใฃใๆฐใใใธใชใกใใชใ็ๆใใพใใ</div>
+
+You might notice of most of them come in pairs of `Geometry`
+or `BufferGeometry`. The difference between the 2 types is effectively flexibility
+vs performance.
+ใปใจใใฉใฎใใชใใใฃใใฏ`Geometry`ใ`BufferGeometry`ใฎ2ใคใใใใใจใซๆฐใฅใใใใใใใพใใใ
+ใใฎ2ใคใฎ้ใใฏใๅนๆ็ใชๆ่ปๆงใจใใใฉใผใใณในใงใใ
+
+`BufferGeometry` based primitives are the performance oriented
+types. The vertices for the geometry are generated directly
+into an efficient typed array format ready to be uploaded to the GPU
+for rendering. This means they are faster to start up
+and take less memory but if you want to modify their
+data they take what is often considered more complex
+programming to manipulate.
+`BufferGeometry`ใซๅบใฅใใๅบๆฌๅฝข็ถใฏใใใฉใผใใณในๅฟๅใฎ็จฎ้กใงใใ
+ๅฝข็ถใฎ้ ็นใฏใใฌใณใใชใณใฐใฎใใGPUใซใขใใใญใผใใใใฎใซ้ฉใใ้
ๅๅฝขๅผใซใ็ดๆฅ็ๆใใใพใใ
+ใใใฏใ่ตทๅใ้ใ็ใกใขใชใงใใใใจใๆๅณใใพใใใใใผใฟใฎไฟฎๆญฃใซใใ่ค้ใชใใญใฐใฉใใณใฐใๅฟ
่ฆใซใชใใใจใๅคใใงใใ
+
+`Geometry` based primitives are the more flexible, easier to manipulate
+type. They are built from JavaScript based classes like `Vector3` for
+3D points, `Face3` for triangles.
+They take quite a bit of memory and before they can be rendered three.js will need to
+convert them to something similar to the corresponding `BufferGeometry` representation.
+`Geometry`ใซๅบใฅใใๅบๆฌๅฝข็ถใฏใใๆ่ปใงใๆไฝใใใใ็จฎ้กใงใใ
+ใใใใฏใ3ๆฌกๅ
ใฎ็นใฎใใใฎ`Vector3`ใไธ่งๅฝขใฎใใใฎ`Face3`ใฎใใใชJavaScriptใซๅบใฅใใฏใฉในใใใงใใฆใใพใใ็ตๆงใกใขใชใๅฟ
่ฆใจใใพใใใthree.jsใซใฌใณใใชใณใฐใใใๅใซใๅฏพๅฟใใ`BufferGeometry`่กจ็พใฎ้กไผผ็ฉใซๅคๆใใๅฟ
่ฆใใใใพใใ
+
+If you know you are not going to manipulate a primitive or
+if you're comfortable doing the math to manipulate their
+internals then it's best to go with the `BufferGeometry`
+based primitives. If on the other hand you want to change
+a few things before rendering you might find the `Geometry`
+based primitives easier to deal with.
+ใใชใใใฃใใๆไฝใใชใใใจใๅใใฃใฆใใใใ่จ็ฎใใใฆๅ
้จใๆไฝใใใใจใซๆตๆใใชใใชใใ
+`BufferGeometry`ใซๅบใฅใใใใชใใใฃใใไฝฟใใฎใใในใใงใใ
+ไธๆนใงใใฌใณใใชใณใฐๅใซๅฐใชใใใๅคๆดใๅ
ฅใใใใชใใ`Geometry`ใซๅบใฅใใใใชใใใฃใใไฝฟใใจใ
+ใใ็ฐกๅใซๆฑใใใจใใงใใพใใ
+
+As an simple example a `BufferGeometry`
+can not have new vertices easily added. The number of vertices used is
+decided at creation time, storage is created, and then data for vertices
+are filled in. Whereas for `Geometry` you can add vertices as you go.
+ๅ็ดใชไพใ ใจใ`BufferGeometry`ใฏๆฐใใ้ ็น็พคใ็ฐกๅใซ่ฟฝๅ ใงใใพใใใ
+ไฝฟใ้ ็นใฎๆฐใฏไฝๆๆใซๅฎฃ่จใใใ่จๆถ้ ๅใ็ขบไฟใใใ้ ็น็พคใซ้ขใใใใผใฟใๆธใ่พผใพใใพใใ
+ไธๆนใ`Geometry`ใฏใใใชใใใใใใใใซ้ ็น็พคใ่ฟฝๅ ใงใใพใใ
+
+We'll go over creating custom geometry in [another article](threejs-custom-geometry.html). For now
+let's make an example creating each type of primitive. We'll start
+with the [examples from the previous article](threejs-responsive.html).
+[another article](threejs-custom-geometry.html)ใซใซในใฟใ ใธใชใกใใชใฎไฝๆใซใคใใฆ่ชฌๆใใพใใ
+ไปใฏใใใใใใฎ็จฎ้กใฎใใชใใใฃใใไฝๆใใไพใไฝใฃใฆใฟใพใใใใ
+[examples from the previous article](threejs-responsive.html)ใใๅงใใพใใ
+
+Near the top let's set a background color
+ๆๅใฎๆนใงใ่ๆฏ่ฒใๆๅฎใใพใใใใ
+
+```js
+const scene = new THREE.Scene();
++scene.background = new THREE.Color(0xAAAAAA);
+```
+
+This tells three.js to clear to lightish gray.
+ใใใงthree.jsใซใ้ๆใใใฉใคใใฐใฌใผใซๅคใใใใใซไผใใพใใ
+
+The camera needs to change position so that we can see all the
+objects.
+ๅ
จใฆใฎใชใใธใงใฏใใ่ฆใใใใใใใซใกใฉใไฝ็ฝฎใๅคใใๅฟ
่ฆใใใใพใใ
+
+```js
+-const fov = 75;
++const fov = 40;
+const aspect = 2; // the canvas default
+const near = 0.1;
+-const far = 5;
++const far = 1000;
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+-camera.position.z = 2;
++camera.position.z = 120;
+```
+
+Let's add a function, `addObject`, that takes an x, y position and an `Object3D` and adds
+the object to the scene.
+`addObject`้ขๆฐใๅ ใใพใใใใใใใฏxๅบงๆจใจyๅบงๆจใจ`Object3D`ใๅใใsceneใซใชใใธใงใฏใใ่ฟฝๅ ใใพใใ
+
+```js
+const objects = [];
+const spread = 15;
+
+function addObject(x, y, obj) {
+ obj.position.x = x * spread;
+ obj.position.y = y * spread;
+
+ scene.add(obj);
+ objects.push(obj);
+}
+```
+
+Let's also make a function to create a random colored material.
+We'll use a feature of `Color` that lets you set a color
+based on hue, saturation, and luminance.
+ใฉใณใใ ใซ่ฒไปใใใใใใใชใขใซใไฝใ้ขๆฐใไฝๆใใฆใฟใพใใใใ
+่ฒ็ธใๅฝฉๅบฆใ่ผๅบฆใซๅบใฅใใฆ่ฒใ่จญๅฎใงใใใ`Color`ใฎๆฉ่ฝใไฝฟใฃใฆใฟใพใใ
+
+`hue` goes from 0 to 1 around the color wheel with
+red at 0, green at .33 and blue at .66. `saturation`
+goes from 0 to 1 with 0 having no color and 1 being
+most saturated. `luminance` goes from 0 to 1
+with 0 being black, 1 being white and 0.5 being
+the maximum amount of color. In other words
+as `luminance` goes from 0.0 to 0.5 the color
+will go from black to `hue`. From 0.5 to 1.0
+the color will go from `hue` to white.
+`hue`ใฏ่ฒ็ธ็ฐใ0ใใ1ใพใงๅคๅใใพใใ่ตคใฏ0ใ็ทใฏ.33ใ้ใฏ.66ใงใใ
+`saturation`ใฏ0ใใ1ใพใงๅคๅใใพใใ0 ใฏ็ก่ฒใงใ1ใฏๆใๅฝฉๅบฆใฎ้ซใใงใใ
+`luminance`ใฏ0ใใ1ใพใงๅคๅใใพใใ0ใฏ้ปใ1ใฏ็ฝใ0.5ใ่ฒใฎๆๅคง้ใซใชใใพใใ
+่จใๆใใใจใ`luminance`ใ0.0ใใ0.5ใซๅคๅใใใซใคใใฆใ่ฒใฏ้ปใใ`hue`ใซ
+ๅคใใใพใใ0.5ใใ1.0ใพใงใฏ`hue`ใใ็ฝใซๅคๅใใพใใ
+
+```js
+function createMaterial() {
+ const material = new THREE.MeshPhongMaterial({
+ side: THREE.DoubleSide,
+ });
+
+ const hue = Math.random();
+ const saturation = 1;
+ const luminance = .5;
+ material.color.setHSL(hue, saturation, luminance);
+
+ return material;
+}
+```
+
+We also passed `side: THREE.DoubleSide` to the material.
+This tells three to draw both sides of the triangles
+that make up a shape. For a solid shape like a sphere
+or a cube there's usually no reason to draw the
+back sides of triangles as they all face inside the
+shape. In our case though we are drawing a few things
+like the `PlaneBufferGeometry` and the `ShapeBufferGeometry`
+which are 2 dimensional and so have no inside. Without
+setting `side: THREE.DoubleSide` they would disappear
+when looking at their back sides.
+็งใใกใฏ`side: THREE.DoubleSide`ใใใใชใขใซใซๆธกใใพใใใ
+ใใใฏthreeใซๅฝข็ถใไฝใใจใใซไธ่งๅฝขใฎไธก้ขใๆใใใใซๆ็คบใใพใใ
+็ไฝใ็ซๆนไฝใฎใใใช็ซไฝๅฝข็ถใซใฏใๅฝข็ถใฎๅ
ๅดใๅใใฆใใ่ฃๅดใๆใ
+็็ฑใใชใใฎใงใใ
+ใใใใใฎไพใงใฏใ2ๆฌกๅ
ใง่ฃๅดใๅญๅจใใชใ`PlaneBufferGeometry`ใ`ShapeBufferGeometry`ใฎใใใช
+ใใฎใๆใใใจใใฆใใพใใ
+`side: THREE.DoubleSide`ใ่จญๅฎใใชใใจใ่ฃๅดใ่ฆใใจใใซๆถๆป
ใใฆใใพใใงใใใใ
+
+I should note that it's faster to draw when **not** setting
+`side: THREE.DoubleSide` so ideally we'd set it only on
+the materials that really need it but in this case we
+are not drawing too much so there isn't much reason to
+worry about it.
+`side: THREE.DoubleSide`ใซ**not**ใ่จญๅฎใใใๆนใใๆ็ปใ้ใใชใใใใ
+็ๆณ็ใซใฏๆฌๅฝใซๅฟ
่ฆใชๆใ ใ่จญๅฎใใใฎใ่ฏใใใจใๆณจ่จใใฆใใใพใใ
+ใใใใใใฎไพใ ใจใใใใชใซใใใใๆ็ปใใชใใฎใงใๅฟ้
ใใใพใใใ
+
+Let's make a function, `addSolidGeometry`, that
+we pass a geometry and it creates a random colored
+material via `createMaterial` and adds it to the scene
+via `addObject`.
+ใธใชใกใใชใๆธกใใจ`createMaterial`ใซใใฃใฆใฉใณใใ ใซ่ฒใไปใใใใใชใขใซใไฝใใ
+`addObject`ใซใใฃใฆใทใผใณใซ่ฟฝๅ ใใ`addSolidGeometry`้ขๆฐใไฝใใพใใใใ
+
+```js
+function addSolidGeometry(x, y, geometry) {
+ const mesh = new THREE.Mesh(geometry, createMaterial());
+ addObject(x, y, mesh);
+}
+```
+
+Now we can use this for the majority of the primitives we create.
+For example creating a box
+ใใฆใ็งใใกใฎไฝใใใชใใใฃใใฎๅคงๅคๆฐใซใใใฎ้ขๆฐใไฝฟ็จใงใใพใใ
+ไพใใฐใ็ซๆนไฝใไฝใฃใฆใฟใพใใ
+
+```js
+{
+ const width = 8;
+ const height = 8;
+ const depth = 8;
+ addSolidGeometry(-2, -2, new THREE.BoxBufferGeometry(width, height, depth));
+}
+```
+
+If you look in the code below you'll see a similar section for each type of geometry.
+ไธ่จใฎใณใผใใ่ฆใใฆใฟใใจใใใใใใฎ็จฎ้กใฎใธใชใกใใชใซๅฏพใใฆใๅใใใใชใปใฏใทใงใณใใใใพใใ
+
+Here's the result:
+็ตๆใฏใใฎใใใซใชใใพใ๏ผ
+
+{{{example url="../threejs-primitives.html" }}}
+
+There are a couple of notable exceptions to the pattern above.
+The biggest is probably the `TextBufferGeometry`. It needs to load
+3D font data before it can generate a mesh for the text.
+That data loads asynchronously so we need to wait for it
+to load before trying to create the geometry. By promisifiying
+font loading we can make it mush easier.
+We create a `FontLoader` and then a function `loadFont` that returns
+a promise that on resolve will give us the font. We then create
+an `async` function called `doit` and load the font using `await`.
+And finally create the geometry and call `addObject` to add it the scene.
+ไธ่จใฎใใฟใผใณใซใฏใ2ใคใฎ็น็ญใในใไพๅคใใใใพใใ
+ๆๅคงใฎใใฎใฏใใใใใ`TextBufferGeometry`ใงใใใใญในใใฎใใใฎใกใใทใฅใไฝใๅใซใ
+3Dใใฉใณใใใผใฟใ่ชญใฟ่พผใๅฟ
่ฆใใใใพใใใใฉใณใใฎ่ชญใฟ่พผใฟใซpromiseใไฝฟใใฐใ
+ใใฃใจ้ใใใใใจใใงใใพใใ
+`FontLoader`ใไฝใใจใpromiseใ่ฟใ`loadFont`้ขๆฐใฏ่งฃๆฑบๆใซใใฉใณใใๆไพใใฆใใใใงใใใใ
+ๆฌกใซใ`doit` ใจๅผใฐใใ`async`้ขๆฐใไฝใใ`await`ใไฝฟใฃใฆใใฉใณใใ่ชญใฟ่พผใฟใพใใ
+ๆๅพใซใใธใชใกใใชใไฝใใ`addObject`ใๅผใใงใทใผใณใซ่ฟฝๅ ใใพใใ
+
+```js
+{
+ const loader = new THREE.FontLoader();
+ // promisify font loading
+ function loadFont(url) {
+ return new Promise((resolve, reject) => {
+ loader.load(url, resolve, undefined, reject);
+ });
+ }
+
+ async function doit() {
+ const font = await loadFont('resources/threejs/fonts/helvetiker_regular.typeface.json'); /* threejsfundamentals: url */
+ const geometry = new THREE.TextBufferGeometry('three.js', {
+ font: font,
+ size: 3.0,
+ height: .2,
+ curveSegments: 12,
+ bevelEnabled: true,
+ bevelThickness: 0.15,
+ bevelSize: .3,
+ bevelSegments: 5,
+ });
+ const mesh = new THREE.Mesh(geometry, createMaterial());
+ geometry.computeBoundingBox();
+ geometry.boundingBox.getCenter(mesh.position).multiplyScalar(-1);
+
+ const parent = new THREE.Object3D();
+ parent.add(mesh);
+
+ addObject(-1, -1, parent);
+ }
+ doit();
+}
+```
+
+There's one other difference. We want to spin the text around its
+center but by default three.js creates the text such that its center of rotation
+is on the left edge. To work around this we can ask three.js to compute the bounding
+box of the geometry. We can then call the `getCenter` method
+of the bounding box and pass it our mesh's position object.
+`getCenter` copies the center of the box into the position.
+It also returns the position object so we can call `multiplyScalar(-1)`
+to position the entire object such that its center of rotation
+is at the center of the object.
+ใใไธใค้ใใใใใพใใ็งใใกใฏใใญในใใใใ่ช่บซใฎไธญๅฟใฎๅจใใงๅ่ปขใใใใใฃใใฎใงใใใ
+three.jsใฏใใใฉใซใใงใฏใใญในใใๅทฆ็ซฏใไธญๅฟใซๅ่ปขใใใใใซไฝๆใใพใใ
+ใใใๅ้ฟใใใใใthree.jsใซใธใชใกใใชใฎใใฆใณใใฃใณใฐใใใฏในใฎ่จ็ฎใใใใใใจใใงใใพใใ
+ใใใงใใใฆใณใใฃใณใฐใใใฏในใฎ`getCenter`ใกใฝใใใๅผใใงใใใใใกใใทใฅใฎไฝ็ฝฎใชใใธใงใฏใใซ
+ๆธกใใใจใใงใใพใใ
+`getCenter`ใ็ฎฑใฎไธญๅฟใใใฎไฝ็ฝฎใซใณใใผใใพใใไฝ็ฝฎใชใใธใงใฏใใ่ฟใใฎใงใ
+`multiplyScalar(-1)`ใๅผใใงใชใใธใงใฏใๅ
จไฝใ็ฝฎใใใจใใงใใพใใ
+็ตๆใๅ่ปขใฎไธญๅฟใฏ็ฉไฝใฎไธญๅฟใซใชใใพใใ
+
+If we then just called `addSolidGeometry` like with previous
+examples it would set the position again which is
+no good. So, in this case we create an `Object3D` which
+is the standard node for the three.js scene graph. `Mesh`
+is inherited from `Object3D` as well. We'll cover [how the scene graph
+works in another article](threejs-scenegraph.html).
+For now it's enough to know that
+like DOM nodes, children are drawn relative to their parent.
+By making an `Object3D` and making our mesh a child of that
+we can position the `Object3D` wherever we want and still
+keep the center offset we set earlier.
+ใใใ ใจใใใๅ
ใฎไพใฎใใใซ`addSolidGeometry`ใๅผใถใจใ
+ๅใณไฝ็ฝฎใ่จญๅฎใใใฆใใพใใพใใใใใใฏใใใใใพใใใ
+ใใฎใใใใใฎไพใงใฏใthree.jsใฎใทใผใณใฐใฉใใงใฏๆจๆบ็ใชใใผใใงใใ
+`Object3D`ใไฝใใพใใ`Mesh`ใฏๅๆงใซ`Object3D`ใ็ถๆฟใใฆใใพใใ
+[ๅฅใฎ่จไบใงใฉใฎใใใซใทใผใณใฐใฉใใๅใใ](threejs-scenegraph.html)ๆฑใใพใใ
+ใจใใใใใDOMใใผใใฎใใใซใๅญใใผใใฏ่ฆชใใผใใจ้ข้ฃใใฆๆใใใใจใใใใใซใ
+็ฅใฃใฆใใใฐๅๅใงใใ
+`Object3D`ใไฝๆใใใกใใทใฅใใใฎๅญใซใใใใจใงใใฉใใซใงใ`Object3D`ใซ้
็ฝฎใใ
+ๅ
ใปใฉ่จญๅฎใใไธญๅฟใฎใชใใปใใใ็ถญๆใใใพใพใซใงใใพใใ
+
+If we didn't do this the text would spin off center.
+ใใใใชใใจใใใญในใใไธญๅคฎใใใใใฆๅใฃใฆใใพใใพใใ
+
+{{{example url="../threejs-primitives-text.html" }}}
+
+Notice the one on the left is not spinning around its center
+whereas the one on the right is.
+ๅทฆๅดใฎใใฎใฏ่ช่บซใฎไธญๅฟใฎๅจใใๅ่ปขใใฆใใพใใใใๅณๅดใฎใใฎใฏใใใชใฃใฆใใใใจใซ
+ๆฐใฅใใฆใใ ใใใ
+
+The other exceptions are the 2 line based examples for `EdgesGeometry`
+and `WireframeGeometry`. Instead of calling `addSolidGeometry` they call
+`addLineGeometry` which looks like this
+ใใไธใคใฎไพๅคใฏใ`EdgesGeometry`ใจ`WireframeGeometry`ใฎใ2ใคใฎ็ด็ทใซๅบใฅใใไพใงใใ
+`addSolidGeometry`ใๅผใถไปฃใใใซใใใฎใใใซ`addLineGeometry`ใๅผใใงใใพใใ
+
+```js
+function addLineGeometry(x, y, geometry) {
+ const material = new THREE.LineBasicMaterial({color: 0x000000});
+ const mesh = new THREE.LineSegments(geometry, material);
+ addObject(x, y, mesh);
+}
+```
+
+It creates a black `LineBasicMaterial` and then creates a `LineSegments`
+object which is a wrapper for `Mesh` that helps three know you're rendering
+line segments (2 points per segment).
+้ป่ฒใฎ`LineBasicMaterial`ใไฝใใๆฌกใซ`LineSegments`ใชใใธใงใฏใใไฝๆใใพใใ
+ใใใฏ`Mesh`ใฎใฉใใใผใงใใใชใใ็ทๅ๏ผ็ทๅใใใ2็น๏ผใใฌใณใใชใณใฐใใใใจใใฆใใใใจใ
+threeใ็ฅใ่ฃๅฉใใใพใใ
+
+Each of the primitives has several parameters you can pass on creation
+and it's best to [look in the documentation](https://threejs.org/docs/) for all of them rather than
+repeat them here. You can also click the links above next to each shape
+to take you directly to the docs for that shape.
+ใใชใใใฃใใฎใใใใใฏใไฝๆใใ้ใซๆธกใใใจใใงใใ่คๆฐใฎใใฉใกใผใฟใผใๆใฃใฆใใฆใ
+ใใใง็นฐใ่ฟใใใใ[ใใฎใใญใฅใกใณใใ่ฆใใฆใใใ](https://threejs.org/docs/)ใใจใไธ็ช่ฏใใงใใ
+ใพใใๅๅฝข็ถใฎๆจชใซใใไธ่จใฎใชใณใฏใใฏใชใใฏใใใจใใใฎๅฝข็ถใฎใใญใฅใกใณใใซ็ดๆฅๆกๅ
ใใใพใใ
+
+There is one other pair of classes that doesn't really fit the patterns above. Those are
+the `PointsMaterial` and the `Points` class. `Points` is like `LineSegments` above in that it takes a
+a `Geometry` or `BufferGeometry` but draws points at each vertex instead of lines.
+To use it you also need to pass it a `PointsMaterial` which
+take a [`size`](PointsMaterial.size) for how large to make the points.
+
+ไธ่จใฎใใฟใผใณใซๅ
จ็ถใฏใพใใชใ1็ตใฎใฏใฉในใใปใใซใใใพใใ
+ใใใฏ`PointsMaterial`ใจ`Points`ใฏใฉในใงใใ`Points`ใฏ`LineSegments`ใซไผผใฆใใฆใ
+`Geometry`ใ`BufferGeometry`ใๅผๆฐใซๅใใพใใใใใใ็ทใฎไปฃใใใซๅ้ ็นใฎ็นใๆ็ปใใพใใ
+ไฝฟใใใใซใฏใ`PointsMaterial`ใๆธกใๅฟ
่ฆใใใใพใใ
+ใใใฏใ็นใใฉใใใใๅคงใใใใใๆฑบใใใใ[`size`](PointsMaterial.size) ใๅใใพใใ
+
+```js
+const radius = 7;
+const widthSegments = 12;
+const heightSegments = 8;
+const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+const material = new THREE.PointsMaterial({
+ color: 'red',
+ size: 0.2, // in world units
+});
+const points = new THREE.Points(geometry, material);
+scene.add(points);
+```
+
+<div class="spread">
+<div data-diagram="Points"></div>
+</div>
+
+You can turn off [`sizeAttenuation`](PointsMaterial.sizeAttenuation) by setting it to false if you want the points to
+be the same size regardless of their distance from the camera.
+ใซใกใฉใใใฎ่ท้ขใซ้ขใใใๅบใฎๅคงใใใๅใใซใใใใฎใงใใใฐใ
+ [`sizeAttenuation`](PointsMaterial.sizeAttenuation) ใfalseใซใใใใจใงใๆญขใใใใจใใงใใพใใ
+
+```js
+const material = new THREE.PointsMaterial({
+ color: 'red',
++ sizeAttenuation: false,
++ size: 3, // in pixels
+- size: 0.2, // in world units
+});
+...
+```
+
+<div class="spread">
+<div data-diagram="PointsUniformSize"></div>
+</div>
+
+One other thing that's important to cover is that almost all shapes
+have various settings for how much to subdivide them. A good example
+might be the sphere geometries. Spheres take parameters for
+how many divisions to make around and how many top to bottom. For example
+่ชฌๆใๅฟ
่ฆใชใใไธใคใฎๅคงๅใชใใจใฏใใปใจใใฉๅ
จ้จใฎๅฝข็ถใใ
+ใฉใฎใใใๅฐๅใใซใใใๆฑบใใใๆงใ
ใช่จญๅฎใๆใฃใฆใใใใจใงใใ
+็ไฝใฎใธใชใกใใชใ่ฏใไพใใใใใพใใใ
+็ไฝใฏๅจๅฒใจไธไธใซใฉใฎใใใๅๅฒใใใใฎใใฉใกใผใฟใใใใพใใ
+ไพใใฐใ
+
+<div class="spread">
+<div data-diagram="SphereBufferGeometryLow"></div>
+<div data-diagram="SphereBufferGeometryMedium"></div>
+<div data-diagram="SphereBufferGeometryHigh"></div>
+</div>
+
+The first sphere has 5 segments around and 3 high which is 15 segments
+or 30 triangles. The second sphere has 24 segments by 10. That's 240 segments
+or 480 triangles. The last one has 50 by 50 which is 2500 segments or 5000 triangles.
+ๆๅใฎ็ไฝใฏใๅจๅฒใซ5ใปใฐใกใณใใ้ซใ3ใชใฎใงใ15ใปใฐใกใณใใพใใฏ30ๅใฎไธ่งๅฝขใงใใใ
+ไบใค็ฎใฎ็ไฝใฏใๅจๅฒใซ24ใปใฐใกใณใใ้ซใใ10ใงใใ240ใปใฐใกใณใใ480ๅใฎไธ่งๅฝขใงใใ
+ๆๅพใฎ็ไฝใฏใๅจๅฒใซ50ใปใฐใกใณใใ้ซใใ50ใงใ2500ใปใฐใกใณใใ5000ๅใฎไธ่งๅฝขใงใใ
+
+It's up to you to decide how many subdivisions you need. It might
+look like you need a high number of segments but remove the lines
+and the flat shading and we get this
+ใฉใฎใใใๅๅฒใๅฟ
่ฆใใฏใใใชใใๆฑบใใใใจใงใใ
+ๅคใใฎใปใฐใกใณใใๅฟ
่ฆใชใใใซ่ฆใใใใใใใพใใใใ็ทใ้คๅปใใฆใ
+ๅฝฑใใชใใใใจใงใใใฎใใใซใชใใพใใ
+
+<div class="spread">
+<div data-diagram="SphereBufferGeometryLowSmooth"></div>
+<div data-diagram="SphereBufferGeometryMediumSmooth"></div>
+<div data-diagram="SphereBufferGeometryHighSmooth"></div>
+</div>
+
+It's now not so clear that the one on the right with 5000 triangles
+is entirely better than the one in the middle with only 480.
+If you're only drawing a few spheres, like say a single globe for
+a map of the earth, then a single 10000 triangle sphere is not a bad
+choice. If on the other hand you're trying to draw 1000 spheres
+then 1000 spheres times 10000 triangles each is 10 million triangles.
+To animate smoothly you need the browser to draw at 60 frames per
+second so you'd be asking the browser to draw 600 million triangles
+per second. That's a lot of computing.
+5000ๅใฎไธ่งๅฝขใซใใๅณๅดใฎ็ไฝใฎๆนใใใใฃใ480ใฎ็ใไธญใฎ็ไฝใใใ
+ๅ
จใใใฃใฆ่ฏใใใฏใๆใใใงใฏใใใพใใใ
+ๅฐ็ใฎๅฐๅณใจใใฆไธๅใฎๅฐ็ๅใจใใใใใซใใใใใใใคใใฎ็ไฝใๆใใ ใใชใใ
+10000ๅใฎไธ่งๅฝขใฎ็ไฝใงใๆชใ้ธๆใงใฏใใใพใใใ
+ไธๆนใงใ1000ๅใฎ็ไฝใๆธใใใจใใฆใใใชใใ1000ๅใฎ็ไฝใซใใฎใใฎ10000ๅใฎไธ่งๅฝขใ
+ใใใใไธๅไธๅใฎไธ่งๅฝขใซใชใใพใใ
+ๆปใใใซๅใใใซใฏใใฉใฆใถใไธ็ง้ใซ60ใใฌใผใ ๆ็ปใใๅฟ
่ฆใใใใใใ
+ใใฉใฆใถใฏ1็ง้ใซ6ๅๅใฎไธ่งๅฝขใๆ็ปใใๅฟ
่ฆใใใใพใใ
+ใใใฏ่จ็ฎใๅคใใใพใใ
+
+Sometimes it's easy to choose. For example you can also choose
+to subdivide a plane.
+้ธใถใฎใ็ฐกๅใชๆใใใใพใใไพใใฐใๅนณ้ขใฎ็ดฐๅๅใ้ธใถใใจใใงใใพใใ
+
+<div class="spread">
+<div data-diagram="PlaneBufferGeometryLow"></div>
+<div data-diagram="PlaneBufferGeometryHigh"></div>
+</div>
+
+The plane on the left is 2 triangles. The plane on the right
+is 200 triangles. Unlike the sphere there is really no trade off in quality for most
+use cases of a plane. You'd most likely only subdivide a plane
+if you expected to want to modify or warp it in some way. A box
+is similar.
+ๅทฆๅดใฎๅ่งๅฝขใฏ2ใคใฎไธ่งๅฝขใใๆใใพใใๅณๅดใฎๅ่งๅฝขใฏ200ๅใฎไธ่งๅฝขใใๆใใพใใ
+็ไฝใฎๆใจ็ฐใชใใๅ่งๅฝขใฎๅ ดๅใ ใจใ่ณช็ใชใใฌใผใใชใใฏๅ
จใใใใพใใใ
+ใใใคใใฎ็จ้ใงใๅคงๆตใฎๅ ดๅใๅ่งๅฝขใๆน้ ใใใๆญชใใใใใใใจๆใฃใฆใใๆใซใ
+ๅ่งๅฝขใ็ดฐๅๅใใใ ใใง่ฏใใงใใใใ
+็ซๆนไฝใๅๆงใงใใ
+
+So, choose whatever is appropriate for your situation. The less
+subdivisions you choose the more likely things will run smoothly and the less
+memory they'll take. You'll have to decide for yourself what the correct
+tradeoff is for your particular situation.
+ใใชใใฎ็ถๆณใซใตใใใใใใฎใ้ธใณใพใใใใ
+้ธใใ ็ดฐๅๅใๅฐใชใใปใฉใใใๆปใใใซๅใใฆใ็ใกใขใชใซใชใใใจใงใใใใ
+ใใชใใฎ็นๅฎใฎ็ถๆณใซใตใใใใใๆญฃใใใใฌใผใใชใใฏไฝใใๆฑบใใชใใใฐใใใพใใใ
+
+If none of the shapes above fit your use case you can load
+geometry for example from a [.obj file](threejs-load-obj.html)
+or a [.gltf file](threejs-load-gltf.html).
+You can also create your own [custom Geometry](threejs-custom-geometry.html)
+or [custom BufferGeometry](threejs-custom-buffergeometry.html).
+ใใชใใฎ็จ้ใซ้ฉใใๅฝข็ถใใชใใชใใไพใใฐใ[.obj file](threejs-load-obj.html)
+ใ[.gltf file](threejs-load-gltf.html)ใใใธใชใกใใชใ่ชญใฟ่พผใใใจใใงใใพใใ
+[ใซในใฟใ ใธใชใกใใช](threejs-custom-geometry.html)
+ใ[ใซในใฟใ BufferGeometry](threejs-custom-buffergeometry.html)ใไฝใใใจใใงใใพใใ
+
+Next up let's go over [how three's scene graph works and how
+to use it](threejs-scenegraph.html).
+ๆฌกใฏใ[threeใฎใทใผใณใฐใฉใใฎๅใๆนใจไฝฟใๆน](threejs-scenegraph.html)ใ่ชฌๆใใพใใ
+
+<link rel="stylesheet" href="../resources/threejs-primitives.css">
+<script type="module" src="../resources/threejs-primitives.js"></script>
+ | false |
Other | mrdoob | three.js | 682f4bd31093fe1fd5b70cb40c8f83bd245d5371.json | add translation kr/threejs-game.md | threejs/lessons/kr/threejs-game.md | @@ -0,0 +1,1878 @@
+Title: Three.js๋ก ๊ฒ์ ๋ง๋ค๊ธฐ
+Description: Three.js๋ก ๊ฒ์์ ๋ง๋ค์ด๋ด
๋๋ค
+Category: solutions
+TOC: ๊ฒ์ ๋ง๋ค๊ธฐ
+
+์ ๊ฐ ๊ฝค ๋ง์ด ๋ฐ์๋ ์ง๋ฌธ ์ค ํ๋๊ฐ Three.js๋ก ๊ฒ์์ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๊ดํ ๊ฒ์ด์์ต๋๋ค. ๊ธฐ์ด์ ์ธ ๊ฒ์ด๊ธด ํด๋ ๋ถ๋ ์ด ๊ธ์ ์ฌ๋ฌ๋ถ์ด ์ํ๋ ๋ด์ฉ์ด ์๋ค๋ฉด ์ข๊ฒ ๋ค์.
+
+๊ธ์ ์ฐ๋ ํ์ฌ๋ฅผ ๊ธฐ์ค์ผ๋ก, ์๋ง ์ด ๊ธ์ด ์ด ์๋ฆฌ์ฆ์์ ๊ฐ์ฅ ๊ธด ๊ธ์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์์ ๋ก ์ด ์ฝ๋๊ฐ ์ง๋์น๊ฒ ์ ๋ฌธ์ ์ผ๋ก ๋ณด์ผ ์๋ ์์ง๋ง ๊ทธ๊ฑด ์์ ๋ฅผ ๋ง๋ค๋ฉฐ ๋ฌธ์ ๊ฐ ์๊ธธ ๋๋ง๋ค ์ด์ ์ ์ ๊ฐ ์ค์ ๋ก ๋ง๋ค์๋ ๊ฒ์์ ์ฝ๋๋ฅผ ๊ฐ์ ธ์์ ๊ทธ๋ ์ต๋๋ค. ๋ํ ์ ์ด๋ฐ ํด๊ฒฐ์ฑ
์ ์ผ๋์ง ์ต๋ํ ์ ์ผ๋ ค๊ณ ํ์ผ๋ ๊ธธ ์๋ฐ์ ์์ฃ . ๋ฌผ๋ก ๋ง๋ค๋ ค๋ ๊ฒ์์ ๊ท๋ชจ๊ฐ ์๋ค๋ฉด ์ด๋ฐ ํด๊ฒฐ์ฑ
์ด ์ ๋ถ ํ์ ์์ ์ ์์ต๋๋ค. ํ์ง๋ง ์์ ๋ก ๊ตฌํํ ๊ฒ๋ ๊ต์ฅํ ๊ฐ๋จํ ๊ฒ์์ ์ํฉ๋๋ค. ํต์์ ์ผ๋ก 3D ์บ๋ฆญํฐ๊ฐ 2D ์บ๋ฆญํฐ๋ณด๋ค ๋ ๋ณต์กํ๋ ์ฒ๋ฆฌํด์ค์ผ ํ ๊ฒ์ด ๋ง์ ์๋ฐ์ ์์ฃ .
+
+ํฉ๋งจ(PacMan)์ 2D๋ก ๊ตฌํํ๋ค๋ฉด ํฉ๋งจ์ด ์ฝ๋๋ฅผ ๋ ๋ ๋ฐ๋ก 90๋ ๊บพ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ํ๋ ์ ์ฌ์ด์ ๋ฐ๋ก ์ฒ๋ฆฌํด์ค์ผ ํ ๊ฒ์ด ์์ฃ . ํ์ง๋ง 3D์ ์ธ๊ณ์์๋ ๋ฐ๋ก ๋ฐฉํฅ์ ํ๊ธฐ๋ณด๋ค ๋ช ํ๋ ์์ ๊ฑธ์ณ ์์ํ ๋ฐฉํฅ์ ํธ๋ ๊ฒ ์ผ๋ฐ์ ์
๋๋ค. ์์ฃผ ๊ฐ๋จํ ์ฐจ์ด์ ์ด์ง๋ง, ์ด๊ฒ ๋๋ฌธ์ ์์
์ด ํจ์ฌ ๋ณต์กํด์ง๋๋ค.
+
+์ด ๊ธ์์ ๋ค๋ฃฐ ๋ด์ฉ์ Three.js์ ๊ดํ ๊ฒ์ด๋ผ๊ณ ๋ณด๊ธฐ ์ด๋ ต์ต๋๋ค. ์๋ํ๋ฉด **Three.js๋ ๊ฒ์ ์์ง์ด ์๋๊ธฐ ๋๋ฌธ**์ด์ฃ . Three.js๋ 3D ๋ผ์ด๋ธ๋ฌ๋ฆฌ์
๋๋ค. 3D ์์๋ฅผ ๊ณ์ดํํ๋ [์ฌ ๊ทธ๋ํ](threejs-scenegraph.html)์ 3D ์์๋ฅผ ๋ ๋๋งํ๋๋ก ๋์์ฃผ๋ ๊ธฐ๋ฅ ๋ฑ์ ์ ๊ณตํ์ฃ . ํ์ง๋ง ๊ฒ์๊ณผ ๊ด๋ จํ ๊ธฐ๋ฅ์ ์ง์ํ์ง ์์ต๋๋ค. ์ถฉ๋(collision), ๋ฌผ๋ฆฌ(physics), ์
๋ ฅ ์์คํ
, ํจ์ค ํ์ธ๋ฉ(path finding) ๋ฑ๋ฑ.. ์ด๋ฐ ๊ธฐ๋ฅ์ ์ง์ ๋ง๋ค์ด์ผ ํฉ๋๋ค.
+
+๊ฒฐ๊ตญ ์ด ๊ธ์ *๋ฏธ์์ฑ* ๊ฒ์์ ๋ง๋๋ ๋ฐ ๊ฝค ๋ง์ ์ฝ๋๋ฅผ ์ผ์ต๋๋ค. ์๊น ๋งํ๋ฏ ์ ๊ฐ ์ฝ๋๋ฅผ ๋๋ฌด ์ง๋์น๊ฒ ์งฐ์ ์๋ ์๊ณ , ๋ ๊ฐ๋จํ ํด๊ฒฐ์ฑ
์ด ์์ ์๋ ์์ผ๋, ์ ๋ ๊ธ์ ๋ง๋ฌด๋ฆฌํ ์ง๊ธ๋ ์ถฉ๋ถํ ๋ง์ ์ฝ๋๋ฅผ ์ผ๋์ง, ์ค๋ช
์ ๋น ๋จ๋ฆฐ ๊ฒ์ด ์๋์ง ๊ฑฑ์ ๋ฉ๋๋ค.
+
+์ด ๊ธ์์ ์ด ๋ฐฉ๋ฒ์ ๋๋ถ๋ถ [์ ๋ํฐ(Unity) ์์ง](https://unity.com)์ ์ํฅ์ ํฌ๊ฒ ๋ฐ์์ต๋๋ค. ํ์ง๋ง ์ ๋ํฐ๋ฅผ ์ ๋ชจ๋ฅธ๋ค๊ณ ํด์ ์ด ๊ธ์ ์ฝ๋ ๊ฒ ์ด๋ ต์ง ์์ ๊ฒ๋๋ค. 1000๊ฐ์ ๊ธฐ๋ฅ์ด ์๋ค๋ฉด ๊ทธ ์ค 10๊ฐ ์ ๋ ๋ฐ์ ์ฐ์ง ์์๊ฑฐ๋ ์.
+
+๋จผ์ Three.js ๋ถ๋ถ๋ถํฐ ์์ํด๋ด
์๋ค. ๊ฒ์์ ์ธ ๋ชจ๋ธ๋ค๋ถํฐ ์ฐพ์๋ณด์ฃ .
+
+[opengameart.org](https://opengameart.org) ์ฌ์ดํธ์์ [quaternius](https://opengameart.org/users/quaternius) ์๊ฐ์ [์์ง์ด๋ ๊ธฐ์ฌ ๋ชจ๋ธ](https://opengameart.org/content/lowpoly-animated-knight)์ ์ฐพ์์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/knight.jpg" style="width: 375px;"></div>
+
+[๊ฐ์ ์๊ฐ](https://opengameart.org/users/quaternius)๊ฐ ๋ง๋ ์ํ ์ค์ [์์ง์ด๋ ๋๋ฌผ๋ค](https://opengameart.org/content/lowpoly-animated-farm-animal-pack)๋ ์๋๊ตฐ์.
+
+<div class="threejs_center"><img src="resources/images/animals.jpg" style="width: 606px;"></div>
+
+์ด ๋ชจ๋ธ๋ค๋ก ๊ฝค ๊ด์ฐฎ์ ๊ฒ์์ ๋ง๋ค ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค. ๋ชจ๋ธ๋ค์ ๋ถ๋ฌ์๋ณด์ฃ .
+
+[glTF ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html)์ ๋ํด์๋ ์ด์ ์ ๋ค๋ค์์ต๋๋ค. ๋์ผํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ง๋ง ์ด๋ฒ์๋ ๋ชจ๋ธ์ด ์ฌ๋ฌ ๊ฐ์ด๊ธฐ๋ ํ๊ณ , ๋ชจ๋ธ์ ์ ๋ถ ๋ถ๋ฌ์ค๊ธฐ ์ ์ ๊ฒ์์ ์์ํด์ ์ ๋ฉ๋๋ค.
+
+์ด๋ฐ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด Three.js๋ `LoadingManager`๋ฅผ ์ ๊ณตํฉ๋๋ค. `LoadingManager`์ ์ธ์คํด์ค๋ฅผ ์์ฑํด ๋ค๋ฅธ ๋ก๋(loader)์ ๋๊ฒจ์ฃผ๊ธฐ๋ฉด ๋์ฃ . `LoadingManager`์ [`onProgress`](LoadingManager.onProgress)์ [`onLoad`](LoadingManager.onLoad) ์์ฑ์ ์ฝ๋ฐฑ ํจ์๋ฅผ ์ง์ ํ๋ฉด ๋๋๋ฐ, [`onLoad`](LoadingManager.onLoad)๋ ๋ชจ๋ ํ์ผ์ ๋ถ๋ฌ์จ ๋ค ํธ์ถํ๊ณ , [`onProgress`](LoadingManager.onProgress)๋ ๊ฐ ํ์ผ์ ๋ถ๋ฌ์์ ๋ ํธ์ถํฉ๋๋ค. [`onProgress`](LoadingManager.onProgress)๋ฅผ ์ด์ฉํ๋ฉด ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ๋ณด์ฌ์ค ์ ์์ฃ .
+
+[glTF ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html) ์์ ๋ฅผ ๊ฐ์ ธ์ ์นด๋ฉ๋ผ ์ ๋์ฒด(frustum)๋ฅผ ์กฐ์ ํ๋ ์ฝ๋๋ฅผ ์ง์ฐ๊ณ ์๋ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+const manager = new THREE.LoadingManager();
+manager.onLoad = init;
+const models = {
+ pig: { url: 'resources/models/animals/Pig.gltf' },
+ cow: { url: 'resources/models/animals/Cow.gltf' },
+ llama: { url: 'resources/models/animals/Llama.gltf' },
+ pug: { url: 'resources/models/animals/Pug.gltf' },
+ sheep: { url: 'resources/models/animals/Sheep.gltf' },
+ zebra: { url: 'resources/models/animals/Zebra.gltf' },
+ horse: { url: 'resources/models/animals/Horse.gltf' },
+ knight: { url: 'resources/models/knight/KnightCharacter.gltf' },
+};
+{
+ const gltfLoader = new GLTFLoader(manager);
+ for (const model of Object.values(models)) {
+ gltfLoader.load(model.url, (gltf) => {
+ model.gltf = gltf;
+ });
+ }
+}
+
+function init() {
+ // ๋์ค์ ์์ฑํ ์์
+}
+```
+
+์ ์ฝ๋๋ `models` ๊ฐ์ฒด์ ์๋ ํ์ผ์ ๋ถ๋ฌ์ค๊ณ , `LoadingManager`๊ฐ ํ์ผ์ ์ ๋ถ ๋ถ๋ฌ์์ ๋ `init` ํจ์๋ฅผ ํธ์ถํฉ๋๋ค. `models` ๊ฐ์ฒด๋ฅผ ์ ์ญ์ผ๋ก ์ ์ธํ ๊ฑด ๋์ค์ `GLTFLoader`์ ์ฝ๋ฐฑ์ ์ด์ฉํด ๊ฐ ๋ชจ๋ธ์ ์ ๋ณด๋ฅผ ์ฌ์ฉํ ๋ ๋ถ๋ฌ์จ ๊ฐ ๋ชจ๋ธ์ ์ ๊ทผํ ์ ์๋๋ก ํ๊ธฐ ์ํจ์
๋๋ค.
+
+๋ชจ๋ ๋ชจ๋ธ๊ณผ ๋ชจ๋ธ์ ์ ๋๋ฉ์ด์
๋ฐ์ดํฐ๋ ํ์ฌ ์ฝ 6.6MB์
๋๋ค. ๊ฝค ์ฉ๋์ด ํฌ๋ค์. ์ฌ๋ฌ๋ถ์ ์๋ฒ๊ฐ ์์ถ์ ์ง์(์ด ์ฌ์ดํธ์ ์น ์๋ฒ๊ฐ ์ด ๊ธฐ๋ฅ์ ์ง์ํฉ๋๋ค)ํ๋ค๋ฉด ์ฉ๋์ ์ฝ 1.4MB๊น์ง ์ค์ด๋ค ๊ฒ๋๋ค. 6.6MB์ ๋น๊ตํ๋ฉด ํ์คํ ์ ์ ๋ฐ์ดํฐ์ง๋ง ์ ๋ ์์ ๋ฐ์ดํฐ๋ ์๋๋๋ค. ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ๋ง๋ค์ด ์ฌ์ฉ์์๊ฒ ์ผ๋ง๋ ๊ธฐ๋ค๋ ค์ผ ํ๋์ง๋ฅผ ํ์ํด์ค๋ค๋ฉด ์ข๊ฒ ๋ค์.
+
+[`onProgress`](LoadingManager.onProgress)์ ์ฝ๋ฐฑ ํจ์๋ฅผ ์ง์ ํด์ค์๋ค. ์ด ์ฝ๋ฐฑ ํจ์๋ ํธ์ถํ ๋ 3๊ฐ์ ๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ต๋๋ค. ๊ฐ๊ฐ ๋ง์ง๋ง์ ๋ถ๋ฌ์จ ํ์ผ์ `url`, ๊ทธ๋ฆฌ๊ณ ๋ถ๋ฌ์จ ํ์ผ์ ๊ฐ์, ์ ์ฒด ํ์ผ์ ๊ฐ์์
๋๋ค.
+
+ํ๋ก๊ทธ๋์ค ๋ฐ๋ HTML๋ก ๊ฐ๋จํ ๊ตฌํํ๋๋ก ํ์ฃ .
+
+```html
+<body>
+ <canvas id="c"></canvas>
++ <div id="loading">
++ <div>
++ <div>...loading...</div>
++ <div class="progress"><div id="progressbar"></div></div>
++ </div>
++ </div>
+</body>
+```
+
+`#progressbar`๋ฅผ ์ฐธ์กฐํ ๋ค `width`๋ฅผ ํผ์ผํธ(%) ๋จ์๋ก ํ์ํด ํ์ฌ ์งํ์จ์ ๋ณด์ฌ์ค ๊ฒ๋๋ค. ์ฝ๋ฐฑ์์ ์ด ์คํ์ผ๋ง ์ฒ๋ฆฌํด์ฃผ๋ฉด ๋๊ฒ ๋ค์.
+
+```js
+const manager = new THREE.LoadingManager();
+manager.onLoad = init;
+
++const progressbarElem = document.querySelector('#progressbar');
++manager.onProgress = (url, itemsLoaded, itemsTotal) => {
++ progressbarElem.style.width = `${ itemsLoaded / itemsTotal * 100 | 0 }%`;
++};
+```
+
+์ด๋ฏธ ๋ชจ๋ ๋ชจ๋ธ์ ๋ถ๋ฌ์์ ๋ `init` ํจ์๋ฅผ ํธ์ถํ๊ฒ ํด๋์์ผ๋, ์ฌ๊ธฐ์ `#loading` ์์๋ฅผ ์จ๊ฒจ ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์์ฑ๋๋ค.
+
+```js
+function init() {
++ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
++ const loadingElem = document.querySelector('#loading');
++ loadingElem.style.display = 'none';
+}
+```
+
+์๋๋ ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ๊พธ๋ฏธ๊ธฐ ์ํ CSS์
๋๋ค. `#loading`์ ํ์ด์ง ์ ์ฒด๋ฅผ ๊ฝ ์ฑ์ฐ๊ณ ์์ ์์๋ฅผ ๊ฐ์ด๋ฐ ์ ๋ ฌ์ํต๋๋ค. ๊ทธ๋ฆฌ๊ณ `.progress`๋ ํ๋ก๊ทธ๋์ค ๋ฐ๊ฐ ๋ค์ด๊ฐ ์์ญ์ ์ ์ํ์ฃ . ํ๋ก๊ทธ๋์ค ๋ฐ์ ๊ฐ๋จํ ์ ๋๋ฉ์ด์
๋ ๋ฃ์ด์คฌ์ต๋๋ค.
+
+```css
+#loading {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ font-size: xx-large;
+ font-family: sans-serif;
+}
+#loading>div>div {
+ padding: 2px;
+}
+.progress {
+ width: 50vw;
+ border: 1px solid black;
+}
+#progressbar {
+ width: 0;
+ transition: width ease-out .5s;
+ height: 1em;
+ background-color: #888;
+ background-image: linear-gradient(
+ -45deg,
+ rgba(255, 255, 255, .5) 25%,
+ transparent 25%,
+ transparent 50%,
+ rgba(255, 255, 255, .5) 50%,
+ rgba(255, 255, 255, .5) 75%,
+ transparent 75%,
+ transparent
+ );
+ background-size: 50px 50px;
+ animation: progressanim 2s linear infinite;
+}
+
+@keyframes progressanim {
+ 0% {
+ background-position: 50px 50px;
+ }
+ 100% {
+ background-position: 0 0;
+ }
+}
+```
+
+์ด์ ํ๋ก๊ทธ๋์ค ๋ฐ๊ฐ ์๊ฒผ์ผ๋ ๋ชจ๋ธ์ ์ฒ๋ฆฌํ ์ฐจ๋ก์
๋๋ค. ์ด ๋ชจ๋ธ๋ค์๋ ์ ๋๋ฉ์ด์
์ด ์๋๋ฐ, ์ด ์ ๋๋ฉ์ด์
์ ์ ์ดํ ์ ์๋ค๋ฉด ์ ๋๋ฉ์ด์
์ด ์๋ ์๋ฏธ๊ฐ ์๊ฒ ์ฃ . Three.js๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์ ๋๋ฉ์ด์
๋ค์ ๋ฐฐ์ด ํํ๋ก ์ ์ฅํฉ๋๋ค. ํ์ง๋ง ๋ฐฐ์ด์ด ์๋ ์ด๋ฆ ํํ๋ก ์ ์ฅํ๋ ๊ฒ ๋์ค์ ์ฐ๊ธฐ์ ํธํ๋ ๊ฐ ๋ชจ๋ธ์ `animation` ์์ฑ์ ๋ง๋ค๊ฒ ์ต๋๋ค. ๋ฌผ๋ก ๊ฐ ์ ๋๋ฉ์ด์
์ ์ด๋ฆ์ ๊ณ ์ ํ ๊ฐ์ด์ด์ผ ํ๊ฒ ์ฃ .
+
+```js
++function prepModelsAndAnimations() {
++ Object.values(models).forEach(model => {
++ const animsByName = {};
++ model.gltf.animations.forEach((clip) => {
++ animsByName[clip.name] = clip;
++ });
++ model.animations = animsByName;
++ });
++}
+
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
++ prepModelsAndAnimations();
+}
+```
+
+์ด์ ์ ๋๋ฉ์ด์
์ด ๋ค์ด๊ฐ ๋ชจ๋ธ์ ํ๋ฉด์ ๋์๋ด
์๋ค.
+
+[์ด์ glTF ํ์ผ ์์ ](threejs-load-gltf.html)์ ๋ฌ๋ฆฌ ์ด๋ฒ์๋ ๊ฐ ๋ชจ๋ธ์ ํ๋ ์ด์ ๋ฐฐ์นํ ๊ณํ์
๋๋ค. ๊ทธ๋ฌ๋ ํ์ผ์ ๋ถ๋ฌ์จ ๋ค ๋ฐ๋ก ์ฅ๋ฉด์ ๋ฃ๋ ๋์ ๊ฐ glTF์ ์ฌ ๊ทธ๋ํ(scene), ์ด ๊ฒฝ์ฐ์๋ ์์ง์ด๋ ์บ๋ฆญํฐ๋ฅผ ๋ณต์ฌํด์ผ ํฉ๋๋ค. ๋คํํ Three.js์๋ `SkeletonUtil.clone`์ด๋ผ๋ ํจ์๊ฐ ์์ด ์ด๋ฅผ ์ฝ๊ฒ ๊ตฌํํ ์ ์์ฃ . ๋จผ์ ํด๋น ๋ชจ๋์ ๋ถ๋ฌ์ค๊ฒ ์ต๋๋ค.
+
+```js
+import * as THREE from './resources/three/r115/build/three.module.js';
+import { OrbitControls } from './resources/threejs/r115/examples/jsm/controls/OrbitControls.js';
+import { GLTFLoader } from './resources/threejs/r115/examples/jsm/loaders/GLTFLoader.js';
++import { SkeletonUtils } from './resources/threejs/r115/examples/jsm/utils/SkeletonUtils.js';
+```
+
+๊ทธ๋ฆฌ๊ณ ์๊น ๋ถ๋ฌ์๋ ๋ชจ๋ธ์ ๋ณต์ฌํฉ๋๋ค.
+
+```js
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
+ prepModelsAndAnimations();
+
++ Object.values(models).forEach((model, ndx) => {
++ const clonedScene = SkeletonUtils.clone(model.gltf.scene);
++ const root = new THREE.Object3D();
++ root.add(clonedScene);
++ scene.add(root);
++ root.position.x = (ndx - 3) * 3;
++ });
+}
+```
+
+์ ์ฝ๋์์๋ ๋ถ๋ฌ์จ ๊ฐ ๋ชจ๋ธ์ `gltf.scene`์ ๋ณต์ฌํด ์๋ก์ด `Object3D`์ ์์์ผ๋ก ์ถ๊ฐํ์ต๋๋ค. ๋ถ๋ชจ๋ฅผ ๋ฐ๋ก ๋ง๋ ๊ฑด ๋ชจ๋ธ์ ์ ๋๋ฉ์ด์
์ด ๋ชจ๋ธ์ ๊ฐ ์์์ ์์น๊ฐ์ ์ํฅ์ ๋ฏธ์น๊ธฐ์ ์ฝ๋๋ก ์ง์ ์์น๊ฐ์ ์์ ํ๊ธฐ๋ ์ด๋ ต๊ณ , ์ ๋๋ก ๋ฐ์๋ ์ ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์
๋๋ค.
+
+๊ฐ ๋ชจ๋ธ์ ์ ๋๋ฉ์ด์
์ ์ฌ์ํ๋ ค๋ฉด `AnimationMixer`๋ฅผ ์จ์ผ ํฉ๋๋ค. `AnimationMixer`๋ ํ๋ ์ด์์ `AnimationAction`์ผ๋ก ์ด๋ฃจ์ด์ง๊ณ , ๊ฐ `AnimationAction`์๋ ํ๋์ `AnimationClip`์ด ์์ต๋๋ค. `AnimationAction`์๋ ์ฌ๋ฌ ์ก์
(action)์ ์ด์ด์ ์ฌ์ํ๊ฑฐ๋, ๋ค๋ฅธ ์ ๋๋ฉ์ด์
์ผ๋ก ๋ถ๋๋ฝ๊ฒ ์ ํํ๊ธฐ ๋ฑ ๋ค์ํ ์ค์ ์ด ์์ฃ . ๋น์ฅ์ ์ฒซ ๋ฒ์งธ `AnimationClip`์ผ๋ก ์ก์
์ ๋ง๋ค์ด๋ด
์๋ค. ์ค์ ์ ๋ฐ๊พธ์ง ์๋๋ค๋ฉด ํด๋น ์ ๋๋ฉ์ด์
ํด๋ฆฝ(clip)์ ๋ฐ๋ณตํด ์ฌ์ํ ๊ฒ๋๋ค.
+
+```js
++const mixers = [];
+
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
+ prepModelsAndAnimations();
+
+ Object.values(models).forEach((model, ndx) => {
+ const clonedScene = SkeletonUtils.clone(model.gltf.scene);
+ const root = new THREE.Object3D();
+ root.add(clonedScene);
+ scene.add(root);
+ root.position.x = (ndx - 3) * 3;
+
++ const mixer = new THREE.AnimationMixer(clonedScene);
++ const firstClip = Object.values(model.animations)[0];
++ const action = mixer.clipAction(firstClip);
++ action.play();
++ mixers.push(mixer);
+ });
+}
+```
+
+์ ๋๋ฉ์ด์
์ ์์ํ๊ธฐ ์ํด [`play`](AnimationAction.play) ๋ฉ์๋๋ฅผ ํธ์ถํ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ์์ฑํ `AnimationMixer`๋ค์ ์ ๋ถ `mixers` ๋ฐฐ์ด์ ๋ฃ์์ฃ . ๋ง์ง๋ง์ผ๋ก ๋ ๋๋ง ๋ฃจํ์์ ๊ฐ `AnimationMixer`์ `AnimationMixer.update` ๋ฉ์๋์ ๋ฐ๋ก ์ง์ ํ๋ ์๊ณผ ํ์ฌ ํ๋ ์์ ์๊ฐ๊ฐ์ ๋๊ฒจ์ฃผ์ด์ผ ํฉ๋๋ค.
+
+```js
++let then = 0;
+function render(now) {
++ now *= 0.001; // ์ด ๋จ์๋ก ๋ณํ
++ const deltaTime = now - then;
++ then = now;
+
+ if (resizeRendererToDisplaySize(renderer)) {
+ const canvas = renderer.domElement;
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
+ camera.updateProjectionMatrix();
+ }
+
++ for (const mixer of mixers) {
++ mixer.update(deltaTime);
++ }
+
+ renderer.render(scene, camera);
+
+ requestAnimationFrame(render);
+}
+```
+
+์ด์ ๊ฐ ๋ชจ๋ธ๊ณผ ๋ชจ๋ธ์ ์ฒซ ๋ฒ์งธ ์ ๋๋ฉ์ด์
์ด ๋ณด์ผ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-game-load-models.html"}}}
+
+๋ชจ๋ ์ ๋๋ฉ์ด์
์ ํ์ธํ ์ ์๋๋ก ์์ ๋ฅผ ์์ ํด๋ด
์๋ค. ์ ๋๋ฉ์ด์
ํด๋ฆฝ์ ์ ๋ถ ์ก์
์ผ๋ก ๋ง๋ค์ด ์ฌ์ํ ์ ์๋๋ก ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+-const mixers = [];
++const mixerInfos = [];
+
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
+ prepModelsAndAnimations();
+
+ Object.values(models).forEach((model, ndx) => {
+ const clonedScene = SkeletonUtils.clone(model.gltf.scene);
+ const root = new THREE.Object3D();
+ root.add(clonedScene);
+ scene.add(root);
+ root.position.x = (ndx - 3) * 3;
+
+ const mixer = new THREE.AnimationMixer(clonedScene);
+- const firstClip = Object.values(model.animations)[0];
+- const action = mixer.clipAction(firstClip);
+- action.play();
+- mixers.push(mixer);
++ const actions = Object.values(model.animations).map((clip) => {
++ return mixer.clipAction(clip);
++ });
++ const mixerInfo = {
++ mixer,
++ actions,
++ actionNdx: -1,
++ };
++ mixerInfos.push(mixerInfo);
++ playNextAction(mixerInfo);
+ });
+}
+
++function playNextAction(mixerInfo) {
++ const { actions, actionNdx } = mixerInfo;
++ const nextActionNdx = (actionNdx + 1) % actions.length;
++ mixerInfo.actionNdx = nextActionNdx;
++ actions.forEach((action, ndx) => {
++ const enabled = ndx === nextActionNdx;
++ action.enabled = enabled;
++ if (enabled) {
++ action.play();
++ }
++ });
++}
+```
+
+์ ์ฝ๋์์๋ ๊ฐ ๋ชจ๋ธ๋ง๋ค ์ก์
๋ฐฐ์ด๊ณผ `AnimationMixer`๋ฅผ ๊ฐ์ฒด๋ก ๋ง๋ค์ด ์ ์ฅํ์ต๋๋ค. ์ก์
๋ฐฐ์ด์ ๋ชจ๋ธ์ ๊ฐ `AnimationClip`๋ง๋ค `AnimationAction`์ ํ๋์ฉ ์์ฑํด ๋ฐฐ์ด๋ก ๋ง๋ ๊ฒ์ด์ฃ . ๊ทธ๋ฆฌ๊ณ ํ๋์ ์ก์
์ ์ ์ธํ ๋๋จธ์ง ์ก์
์ `enabled` ์์ฑ์ ๋๋ `playNextAction`์ ํธ์ถํ์ต๋๋ค.
+
+๋ฐ์ดํฐ ํ์์ด ๋ฐ๋์์ผ๋ ๋ ๋๋ง ๋ฃจํ์ ์
๋ฐ์ดํธ ์ชฝ ์ฝ๋๋ ์์ ํด์ผ ํฉ๋๋ค.
+
+```js
+-for (const mixer of mixers) {
++for (const { mixer } of mixerInfos) {
+ mixer.update(deltaTime);
+}
+```
+
+์ซ์ํค 1-8๋ฒ์ ๋๋ฌ ๊ฐ ๋ชจ๋ธ์ ์ ๋๋ฉ์ด์
์ ์ ํํ ์ ์๋๋ก ๋ฆฌ์ค๋๋ฅผ ์ง์ ํฉ๋๋ค.
+
+```js
+window.addEventListener('keydown', (e) => {
+ const mixerInfo = mixerInfos[e.keyCode - 49];
+ if (!mixerInfo) {
+ return;
+ }
+ playNextAction(mixerInfo);
+});
+```
+
+์ด์ ์์ ๋ฅผ ํด๋ฆญํ ๋ค ์ซ์ํค 1-8๋ฒ์ ๋๋ฅด๋ฉด ๊ฐ ๋ฒํธ์ ํด๋นํ๋ ๋ชจ๋ธ์ ์ ๋๋ฉ์ด์
์ด ๋ฐ๋ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-game-check-animations.html"}}}
+
+Three.js ๊ด๋ จ ๋ด์ฉ์ ์ฌ๊ธฐ๊น์ง์
๋๋ค. ์ฌํ๊น์ง ๋ค์์ ํ์ผ์ ๋ถ๋ฌ์ค๋ ๋ฒ, ํ
์ค์ฒ๊ฐ ์์์ง ๋ชจ๋ธ์ ๋ณต์ฌํ๋ ๋ฒ, ํด๋น ๋ชจ๋ธ์ ์ ๋๋ฉ์ด์
์ ์ฌ์ํ๋ ๋ฒ์ ์์๋ดค์ฃ . ์ค์ ๊ฒ์์์๋ `AnimationAction` ๊ฐ์ฒด๋ก ๋ค์ํ ๋์์ ์ง์ ์ฒ๋ฆฌํด์ค์ผ ํฉ๋๋ค.
+
+์, ์ด์ ๊ฒ์์ ๊ธฐ๋ณธ ํ์ ๋ง๋ค์ด๋ด
์๋ค.
+
+์ต์ ๊ฒ์์ ๋ง๋ค ๋๋ ๋ณดํต [Entity Component System(ECS)](https://www.google.com/search?q=entity+component+system)์ ๋ง์ด ์ฌ์ฉํฉ๋๋ค. Entity Component System์์๋ ๊ฒ์์ ์์๋ฅผ ์ฌ๋ฌ ๊ฐ์ *์ปดํฌ๋ํธ(component)*๋ก ์ด๋ฃจ์ด์ง *์ํฐํฐ(entity)*๋ผ ๋ถ๋ฅด์ฃ . ์๋ก์ด ์ํฐํฐ๋ฅผ ์์ฑํ ๋๋ ๋ชจ๋ ์ฝ๋๋ฅผ ์๋ก ์ฐ๋ ๊ฒ์ด ์๋, ๋ฏธ๋ฆฌ ๋ง๋ค์ด ๋์ ์ปดํฌ๋ํธ๋ค์ ์ฎ์ด ์์ฑํฉ๋๋ค.
+
+์์ ์์๋ ์ํฐํฐ๋ฅผ `GameObject`๋ผ ๋ถ๋ฅด๊ฒ ์ต๋๋ค. ์ด๋ ๋จ์ํ ์ปดํฌ๋ํธ ๋ฐฐ์ด๊ณผ `THREE.Object3D`๋ฅผ ํฉ์น ๊ฒ์
๋๋ค.
+
+```js
+function removeArrayElement(array, element) {
+ const ndx = array.indexOf(element);
+ if (ndx >= 0) {
+ array.splice(ndx, 1);
+ }
+}
+
+class GameObject {
+ constructor(parent, name) {
+ this.name = name;
+ this.components = [];
+ this.transform = new THREE.Object3D();
+ parent.add(this.transform);
+ }
+ addComponent(ComponentType, ...args) {
+ const component = new ComponentType(this, ...args);
+ this.components.push(component);
+ return component;
+ }
+ removeComponent(component) {
+ removeArrayElement(this.components, component);
+ }
+ getComponent(ComponentType) {
+ return this.components.find(c => c instanceof ComponentType);
+ }
+ update() {
+ for (const component of this.components) {
+ component.update();
+ }
+ }
+}
+```
+
+`GameObject.update` ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด ๊ฐ ์ปดํฌ๋ํธ์ `update` ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค.
+
+name ์์ฑ์ ๋จ์ํ ๋๋ฒ๊น
์ ์ํ ๊ฒ์
๋๋ค. ์ฝ์์์ `GameObject`๋ฅผ ๋ดค์ ๋ ์ด๋ค ์์์ธ์ง ์ฝ๊ฒ ํ์ธํ ์ ์๊ฒ ์ฃ .
+
+์์ํด ๋ณด์ผ ์ ์๋ ๊ฒ๋ค ๋ช ๊ฐ์ง๋ง ์ง๊ณ ๋์ด๊ฐ๊ฒ ์ต๋๋ค.
+
+`GameObject.addComponent`๋ ์ปดํฌ๋ํธ๋ฅผ ์์ฑํ ๋ ์ฌ์ฉํฉ๋๋ค. GameObject ์์์ ์ปดํฌ๋ํธ๋ฅผ ์์ฑํ๋ ๊ฒ ์ต์ ์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ผ๋, ๊ฐ์ธ์ ์ผ๋ก ์ปดํฌ๋ํธ๊ฐ GameObject ๋ฐ์ ์กด์ฌํ๋ ๊ฑด ์๋ฏธ๊ฐ ์์ด ๋ณด์์ต๋๋ค. ๊ทธ๋์ ์์ฑํ ์ปดํฌ๋ํธ๋ฅผ ์๋์ผ๋ก GameObject์ ๋ฐฐ์ด์ ์ถ๊ฐํ๊ณ , GameObject ์์ฒด๋ ์ปดํฌ๋ํธ์ constructor์ ๋๊ฒจ์ค ์ ์์ผ๋ฉด ํธํ๊ฒ ๋ค๊ณ ์๊ฐํ์ฃ . ์ฝ๊ฒ ๋งํด ์ง๊ธ์ ๋ค์์ฒ๋ผ ์ปดํฌ๋ํธ๋ฅผ ์ถ๊ฐํ์ง๋ง,
+
+```js
+const gameObject = new GameObject(scene, 'foo');
+gameObject.addComponent(TypeOfComponent);
+```
+
+์์ ๊ฐ์ ๋ฐฉ์์ ์ ํธํ์ง ์๋๋ค๋ฉด ๋ค์์ฒ๋ผ ์ถ๊ฐํ ์๋ ์์ต๋๋ค.
+
+```js
+const gameObject = new GameObject(scene, 'foo');
+const component = new TypeOfComponent(gameObject);
+gameObject.addComponent(component);
+```
+
+์ฒซ ๋ฒ์งธ ์ฝ๋๊ฐ ์งง๊ณ ์๋ํ๋๋ค๋ ๋ฉด์์ ๋ ์ข์๊น์, ์๋๋ฉด ๊ธฐ์กด ํ์์ ํด์ณ์ ๋ ๋ณ๋ก์ผ๊น์? ์ ๋ ์ด๋ป๋ค๊ณ ํ๋จํ๊ธฐ๊ฐ ์ด๋ ต๋ค์.
+
+`GameObject.getComponent`๋ ์ปดํฌ๋ํธ์ ํ์
์ ์ด์ฉํด ์ปดํฌ๋ํธ๋ฅผ ์ฐพ์ต๋๋ค. ์ด๋ ํ๋์ GameObject๊ฐ ๊ฐ์ ํ์
์ ์ปดํฌ๋ํธ๋ฅผ ๋ ๊ฐ ์ด์ ์ฌ์ฉํ ์ ์๋ค๋ ์ด์ผ๊ธฐ์ฃ . ๋ฌผ๋ก ๋ ๊ฐ ์ด์ ์ฌ์ฉํ๋ค๊ณ ์๋ฌ๊ฐ ๋๊ฑฐ๋ ํ์ง ์๊ฒ ์ง๋ง, ๋ณ๋์ API๋ฅผ ์ถ๊ฐํ์ง ์๋ ํ ์ ๋ฉ์๋๋ ํญ์ ๊ฐ์ ํ์
์ค ์ฒซ ๋ฒ์งธ ์ปดํฌ๋ํธ๋ง์ ๋ฐํํ ๊ฒ๋๋ค.
+
+์ปดํฌ๋ํธ๊ฐ ๋ค๋ฅธ ์ปดํฌ๋ํธ๋ฅผ ์ฐพ๋ ๊ฑด ํํ ์ผ์
๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ปดํฌ๋ํธ๋ฅผ ์ฐพ์ ๋๋ ์๋ชป ์ฐธ์กฐํ๋ ์ผ์ด ์๋๋ก ํ์
์ ์ฒดํฌํด์ผ ํ์ฃ . ๊ทธ๋ฅ ๊ฐ ์ปดํฌ๋ํธ์ ๊ณ ์ ํ ์ด๋ฆ ์์ฑ์ ์ฃผ๊ณ ๊ทธ ์ด๋ฆ์ผ๋ก ํด๋น ์ปดํฌ๋ํธ๋ฅผ ์ฐพ์ ์๋ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ๊ฐ์ ํ์
์ ์ปดํฌ๋ํธ๋ฅผ ์ฌ๋ฌ ๊ฐ ์ธ ์ ์์ผ๋ ํ์ฅ์ฑ ๋ฉด์์ ์ ๋ฆฌํ ๊ฒ๋๋ค. ํ์ง๋ง ์ด ๋ฐฉ๋ฒ์ ๊ทธ๋ค์ง ์ผ๊ด์ฑ์ด ์์ต๋๋ค. ์ด๋ฒ์๋ ์ด๋ค ์ชฝ์ด ๋ ์ข๋ค๊ณ ํ๋จํ๊ธฐ๊ฐ ์ด๋ ต๋ค์.
+
+์๋๋ ์ปดํฌ๋ํธ์ ๊ธฐ์ด ํด๋์ค์
๋๋ค.
+
+```js
+// ๋ชจ๋ ์ปดํฌ๋ํธ์ ๊ธฐ์ด
+class Component {
+ constructor(gameObject) {
+ this.gameObject = gameObject;
+ }
+ update() {
+ }
+}
+```
+
+์ปดํฌ๋ํธ์ ๊ธฐ์ด ํด๋์ค๊ฐ ํ์ํ ๊น์? ์๋ฐ์คํฌ๋ฆฝํธ๋ ํ์
์ด ๋์จํ ์ธ์ด์ด๊ธฐ์ ๊ตณ์ด ๊ธฐ์ด ํด๋์ค๋ฅผ ์ธ ํ์๋ ์์ต๋๋ค. ๊ฐ ์ปดํฌ๋ํธ์ constructor์์ ์ฒซ ๋ฒ์งธ ์ธ์๊ฐ GameObject์ด๊ธฐ๋ง ํ๋ฉด ๋์ฃ . ๋ง์ฝ GameObject๋ฅผ ๋์ค์ ์ฐธ์กฐํ ํ์๊ฐ ์๋ค๋ฉด ๊ตณ์ด ์ ์ฅํ์ง ์์๋ ๋ ๊ฒ๋๋ค. ํ์ง๋ง ์ ๋ ์ ์ง ์ด ํ์์ด ๋ ์ข์ ๋ณด์ด๋ค์. ๊ธฐ์ด ํด๋์ค๋ฅผ ๋๋ฉด ๋ถ๋ชจ์ GameObject์ ์ฝ๊ฒ ์ ๊ทผํ ์ ์์ ๋ฟ๋ง ์๋๋ผ ๋ค๋ฅธ ์ปดํฌ๋ํธ๋ฅผ ์ฝ๊ฒ ์ฐพ์ ์ ์๊ณ , ์ด๋ค ์ฐจ์ด์ ์ด ์๋์ง๋ ์ฝ๊ฒ ์ ์ ์์ ํ
๋๊น์.
+
+GameObject๋ฅผ ๋ค๋ฃจ๋ ค๋ฉด GameObject๋ฅผ ๊ด๋ฆฌํ๋ ํด๋์ค๋ฅผ ๋ง๋๋ ๊ฒ ์ข์ ๋ฏํฉ๋๋ค. ์ผํ GameObject๋ฅผ ๋ฐฐ์ด ํ์์ผ๋ก ๊ฐ๊ณ ์์ด๋ ๊ด์ฐฎ์ง ์๋ ์ถ์ ์ ์์ผ๋, ์ค์ ๋ก ๊ฒ์์ ํ๋ ์ดํ ๋๋ ์์๊ฐ ์ถ๊ฐ๋๊ธฐ๋ ํ๊ณ , ์์ด์ง๊ธฐ๋ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ์ด GameObject๋ ์ด์ ๋ฐ์ฌํ ๋๋ง๋ค ์ด์ GameObject๋ฅผ ์ถ๊ฐํ ๊ฒ๋๋ค. ๋ชฌ์คํฐ GameObject๊ฐ ๋๊ตฐ๊ฐ์ ์ํด ์ฃฝ๋๋ค๋ฉด ํด๋น GameObject๋ ์ฌ๋ผ์ง๊ฒ ์ฃ . GameObject๋ฅผ ๋ฐฐ์ด๋ก ์ ์ฅํ๋ค๋ฉด ์ญ์คํ๊ตฌ ๋ค์๊ณผ ๊ฐ์ ์์ ์ฝ๋๋ฅผ ์ธ ๊ฒ๋๋ค.
+
+```js
+for (const gameObject of globalArrayOfGameObjects) {
+ gameObject.update();
+}
+```
+
+์ ๋ฐ๋ณต๋ฌธ์ `globalArrayOfGameObjects`์ GameObject๊ฐ ์ถ๊ฐ๋๊ฑฐ๋ ์ ๊ฑฐ๋์ ๊ฒฝ์ฐ, ํน์ ์ปดํฌ๋ํธ์ `update` ๋ฉ์๋์์ ์๋ฌ๋ฅผ ๋์ง๊ฑฐ๋ ์์ ๋ฐ์ ๋์์ ํ ์ ์์ต๋๋ค.
+
+์ด๋ฐ ์ผ์ ๋ฐฉ์งํ๊ธฐ ์ํด ์์ ์ฅ์น๋ฅผ ์ถ๊ฐํด๋ณด๋๋ก ํ์ฃ .
+
+```js
+class SafeArray {
+ constructor() {
+ this.array = [];
+ this.addQueue = [];
+ this.removeQueue = new Set();
+ }
+ get isEmpty() {
+ return this.addQueue.length + this.array.length > 0;
+ }
+ add(element) {
+ this.addQueue.push(element);
+ }
+ remove(element) {
+ this.removeQueue.add(element);
+ }
+ forEach(fn) {
+ this._addQueued();
+ this._removeQueued();
+ for (const element of this.array) {
+ if (this.removeQueue.has(element)) {
+ continue;
+ }
+ fn(element);
+ }
+ this._removeQueued();
+ }
+ _addQueued() {
+ if (this.addQueue.length) {
+ this.array.splice(this.array.length, 0, ...this.addQueue);
+ this.addQueue = [];
+ }
+ }
+ _removeQueued() {
+ if (this.removeQueue.size) {
+ this.array = this.array.filter(element => !this.removeQueue.has(element));
+ this.removeQueue.clear();
+ }
+ }
+}
+```
+
+์ ํด๋์ค๋ `SafeArray`์ ์์๋ฅผ ๋ํ๊ฑฐ๋ ์ ๊ฑฐํ ์ ์๋๋ก ํด์ค๋๋ค. ์๋ณธ ๋ฐฐ์ด์ ๋ฐ๋ณต๋๋ ๋์ ์๋ณธ ๋ฐฐ์ด์ ๋ณ๊ฒฝํ์ง ์๋๋ค๋ ๊ฒ ์ฐจ์ด์ ์ด์ฃ . ๋์ ๋ฐ๋ณต ์ค๊ฐ์ ์ถ๊ฐ๋ ์์๋ `addQueue`์, ์ ๊ฑฐ๋ ์์๋ `removeQueue`์ ๋ค์ด๊ฐ ๋ค, ๋ฐ๋ณต๋ฌธ์ด ๋์๊ฐ์ง ์์ ๋ ์๋ณธ ๋ฐฐ์ด์ ์ ๊ฑฐ/์ถ๊ฐ๋ฉ๋๋ค.
+
+์๋๋ ์ ํด๋์ค๋ฅผ ์ด์ฉํ GameObject์ ๊ด๋ฆฌ ํด๋์ค์
๋๋ค.
+
+```js
+class GameObjectManager {
+ constructor() {
+ this.gameObjects = new SafeArray();
+ }
+ createGameObject(parent, name) {
+ const gameObject = new GameObject(parent, name);
+ this.gameObjects.add(gameObject);
+ return gameObject;
+ }
+ removeGameObject(gameObject) {
+ this.gameObjects.remove(gameObject);
+ }
+ update() {
+ this.gameObjects.forEach(gameObject => gameObject.update());
+ }
+}
+```
+
+์ฌํ๊น์ง ๋ง๋ ์์๋ก ์ฒซ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค์ด๋ด
์๋ค. ์ด ์ปดํฌ๋ํธ๋ ์๊น ๋ง๋ค์๋ ๊ฒ๊ณผ ๊ฐ์ Three.js glTF ๊ฐ์ฒด๋ฅผ ๊ด๋ฆฌํ ๊ฒ๋๋ค. ๊ฐ๋จํ ์ ๋๋ฉ์ด์
์ ์ด๋ฆ์ ๋ฐ์ ํด๋น ์ ๋๋ฉ์ด์
์ ์ฌ์ํ๋ `setAnimation` ๋ฉ์๋๋ง ์๋ก ๋ง๋ค๋๋ก ํ๊ฒ ์ต๋๋ค.
+
+```js
+class SkinInstance extends Component {
+ constructor(gameObject, model) {
+ super(gameObject);
+ this.model = model;
+ this.animRoot = SkeletonUtils.clone(this.model.gltf.scene);
+ this.mixer = new THREE.AnimationMixer(this.animRoot);
+ gameObject.transform.add(this.animRoot);
+ this.actions = {};
+ }
+ setAnimation(animName) {
+ const clip = this.model.animations[animName];
+ // ๋ชจ๋ ์ก์
์ ๋๋๋ค.
+ for (const action of Object.values(this.actions)) {
+ action.enabled = false;
+ }
+ // ํด๋น ํด๋ฆฝ์ ํด๋นํ๋ ์ก์
์ ์์ฑ ๋๋ ๊ฐ์ ธ์ต๋๋ค.
+ const action = this.mixer.clipAction(clip);
+ action.enabled = true;
+ action.reset();
+ action.play();
+ this.actions[animName] = action;
+ }
+ update() {
+ this.mixer.update(globals.deltaTime);
+ }
+}
+```
+
+์ด ํด๋์ค๋ ์๊น ํ๋ ๊ฒ์ฒ๋ผ ๋ถ๋ฌ์จ ์ฌ ๊ทธ๋ํ๋ฅผ ๋ณต์ฌํ๊ณ , `AnimationMixer`๋ฅผ ๋ง๋ญ๋๋ค. ํด๋์ค์ `setAnimation` ๋ฉ์๋๋ ํด๋น ํด๋ฆฝ์ ๋ํ ์ก์
์ด ์กด์ฌํ์ง ์๋๋ค๋ฉด ์๋ก ์์ฑํ๊ณ , ๋ค๋ฅธ ์ก์
์ ์ ๋ถ ๋๋ ์ญํ ์ ํฉ๋๋ค.
+
+์ด ์ฝ๋๋ `globals.deltaTime`์ ์ฌ์ฉํฉ๋๋ค. ์ด ์ ์ญ ๊ฐ์ฒด๋ ๋ง๋ค์ด์ผ๊ฒ ์ฃ .
+
+```js
+const globals = {
+ time: 0,
+ deltaTime: 0,
+};
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ ๋๋ง ๋ฃจํ์์ ์ ์ญ ๊ฐ์ฒด๋ฅผ ์
๋ฐ์ดํธํ๋๋ก ํฉ๋๋ค.
+
+```js
+let then = 0;
+function render(now) {
+ // ์ด ๋จ์๋ก ๋ณํ
+ globals.time = now * 0.001;
+ // ์๊ฐ๊ฐ์ด ๋๋ฌด ํฌ์ง ์๋๋ก ์ ํํฉ๋๋ค.
+ globals.deltaTime = Math.min(globals.time - then, 1 / 20);
+ then = globals.time;
+```
+
+์ ์ฝ๋์์๋ ์๊ฐ๊ฐ์ ๋ฒ์๊ฐ 1/20์ด๋ฅผ ๋์ง ์๋๋ก ํ์ต๋๋ค. ์ด๋ ์ฌ์ฉ์๊ฐ ํญ์ ์จ๊ธฐ๊ฑฐ๋ ํ์ ๊ฒฝ์ฐ ์๊ฐ๊ฐ์ด ๋๋ฌด ์ปค์ง์ง ์๊ฒ ํ๊ธฐ ์ํ ๊ฒ์ด์ฃ . ๋ง์ฝ ์ด๋ ๊ฒ ์ ํ์ ๋์ง ์๋๋ค๋ฉด ์ฌ์ฉ์๊ฐ ํญ์ ๋ช ์ด, ๋๋ ๋ช ๋ถ ์จ๊ฒผ๋ค๊ฐ ๋ค์ ํญ์ ์ด์์ ๋ ํ๋ ์ ๊ฐ ์๊ฐ๊ฐ์ด ๋๋ฌด ์ปค์ง ํ
๊ณ , ์๋์ ๊ฐ์ด ์๊ฐ์ผ๋ก ์๋ ฅ์ ๊ณ์ฐํ๋ ๊ฒฝ์ฐ ์บ๋ฆญํฐ๊ฐ ์๊ฐ์ด๋ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ผ ์ ์์ต๋๋ค.
+
+```js
+position += velocity * deltaTime;
+```
+
+`deltaTime`์ ์ต๋๊ฐ์ ์ค์ ํ๋ฉด ์ด๋ฐ ๋ฌธ์ ๋ฅผ ๋ง์ ์ ์์ฃ .
+
+์ด์ ํ๋ ์ด์ด ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค์ด๋ด
์๋ค.
+
+```js
+class Player extends Component {
+ constructor(gameObject) {
+ super(gameObject);
+ const model = models.knight;
+ this.skinInstance = gameObject.addComponent(SkinInstance, model);
+ this.skinInstance.setAnimation('Run');
+ }
+}
+```
+
+ํ๋ ์ด์ด ์ปดํฌ๋ํธ๋ ์ด๊ธฐํ ์์ `'Run'`์ ์ธ์๋ก `setAnimation`์ ํธ์ถํฉ๋๋ค. ๊ฐ์ธ์ ์ผ๋ก ๋ฏธ๋ฆฌ ์ด๋ค ์ ๋๋ฉ์ด์
์ด ์๋์ง ๋ณด๋ ค๊ณ ์ด์ ์์ ๋ฅผ ์์ ํด ์ ๋๋ฉ์ด์
์ ์ด๋ฆ์ ์ถ๋ ฅํ๋๋ก ํ์ฃ .
+
+```js
+function prepModelsAndAnimations() {
+ Object.values(models).forEach(model => {
++ console.log('------->:', model.url);
+ const animsByName = {};
+ model.gltf.animations.forEach((clip) => {
+ animsByName[clip.name] = clip;
++ console.log(' ', clip.name);
+ });
+ model.animations = animsByName;
+ });
+}
+```
+
+์๋๋ ์ค์ ๋ก [์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ๋ฐ์ ์ฝ์](https://developers.google.com/web/tools/chrome-devtools/console/javascript)์ ์ถ๋ ฅ๋ ๊ฒฐ๊ณผ์
๋๋ค.
+
+```
+ ------->: resources/models/animals/Pig.gltf
+ Idle
+ Death
+ WalkSlow
+ Jump
+ Walk
+ ------->: resources/models/animals/Cow.gltf
+ Walk
+ Jump
+ WalkSlow
+ Death
+ Idle
+ ------->: resources/models/animals/Llama.gltf
+ Jump
+ Idle
+ Walk
+ Death
+ WalkSlow
+ ------->: resources/models/animals/Pug.gltf
+ Jump
+ Walk
+ Idle
+ WalkSlow
+ Death
+ ------->: resources/models/animals/Sheep.gltf
+ WalkSlow
+ Death
+ Jump
+ Walk
+ Idle
+ ------->: resources/models/animals/Zebra.gltf
+ Jump
+ Walk
+ Death
+ WalkSlow
+ Idle
+ ------->: resources/models/animals/Horse.gltf
+ Jump
+ WalkSlow
+ Death
+ Walk
+ Idle
+ ------->: resources/models/knight/KnightCharacter.gltf
+ Run_swordRight
+ Run
+ Idle_swordLeft
+ Roll_sword
+ Idle
+ Run_swordAttack
+```
+
+์ด ์ข๊ฒ๋ ๋๋ฌผ๋ค์ ์ ๋๋ฉ์ด์
์ด๋ฆ์ด ์ ๋ถ ๋๊ฐ๋ค์. ๋์ค์ ํธํ ๋ฏํฉ๋๋ค. ๋ญ, ๊ทธ๊ฑด ๋์ค ์๊ธฐ๊ณ , ์ง๊ธ์ ํ๋ ์ด์ด์ ์ ๋๋ฉ์ด์
์ค `Run`๋ง ์ ๊ฒฝ์์๋ค.
+
+์ด์ ๋ง๋ ์ปดํฌ๋ํธ๋ฅผ ์จ ๋ณด๊ฒ ์ต๋๋ค. ๋จผ์ `init` ํจ์๋ฅผ ์ฝ๊ฐ ์์ ํฉ๋๋ค. `init` ํจ์๋ `GameObject`๋ฅผ ๋ง๋ค๊ณ ๊ฑฐ๊ธฐ์ `Player` ์ปดํฌ๋ํธ๋ฅผ ์ถ๊ฐํ๋ ์ญํ ์ ํ ๊ฒ๋๋ค.
+
+```js
+const globals = {
+ time: 0,
+ deltaTime: 0,
+};
++const gameObjectManager = new GameObjectManager();
+
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
+ prepModelsAndAnimations();
+
++ {
++ const gameObject = gameObjectManager.createGameObject(scene, 'player');
++ gameObject.addComponent(Player);
++ }
+}
+```
+
+๋ ๋๋ง ๋ฃจํ์์ `gameObjectManager.update`๋ฅผ ํธ์ถํ๋๋ก ํฉ๋๋ค.
+
+```js
+let then = 0;
+function render(now) {
+ // ์ด ๋จ์๋ก ๋ณํ
+ globals.time = now * 0.001;
+ // ์๊ฐ๊ฐ์ด ๋๋ฌด ํฌ์ง ์๋๋ก ์ ํํฉ๋๋ค.
+ globals.deltaTime = Math.min(globals.time - then, 1 / 20);
+ then = globals.time;
+
+ if (resizeRendererToDisplaySize(renderer)) {
+ const canvas = renderer.domElement;
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
+ camera.updateProjectionMatrix();
+ }
+
+- for (const { mixer } of mixerInfos) {
+- mixer.update(deltaTime);
+- }
++ gameObjectManager.update();
+
+ renderer.render(scene, camera);
+
+ requestAnimationFrame(render);
+}
+```
+
+์์ ๋ฅผ ์คํํ๋ฉด ํ๋ ์ด์ด ํ๋๋ง ๋ณด์ผ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-game-just-player.html"}}}
+
+๋จ์ํ Entity Component System์ ๊ตฌํํ๋ ๋ฐ๋ง ๋๋ฌด ๋ง์ ์ฝ๋๋ฅผ ์ด ๊ฒ ์๋๊ฐ ์ถ์ง๋ง, ์ด ์ ๋๊ฐ ๋๋ถ๋ถ์ ๊ฒ์์ด ๊ฐ์ถฐ์ผํ ๊ธฐ๋ณธ์
๋๋ค.
+
+์ด์ ์ฌ์ฉ์ ์
๋ ฅ ์์คํ
์ ์ถ๊ฐํด๋ด
์๋ค. ๋จ์ํ ํค๋ณด๋ ์ด๋ฒคํธ์ ์ง์ ์ฝ๋๋ฅผ ์์ฑํ๊ธฐ๋ณด๋ค ํด๋์ค๋ฅผ ๋ง๋ค์ด ์ฝ๋์ ๋ค๋ฅธ ๋ถ๋ถ์์๋ `์ผ์ชฝ`, `์ค๋ฅธ์ชฝ`์ ํ์ธํ ์ ์๋๋ก ํ๊ฒ ์ต๋๋ค. ์ด๋ฌ๋ฉด `์ผ์ชฝ`, `์ค๋ฅธ์ชฝ` ๋ฑ ๋ค์ํ ํค๋ฅผ ๋ค์ํ ๋ฐฉ๋ฒ์ผ๋ก ์ง์ ํ ์ ์๊ฒ ์ฃ . ๋จผ์ ํค๋ณด๋ ์ด๋ฒคํธ๋ถํฐ ์ง์ ํฉ์๋ค.
+
+```js
+/**
+ * ํค ๋๋ ๋ฒํผ์ ์ํ๋ฅผ ์ถ์ ํฉ๋๋ค.
+ *
+ * ์ผ์ชฝ ๋ฐฉํฅํค๊ฐ ๋๋ ธ๋์ง ํ์ธํ๋ ค๋ฉด
+ *
+ * inputManager.keys.left.down
+ *
+ * ์ ํ์ธํ๊ณ , ํ์ฌ ํ๋ ์์์ ์ผ์ชฝ ํค๋ฅผ ๋๋ ๋์ง ํ์ธํ๋ ค๋ฉด
+ *
+ * inputManager.keys.left.justPressed
+ *
+ * ๋ฅผ ํ์ธํ๋ฉด ๋ฉ๋๋ค.
+ *
+ * ํ์ฌ ๋ฑ๋ก๋ ํค๋ 'left', 'right', 'a', 'b', 'up', 'down' ์
๋๋ค.
+ **/
+class InputManager {
+ constructor() {
+ this.keys = {};
+ const keyMap = new Map();
+
+ const setKey = (keyName, pressed) => {
+ const keyState = this.keys[keyName];
+ keyState.justPressed = pressed && !keyState.down;
+ keyState.down = pressed;
+ };
+
+ const addKey = (keyCode, name) => {
+ this.keys[name] = { down: false, justPressed: false };
+ keyMap.set(keyCode, name);
+ };
+
+ const setKeyFromKeyCode = (keyCode, pressed) => {
+ const keyName = keyMap.get(keyCode);
+ if (!keyName) {
+ return;
+ }
+ setKey(keyName, pressed);
+ };
+
+ addKey(37, 'left');
+ addKey(39, 'right');
+ addKey(38, 'up');
+ addKey(40, 'down');
+ addKey(90, 'a');
+ addKey(88, 'b');
+
+ window.addEventListener('keydown', (e) => {
+ setKeyFromKeyCode(e.keyCode, true);
+ });
+ window.addEventListener('keyup', (e) => {
+ setKeyFromKeyCode(e.keyCode, false);
+ });
+ }
+ update() {
+ for (const keyState of Object.values(this.keys)) {
+ if (keyState.justPressed) {
+ keyState.justPressed = false;
+ }
+ }
+ }
+}
+```
+
+์ ์ฝ๋๋ ํค๊ฐ ๋๋ ธ๋์ง, ๋๋์ง๋ฅผ ์ถ์ ํฉ๋๋ค. ํน์ ํค๋ฅผ ๋๋ ๋์ง ํ์ธํ๋ ค๋ฉด ์๋ฅผ ๋ค์ด `inputManager.keys.left.down`์ ์ฒดํฌํ๋ฉด ๋๊ณ , ํด๋น ๊ฐ์ฒด์ `justPressed`๋ฅผ ์ฒดํฌํ๋ฉด ์ฌ์ฉ์๊ฐ ํด๋น ํ๋ ์์์ ํค๋ฅผ ๋๋ ๋์ง ํ์ธํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ์ ํ๋ฅผ ๊ตฌํํ ๊ฒฝ์ฐ ์ ์ ๊ฐ ํค๋ฅผ ๋๋ฅด๊ณ ์๋์ง๋ฅผ ์ถ์ ํ ์ด์ ๋ ์๊ฒ ์ฃ . ๋จ์ํ ํด๋น ํ๋ ์์์ ํค๋ฅผ ๋๋ ๋์ง๋ง ํ์ธํ๋ฉด ๋ ๊ฒ๋๋ค.
+
+์ด์ `InputManager`์ ์ธ์คํด์ค๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
+const globals = {
+ time: 0,
+ deltaTime: 0,
+};
+const gameObjectManager = new GameObjectManager();
++const inputManager = new InputManager();
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ ๋๋ง ๋ฃจํ์์ `update` ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ก ํฉ๋๋ค.
+
+```js
+function render(now) {
+
+ ...
+
+ gameObjectManager.update();
++ inputManager.update();
+
+ ...
+}
+```
+
+`gameObjectManager.update` ์ ์ ์ด ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด `justPressed`๊ฐ ํญ์ `false`์ผ ํ
๋ `gameObjectManager.update` ๋ค์ ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ก ํ์ต๋๋ค.
+
+์ด์ `Player` ์ปดํฌ๋ํธ์ ์ฌ์ฉ์ ์
๋ ฅ์ ์ถ๊ฐํด๋ด
์๋ค.
+
+```js
++const kForward = new THREE.Vector3(0, 0, 1);
+const globals = {
+ time: 0,
+ deltaTime: 0,
++ moveSpeed: 16,
+};
+
+class Player extends Component {
+ constructor(gameObject) {
+ super(gameObject);
+ const model = models.knight;
+ this.skinInstance = gameObject.addComponent(SkinInstance, model);
+ this.skinInstance.setAnimation('Run');
++ this.turnSpeed = globals.moveSpeed / 4;
+ }
++ update() {
++ const { deltaTime, moveSpeed } = globals;
++ const { transform } = this.gameObject;
++ const delta = (inputManager.keys.left.down ? 1 : 0) +
++ (inputManager.keys.right.down ? -1 : 0);
++ transform.rotation.y += this.turnSpeed * delta * deltaTime;
++ transform.translateOnAxis(kForward, moveSpeed * deltaTime);
++ }
+}
+```
+
+์ ์ฝ๋์์๋ ํ๋ ์ด์ด๋ฅผ ์์ผ๋ก ์์ง์ด๊ธฐ ์ํด `Object3D.transformOnAxis`๋ฅผ ์ฌ์ฉํ์ต๋๋ค. `Object3D.transformOnAxis`๋ ์ง์ญ ๊ณต๊ฐ์ ๊ธฐ์ค์ผ๋ก ํ๊ธฐ์ ํด๋น ๊ฐ์ฒด๊ฐ ์ฅ๋ฉด์ ๋ฃจํธ(root) ์์์ ์ํ ๋๋ง ์ ์์ ์ผ๋ก ์๋ํฉ๋๋ค. <a class="footnote" href="#parented" id="parented-backref">1</a>
+
+๋ํ ์ ์ญ ๊ฐ์ฒด์ `moveSpeed`๋ฅผ ์ถ๊ฐํ๊ณ ์ด๋ฅผ `turnSpeed`์ ๊ธฐ์ค์ผ๋ก ์ผ์์ต๋๋ค. ์ด๋ ์บ๋ฆญํฐ๊ฐ ๋ชฉํ๋ฅผ ํฅํด ์๋์ ์ผ๋ก ๋น ๋ฅด๊ฒ ๋๋๋ก ๋ง๋ ๊ฒ์ผ๋ก, ์ด `turnSpeed`์ ๊ฐ์ด ๋๋ฌด ์๋ค๋ฉด ์บ๋ฆญํฐ๋ ๋ชฉํ ์ฃผ์๋ฅผ ๋น๋น ๋๊ธฐ๋ง ํ๊ณ ์ ๋ ๋ชฉํ์ ๋ฟ์ง๋ ๋ชปํ ๊ฒ๋๋ค. ๋ฌผ๋ก ์ ๊ฐ์ ์ด๋ค ์ํ์ ๊ณต์์ ์ฌ์ฉํ ๊ฒ์ด ์๋๋๋ค. ๊ทธ๋ฅ ๋์ถฉ ๋๋ ค ๋ฃ์ ๊ฒ์ด์ฃ .
+
+์ด๋๋ก๋ ์์ ๋ ์ ์๋ํ ํ
์ง๋ง ํ๋ ์ด์ด๊ฐ ํ๋ฉด์ ๋ฒ์ด๋๋ฉด ์บ๋ฆญํฐ๊ฐ ์ด๋ ์๋์ง ์ฐพ๊ธฐ๊ฐ ์ด๋ ค์ธ ๊ฒ๋๋ค. ์ผ๋จ ํ๋ฉด์์ ๋ฒ์ด๋ ๋ค ์ผ์ ์๊ฐ์ด ์ง๋๋ฉด ํ๋ ์ด์ด๋ฅผ ๋ค์ ์ค์ ์ผ๋ก ์๊ฐ์ด๋์ํค๊ธฐ๋ก ํฉ์๋ค. Three.js์ `Frustum` ํด๋์ค๋ฅผ ์ด์ฉํ๋ฉด ํน์ ์ ์ด ์นด๋ฉ๋ผ์ ์ ๋์ฒด(frustum) ์์ ์๋์ง ์ ์ ์์ต๋๋ค.
+
+๋จผ์ ์นด๋ฉ๋ผ๋ก ์ ๋์ฒด๋ฅผ ๋ง๋ค์ด์ผ ํฉ๋๋ค. ํ๋ ์ด์ด ์ปดํฌ๋ํธ์์ ์ด๊ฑธ ์ฒ๋ฆฌํ ์๋ ์์ง๋ง, ๋ค๋ฅธ ์์๋ ์ด ๋ฐฉ๋ฒ์ ์จ์ผ ํ ์ ์์ผ๋ ์นด๋ฉ๋ผ์ ์ ๋์ฒด๋ฅผ ๊ด๋ฆฌํ๋ ์๋ก์ด ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+class CameraInfo extends Component {
+ constructor(gameObject) {
+ super(gameObject);
+ this.projScreenMatrix = new THREE.Matrix4();
+ this.frustum = new THREE.Frustum();
+ }
+ update() {
+ const { camera } = globals;
+ this.projScreenMatrix.multiplyMatrices(
+ camera.projectionMatrix,
+ camera.matrixWorldInverse);
+ this.frustum.setFromProjectionMatrix(this.projScreenMatrix);
+ }
+}
+```
+
+๋ค์์ผ๋ก `init` ํจ์์์ ๋ฐฉ๊ธ ๋ง๋ ์ปดํฌ๋ํธ๋ก ์๋ก์ด GameObject๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
+ prepModelsAndAnimations();
+
++ {
++ const gameObject = gameObjectManager.createGameObject(camera, 'camera');
++ globals.cameraInfo = gameObject.addComponent(CameraInfo);
++ }
+
+ {
+ const gameObject = gameObjectManager.createGameObject(scene, 'player');
+ gameObject.addComponent(Player);
+ }
+}
+```
+
+`Player` ์ปดํฌ๋ํธ์ ๋ฐฉ๊ธ ๋ง๋ GameObject๋ฅผ ์ฌ์ฉํ๋ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+class Player extends Component {
+ constructor(gameObject) {
+ super(gameObject);
+ const model = models.knight;
+ this.skinInstance = gameObject.addComponent(SkinInstance, model);
+ this.skinInstance.setAnimation('Run');
+ this.turnSpeed = globals.moveSpeed / 4;
++ this.offscreenTimer = 0;
++ this.maxTimeOffScreen = 3;
+ }
+ update() {
+- const { deltaTime, moveSpeed } = globals;
++ const { deltaTime, moveSpeed, cameraInfo } = globals;
+ const { transform } = this.gameObject;
+ const delta = (inputManager.keys.left.down ? 1 : 0) +
+ (inputManager.keys.right.down ? -1 : 0);
+ transform.rotation.y += this.turnSpeed * delta * deltaTime;
+ transform.translateOnAxis(kForward, moveSpeed * deltaTime);
+
++ const { frustum } = cameraInfo;
++ if (frustum.containsPoint(transform.position)) {
++ this.offscreenTimer = 0;
++ } else {
++ this.offscreenTimer += deltaTime;
++ if (this.offscreenTimer >= this.maxTimeOffScreen) {
++ transform.position.set(0, 0, 0);
++ }
++ }
+ }
+}
+```
+
+์์ ๋ฅผ ์คํํ๊ธฐ ์ ์ ๋ชจ๋ฐ์ผ ํ๊ฒฝ์ ์ํ ํฐ์น ์ธํฐํ์ด์ค๋ฅผ ์ถ๊ฐํ๊ฒ ์ต๋๋ค. ๋จผ์ ํฐ์น ์ด๋ฒคํธ๋ฅผ ๋ฐ์ HTML ์์๋ฅผ ๋ง๋ญ๋๋ค.
+
+```html
+<body>
+ <canvas id="c"></canvas>
++ <div id="ui">
++ <div id="left"><img src="resources/images/left.svg"></div>
++ <div style="flex: 0 0 40px;"></div>
++ <div id="right"><img src="resources/images/right.svg"></div>
++ </div>
+ <div id="loading">
+ <div>
+ <div>...loading...</div>
+ <div class="progress"><div id="progressbar"></div></div>
+ </div>
+ </div>
+</body>
+```
+
+๋ฒํผ์ ์คํ์ผ๋ ์์ฑํฉ๋๋ค.
+
+```css
+#ui {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 100%;
+ height: 100%;
+ display: flex;
+ justify-items: center;
+ align-content: stretch;
+}
+#ui>div {
+ display: flex;
+ align-items: flex-end;
+ flex: 1 1 auto;
+}
+.bright {
+ filter: brightness(2);
+}
+#left {
+ justify-content: flex-end;
+}
+#right {
+ justify-content: flex-start;
+}
+#ui img {
+ padding: 10px;
+ width: 80px;
+ height: 80px;
+ display: block;
+}
+```
+
+์ ๊ฐ ์ฌ์ฉํ ๋ฐฉ๋ฒ์ ํ๋์ div ์์, `#ui`๋ก ํ๋ฉด ์ ์ฒด๋ฅผ ์ฑ์ฐ๊ณ , ํด๋น ์์์ ์์์ผ๋ก ํ๋ฉด์ ๋๋ต ๋ฐ์ ์ฐจ์งํ๋ `#left`์ `#right`๋ฅผ ๊ฐ๊ฐ ์์ชฝ์, ๊ฐ์ด๋ฐ์๋ 40px์ง๋ฆฌ ๊ตฌ๋ถ์ ์ ๋ฃ์ด ํ๋ฉด ์ ์ฒด๊ฐ ์ด๋ฒคํธ๋ฅผ ๊ฐ์งํ๋๋ก ํ ๊ฒ์
๋๋ค. ์ด๋ฌ๋ฉด ์ฌ์ฉ์๊ฐ ์ผ์ชฝ ํ์ดํ๋ฅผ ๋๋ฅธ ๋ค ์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก ์๊ฐ๋ฝ์ ์์ง์์ ๋ `InputManager`์ `keys.left`๊ณผ `keys.right`๋ฅผ ์
๋ฐ์ดํธํ ์ ์๊ฒ ์ฃ . ๊ตณ์ด ์์ ํ์ดํ๋ฅผ ๋๋ฅด๋๋ผ ๊ณ ์ํ์ง ์์๋ ๋๋ ์ด ํธ์ด ํจ์ฌ ๋์ ๊ฒ๋๋ค.
+
+```js
+class InputManager {
+ constructor() {
+ this.keys = {};
+ const keyMap = new Map();
+
+ const setKey = (keyName, pressed) => {
+ const keyState = this.keys[keyName];
+ keyState.justPressed = pressed && !keyState.down;
+ keyState.down = pressed;
+ };
+
+ const addKey = (keyCode, name) => {
+ this.keys[name] = { down: false, justPressed: false };
+ keyMap.set(keyCode, name);
+ };
+
+ const setKeyFromKeyCode = (keyCode, pressed) => {
+ const keyName = keyMap.get(keyCode);
+ if (!keyName) {
+ return;
+ }
+ setKey(keyName, pressed);
+ };
+
+ addKey(37, 'left');
+ addKey(39, 'right');
+ addKey(38, 'up');
+ addKey(40, 'down');
+ addKey(90, 'a');
+ addKey(88, 'b');
+
+ window.addEventListener('keydown', (e) => {
+ setKeyFromKeyCode(e.keyCode, true);
+ });
+ window.addEventListener('keyup', (e) => {
+ setKeyFromKeyCode(e.keyCode, false);
+ });
+
++ const sides = [
++ { elem: document.querySelector('#left'), key: 'left' },
++ { elem: document.querySelector('#right'), key: 'right' },
++ ];
++
++ const clearKeys = () => {
++ for (const {key} of sides) {
++ setKey(key, false);
++ }
++ };
++
++ const checkSides = (e) => {
++ for (const {elem, key} of sides) {
++ let pressed = false;
++ const rect = elem.getBoundingClientRect();
++ for (const touch of e.touches) {
++ const x = touch.clientX;
++ const y = touch.clientY;
++ const inRect = x >= rect.left && x < rect.right &&
++ y >= rect.top && y < rect.bottom;
++ if (inRect) {
++ pressed = true;
++ }
++ }
++ setKey(key, pressed);
++ }
++ };
++
++ const uiElem = document.querySelector('#ui');
++ uiElem.addEventListener('touchstart', (e) => {
++ e.preventDefault();
++ checkSides(e);
++ }, { passive: false });
++ uiElem.addEventListener('touchmove', (e) => {
++ e.preventDefault(); // ํ๋ฉด ์คํฌ๋กค ๋ฐฉ์ง
++ checkSides(e);
++ }, { passive: false });
++ uiElem.addEventListener('touchend', () => {
++ clearKeys();
++ });
++
++ function handleMouseMove(e) {
++ e.preventDefault();
++ checkSides({
++ touches: [e],
++ });
++ }
++
++ function handleMouseUp() {
++ clearKeys();
++ window.removeEventListener('mousemove', handleMouseMove, { passive: false });
++ window.removeEventListener('mouseup', handleMouseUp);
++ }
++
++ uiElem.addEventListener('mousedown', (e) => {
++ handleMouseMove(e);
++ window.addEventListener('mousemove', handleMouseMove);
++ window.addEventListener('mouseup', handleMouseUp);
++ }, { passive: false });
+ }
+ update() {
+ for (const keyState of Object.values(this.keys)) {
+ if (keyState.justPressed) {
+ keyState.justPressed = false;
+ }
+ }
+ }
+}
+```
+
+์ด์ ํ์ดํ ํค๋ ํ๋ฉด์ ํฐ์นํด ์บ๋ฆญํฐ๋ฅผ ์์ง์ผ ์ ์์ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-game-player-input.html"}}}
+
+๋ฌผ๋ก ํ๋ ์ด์ด๊ฐ ํ๋ฉด ๋ฐ์ผ๋ก ๋๊ฐ์ ๋ ์นด๋ฉ๋ผ๋ฅผ ์์ง์ด๊ฑฐ๋, "ํ๋ฉด ๋ฐ = ์ฃฝ์"์ด๋ผ๋ ์ค์ ์ ๋ฃ์ ์๋ ์์ต๋๋ค. ํ์ง๋ง ์ด๊ฒ๊น์ง ๋ค๋ฃฌ๋ค๋ฉด ์ ๊ทธ๋๋ ๊ธด ๊ธ์ด ๋ ๊ธธ์ด์ง ํ
๋ ์ด ๋ฐฉ๋ฒ์ผ๋ก ๋ง์กฑํ๊ฒ ์ต๋๋ค.
+
+์ด์ ๋๋ฌผ์ ์ถ๊ฐํด๋ด
์๋ค. `Player`์ ๋น์ทํ ๋ฐฉ๋ฒ์ผ๋ก `Animal` ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+class Animal extends Component {
+ constructor(gameObject, model) {
+ super(gameObject);
+ const skinInstance = gameObject.addComponent(SkinInstance, model);
+ skinInstance.mixer.timeScale = globals.moveSpeed / 4;
+ skinInstance.setAnimation('Idle');
+ }
+}
+```
+
+์ ์ฝ๋์์๋ `AnimationMixer.timeScale`์ ์ค์ ํด ์ ๋๋ฉ์ด์
์๋๊ฐ ์ด๋ ์๋์ ๋น๋กํ๋๋ก ๋ง๋ค์์ต๋๋ค. ์ด๋ฌ๋ฉด ์ด๋ ์๋์ ๊ฐ์ด ์ ๋๋ฉ์ด์
์๋๊ฐ ๋นจ๋ผ์ง๊ณ ๋๋ ค์ง๊ฒ ์ฃ .
+
+๋ค์์ผ๋ก `init` ํจ์์์ ๊ฐ ๋๋ฌผ์ ๋ฐฐ์นํฉ๋๋ค.
+
+```js
+function init() {
+ // ํ๋ก๊ทธ๋์ค ๋ฐ๋ฅผ ์จ๊น๋๋ค.
+ const loadingElem = document.querySelector('#loading');
+ loadingElem.style.display = 'none';
+
+ prepModelsAndAnimations();
+ {
+ const gameObject = gameObjectManager.createGameObject(camera, 'camera');
+ globals.cameraInfo = gameObject.addComponent(CameraInfo);
+ }
+
+ {
+ const gameObject = gameObjectManager.createGameObject(scene, 'player');
+ globals.player = gameObject.addComponent(Player);
+ globals.congaLine = [gameObject];
+ }
+
++ const animalModelNames = [
++ 'pig',
++ 'cow',
++ 'llama',
++ 'pug',
++ 'sheep',
++ 'zebra',
++ 'horse',
++ ];
++ animalModelNames.forEach((name, ndx) => {
++ const gameObject = gameObjectManager.createGameObject(scene, name);
++ gameObject.addComponent(Animal, models[name]);
++ gameObject.transform.position.x = (ndx + 1) * 5;
++ });
+}
+```
+
+๋๋ฌผ๋ค์ ๋ฐฐ์นํ๊ณ ๋๋ด๋ฉด ์ฌ์ฌํ๋ ๋ญ๊ฐ๋ฅผ ์ถ๊ฐํด์ผ๊ฒ ๋ค์.
+
+๋๋ฌผ์ด ํ๋ ์ด์ด๋ฅผ ๋ฐ๋ผ ๊ธฐ์ฐจ๋์ด๏ผ๋ฅผ ํ๊ฒ ํด๋ด
์๋ค. ํ๋ ์ด์ด๊ฐ ๋๋ฌผ์ ๊ฐ๊น์ด ๊ฐ์ ๋๋ง ๊ธฐ์ฐจ์ ํฉ๋ฅํ๋๋ก ํ๊ฒ ์ต๋๋ค. ์ด๋ฅผ ๊ตฌํํ๋ ค๋ฉด ์๋์ ๊ฐ์ ๋ชจ์
(์ํ, state)์ด ํ์ํ ๊ฒ๋๋ค.
+
+โป ์๋ฌธ์ "conga line"์
๋๋ค. ๊ธฐ์ฐจ๋์ด์ ์ ์ฌํ ๊ผฌ๋ฆฌ์๊ธฐ ๋์ด๋ก, ์ฐ๋ฆฌ์๊ฒ ๋ ์ต์ํ "๊ธฐ์ฐจ๋์ด"๋ก ์์ญํ์ต๋๋ค. ์ญ์ฃผ.
+
+* ๊ฐ๋งํ ์ ์๋ ๋ชจ์
(Idle):
+
+ ํ๋ ์ด์ด๊ฐ ๊ฐ๊น์์ง๊ธฐ ์ ๊น์ง์ ๋ชจ์
์
๋๋ค.
+
+* ๊ธฐ์ฐจ์ ๋์ ๊ฐ ๋๊น์ง ๊ธฐ๋ค๋ฆฌ๋ ๋ชจ์
(Wait for End of Line):
+
+ ํ๋ ์ด์ด๊ฐ ๋๋ฌผ๊ณผ ๋ฟ๋๋ผ๋ ๊ธฐ์ฐจ์ ๋์ ํฉ๋ฅํด์ผ ํ๋ฏ๋ก ๊ทธ ์ ๊น์ง ๊ธฐ๋ค๋ฆฌ๋ ๋ชจ์
์
๋๋ค.
+
+* ๋ฐ๋ผ๋ถ๊ธฐ(Go to Last):
+
+ ์์ ์ด ๋ฐ๋ผ๊ฐ ๋์์ด ์๋ ์์น๋ก ์ด๋ํจ๊ณผ ๋์์ ๋ฐ๋ผ๊ฐ ๋์์ด ์ด๋ ์๋์ง ๊ธฐ๋กํฉ๋๋ค.
+
+* ๋ฐ๋ผ๊ฐ๊ธฐ(Follow):
+
+ ์์ ์ด ๋ฐ๋ผ๊ฐ๋ ๋์์ ํ์ฌ ์์น๋ฅผ ๊ธฐ๋กํจ๊ณผ ๋์์ ๋์์ด ์์๋ ์์น๋ก ์ด๋ํฉ๋๋ค.
+
+์ด๋ฐ ์ํ๋ฅผ ๋ค๋ฃฐ ๋ฐฉ๋ฒ์ ์์ฃผ ๋ค์ํฉ๋๋ค. ๋ณดํต์ [์ ํ ์ํ ๊ธฐ๊ณ(Finite State Machine)](https://www.google.com/search?q=finite+state+machine)์ ์ด๋ฐ ์ํ๋ฅผ ๋ค๋ฃฐ ํฌํผ ํด๋์ค๋ฅผ ์ฌ์ฉํ์ฃ .
+
+```js
+class FiniteStateMachine {
+ constructor(states, initialState) {
+ this.states = states;
+ this.transition(initialState);
+ }
+ get state() {
+ return this.currentState;
+ }
+ transition(state) {
+ const oldState = this.states[this.currentState];
+ if (oldState && oldState.exit) {
+ oldState.exit.call(this);
+ }
+ this.currentState = state;
+ const newState = this.states[state];
+ if (newState.enter) {
+ newState.enter.call(this);
+ }
+ }
+ update() {
+ const state = this.states[this.currentState];
+ if (state.update) {
+ state.update.call(this);
+ }
+ }
+}
+```
+
+์ ํด๋์ค๋ ์์ ๋งํ ํฌํผ ํด๋์ค๋ฅผ ๊ฐ๋จํ ๊ตฌํํ ๊ฒ์
๋๋ค. ํด๋์ค๋ ์์ฑ ์ ์ํ๋ค์ ๊ฐ์ฒด๋ฅผ ๋ฐ๊ณ , ๊ฐ ์ํ์๋ `enter`, `update`, `exit`์ด๋ผ๋ ๋ฉ์๋๊ฐ ์์ต๋๋ค. ์ํ๋ฅผ ๋ฐ๊พธ๋ ค๋ฉด `FiniteStateMachine.transition`์ ํธ์ถํ ๋ ์๋ก์ด ์ด๋ฆ์ ๋๊ฒจ์ฃผ๋ฉด ๋์ฃ . ๋ง์ฝ ํ์ฌ ์ํ์ `exit` ๋ฉ์๋๊ฐ ์๋ค๋ฉด ํด๋น ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์๋ก์ด ์ํ์ `enter` ๋ฉ์๋๊ฐ ์์ ๊ฒฝ์ฐ `enter` ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค. ๋ง์ง๋ง์ผ๋ก ๋งค ํ๋ ์๋ง๋ค `FiniteStateMachine.update`๋ฅผ ํธ์ถํ๋ฉด ๊ฐ ์ํ์ `update` ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค.
+
+์ด์ ์ด ํด๋์ค๋ฅผ ํ์ฉํด ๋๋ฌผ๋ค์ ์ํ๋ฅผ ๋ฐ๊ฟ๋ด
์๋ค.
+
+```js
+// ๋งค๊ฐ๋ณ์ obj1๊ณผ obj2์ด ๊ฐ๊น๋ค๋ฉด true๋ฅผ ๋ฐํํฉ๋๋ค.
+function isClose(obj1, obj1Radius, obj2, obj2Radius) {
+ const minDist = obj1Radius + obj2Radius;
+ const dist = obj1.position.distanceTo(obj2.position);
+ return dist < minDist;
+}
+
+// v ์ ๊ฐ์ด -min๊ณผ +min ์ฌ์ด๊ฐ ๋๋๋ก ํฉ๋๋ค.
+function minMagnitude(v, min) {
+ return Math.abs(v) > min
+ ? min * Math.sign(v)
+ : v;
+}
+
+const aimTowardAndGetDistance = function() {
+ const delta = new THREE.Vector3();
+
+ return function aimTowardAndGetDistance(source, targetPos, maxTurn) {
+ delta.subVectors(targetPos, source.position);
+ // ๋ฐ๋ผ๋ณผ ๋ฐฉํฅ์ ๊ณ์ฐํฉ๋๋ค.
+ const targetRot = Math.atan2(delta.x, delta.z) + Math.PI * 1.5;
+ // ๋ ๊ฐ๊น์ด ๋ฐฉํฅ์ผ๋ก ํ์ ํฉ๋๋ค.
+ const deltaRot = (targetRot - source.rotation.y + Math.PI * 1.5) % (Math.PI * 2) - Math.PI;
+ // maxTurn๋ณด๋ค ๋น ๋ฅธ ์๋๋ก ๋์ง ์๋๋ก ํฉ๋๋ค.
+ const deltaRotation = minMagnitude(deltaRot, maxTurn);
+ // rotation ๊ฐ์ 0์์ Math.PI * 2 ์ฌ์ด๋ก ์ ์งํฉ๋๋ค.
+ source.rotation.y = THREE.MathUtils.euclideanModulo(
+ source.rotation.y + deltaRotation, Math.PI * 2);
+ // ๋ชฉํ๊น์ง์ ๊ฑฐ๋ฆฌ๋ฅผ ๋ฐํํฉ๋๋ค.
+ return delta.length();
+ };
+}();
+
+class Animal extends Component {
+ constructor(gameObject, model) {
+ super(gameObject);
++ const hitRadius = model.size / 2;
+ const skinInstance = gameObject.addComponent(SkinInstance, model);
+ skinInstance.mixer.timeScale = globals.moveSpeed / 4;
++ const transform = gameObject.transform;
++ const playerTransform = globals.player.gameObject.transform;
++ const maxTurnSpeed = Math.PI * (globals.moveSpeed / 4);
++ const targetHistory = [];
++ let targetNdx = 0;
++
++ function addHistory() {
++ const targetGO = globals.congaLine[targetNdx];
++ const newTargetPos = new THREE.Vector3();
++ newTargetPos.copy(targetGO.transform.position);
++ targetHistory.push(newTargetPos);
++ }
++
++ this.fsm = new FiniteStateMachine({
++ idle: {
++ enter: () => {
++ skinInstance.setAnimation('Idle');
++ },
++ update: () => {
++ // ํ๋ ์ด์ด๊ฐ ๊ทผ์ฒ์ ์๋์ง ํ์ธํฉ๋๋ค.
++ if (isClose(transform, hitRadius, playerTransform, globals.playerRadius)) {
++ this.fsm.transition('waitForEnd');
++ }
++ },
++ },
++ waitForEnd: {
++ enter: () => {
++ skinInstance.setAnimation('Jump');
++ },
++ update: () => {
++ // ๊ธฐ์ฐจ์ ๊ฐ์ฅ ๋ง์ง๋ง์ ์๋ gameObject๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
++ const lastGO = globals.congaLine[globals.congaLine.length - 1];
++ const deltaTurnSpeed = maxTurnSpeed * globals.deltaTime;
++ const targetPos = lastGO.transform.position;
++ aimTowardAndGetDistance(transform, targetPos, deltaTurnSpeed);
++ // ๊ธฐ์ฐจ์ ๋ง์ง๋ง์ ์๋ ์์๊ฐ ๊ทผ์ฒ์ ์๋์ง ํ์ธํฉ๋๋ค.
++ if (isClose(transform, hitRadius, lastGO.transform, globals.playerRadius)) {
++ this.fsm.transition('goToLast');
++ }
++ },
++ },
++ goToLast: {
++ enter: () => {
++ // ๋ฐ๋ผ๊ฐ ๋์์ ๊ธฐ๋กํฉ๋๋ค. remember who we're following
++ targetNdx = globals.congaLine.length - 1;
++ // ๊ธฐ์ฐจ์ ๋ง์ง๋ง์ ์ค์ค๋ก๋ฅผ ์ถ๊ฐํฉ๋๋ค.
++ globals.congaLine.push(gameObject);
++ skinInstance.setAnimation('Walk');
++ },
++ update: () => {
++ addHistory();
++ // ๊ธฐ๋ก๋ ์์น ์ค ๊ฐ์ฅ ๋์ค ์์น๋ก ์ด๋ํฉ๋๋ค.
++ const targetPos = targetHistory[0];
++ const maxVelocity = globals.moveSpeed * globals.deltaTime;
++ const deltaTurnSpeed = maxTurnSpeed * globals.deltaTime;
++ const distance = aimTowardAndGetDistance(transform, targetPos, deltaTurnSpeed);
++ const velocity = distance;
++ transform.translateOnAxis(kForward, Math.min(velocity, maxVelocity));
++ if (distance <= maxVelocity) {
++ this.fsm.transition('follow');
++ }
++ },
++ },
++ follow: {
++ update: () => {
++ addHistory();
++ // ๊ฐ์ฅ ์ค๋๋ ์์น๊ฐ์ ์ง์ฐ๊ณ ์๊ธฐ ์์ ์ ์์น๊ฐ์ ์ถ๊ฐํฉ๋๋ค.
++ const targetPos = targetHistory.shift();
++ transform.position.copy(targetPos);
++ const deltaTurnSpeed = maxTurnSpeed * globals.deltaTime;
++ aimTowardAndGetDistance(transform, targetHistory[0], deltaTurnSpeed);
++ },
++ },
++ }, 'idle');
++ }
++ update() {
++ this.fsm.update();
++ }
+}
+```
+
+ํ ๋ฒ์ ๋๋ฌด ๋ง์ ์ฝ๋๋ฅผ ๋ณด์ฌ์ค ๋ฏํ์ง๋ง ์ ์ฝ๋๋ ๋ฐฉ๊ธ ์ธ๊ธํ ์ญํ ์ ํฉ๋๋ค. ๊ฐ ์ํ์ ๋ํ ์ฝ๋๋ฅผ ๋ณด๊ณ ์ด๋ค ์์ผ๋ก ์๋ํ๋์ง ๋ถ์ํด๋ณด๊ธฐ ๋ฐ๋๋๋ค.
+
+์ฌ๊ธฐ์ ๋ช ๊ฐ์ง ์์๋ฅผ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ํ๋ ์ด์ด๊ฐ ์๊ธฐ ์์ ์ ์ ์ญ ๊ฐ์ฒด(globals)์ ์ถ๊ฐํด ๋ค๋ฅธ ๋๋ฌผ์ด ์์ ์ ์์น๋ฅผ ์ถ์ ํ๋๋ก ํด์ผ ํ๊ณ , ๋ ๊ธฐ์ฐจ์ ๋จธ๋ฆฌ๋ฅผ ํ๋ ์ด์ด์ `GameObject`๋ก ์ง์ ํด์ผ ํฉ๋๋ค.
+
+```js
+function init() {
+
+ ...
+
+ {
+ const gameObject = gameObjectManager.createGameObject(scene, 'player');
++ globals.player = gameObject.addComponent(Player);
++ globals.congaLine = [gameObject];
+ }
+
+}
+```
+
+๊ฐ ๋ชจ๋ธ์ ํฌ๊ธฐ๋ ๊ณ์ฐํด์ผ ํฉ๋๋ค.
+
+```js
+function prepModelsAndAnimations() {
++ const box = new THREE.Box3();
++ const size = new THREE.Vector3();
+ Object.values(models).forEach(model => {
++ box.setFromObject(model.gltf.scene);
++ box.getSize(size);
++ model.size = size.length();
+ const animsByName = {};
+ model.gltf.animations.forEach((clip) => {
+ animsByName[clip.name] = clip;
+ // ์ด๋ฐ ๋ถ๋ถ์ .blend ํ์ผ์์ ์์ ํ๋ ๊ฒ ์ข์ต๋๋ค.
+ if (clip.name === 'Walk') {
+ clip.duration /= 2;
+ }
+ });
+ model.animations = animsByName;
+ });
+}
+```
+
+๊ทธ๋ฆฌ๊ณ ํ๋ ์ด์ด๊ฐ ์๊ธฐ ์์ ์ ํฌ๊ธฐ๋ฅผ ๊ธฐ๋กํ๋๋ก ํฉ๋๋ค.
+
+```js
+class Player extends Component {
+ constructor(gameObject) {
+ super(gameObject);
+ const model = models.knight;
++ globals.playerRadius = model.size / 2;
+```
+
+์ด์ ์ ์๊ฐํด๋ณด๋ ํ๋ ์ด์ด๊ฐ ์๋๋ผ ๊ธฐ์ฐจ์ ๋จธ๋ฆฌ๋ฅผ ๋ฐ๋ผ๋ณด๊ฒ ํ๋ ํธ์ด ๋ ๋์๊ฒ ๋ค์. ์ด๊ฑด ๋์ค์ ๋์์ ๊ณ ์น๋๋ก ํ๊ฒ ์ต๋๋ค.
+
+์์ ๋ฅผ ์ฒ์ ๋ง๋ค์์ ๋๋ ๋๋ฌผ๋ค์ด ๋ชจ๋ ๊ฐ์ ํฌ๊ธฐ์ ๊ฒฝ๊ณ ์(radius)์ ์ผ์ง๋ง, ์ด๋ ๊ฒ ํ๊ณ ๋ณด๋ ๋ง๊ณผ ํผ๊ทธ(๊ฐ์์ง)์ ํฌ๊ธฐ๊ฐ ๊ฐ์ ๊ฒ ๋ง์ด ์ ๋๋ค๋ ์๊ฐ์ด ๋ค์์ต๋๋ค. ๊ทธ๋์ ๊ฐ ๋ชจ๋ธ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ๊ฒฝ๊ณ ์์ ๋ฐ๋ก ์ง์ ํ์ฃ . ๊ทธ๋ฆฌ๊ณ ์ํ๋ฅผ ๋ณด์ฌ์ฃผ๋ฉด ์ข๊ฒ ๋ค๋ ์๊ฐ์ด ๋ค์ด ์ํ๋ฅผ ๋ณด์ฌ ์ค `StatusDisplayHelper` ์ปดํฌ๋ํธ๋ฅผ ์ถ๊ฐํ์ต๋๋ค.
+
+๋ํ `PolarGridHelper`๋ฅผ ์จ ๊ฐ ์บ๋ฆญํฐ์ ๊ฒฝ๊ณ ์์ด ๋ณด์ด๋๋ก ํ๊ณ , [HTML ์์๋ฅผ 3D๋ก ์ ๋ ฌํ๊ธฐ](threejs-align-html-elements-to-3d.html)์์ ์ผ๋ ๋ฐฉ๋ฒ์ผ๋ก ๊ฐ ์บ๋ฆญํฐ์ ์ํ๋ฅผ HTML๋ก ๋ณด์ฌ์ฃผ๋๋ก ํ์ต๋๋ค.
+
+๋จผ์ ๊ฐ ์์๋ฅผ ๋ด์ HTML์ ์ถ๊ฐํฉ๋๋ค.
+
+```html
+<body>
+ <canvas id="c"></canvas>
+ <div id="ui">
+ <div id="left"><img src="resources/images/left.svg"></div>
+ <div style="flex: 0 0 40px;"></div>
+ <div id="right"><img src="resources/images/right.svg"></div>
+ </div>
+ <div id="loading">
+ <div>
+ <div>...loading...</div>
+ <div class="progress"><div id="progressbar"></div></div>
+ </div>
+ </div>
++ <div id="labels"></div>
+</body>
+```
+
+CSS๋ ์์ฑํฉ๋๋ค.
+
+```css
+#labels {
+ position: absolute; /* ๊ธฐ์ค ์์ ์๋ก ์ฌ๋ผ๊ฐ๋๋ก ํฉ๋๋ค. */
+ left: 0; /* ๊ธฐ์ค ์์ ์ผ์ชฝ ์๋ก ์ ๋ ฌํฉ๋๋ค. */
+ top: 0;
+ color: white;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ pointer-events: none;
+}
+#labels>div {
+ position: absolute; /* ๊ธฐ์ค ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ํฉ๋๋ค. */
+ left: 0; /* ๊ธฐ์ค ์์์ ์ผ์ชฝ ์๋ก ์ ๋ ฌํฉ๋๋ค. */
+ top: 0;
+ font-size: large;
+ font-family: monospace;
+ user-select: none; /* ํ
์คํธ๋ฅผ ์ ํํ ์ ์๋๋ก ํฉ๋๋ค. */
+ text-shadow: /* ๊ธ์์ ๊ฒ์ ์ค๊ณฝ์ ์ ๋ฃ์ต๋๋ค. */
+ -1px -1px 0 #000,
+ 0 -1px 0 #000,
+ 1px -1px 0 #000,
+ 1px 0 0 #000,
+ 1px 1px 0 #000,
+ 0 1px 0 #000,
+ -1px 1px 0 #000,
+ -1px 0 0 #000;
+}
+```
+
+์๋๋ `StateDisplayHelper` ์ปดํฌ๋ํธ์
๋๋ค.
+
+```js
+const labelContainerElem = document.querySelector('#labels');
+
+class StateDisplayHelper extends Component {
+ constructor(gameObject, size) {
+ super(gameObject);
+ this.elem = document.createElement('div');
+ labelContainerElem.appendChild(this.elem);
+ this.pos = new THREE.Vector3();
+
+ this.helper = new THREE.PolarGridHelper(size / 2, 1, 1, 16);
+ gameObject.transform.add(this.helper);
+ }
+ setState(s) {
+ this.elem.textContent = s;
+ }
+ setColor(cssColor) {
+ this.elem.style.color = cssColor;
+ this.helper.material.color.set(cssColor);
+ }
+ update() {
+ const { pos } = this;
+ const { transform } = this.gameObject;
+ const { canvas } = globals;
+ pos.copy(transform.position);
+
+ /**
+ * ํด๋น ์์น๊ฐ์ ์ ๊ทํํ๋ฉด x์ y ๊ฐ์ -1์์ +1 ์ฌ์ด์ ๊ฐ์ด ๋ฉ๋๋ค.
+ * x = -1 ์ด๋ฉด ์ผ์ชฝ, y = -1 ์ด๋ฉด ์ค๋ฅธ์ชฝ์ด์ฃ .
+ **/
+ pos.project(globals.camera);
+
+ // ์ ๊ทํํ ์์น๊ฐ์ CSS ์์น๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
+ const x = (pos.x * .5 + .5) * canvas.clientWidth;
+ const y = (pos.y * -.5 + .5) * canvas.clientHeight;
+
+ // HTML ์์๋ฅผ ํด๋น ์์น๋ก ์ฎ๊น๋๋ค.
+ this.elem.style.transform = `translate(-50%, -50%) translate(${ x }px, ${ y }px)`;
+ }
+}
+```
+
+๋๋ฌผ ์ปดํฌ๋ํธ๋ฅผ ์์ฑํ ๋ ์ ์ปดํฌ๋ํธ๋ฅผ ์ถ๊ฐํ๋๋ก ํฉ๋๋ค.
+
+```js
+class Animal extends Component {
+ constructor(gameObject, model) {
+ super(gameObject);
++ this.helper = gameObject.addComponent(StateDisplayHelper, model.size);
+
+ ...
+
+ }
+ update() {
+ this.fsm.update();
++ const dir = THREE.MathUtils.radToDeg(this.gameObject.transform.rotation.y);
++ this.helper.setState(`${ this.fsm.state }:${ dir.toFixed(0) }`);
+ }
+}
+```
+
+์ถ๊ฐ๋ก dat.GUI๋ฅผ ์ด์ฉํด ์ ๋๋ฒ๊น
์์๋ค๋ฅผ ์ผ๊ณ ๋ ์ ์๋๋ก ํฉ๋๋ค.
+
+```js
+import * as THREE from './resources/three/r115/build/three.module.js';
+import { OrbitControls } from './resources/threejs/r115/examples/jsm/controls/OrbitControls.js';
+import { GLTFLoader } from './resources/threejs/r115/examples/jsm/loaders/GLTFLoader.js';
+import { SkeletonUtils } from './resources/threejs/r115/examples/jsm/utils/SkeletonUtils.js';
++import { GUI } from '../3rdparty/dat.gui.module.js';
+```
+
+```js
++const gui = new GUI();
++gui.add(globals, 'debug').onChange(showHideDebugInfo);
++showHideDebugInfo();
+
+const labelContainerElem = document.querySelector('#labels');
++function showHideDebugInfo() {
++ labelContainerElem.style.display = globals.debug ? '' : 'none';
++}
++showHideDebugInfo();
+
+class StateDisplayHelper extends Component {
+
+ ...
+
+ update() {
++ this.helper.visible = globals.debug;
++ if (!globals.debug) {
++ return;
++ }
+
+ ...
+ }
+}
+```
+
+๊ฒ์์ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ํ์ ์์ฑํ๋ค์.
+
+{{{example url="../threejs-game-conga-line.html"}}}
+
+์๋ ์ฒ์์๋ [์ง๋ ์ด ๊ฒ์](https://www.google.com/search?q=snake+game)์ ๋ง๋ค๋ ค๊ณ ํ์ต๋๋ค. ๋๋ฌผ์ด ๊ธฐ์ฐจ์ ๋ถ์ด ๊ธฐ์ฐจ๊ฐ ๊ธธ์ด์ง์๋ก ์ฅ์ ๋ฌผ์ ํผํ๊ธฐ ์ด๋ ค์์ง๋ ๊ฒ์์ด์ฃ . ์์ ์ ๋ช ๊ฐ์ง ์ฅ์ ๋ฌผ ๋๊ฑฐ๋ ํ๋ฉด ๋๋ ์ ๋ฒฝ์ ์ธ์ฐ๊ธฐ๋ ํ์ต๋๋ค.
+
+ํ์ง๋ง ์์ ์์ ์ฌ์ฉํ ๋๋ฌผ์ ์ด์ ์ ํฉํ์ง ์์ต๋๋ค. ์์ ์ ๋๋ฌผ๋ค์ ๋๋ถ๋ถ ์์์ ๋ดค์ ๋ ๊ธธ๊ณ ํญ์ด ์๊ฑฐ๋ ์. ์๋๋ ์ผ๋ฃฉ๋ง์ ์์์ ๋ณธ ๊ฒ์
๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/zebra.png" style="width: 113px;"></div>
+
+์์ ๋ ์ ๋ชจ์์ ๊ฒฝ๊ณ๋ก ์์๋ผ๋ฆฌ์ ์ถฉ๋์ ๊ฐ์งํ๊ธฐ์ ์๋์ ๊ฐ์ด ์ธํ๋ฆฌ์ ๋ฟ๋ ๊ฒฝ์ฐ๋ ์ถฉ๋๋ก ๊ฐ์งํ ๊ฒ๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/zebra-collisions.svg" style="width: 400px;"></div>
+
+๋๋ฌผ๊ณผ ๋๋ฌผ์ด ๋ถ๋ชํ๋ ๊ฒฝ์ฐ์๋ ๋ง์ฐฌ๊ฐ์ง์
๋๋ค. ํนํ ๊ฒ์์์๋ ์ด๋์ ์ข์ ๊ฒ ์์ฃ .
+
+2D ์ฌ๊ฐํ์ ๋ง๋ค์ด ์ถฉ๋์ ๊ฐ์งํ๋ ๊ฒ๋ ์๊ฐํ์ผ๋, ๋ฐ๋ก ๋๋ฌด ๋ง์ ์ฝ๋๋ฅผ ์จ์ผ ํ๋ค๋ ๊ฑธ ๊นจ๋ฌ์์ต๋๋ค. ์์ ์ ๊ฐ ๋ชจ๋ธ์ ๋ค๋ฅธ ํฌ๊ธฐ์ ์ฌ๊ฐํ์ ์ถ๊ฐํ๋ ๋ฐ๋ ๊ทธ๋ค์ง ๋ง์ ์ฝ๋๊ฐ ๋ค์ด๊ฐ์ง ์์ต๋๋ค. ํ์ง๋ง ์ด๋ ๊ฒ ๋ช ๊ฐ์ง ๋ชจ๋ธ์ ์ฌ๊ฐํ์ ์ถ๊ฐํด๋ณด๋ฉด ๊ณง ์ถฉ๋์ ๊ฐ์งํ๋ ์ฝ๋๋ฅผ ์๋ด์ผ ํ ํ์๊ฐ ์๊ธธ ๊ฒ๋๋ค. ๋จผ์ ๊ฐ ๋ชจ๋ธ์ด ์๋ก ์ถฉ๋ํ๋์ง ํ์ธํด์ผ ํ๋ ๊ฐ ๋ชจ๋ธ์ ๊ฒฝ๊ณ ์ ์ก๋ฉด์ฒด๋ ๊ฒฝ๊ณ ๊ตฌ์ฒด, ๋๋ ๋ชจ๋ธ๊ณผ ๊ฐ์ ๋ฐฉํฅ์ผ๋ก ์ ๋ ฌ๋ ๊ฒฝ๊ณ ์ก๋ฉด์ฒด๋ฅผ ๊ฒ์ฌํด์ผ ํฉ๋๋ค. ๊ฐ ๋ชจ๋ธ์ ๊ฒฝ๊ณ๊ฐ ์ถฉ๋ํ๋ค๋ ๊ฑด ๋ ๋ชจ๋ธ์ด *์ด์ฉ๋ฉด* ์๋ก ์ถฉ๋ํ์ ์๋ ์๋ค๋ ์ด์ผ๊ธฐ์ด๊ธฐ์, ๊ฐ ๋ชจ๋ธ์ด *์ค์ ๋ก* ์ถฉ๋ํ๋์ง ๊ฒ์ฌํ๊ธฐ ์ํด ํด๋น ๋ชจ๋ธ๋ค์ ๋ค์ ๊ฒ์ฌํด์ผ ํฉ๋๋ค. ๋์ฒด๋ก ๊ฒฝ๊ณ ๊ตฌ์ฒด๋ฅผ ๊ฒ์ฌํ๋ ๊ฒ๋ง ํด๋ ๊ฝค ๋ง์ ์์
์ด ํ์ํฉ๋๋ค. ๊ฐ๋ฅํ๋ค๋ฉด ๊ฐ ์์๊ฐ ๊ทผ์ ํ๋์ง์ ์ฌ๋ถ๋ง ๊ฒ์ฌํ๋ ๋ฑ ๋ ํน์ํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ๊ฒ ๋ ๊ฒฝ์ ์ ์ด์ฃ .
+
+๋ํ ์ถฉ๋ ์ฌ๋ถ๋ฅผ ๊ฒ์ฌํ๊ธฐ๋ง ํ๋ ๊ฒ์ผ๋ก ๋๋๋ ๊ฒ์ด ์๋๋ผ ์ถฉ๋ ์์คํ
๋ ๊ตฌ์ถํด์ผ ํฉ๋๋ค. ๊ทธ๋ ๊ทธ๋ ๊ฐ ๋ชจ๋ธ์๊ฒ "๋ ๋ค๋ฅธ ์ ๋ ์ถฉ๋ํ๋?" ์ด๋ ๊ฒ ๋ฌผ์ด๋ณด๋ ๊ฒ๋ณด๋ค ์์คํ
์ด ์ง์ ์ถฉ๋ ์ฌ๋ถ๋ฅผ ์ด๋ฒคํธ ๋ฑ์ผ๋ก ์๋ ค์ฃผ๋ ๊ฒ ๋ ํธํ ํ
๋๊น์. ์ถฉ๋ ์์คํ
์ ์ถฉ๋๊ณผ ๊ด๋ จํ ์ด๋ฒคํธ๋ ์ฝ๋ฐฑ์ ์ฌ์ฉํฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ ์ฅ์ ์ ๋ชจ๋ ์ถฉ๋์ ํ ๋ฒ๋ง ๊ฒ์ฌํ๊ธฐ์ ๊ฐ ๋ชจ๋ธ์ด "๋ด๊ฐ ๋ค๋ฅธ ์ ๋ ์ถฉ๋ํ๋?" ์ด๋ ๊ฒ ๊ฒ์ฌ๋ฅผ ๋ฐ๋ก ํ ํ์๊ฐ ์๋ค๋ ๊ฑฐ์ฃ . ์ฐ์ฐ๋์ ํจ์ฌ ์ค์ผ ์ ์์ต๋๋ค.
+
+์ฌ๊ฐํ์ ํ์ธํ๋ ์ ๋์ ๊ฐ๋จํ ์ถฉ๋ ์์คํ
์ ๋ง๋๋ ์ฝ๋๋ 100-300 ์ค ์ ๋๋ฅผ ๋์ง ์์ ๊ฒ๋๋ค. ํ์ง๋ง ์์ ์ ๋น๊ตํ๋ฉด ์ฌ์ ํ ๋ง์ ์ฝ๋์ด๋ ์ง๊ธ์ ์ด๋๋ก ๋จ๊ฒจ ๋๊ฒ ์ต๋๋ค.
+
+์๋ํด๋ด์งํ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ค๋ฅธ ์บ๋ฆญํฐ ์ค ์์์ ๋ฐ๋ผ๋ดค์ ๋ ๊ฐ์ฅ ์ํ์ ๊ฐ๊น์ด ์บ๋ฆญํฐ๋ฅผ ์ฐพ๋ ๊ฒ๋๋ค๏ผ. ์ธ๊ฐํ ์บ๋ฆญํฐ์ ๊ฒฝ์ฐ๋ ๋๋ถ๋ถ ์ ์๋ํ ํ
๊ณ , ๋๋ฌผ๊ณผ ๋๋ฌผ์ ๊ฒฝ์ฐ๋ ์ผ๋ถ ๊ฒฝ์ฐ๋ ์ ์๋ํ ๊ฒ๋๋ค. ํ์ง๋ง ๋๋ฌผ๊ณผ ์ธํ๋ฆฌ์ ๊ฒฝ์ฐ๋ ๊ฐ์งํ์ง ๋ชปํ๊ฒ ์ฃ . ์๋ ํ๋ฉด ์ฃผ์์ ์ธํ๋ฆฌ๋ ๋ค๋ถ, ๋ฅ๊ทผ ๋ง๋๋ฅผ ๋๋ฌ๋ณด๋ ค๊ณ ํ์ผ๋ ์ด๋ฌ๋ ค๋ฉด 120์์ 200๊ฐ ์ ๋์ ์์๋ฅผ ๋ ๋ง๋ค์ด์ผ ํ๊ณ , ์์์ ์ธ๊ธํ ์ต์ ํ ๋ฌธ์ ์ ๋ถ๋ช์ณค์ ๊ฒ๋๋ค.
+
+โป ์์ผ๊ฐ ๋๋ฌธ์ ์นด๋ฉ๋ผ์ ์ค์ฌ์์ ๋ฒ์ด๋ ์๋ก ๋จธ๋ฆฌ ์๊ฐ ์๋ ์์ด ๋ณด์ด๋ ๊ฑธ ์ด์ฉํ ๋ฐฉ๋ฒ. ์ญ์ฃผ.
+
+์ด๋ฐ ์ฌ๋ฌ ๋ฌธ์ ๋๋ฌธ์ ๋๋ถ๋ถ์ ๊ฒ์๋ค์ด ๊ธฐ์กด์ ์ฐ๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ด ๋ฐฉ๋ฒ๋ค ์ค์๋ ๋ฌผ๋ฆฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ฐ๋ ๊ฒ๋ค๋ ์์ฃ . ๋ฌผ๋ฆฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์์๊ฐ ์๋ก ์ถฉ๋ํ๋์ง ํ์ธํ๋ ๊ธฐ๋ฅ์ด ํ์๊ธฐ์, ์ ๊ฐ ์์์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๊ธฐ๋ ํฉ๋๋ค.
+
+Three.js์ ์์ ์ค [ammo.js](https://github.com/kripken/ammo.js/)๋ฅผ ์ฌ์ฉํ ๊ฒ์ ๋ณด๋ฉด ์ด๋ฐ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฐพ๋ ๋ฐ ๋์์ด ๋ ์ง๋ ๋ชจ๋ฅด๊ฒ ๋ค์.
+
+๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ์ฅ์ ๋ฌผ์ ์ผ์ ํ ๊ฒฉ์(grid)์ ๋๊ณ ํ๋ ์ด์ด์ ๋๋ฌผ์ด ํด๋น ๊ฒฉ์๋ง ์ฐธ์กฐํ๊ฒ ํ๋ ๊ฒ๋๋ค. ์ฑ๋ฅ ๋ฉด์์ ๊ต์ฅํ ์ข์ ๋ฐฉ๋ฒ์ธ๋ฐ, ์ด ๋ํ ์ฌ๋ฌ๋ถ์ด ์ง์ ์ฐ์ตํ ์ ์๋ ๐ ์์๋ก ๋จ๊ฒจ ๋๋ฉด ์ข๊ฒ ๋ค๋ ์๊ฐ์ด ๋ค๋๊ตฐ์.
+
+๋ง๋ถ์ฌ ๋๋ถ๋ถ์ ๊ฒ์ ์์คํ
์๋ [์ฝ๋ฃจํด(coroutine)](https://www.google.com/search?q=coroutines)์ด๋ผ๋ ๊ฒ์ด ์์ต๋๋ค. ์ฝ๋ฃจํด์ ํน์ ์์
์ ํ๋ ๋์ ๋ฉ์ท๋ค๊ฐ ๋์ค์ ๋ค์ ์์ํ๋ ๋ฃจํด(routine)์ ๋งํ์ฃ .
+
+ํ๋ ์ด์ด ์์ ์ํ๋ฅผ ๋์ ๋
ธ๋๋ก ๋๋ฌผ๋ค์ ๊ผฌ์๋ ๊ฒ์ฒ๋ผ ํด๋ณด๊ฒ ์ต๋๋ค. ๊ตฌํํ ์ ์๋ ๋ฐฉ๋ฒ์ ์์ฃผ ๋ง์ง๋ง, ์์ ์์๋ ์ฝ๋ฃจํด์ ์ฌ์ฉํด ์ด๋ฅผ ๊ตฌํํ๊ฒ ์ต๋๋ค.
+
+๋จผ์ ์ฝ๋ฃจํด์ ๊ด๋ฆฌํ๋ ํด๋์ค๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+function* waitSeconds(duration) {
+ while (duration > 0) {
+ duration -= globals.deltaTime;
+ yield;
+ }
+}
+
+class CoroutineRunner {
+ constructor() {
+ this.generatorStacks = [];
+ this.addQueue = [];
+ this.removeQueue = new Set();
+ }
+ isBusy() {
+ return this.addQueue.length + this.generatorStacks.length > 0;
+ }
+ add(generator, delay = 0) {
+ const genStack = [generator];
+ if (delay) {
+ genStack.push(waitSeconds(delay));
+ }
+ this.addQueue.push(genStack);
+ }
+ remove(generator) {
+ this.removeQueue.add(generator);
+ }
+ update() {
+ this._addQueued();
+ this._removeQueued();
+ for (const genStack of this.generatorStacks) {
+ const main = genStack[0];
+ // ๋ค๋ฅธ ์ฝ๋ฃจํด์ด ํด๋น ์์๋ฅผ ์ ๊ฑฐํ์ ๊ฒฝ์ฐ
+ if (this.removeQueue.has(main)) {
+ continue;
+ }
+ while (genStack.length) {
+ const topGen = genStack[genStack.length - 1];
+ const { value, done } = topGen.next();
+ if (done) {
+ if (genStack.length === 1) {
+ this.removeQueue.add(topGen);
+ break;
+ }
+ genStack.pop();
+ } else if (value) {
+ genStack.push(value);
+ } else {
+ break;
+ }
+ }
+ }
+ this._removeQueued();
+ }
+ _addQueued() {
+ if (this.addQueue.length) {
+ this.generatorStacks.splice(this.generatorStacks.length, 0, ...this.addQueue);
+ this.addQueue = [];
+ }
+ }
+ _removeQueued() {
+ if (this.removeQueue.size) {
+ this.generatorStacks = this.generatorStacks.filter(genStack => !this.removeQueue.has(genStack[0]));
+ this.removeQueue.clear();
+ }
+ }
+}
+```
+
+์ ํด๋์ค๋ ๋ค๋ฅธ ์ฝ๋ฃจํด์ด ์คํ๋๋ ๋์ ์์๋ฅผ ์์ ํ๊ฒ ์ ๊ฑฐ/์ถ๊ฐํ๋๋ก `SafeArray`์ ๋น์ทํ ๊ตฌ์กฐ๋ก ๋ง๋ค์์ต๋๋ค. ๋ํ ์ด ํด๋์ค๋ ์ค์ฒฉ๋ ์ฝ๋ฃจํด๋ ์ฒ๋ฆฌํฉ๋๋ค.
+
+์ฝ๋ฃจํด์ ๋ง๋ค๋ ค๋ฉด ์๋ฐ์คํฌ๋ฆฝํธ์ [์ ๋๋ ์ดํฐ ํจ์](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/function*)๋ฅผ ๋ง๋ค์ด์ผ ํฉ๋๋ค. ์ ๋๋ ์ดํฐ ํจ์๋ `function*`์ด๋ผ๋ ํค์๋๋ก ์์ฑํ์ฃ (๋ณํ๋ฅผ ๋ถ์ฌ์ผ ํฉ๋๋ค!).
+
+์ ๋๋ ์ดํฐ ํจ์๋ `yield` ํค์๋๋ก ์คํ ์์๋ฅผ **์๋ณด(yield)**ํ ์ ์์ต๋๋ค.
+
+```js
+function* countOTo9() {
+ for (let i = 0; i < 10; ++i) {
+ console.log(i);
+ yield;
+ }
+}
+```
+
+์ด ํจ์๋ฅผ ์๊น ๋ง๋ `CoroutineRunner`์ ์ถ๊ฐํ๋ฉด ํ ํ๋ ์, ๋๋ `runner.update`๋ฅผ ํธ์ถํ ๋๋ง๋ค 0๋ถํฐ 9๊น์ง์ ์ซ์๋ฅผ ์ฐจ๋ก๋๋ก ์ถ๋ ฅํ ๊ฒ๋๋ค.
+
+```js
+const runner = new CoroutineRunner();
+runner.add(count0To9);
+while(runner.isBusy()) {
+ runner.update();
+}
+```
+
+์ฝ๋ฃจํด์ ๋์์ด ๋๋ฌ์ ๋ ์๋์ผ๋ก ์ ๊ฑฐ๋ฉ๋๋ค. ์ฝ๋ฃจํด์ด ๋๋๊ธฐ ์ ์ ์ ๊ฑฐํ๋ ค๋ฉด ์ ๋๋ ์ดํฐ๋ฅผ ๋ฏธ๋ฆฌ ์ฐธ์กฐํ ๋ค `remove` ๋ฉ์๋๋ฅผ ํธ์ถํด์ผ ํฉ๋๋ค.
+
+```js
+const gen = count0To9();
+runner.add(gen);
+
+// ์ผ๋ง ํ
+
+runner.remove(gen);
+```
+
+์ด์ ํ๋ ์ด์ด๊ฐ 0.5์์ 1์ด ์ฌ์ด๋ง๋ค ํ ๋ฒ์ฉ ์ํ๋ฅผ ๋ฑ๋๋ก ํด๋ด
์๋ค.
+
+```js
+class Player extends Component {
+ constructor(gameObject) {
+
+ ...
+
++ this.runner = new CoroutineRunner();
++
++ function* emitNotes() {
++ for (;;) {
++ yield waitSeconds(rand(0.5, 1));
++ const noteGO = gameObjectManager.createGameObject(scene, 'note');
++ noteGO.transform.position.copy(gameObject.transform.position);
++ noteGO.transform.position.y += 5;
++ noteGO.addComponent(Note);
++ }
++ }
++
++ this.runner.add(emitNotes());
+ }
+ update() {
++ this.runner.update();
+
+ ...
+
+ }
+}
+
+function rand(min, max) {
+ if (max === undefined) {
+ max = min;
+ min = 0;
+ }
+ return Math.random() * (max - min) + min;
+}
+```
+
+์ ์ฝ๋์์๋ `CoroutineRunner`๋ฅผ ๋ง๋ค๊ณ `emitNotes` ์ฝ๋ฃจํด์ ์ถ๊ฐํ์ต๋๋ค. ์ด ํจ์๋ 0.5์ด์์ 1์ด ์ฌ์ด๋ง๋ค ๊ณ์ํด์ `Note` ์ปดํฌ๋ํธ๋ฅผ ์์ฑํฉ๋๋ค.
+
+`Note` ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค๋ ค๋ฉด ๋จผ์ ํ
์ค์ฒ๊ฐ ํ์ํฉ๋๋ค. ์ํ ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์ฌ ์๋ ์์ง๋ง, [์บ๋ฒ์ค๋ก ํ
์ค์ฒ ๋ง๋ค๊ธฐ](threejs-canvas-textures.html)์์ ๋ค๋ค๋ ๊ฒ์ฒ๋ผ ์บ๋ฒ์ค๋ฅผ ์ด์ฉํด ์ง์ ์ํ๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+function makeTextTexture(str) {
+ const ctx = document.createElement('canvas').getContext('2d');
+ ctx.canvas.width = 64;
+ ctx.canvas.height = 64;
+ ctx.font = '60px sans-serif';
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillStyle = '#FFF';
+ ctx.fillText(str, ctx.canvas.width / 2, ctx.canvas.height / 2);
+ return new THREE.CanvasTexture(ctx.canvas);
+}
+const noteTexture = makeTextTexture('โช');
+```
+
+์์์ ๋ง๋ ํ
์ค์ฒ๋ ํ์์์ผ๋ก, ๋์ค์ ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ ๋ ์์ ๋ฐ๋ก ์ง์ ํด ์ํ๋ ์์ ์ํ๋ฅผ ๊ทธ๋ฆด ์ ์์ต๋๋ค.
+
+์ด์ ์ํ ํ
์ค์ฒ๋ฅผ ๋ง๋ค์์ผ๋ `Note` ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ค ์ฐจ๋ก์
๋๋ค. ์ํ ์ปดํฌ๋ํธ๋ [๋น๋ณด๋์ ๊ดํ ๊ธ](threejs-billboards.html)์์ ๋ค๋ค๋ `SpriteMaterial`๊ณผ `Sprite`๋ฅผ ์ฌ์ฉํฉ๋๋ค.
+
+```js
+class Note extends Component {
+ constructor(gameObject) {
+ super(gameObject);
+ const { transform } = gameObject;
+ const noteMaterial = new THREE.SpriteMaterial({
+ color: new THREE.Color().setHSL(rand(1), 1, 0.5),
+ map: noteTexture,
+ side: THREE.DoubleSide,
+ transparent: true,
+ });
+ const note = new THREE.Sprite(noteMaterial);
+ note.scale.setScalar(3);
+ transform.add(note);
+ this.runner = new CoroutineRunner();
+ const direction = new THREE.Vector3(rand(-0.2, 0.2), 1, rand(-0.2, 0.2));
+
+ function* moveAndRemove() {
+ for (let i = 0; i < 60; ++i) {
+ transform.translateOnAxis(direction, globals.deltaTime * 10);
+ noteMaterial.opacity = 1 - (i / 60);
+ yield;
+ }
+ transform.parent.remove(transform);
+ gameObjectManager.removeGameObject(gameObject);
+ }
+
+ this.runner.add(moveAndRemove());
+ }
+ update() {
+ this.runner.update();
+ }
+}
+```
+
+์ด ์ปดํฌ๋ํธ๋ `Sprite`๋ฅผ ๋ง๋ค๊ณ ๋ฌด์์๋ก ์๋๋ฅผ ์ ํด 60ํ๋ ์ ๋์ ๊ทธ ์๋๋ก ์ด๋ํ๊ฒ ํฉ๋๋ค. ๋์์ ์ฌ์ง์ [`opacity`](Material.opacity) ์์ฑ์ ๋ฐ๊ฟ ํ์ด๋-์์ ํจ๊ณผ๋ ์ฃผ์ฃ . ๋ฐ๋ณต๋ฌธ์ด ๋๋๋ฉด ์ด ์ปดํฌ๋ํธ๋ ์์น๊ฐ๊ณผ ์ํ๋ฅผ ํด๋น GameObject์์ ์ ๊ฑฐํฉ๋๋ค.
+
+์ ๋ง ๋ง์ง๋ง์ผ๋ก, ๋๋ฌผ์ ์๋ฅผ ์ข ๋๋ ค๋ณด๊ฒ ์ต๋๋ค.
+
+```js
+function init() {
+
+ ...
+
+ const animalModelNames = [
+ 'pig',
+ 'cow',
+ 'llama',
+ 'pug',
+ 'sheep',
+ 'zebra',
+ 'horse',
+ ];
++ const base = new THREE.Object3D();
++ const offset = new THREE.Object3D();
++ base.add(offset);
++
++ // ์์ฉ๋์ด ํํ๋ก ๋๋ฌผ๋ค์ ๋ฐฐ์นํฉ๋๋ค.
++ const numAnimals = 28;
++ const arc = 10;
++ const b = 10 / (2 * Math.PI);
++ let r = 10;
++ let phi = r / b;
++ for (let i = 0; i < numAnimals; ++i) {
++ const name = animalModelNames[rand(animalModelNames.length) | 0];
+ const gameObject = gameObjectManager.createGameObject(scene, name);
+ gameObject.addComponent(Animal, models[name]);
++ base.rotation.y = phi;
++ offset.position.x = r;
++ offset.updateWorldMatrix(true, false);
++ offset.getWorldPosition(gameObject.transform.position);
++ phi += arc / r;
++ r = b * phi;
+ }
+```
+
+{{{example url="../threejs-game-conga-line-w-notes.html"}}}
+
+๋๊ตฐ๊ฐ `setTimeout`์ ์ฐ๋ฉด ์ ๋๋๊ณ ๋ฌผ์์ง๋ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. `setTimeout`์ ์ฐ์ง ์์ ๊ฑด `setTimeout`์ ๊ฒ์์ ํ๋ ์ ์ฃผ๊ธฐ์ ๋ฌด๊ดํ๊ธฐ ๋๋ฌธ์
๋๋ค. ์๋ฅผ ๋ค์ด ์์ ์์๋ ํ๋ ์ ๊ฐ ์๊ฐ๊ฐ์ ์ต๋ 1/20์ด๋ก ์ ํํ์ฃ . ๋ฐฉ๊ธ ๊ตฌ์ถํ ์ฝ๋ฃจํด ์์คํ
๋ ์ด ์ ํ์ ๋ฐ๋ฅผ ํ
์ง๋ง, `setTimeout`์ ์ฐ๋ฉด ๊ทธ๋ ์ง ์์ ๊ฒ๋๋ค.
+
+๋ฌผ๋ก ์ข ๋ ๊ฐ๋จํ ํ์ด๋จธ๋ฅผ ๋ง๋ค ์๋ ์์ต๋๋ค.
+
+```js
+class Player ... {
+ update() {
+ this.noteTimer -= globals.deltaTime;
+ if (this.noteTimer <= 0) {
+ // ํ์ด๋จธ๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
+ this.noteTimer = rand(0.5, 1);
+ // GameObject๋ก ์ํ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋ญ๋๋ค.
+ }
+ }
+```
+
+ํน์ ๊ฒฝ์ฐ์์ผ ์ด ๋ฐฉ๋ฒ์ด ๋ ์ข์ ์๋ ์์ง๋ง, ๋ ๋ง์ ์์๋ฅผ ์ถ๊ฐํ๋ฉด ๊ทธ๋งํผ ๋ ๋ง์ ๋ณ์์ ์ฝ๋ฃจํด์ ์ถ๊ฐํด์ผ ํ ํ
๊ณ , ๊ทธ๋ด์๋ก `setTimeout`์ *์ค์ ํ๊ณ ๊น๋จน์* ํ๋ฅ ์ด ๋์์ง ๊ฒ๋๋ค.
+
+๋๋ฌผ๋ค์ ์ํ๋ฅผ ์ค์ ํ ๋๋ ์๋์ ๊ฐ์ด ์ฝ๋ฃจํด์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
+
+```js
+// ์ค์ ๋ก ์ฌ์ฉํ์ง ์๋ ํจ์
+function* animalCoroutine() {
+ setAnimation('Idle');
+ while(playerIsTooFar()) {
+ yield;
+ }
+ const target = endOfLine;
+ setAnimation('Jump');
+ while(targetIsTooFar()) {
+ aimAt(target);
+ yield;
+ }
+ setAnimation('Walk')
+ while(notAtOldestPositionOfTarget()) {
+ addHistory();
+ aimAt(target);
+ yield;
+ }
+ for(;;) {
+ addHistory();
+ const pos = history.unshift();
+ transform.position.copy(pos);
+ aimAt(history[0]);
+ yield;
+ }
+}
+```
+
+์ด ๋ฐฉ๋ฒ์ ์จ๋ ๋ฑํ ๋ฌธ์ ๋ ์์๊ฒ ์ง๋ง, ์ํ๊ฐ ์ผ์ ํ์ง ์์ ๋ค์ `FiniteStateMachine`์ ์ฐพ๊ฒ ๋ ๊ฒ๋๋ค.
+
+๋ ์ ๋ ์ฝ๋ฃจํด์ ํด๋น ์ปดํฌ๋ํธ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ๋ ๊ฒ ์ข์์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋ฌผ๋ก ๊ทธ๋ฅ ์ ์ญ์ `CoroutineRunner`๋ฅผ ๋ง๋ค์ด ๋ชจ๋ ์ฝ๋ฃจํด์ ์ฌ๊ธฐ์ ์ง์ด ๋ฃ์ ์๋ ์์ฃ . ํ์ง๋ง ์ด๋ฌ๋ฉด ์ฝ๋ฃจํด์ ์์ ๊ธฐ๊ฐ ํ๋ค์ด์ง ๊ฒ๋๋ค. ์ง๊ธ ์์ ๋ GameObject๋ฅผ ์ ๊ฑฐํ๋ฉด ํด๋น ์ปดํฌ๋ํธ๋ ์ ๊ฑฐ๋๊ณ , ๊ทธ๋ฌ๋ฉด ์์ฑํ `CoroutineRunner`์ ๋ฉ์๋๋ฅผ ํธ์ถํ ์ผ๋ ์์ผ๋ ์ฝ๋ฃจํด๋ ์ ๋ถ ๊ฐ๋น์ง ์ปฌ๋ ์
์ ๋ค์ด๊ฐ ๊ฒ๋๋ค. ์ ์ญ์ `CoroutineRunner`๋ฅผ ๋๋ฉด ์ปดํฌ๋ํธ์์ ์ง์ ์ด ์ ์ญ ๊ฐ์ฒด์ ์ฝ๋ฃจํด์ ์ ๊ฑฐํ๊ฑฐ๋ ์๋์ผ๋ก ์ฝ๋ฃจํด์ ์ ๊ฑฐํ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ด ํ์ํ ๊ฒ๋๋ค.
+
+์ค์ ๊ฒ์ ์์ง์ด๋ผ๋ฉด ๋ ๊ณ ๋ คํด์ผ ํ ๋ฌธ์ ๊ฐ ๋ง์ต๋๋ค. ์ง๊ธ์ GameObject๋ ์ปดํฌ๋ํธ์ ๋ฐ๋ก ์์๋ฅผ ์ง์ ํ ์ ์์ฃ . ๊ทธ๋ฅ ์ถ๊ฐํ ์์๊ฐ ํด๋น ์์์ ์์๊ฐ ๋ฉ๋๋ค. ๋๋ถ๋ถ์ ๊ฒ์ ์์ง์ ์ฐ์ ์์๋ฅผ ์ ํด ์์๋ฅผ ๋ฐ๊ฟ ์ ์์ต๋๋ค.
+
+๋ค๋ฅธ ๋ฌธ์ ๋ `Note` ์ปดํฌ๋ํธ๊ฐ ์ฅ๋ฉด ์ GameObject์ transform ์์ฑ์ ๋ณ๊ฒฝํ๋ค๋ ๊ฒ๋๋ค. ์ ์ด์ `GameObject`๊ฐ transform ์์ฑ์ ๋ณ๊ฒฝํ์ผ๋ ์ข ๋ ์ ๋๋ก ๊ตฌํํ๋ ค๋ฉด `GameObject`๊ฐ ๊ณ์ transform ์์ฑ์ ๊ด๋ฆฌํ๋ ๊ฒ ๋ง๊ฒ ์ฃ . `GameObject`์ `dispose` ๊ฐ์ ๋ฉ์๋๋ฅผ ๋๊ณ `GameObjectManager.removeGameObject`์์ ์ด ๋ฉ์๋๋ฅผ ํธ์ถํ๋ค๋ฉด ์ด๋จ๊น์?
+
+๋ `gameObjectManager.update`๋ `inputManager.update`๋ฅผ ์ง์ ํธ์ถํ๋ ๋์ `SystemManager`๋ฅผ ๋ง๋ค์ด `update`๋ฉ์๋๋ฅผ ๊ฐ์ง ์์๋ฅผ ์ ๋ถ ์ถ๊ฐํด ์ด ํด๋์ค๊ฐ ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ก ํ๋ ๊ฒ ๋ ๋์ ์๋ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด `CollisionManager` ๋ฑ ์๋ก์ด ์์คํ
์ ๋ง๋ค์์ ๋ `render` ํจ์๋ฅผ ์์ ํ๋ ๊ฒ ์๋๋ผ `SystemManager`์ ์ด ์์คํ
์ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋ ๊ฒ๋๋ค.
+
+์ ๋ ์ด๋ฐ ๋ฌธ์ ๋ค์ ์ ๋ถ ๋ค๋ฃจ๊ธฐ๋ณด๋ค ์ฌ๋ฌ๋ถ์ ๋ชซ์ผ๋ก ๋จ๊ฒจ ๋๊ณ ์ ํฉ๋๋ค. ๋ถ๋ ์ด ๊ธ์ด ์ฌ๋ฌ๋ถ๋ง์ ๊ฒ์ ์์ง์ ๋ง๋๋ ๋ฐ ๋์์ด ๋์๋ค๋ฉด ์ข๊ฒ ๋ค์.
+
+์ด์ฉ๋ฉด ์ ๊ฐ ๊ฒ์ ์ผ(game jam)๏ผ์ ์ด ์๋ ์๊ฒ ๋ค์. ์ ์์ ์ *jsfiddle*์ด๋ *codepen*์ ํด๋ฆญํด๋ณด๋ฉด ์ฝ๋๋ฅผ ๋ฐ๋ก ํธ์งํด ๋ณผ ์ ์๋ ์ฌ์ดํธ๊ฐ ์ด๋ฆด ๊ฒ๋๋ค. ํน์ ๊ธฐ๋ฅ์ ์ถ๊ฐํ๊ฑฐ๋ ํด์ ์์ ๋ฅผ ํผ๊ทธ๊ฐ ๊ธฐ์ฌ(knight)์ ๋๊ณ ๋ค๋๋ ๊ฒ์์ ๋ง๋ค๊ฑฐ๋, ๊ธฐ์ฌ์ ๊ตฌ๋ฅด๊ธฐ ์ ๋๋ฉ์ด์
์ ๋ณผ๋ง๊ณต์ผ๋ก์จ ๋๋ฌผ ๋ณผ๋ง ๊ฒ์์ ๋ง๋ค ์๋ ์๊ฒ ์ฃ . ๋๋ ๋๋ฌผ ์ด์ด ๋ฌ๋ฆฌ๊ธฐ ๊ฒ์์ด๋ผ๋ ๊ฐ์. ๊ด์ฐฎ์ ๊ฒ์์ ๋ง๋ค์๋ค๋ฉด ์๋์ ๋๊ธ๋ก ๋งํฌ๋ฅผ ๋จ๊ฒจ์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
+
+โป ๊ฒ์ ์ผ: ๋ณดํต 24์๊ฐ์์ 72์๊ฐ ์ ๋์ ์งง์ ๊ธฐ๊ฐ ๋ด์ ํ, ๋๋ ๊ฐ์ธ์ด ๊ฒ์์ ๋ง๋๋ ๋ํ. ์ญ์ฃผ.
+
+<div class="footnotes">
+[<a id="parented">1</a>]: ๋ฌผ๋ก ๋ถ๋ชจ์ ์ด๋ค ์์๋ translation, rotation, scale ์์ฑ์ ๋ฐ๊พธ์ง ์์๋ค๋ฉด ์ ์์ ์ผ๋ก ์๋ํฉ๋๋ค.<a href="#parented-backref">[๋์๊ฐ๊ธฐ]</a>
+</div>
\ No newline at end of file | false |
Other | mrdoob | three.js | d30d88526bb8c4017084e473d2a125225590bc8e.json | add translation kr/threejs-voxel-geometry.md | threejs/lessons/kr/threejs-voxel-geometry.md | @@ -0,0 +1,1088 @@
+Title: Three.js ๋ณต์
Geometry
+Description: ๋ง์ธํฌ๋ํํธ ๊ฐ์ ๋ณต์
geometry๋ฅผ ๋ง๋๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ๋ณต์
Geometry(๋ง์ธํฌ๋ํํธ) ๋ง๋ค๊ธฐ
+
+โป [๋ณต์
](https://ko.wikipedia.org/wiki/%EB%B3%B5%EC%85%80): Voxel, ๋ณผ๋ฅจ(volume, ๋ถํผ)๊ณผ ํฝ์
(pixel)์ ํฉ์ฑ์ด๋ก, ๋ง์ธํฌ๋ํํธ์ ๋ธ๋ก์ฒ๋ผ ๋ถํผ๊ฐ ์๋ ํฝ์
์ ๋งํฉ๋๋ค. ์ญ์ฃผ.
+
+์ด ์ฃผ์ ๋ ๊ฝค ๋ง์ ์ปค๋ฎค๋ํฐ์ ๊ณตํต์ ์ผ๋ก ์ฌ๋ผ์ค๋ ์ฃผ์ ์
๋๋ค. "๋ง์ธํฌ๋ํํธ ๋ธ๋ก ๊ฐ์ ๋ณต์
์ ์ด๋ป๊ฒ ๋ง๋ค ์ ์๋์?"๋ผ๋ ๊ฒ์ด์ฃ .
+
+๋๋ถ๋ถ์ ์ด์ฌ์๊ฐ ์ด๋ฅผ ์ ์ก๋ฉด์ฒด geometry๋ฅผ ๋ง๋ค๊ณ ๊ฐ ๋ณต์
์ ์์น์ mesh๋ฅผ ๋ฐ๋ก ๋ง๋ค์ด ๊ตฌํํ๋ ค๊ณ ํฉ๋๋ค. ์ฌ๋ฏธ์ผ์ ์ด ๋ฐฉ์์ผ๋ก ํ ๋ฒ ๊ตฌํํด๋ณด์ฃ . ๋จผ์ 256x256x256์ง๋ฆฌ ๋ณต์
ํ๋ธ๋ฅผ ๋ง๋ค๊ธฐ ์ํด 16,777,216๊ฐ์ ์์๋ฅผ ๊ฐ์ง `Uint8Array`๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+const cellSize = 256;
+const cell = new Uint8Array(cellSize * cellSize * cellSize);
+```
+
+๊ทธ๋ฆฌ๊ณ ์ฌ์ธ(sine) ํจ์ ๊ณก์ ์ผ๋ก ์ธ๋์ ํ ๊ฒน ๋ง๋ญ๋๋ค.
+
+```js
+for (let y = 0; y < cellSize; ++y) {
+ for (let z = 0; z < cellSize; ++z) {
+ for (let x = 0; x < cellSize; ++x) {
+ const height = (Math.sin(x / cellSize * Math.PI * 4) + Math.sin(z / cellSize * Math.PI * 6)) * 20 + cellSize / 2;
+ if (height > y && height < y + 1) {
+ const offset = y * cellSize * cellSize +
+ z * cellSize +
+ x;
+ cell[offset] = 1;
+ }
+ }
+ }
+}
+```
+
+๋ค์์ผ๋ก ๋ชจ๋ ๋ธ๋ญ์ ๋๋ฉด์ 0์ด ์๋ ๊ฒฝ์ฐ ์ ์ก๋ฉด์ฒด๋ฅผ ์๋ก ๋ง๋ญ๋๋ค.
+
+```js
+const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
+const material = new THREE.MeshPhongMaterial({ color: 'green' });
+
+for (let y = 0; y < cellSize; ++y) {
+ for (let z = 0; z < cellSize; ++z) {
+ for (let x = 0; x < cellSize; ++x) {
+ const offset = y * cellSize * cellSize +
+ z * cellSize +
+ x;
+ const block = cell[offset];
+ const mesh = new THREE.Mesh(geometry, material);
+ mesh.position.set(x, y, z);
+ scene.add(mesh);
+ }
+ }
+}
+```
+
+๋๋จธ์ง ์ฝ๋๋ [๋ถํ์ํ ๋ ๋๋ง ์ ๊ฑฐํ๊ธฐ](threejs-rendering-on-demand.html)์์ ๊ฐ์ ธ์์ต๋๋ค.
+
+{{{example url="../threejs-voxel-geometry-separate-cubes.html" }}}
+
+์ฒ์ ์ด๊ธฐํํ๋ ๋ฐ๋ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆฌ๊ณ ์นด๋ฉ๋ผ๋ฅผ ์์ง์ด๋ฉด ๊ต์ฅํ ๋ฒ๋ฒ
์ผ ๊ฒ๋๋ค. [๋ค์ค ์์ ์ต์ ํํ๊ธฐ](threejs-optimize-lots-of-objects.html)์ ๊ฒฝ์ฐ์ ๋ง์ฐฌ๊ฐ์ง๋ก ๋๋ฌด ๋ง์ ๋ฌผ์ฒด๊ฐ ์๋ ํ์ด์ฃ . 256x256, ์ก๋ฉด์ฒด๊ฐ ์ด 65,536๊ฐ๋ ์์ผ๋ ๊ทธ๋ด ๋งํฉ๋๋ค.
+
+[geometry๋ฅผ ํฉ์น๋ฉด](threejs-rendering-on-demand.html) ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ด์น๊น์ ์ธ๋ ํ ๊ฒน์ด ์๋๋ผ ๋
๊น์ง ๋ณต์
์ ์ฑ์๋ณด๋๋ก ํ์ฃ . ๋ฐ๋ณต๋ฌธ์ ๋ค์์ฒ๋ผ ์์ ํด ๋น ๊ณต๊ฐ์ ์ ๋ถ ์ฑ์ฐ๋๋ก ํฉ๋๋ค.
+
+```js
+for (let y = 0; y < cellSize; ++y) {
+ for (let z = 0; z < cellSize; ++z) {
+ for (let x = 0; x < cellSize; ++x) {
+ const height = (Math.sin(x / cellSize * Math.PI * 4) + Math.sin(z / cellSize * Math.PI * 6)) * 20 + cellSize / 2;
+- if (height > y && height < y + 1) {
++ if (height < y + 1) {
+ const offset = y * cellSize * cellSize +
+ z * cellSize +
+ x;
+ cell[offset] = 1;
+ }
+ }
+ }
+}
+```
+
+ํ
์คํธ๋ฅผ ๋๋ ค๋ดค๋๋ ์ ์ ๋ฉ์ท๋ค๊ฐ *out of memery* ์ค๋ฅ๊ฐ ๋น๋๋ค ๐
.
+
+๋ช ๊ฐ์ง ๋ฌธ์ ๊ฐ ์์ ํ
์ง๋ง ํ์ฌ ๊ฐ์ฅ ํฐ ๋ฌธ์ ๋ ์ ํ ๋ณผ ์ผ์ด ์๋ ์ ์ก๋ฉด์ฒด ์์ชฝ๋ ๋ ๋๋งํ๋ค๋ ๊ฒ๋๋ค.
+
+์ฝ๊ฒ ์ค๋ช
ํด ๋ณต์
๋ก ์ด๋ฃจ์ด์ง 3x2x2์ง๋ฆฌ ์ก๋ฉด์ฒด๊ฐ ์๋ค๊ณ ํด๋ณด์ฃ . ๊ฐ ๋ณต์
์ ํฉ์น๋ฉด ์๋์ ๊ฐ์ ๋ชจ์ต์ด ๋ ๊ฒ๋๋ค.
+
+<div class="spread">
+ <div data-diagram="mergedCubes" style="height: 300px;"></div>
+</div>
+
+๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ์๋์ ๊ฐ์ ํํ๋ก ๊ตฌํํด์ผ ํ์ฃ .
+
+<div class="spread">
+ <div data-diagram="culledCubes" style="height: 300px;"></div>
+</div>
+
+์์ชฝ ์์ ์๋ ๋ณต์
์ฌ์ด์ ๋ฉด๋ค์ด ์์ต๋๋ค. ๋ฐ์์๋ ์ ํ ๋ณผ ์ผ์ด ์๊ธฐ์ ๋ถํ์ํ ๊ฒ๋ค์ด์ฃ . ๊ฑฐ๊ธฐ๋ค ๊ฐ ๋ณต์
์ฌ์ด์๋ ๋ฉด์ด ํ๋๋ ์๋๊ณ ๋ง์ฃผ ๋ณด๋ ๋ฉด๋น ํ๋์ฉ, ์ด ๋ ๊ฐ๊ฐ ์์ต๋๋ค. ์ด ์ญ์ ๋ญ๋น์ด์ฃ . ๋ณต์
์ ์ด๋ฐ ๋ฉด๋ค์ด ๋ง์์ง์๋ก ์ฑ๋ฅ์ ์ฒ์ฐธํด์ง ๊ฒ๋๋ค.
+
+์ด์ฏค์์ ๊ทธ๋ฅ ๋งํด์ผ๊ฒ ๋ค์. ๋จ์ํ geometry๋ฅผ ํฉ์ณ๋ฒ๋ ค์๋ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ณต์
์ด ์๋ก ๋ง์ฃผ ๋ณธ๋ค๋ฉด ํด๋น ๋ฉด์ ๋ง๋ค์ง ์๋๋ก ์ง์ ๋ณต์
์ ๋ง๋ค์ด์ผ ํ์ฃ .
+
+๋ค๋ฅธ ๋ฌธ์ ๋ ํฌ๊ธฐ๊ฐ ๋๋ฌด ํฌ๋ค๋ ๊ฒ๋๋ค. 256x256x256์ด๋ฉด 16MB ์ ๋๋ก ๋ฉ๋ชจ๋ฆฌ ์ ์ ์จ์ด ๊ฝค ํฐ ํธ์ ์ํ์ฃ . ํนํ ๋น ๊ณต๊ฐ์ ์๋ฌด๊ฒ๋ ์์ ํ์๊ฐ ์์ต๋๋ค. ๋ณต์
์ ์ซ์๋ ์ฝ ์ฒ์ก๋ฐฑ๋ง ๊ฐ๊ฐ ๋์ผ๋ ์ฐ์ฐ์ด ๋ฒ๊ฑฐ์ธ ๋งํฉ๋๋ค.
+
+ํ ๊ฐ์ง ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์์ญ์ ์์ ์์ญ์ผ๋ก ์ชผ๊ฐ๋ ๊ฒ๋๋ค. ์๋ฌด๊ฒ๋ ์๋ ์์ญ์๋ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํ ๋นํ ํ์๊ฐ ์์ผ๋, 32x32x32 ํฌ๊ธฐ(32KB)์ ์์ญ์ ๋ง๋ค์ด ์์ ์์๊ฐ ์๋ ์์ญ๋ง ๋ ๋๋งํ๋๋ก ํ๊ฒ ์ต๋๋ค. ์ด 32x32x32 ์์ญ์ ํธ์์ "cell"์ด๋ผ๊ณ ๋ถ๋ฅด๋๋ก ํ์ฃ .
+
+๋จผ์ ๋ณต์
๋ฐ์ดํฐ๋ฅผ ๊ด๋ฆฌํ ํด๋์ค๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+class VoxelWorld {
+ constructor(cellSize) {
+ this.cellSize = cellSize;
+ }
+}
+```
+
+๋ค์์ผ๋ก ๊ฐ cell์ geometry๋ฅผ ์์ฑํ๋ ๋ฉ์๋๋ฅผ ์์ฑํฉ๋๋ค. ์ด ๋ฉ์๋๋ cell์ ์์น๊ฐ์ ์ธ์๋ก ๋ฐ๋๋ฐ, ์ฝ๊ฒ ๋งํด (x์ถ 0-31, y์ถ 0-31, z์ถ 0-31)์ ํฌํจํ๋ ๋ณต์
๋ค์ ์์ฑํ๋ ค๋ฉด (0,0,0)์ ๋๊ฒจ์ฃผ๋ฉด ๋ฉ๋๋ค. (x์ถ 32-63, y์ถ 0-31, z์ถ 0-31)์ ํฌํจํ๋ ๋ณต์
์ ์์ฑํ๋ ค๋ฉด (1,0,0)์ ๋๊ฒจ์ฃผ๋ฉด ๋์ฃ .
+
+๊ทธ๋ฆฌ๊ณ ์ด์ํ๋ ๋ณต์
์ ๊ฒ์ฌํด์ผ ํฉ๋๋ค. ์ผ๋จ ํด๋น ์์น์ ๋ณต์
๊ฐ์ ๋ฐํํ๋ `getVoxel` ๋ฉ์๋๊ฐ ์๋ค๊ณ ๊ฐ์ ํฉ์๋ค. ์๋ฅผ ๋ค์ด cell์ ํฌ๊ธฐ๊ฐ 32์ผ ๊ฒฝ์ฐ, ์ด ๋ฉ์๋์ (35,0,0)์ ๋๊ฒจ์ฃผ๋ฉด (1,0,0) ์ชฝ cell์ ์ฐพ์ ํด๋น cell์ (3,0,0)์ ์์นํ ๋ณต์
๊ฐ์ ๋ฐํํ ๊ฒ๋๋ค. ๋ค๋ฅธ cell์ ๋ณต์
์ด๋ผ๊ณ ํด๋ ์ด์ ๋ณต์
์ ์ผ๋ง๋ ์ง ์ฐพ์๋ผ ์ ์๋ค๋ ์ด์ผ๊ธฐ์ฃ .
+
+```js
+class VoxelWorld {
+ constructor(cellSize) {
+ this.cellSize = cellSize;
+ }
++ generateGeometryDataForCell(cellX, cellY, cellZ) {
++ const { cellSize } = this;
++ const startX = cellX * cellSize;
++ const startY = cellY * cellSize;
++ const startZ = cellZ * cellSize;
++
++ for (let y = 0; y < cellSize; ++y) {
++ const voxelY = startY + y;
++ for (let z = 0; z < cellSize; ++z) {
++ const voxelZ = startZ + z;
++ for (let x = 0; x < cellSize; ++x) {
++ const voxelX = startX + x;
++ const voxel = this.getVoxel(voxelX, voxelY, voxelZ);
++ if (voxel) {
++ for (const { dir } of VoxelWorld.faces) {
++ const neighbor = this.getVoxel(
++ voxelX + dir[0],
++ voxelY + dir[1],
++ voxelZ + dir[2]);
++ if (!neighbor) {
++ // ์ด ๋ณต์
์ ์ด ๋ฐฉํฅ์ ์ด์ํ๋ ๋ณต์
์ด ์์ผ๋ฏ๋ก
++ // ์ด์ชฝ์ ๋ฉด์ ๋ง๋ญ๋๋ค.
++ }
++ }
++ }
++ }
++ }
++ }
++ }
+}
+
++VoxelWorld.faces = [
++ { // ์ผ์ชฝ
++ dir: [ -1, 0, 0, ],
++ },
++ { // ์ค๋ฅธ์ชฝ
++ dir: [ 1, 0, 0, ],
++ },
++ { // ์๋
++ dir: [ 0, -1, 0, ],
++ },
++ { // ์
++ dir: [ 0, 1, 0, ],
++ },
++ { // ๋ค
++ dir: [ 0, 0, -1, ],
++ },
++ { // ์
++ dir: [ 0, 0, 1, ],
++ },
++];
+```
+
+์ด์ ์ธ์ ๋ฉด์ ๋ง๋ค ๊ธฐ์ค์ด ์๊ฒผ์ผ๋ ํ ๋ฒ ๋ฉด๋ค์ ๋ง๋ค์ด๋ด
์๋ค.
+
+```js
+class VoxelWorld {
+ constructor(cellSize) {
+ this.cellSize = cellSize;
+ }
+ generateGeometryDataForCell(cellX, cellY, cellZ) {
+ const { cellSize } = this;
++ const positions = [];
++ const normals = [];
++ const indices = [];
+ const startX = cellX * cellSize;
+ const startY = cellY * cellSize;
+ const startZ = cellZ * cellSize;
+
+ for (let y = 0; y < cellSize; ++y) {
+ const voxelY = startY + y;
+ for (let z = 0; z < cellSize; ++z) {
+ const voxelZ = startZ + z;
+ for (let x = 0; x < cellSize; ++x) {
+ const voxelX = startX + x;
+ const voxel = this.getVoxel(voxelX, voxelY, voxelZ);
+ if (voxel) {
+- for (const { dir } of VoxelWorld.faces) {
++ for (const { dir, corners } of VoxelWorld.faces) {
+ const neighbor = this.getVoxel(
+ voxelX + dir[0],
+ voxelY + dir[1],
+ voxelZ + dir[2]);
+ if (!neighbor) {
++ // ์ด ๋ณต์
์ ์ด ๋ฐฉํฅ์ ์ด์ํ๋ ๋ณต์
์ด ์์ผ๋ฏ๋ก
++ // ์ด์ชฝ์ ๋ฉด์ ๋ง๋ญ๋๋ค.
++ const ndx = positions.length / 3;
++ for (const pos of corners) {
++ positions.push(pos[0] + x, pos[1] + y, pos[2] + z);
++ normals.push(...dir);
++ }
++ indices.push(
++ ndx, ndx + 1, ndx + 2,
++ ndx + 2, ndx + 1, ndx + 3,
++ );
+ }
+ }
+ }
+ }
+ }
+ }
++ return {
++ positions,
++ normals,
++ indices,
+ };
+ }
+}
+
+VoxelWorld.faces = [
+ { // ์ผ์ชฝ
+ dir: [ -1, 0, 0, ],
++ corners: [
++ [ 0, 1, 0 ],
++ [ 0, 0, 0 ],
++ [ 0, 1, 1 ],
++ [ 0, 0, 1 ],
++ ],
+ },
+ { // ์ค๋ฅธ์ชฝ
+ dir: [ 1, 0, 0, ],
++ corners: [
++ [ 1, 1, 1 ],
++ [ 1, 0, 1 ],
++ [ 1, 1, 0 ],
++ [ 1, 0, 0 ],
++ ],
+ },
+ { // ์๋
+ dir: [ 0, -1, 0, ],
++ corners: [
++ [ 1, 0, 1 ],
++ [ 0, 0, 1 ],
++ [ 1, 0, 0 ],
++ [ 0, 0, 0 ],
++ ],
+ },
+ { // ์
+ dir: [ 0, 1, 0, ],
++ corners: [
++ [ 0, 1, 1 ],
++ [ 1, 1, 1 ],
++ [ 0, 1, 0 ],
++ [ 1, 1, 0 ],
++ ],
+ },
+ { // ๋ค
+ dir: [ 0, 0, -1, ],
++ corners: [
++ [ 1, 0, 0 ],
++ [ 0, 0, 0 ],
++ [ 1, 1, 0 ],
++ [ 0, 1, 0 ],
++ ],
+ },
+ { // ์
+ dir: [ 0, 0, 1, ],
++ corners: [
++ [ 0, 0, 1 ],
++ [ 1, 0, 1 ],
++ [ 0, 1, 1 ],
++ [ 1, 1, 1 ],
++ ],
+ },
+];
+```
+
+์ ์ฝ๋๋ ๊ธฐ๋ณธ geometry ๋ฐ์ดํฐ๋ฅผ ๋ง๋ค์ด์ค๋๋ค. ์ด์ `getVoxel` ๋ฉ์๋๋ง ๋ง๋ค๋ฉด ๋๊ฒ ๋ค์. ์ผ๋จ ์ฝ๊ฐ์ ํ๋์ฝ๋ฉ์ ๋ํด cell์ ๋ง๋ญ๋๋ค.
+
+```js
+class VoxelWorld {
+ constructor(cellSize) {
+ this.cellSize = cellSize;
++ this.cell = new Uint8Array(cellSize * cellSize * cellSize);
+ }
++ getCellForVoxel(x, y, z) {
++ const { cellSize } = this;
++ const cellX = Math.floor(x / cellSize);
++ const cellY = Math.floor(y / cellSize);
++ const cellZ = Math.floor(z / cellSize);
++ if (cellX !== 0 || cellY !== 0 || cellZ !== 0) {
++ return null
++ }
++ return this.cell;
++ }
++ getVoxel(x, y, z) {
++ const cell = this.getCellForVoxel(x, y, z);
++ if (!cell) {
++ return 0;
++ }
++ const { cellSize } = this;
++ const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
++ const voxelY = THREE.MathUtils.euclideanModulo(y, cellSize) | 0;
++ const voxelZ = THREE.MathUtils.euclideanModulo(z, cellSize) | 0;
++ const voxelOffset = voxelY * cellSize * cellSize +
++ voxelZ * cellSize +
++ voxelX;
++ return cell[voxelOffset];
++ }
+ generateGeometryDataForCell(cellX, cellY, cellZ) {
+
+ ...
+}
+```
+
+๋ฑํ ๋ฌธ์ ๋ ์์ด๋ณด์
๋๋ค. ๋ฐ์ดํฐ๋ฅผ ์ง์ ํ ์ ์๋ `setVoxel` ๋ฉ์๋๋ ๋ง๋ค๋๋ก ํ์ฃ .
+
+```js
+class VoxelWorld {
+ constructor(cellSize) {
+ this.cellSize = cellSize;
+ this.cell = new Uint8Array(cellSize * cellSize * cellSize);
+ }
+ getCellForVoxel(x, y, z) {
+ const { cellSize } = this;
+ const cellX = Math.floor(x / cellSize);
+ const cellY = Math.floor(y / cellSize);
+ const cellZ = Math.floor(z / cellSize);
+ if (cellX !== 0 || cellY !== 0 || cellZ !== 0) {
+ return null
+ }
+ return this.cell;
+ }
++ setVoxel(x, y, z, v) {
++ let cell = this.getCellForVoxel(x, y, z);
++ if (!cell) {
++ return; // ํ ์ผ: ์๋ก์ด cell ์ถ๊ฐ ๊ธฐ๋ฅ?
++ }
++ const { cellSize } = this;
++ const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
++ const voxelY = THREE.MathUtils.euclideanModulo(y, cellSize) | 0;
++ const voxelZ = THREE.MathUtils.euclideanModulo(z, cellSize) | 0;
++ const voxelOffset = voxelY * cellSize * cellSize +
++ voxelZ * cellSize +
++ voxelX;
++ cell[voxelOffset] = v;
++ }
+ getVoxel(x, y, z) {
+ const cell = this.getCellForVoxel(x, y, z);
+ if (!cell) {
+ return 0;
+ }
+ const {cellSize} = this;
+ const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
+ const voxelY = THREE.MathUtils.euclideanModulo(y, cellSize) | 0;
+ const voxelZ = THREE.MathUtils.euclideanModulo(z, cellSize) | 0;
+ const voxelOffset = voxelY * cellSize * cellSize +
+ voxelZ * cellSize +
+ voxelX;
+ return cell[voxelOffset];
+ }
+ generateGeometryDataForCell(cellX, cellY, cellZ) {
+
+ ...
+}
+```
+
+ํ , ๋ฐ๋ณต๋๋ ์ฝ๋๊ฐ ๋ง๋ค์. ์ฝ๋๋ฅผ ์ข ์ ๋ฆฌํด๋ด
์๋ค.
+
+```js
+class VoxelWorld {
+ constructor(cellSize) {
+ this.cellSize = cellSize;
++ this.cellSliceSize = cellSize * cellSize;
+ this.cell = new Uint8Array(cellSize * cellSize * cellSize);
+ }
+ getCellForVoxel(x, y, z) {
+ const { cellSize } = this;
+ const cellX = Math.floor(x / cellSize);
+ const cellY = Math.floor(y / cellSize);
+ const cellZ = Math.floor(z / cellSize);
+ if (cellX !== 0 || cellY !== 0 || cellZ !== 0) {
+ return null;
+ }
+ return this.cell;
+ }
++ computeVoxelOffset(x, y, z) {
++ const { cellSize, cellSliceSize } = this;
++ const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
++ const voxelY = THREE.MathUtils.euclideanModulo(y, cellSize) | 0;
++ const voxelZ = THREE.MathUtils.euclideanModulo(z, cellSize) | 0;
++ return voxelY * cellSliceSize +
++ voxelZ * cellSize +
++ voxelX;
++ }
+ setVoxel(x, y, z, v) {
+ const cell = this.getCellForVoxel(x, y, z);
+ if (!cell) {
+ return; // ํ ์ผ: ์๋ก์ด cell ์ถ๊ฐ ๊ธฐ๋ฅ?
+ }
+- const { cellSize } = this;
+- const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
+- const voxelY = THREE.MathUtils.euclideanModulo(y, cellSize) | 0;
+- const voxelZ = THREE.MathUtils.euclideanModulo(z, cellSize) | 0;
+- const voxelOffset = voxelY * cellSize * cellSize +
+- voxelZ * cellSize +
+- voxelX;
++ const voxelOffset = this.computeVoxelOffset(x, y, z);
+ cell[voxelOffset] = v;
+ }
+ getVoxel(x, y, z) {
+ const cell = this.getCellForVoxel(x, y, z);
+ if (!cell) {
+ return 0;
+ }
+- const { cellSize } = this;
+- const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
+- const voxelY = THREE.MathUtils.euclideanModulo(y, cellSize) | 0;
+- const voxelZ = THREE.MathUtils.euclideanModulo(z, cellSize) | 0;
+- const voxelOffset = voxelY * cellSize * cellSize +
+- voxelZ * cellSize +
+- voxelX;
++ const voxelOffset = this.computeVoxelOffset(x, y, z);
+ return cell[voxelOffset];
+ }
+ generateGeometryDataForCell(cellX, cellY, cellZ) {
+
+ ...
+}
+```
+
+๋ค์์ผ๋ก ์ฒซ ๋ฒ์งธ cell์ ๋ณต์
๋ก ์ฑ์ฐ๋ ์ฝ๋๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
+const cellSize = 32;
+
+const world = new VoxelWorld(cellSize);
+
+for (let y = 0; y < cellSize; ++y) {
+ for (let z = 0; z < cellSize; ++z) {
+ for (let x = 0; x < cellSize; ++x) {
+ const height = (Math.sin(x / cellSize * Math.PI * 2) + Math.sin(z / cellSize * Math.PI * 3)) * (cellSize / 6) + (cellSize / 2);
+ if (y < height) {
+ world.setVoxel(x, y, z, 1);
+ }
+ }
+ }
+}
+```
+
+[BufferGeometry์ ๊ดํ ๊ธ](threejs-custom-buffergeometry.html)์์ ๋ค๋ค๋ ๋๋ก ์ค์ geometry๋ฅผ ์์ฑํ๋ ์ฝ๋๋ ์์ฑํฉ๋๋ค.
+
+```js
+const { positions, normals, indices } = world.generateGeometryDataForCell(0, 0, 0);
+const geometry = new THREE.BufferGeometry();
+const material = new THREE.MeshLambertMaterial({ color: 'green' });
+
+const positionNumComponents = 3;
+const normalNumComponents = 3;
+geometry.setAttribute(
+ 'position',
+ new THREE.BufferAttribute(new Float32Array(positions), positionNumComponents));
+geometry.setAttribute(
+ 'normal',
+ new THREE.BufferAttribute(new Float32Array(normals), normalNumComponents));
+geometry.setIndex(indices);
+const mesh = new THREE.Mesh(geometry, material);
+scene.add(mesh);
+```
+
+ํ ๋ฒ ํ
์คํธํด๋ณด์ฃ .
+
+{{{example url="../threejs-voxel-geometry-culled-faces.html" }}}
+
+์ ์์ฑํ ๊ฒ ๊ฐ๋ค์! ์ฌ๊ธฐ์ ์ค์ ๋ง์ธํฌ๋ํํธ์ฒ๋ผ ํ
์ค์ฒ๋ฅผ ๋ฃ์ด๋ด
์๋ค.
+
+์ธํฐ๋ท์ ๋ค์ ธ ์ด [ํ
์ค์ฒ๋ค](https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/resource-packs/1245961-16x-1-7-4-wip-flourish)์ ์ฐพ์์ต๋๋ค(๋ผ์ด์ ์ค: [CC-BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/4.0/), ์๊ฐ: [Joshtimus](https://www.minecraftforum.net/members/Joshtimus)). ๊ทธ๋ฆฌ๊ณ ์ฌ๊ธฐ์ ๋ช ๊ฐ์ง๋ฅผ ์์๋ก ๊ณจ๋ผ [ํ
์ค์ฒ ์ํ๋ผ์ค(texture atlas)](https://www.google.com/search?q=texture+atlas)๋ฅผ ๋ง๋ค์์ต๋๋ค.
+
+<div class="threejs_center"><img class="checkerboard" src="../resources/images/minecraft/flourish-cc-by-nc-sa.png" style="width: 512px; image-rendering: pixelated;"></div>
+
+์์
์ ๊ฐ๋จํ ํ๊ธฐ ์ํด ํ
์ค์ฒ๋ฅผ ์ด๋ณ๋ก ์ ๋ ฌํ์ต๋๋ค. ์ฒซ ๋ฒ์งธ ์ค์ ๋ณต์
์ ์๋ฉด, ๋ ๋ฒ์งธ ์ค์ ๋ณต์
์ ์๋ฉด, ์ธ ๋ฒ์งธ ์ค์ ๋ณต์
์ ์๋ซ๋ฉด์ด์ฃ .
+
+์ด ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก `VoxelWorld.faces`์ ๊ฐ ๋ณต์
์ ์ฌ์ฉํ ํ
์ค์ฒ์ ์ค ๋ฒํธ์ ๋ณต์
์ ๊ฐ ๋ฉด์ ์ฌ์ฉํ UV ์ขํ ๋ฐ์ดํฐ๋ฅผ ์ง์ ํฉ๋๋ค.
+
+```js
+VoxelWorld.faces = [
+ { // ์ผ์ชฝ
++ uvRow: 0,
+ dir: [ -1, 0, 0, ],
+ corners: [
+- [ 0, 1, 0 ],
+- [ 0, 0, 0 ],
+- [ 0, 1, 1 ],
+- [ 0, 0, 1 ],
++ { pos: [ 0, 1, 0 ], uv: [ 0, 1 ], },
++ { pos: [ 0, 0, 0 ], uv: [ 0, 0 ], },
++ { pos: [ 0, 1, 1 ], uv: [ 1, 1 ], },
++ { pos: [ 0, 0, 1 ], uv: [ 1, 0 ], },
+ ],
+ },
+ { // ์ค๋ฅธ์ชฝ
++ uvRow: 0,
+ dir: [ 1, 0, 0, ],
+ corners: [
+- [ 1, 1, 1 ],
+- [ 1, 0, 1 ],
+- [ 1, 1, 0 ],
+- [ 1, 0, 0 ],
++ { pos: [ 1, 1, 1 ], uv: [ 0, 1 ], },
++ { pos: [ 1, 0, 1 ], uv: [ 0, 0 ], },
++ { pos: [ 1, 1, 0 ], uv: [ 1, 1 ], },
++ { pos: [ 1, 0, 0 ], uv: [ 1, 0 ], },
+ ],
+ },
+ { // ์๋
++ uvRow: 1,
+ dir: [ 0, -1, 0, ],
+ corners: [
+- [ 1, 0, 1 ],
+- [ 0, 0, 1 ],
+- [ 1, 0, 0 ],
+- [ 0, 0, 0 ],
++ { pos: [ 1, 0, 1 ], uv: [ 1, 0 ], },
++ { pos: [ 0, 0, 1 ], uv: [ 0, 0 ], },
++ { pos: [ 1, 0, 0 ], uv: [ 1, 1 ], },
++ { pos: [ 0, 0, 0 ], uv: [ 0, 1 ], },
+ ],
+ },
+ { // ์
++ uvRow: 2,
+ dir: [ 0, 1, 0, ],
+ corners: [
+- [ 0, 1, 1 ],
+- [ 1, 1, 1 ],
+- [ 0, 1, 0 ],
+- [ 1, 1, 0 ],
++ { pos: [ 0, 1, 1 ], uv: [ 1, 1 ], },
++ { pos: [ 1, 1, 1 ], uv: [ 0, 1 ], },
++ { pos: [ 0, 1, 0 ], uv: [ 1, 0 ], },
++ { pos: [ 1, 1, 0 ], uv: [ 0, 0 ], },
+ ],
+ },
+ { // ๋ค
++ uvRow: 0,
+ dir: [ 0, 0, -1, ],
+ corners: [
+- [ 1, 0, 0 ],
+- [ 0, 0, 0 ],
+- [ 1, 1, 0 ],
+- [ 0, 1, 0 ],
++ { pos: [ 1, 0, 0 ], uv: [ 0, 0 ], },
++ { pos: [ 0, 0, 0 ], uv: [ 1, 0 ], },
++ { pos: [ 1, 1, 0 ], uv: [ 0, 1 ], },
++ { pos: [ 0, 1, 0 ], uv: [ 1, 1 ], },
+ ],
+ },
+ { // ์
++ uvRow: 0,
+ dir: [ 0, 0, 1, ],
+ corners: [
+- [ 0, 0, 1 ],
+- [ 1, 0, 1 ],
+- [ 0, 1, 1 ],
+- [ 1, 1, 1 ],
++ { pos: [ 0, 0, 1 ], uv: [ 0, 0 ], },
++ { pos: [ 1, 0, 1 ], uv: [ 1, 0 ], },
++ { pos: [ 0, 1, 1 ], uv: [ 0, 1 ], },
++ { pos: [ 1, 1, 1 ], uv: [ 1, 1 ], },
+ ],
+ },
+];
+```
+
+๋ฐฉ๊ธ ์ง์ ํ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๋๋ก ์ฝ๋๋ฅผ ์์ ํฉ๋๋ค. ํ
์ค์ฒ ์ํ๋ผ์ค ํ์ผ ํ๋์ ํฌ๊ธฐ์ ํ
์ค์ฒ์ ํฌ๊ธฐ๋ฅผ ์์์ผ ํ๋ ์์ฑ ์์ ๋๊ฒจ ๋ฐ๋๋ก ํฉ๋๋ค.
+
+```js
+class VoxelWorld {
+- constructor(cellSize) {
+- this.cellSize = cellSize;
++ constructor(options) {
++ this.cellSize = options.cellSize;
++ this.tileSize = options.tileSize;
++ this.tileTextureWidth = options.tileTextureWidth;
++ this.tileTextureHeight = options.tileTextureHeight;
++ const { cellSize } = this;
++ this.cellSliceSize = cellSize * cellSize;
++ this.cell = new Uint8Array(cellSize * cellSize * cellSize);
+ }
+
+ ...
+
+ generateGeometryDataForCell(cellX, cellY, cellZ) {
+- const { cellSize } = this;
++ const { cellSize, tileSize, tileTextureWidth, tileTextureHeight } = this;
+ const positions = [];
+ const normals = [];
++ const uvs = [];
+ const indices = [];
+ const startX = cellX * cellSize;
+ const startY = cellY * cellSize;
+ const startZ = cellZ * cellSize;
+
+ for (let y = 0; y < cellSize; ++y) {
+ const voxelY = startY + y;
+ for (let z = 0; z < cellSize; ++z) {
+ const voxelZ = startZ + z;
+ for (let x = 0; x < cellSize; ++x) {
+ const voxelX = startX + x;
+ const voxel = this.getVoxel(voxelX, voxelY, voxelZ);
+ if (voxel) {
+ const uvVoxel = voxel - 1; // 0 ์์น์ ๋ณต์
์ ํ๋์ด๋ฏ๋ก UV์ ๊ฒฝ์ฐ๋ 0์์ ์์ํ๋๋ก ํฉ๋๋ค.
+ // ํ์ฌ ์์น์ ๋ณต์
์ด ์์ ๋ ํด๋น ์์น์ ๋ฉด์ด ํ์ํ์ง ๊ฒ์ฌํฉ๋๋ค.
+- for (const { dir, corners } of VoxelWorld.faces) {
++ for (const { dir, corners, uvRow } of VoxelWorld.faces) {
+ const neighbor = this.getVoxel(
+ voxelX + dir[0],
+ voxelY + dir[1],
+ voxelZ + dir[2]);
+ if (!neighbor) {
+ // ์ด ๋ณต์
์ ์ด ๋ฐฉํฅ์ ์ด์ํ๋ ๋ณต์
์ด ์์ผ๋ฏ๋ก
+ // ์ด์ชฝ์ ๋ฉด์ ๋ง๋ญ๋๋ค.
+ const ndx = positions.length / 3;
+- for (const pos of corners) {
++ for (const {pos, uv} of corners) {
+ positions.push(pos[0] + x, pos[1] + y, pos[2] + z);
+ normals.push(...dir);
++ uvs.push(
++ (uvVoxel + uv[0]) * tileSize / tileTextureWidth,
++ 1 - (uvRow + 1 - uv[1]) * tileSize / tileTextureHeight);
+ }
+ indices.push(
+ ndx, ndx + 1, ndx + 2,
+ ndx + 2, ndx + 1, ndx + 3,
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return {
+ positions,
+ normals,
+ uvs,
+ indices,
+ };
+ }
+}
+```
+
+๋ค์์ผ๋ก ํ
์ค์ฒ๋ฅผ ๋ถ๋ฌ์ต๋๋ค.
+
+```js
+const loader = new THREE.TextureLoader();
+const texture = loader.load('resources/images/minecraft/flourish-cc-by-nc-sa.png', render);
+texture.magFilter = THREE.NearestFilter;
+texture.minFilter = THREE.NearestFilter;
+```
+
+๊ทธ๋ฆฌ๊ณ `VoxelWorld`์ ์ค์ ๊ฐ์ ๋๊ฒจ์ค๋๋ค.
+
+```js
++const tileSize = 16;
++const tileTextureWidth = 256;
++const tileTextureHeight = 64;
+-const world = new VoxelWorld(cellSize);
++const world = new VoxelWorld({
++ cellSize,
++ tileSize,
++ tileTextureWidth,
++ tileTextureHeight,
++});
+```
+
+geometry๋ฅผ ๋ง๋ค ๋ UV ์ขํ๋ฅผ, ์ฌ์ง์ ๋ง๋ค ๋ ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ๋๋ก ๋ณ๊ฒฝํฉ๋๋ค.
+
+```js
+-const { positions, normals, indices } = world.generateGeometryDataForCell(0, 0, 0);
++const { positions, normals, uvs, indices } = world.generateGeometryDataForCell(0, 0, 0);
+const geometry = new THREE.BufferGeometry();
+-const material = new THREE.MeshLambertMaterial({ color: 'green' });
++const material = new THREE.MeshLambertMaterial({
++ map: texture,
++ side: THREE.DoubleSide,
++ alphaTest: 0.1,
++ transparent: true,
++});
+
+const positionNumComponents = 3;
+const normalNumComponents = 3;
++const uvNumComponents = 2;
+geometry.setAttribute(
+ 'position',
+ new THREE.BufferAttribute(new Float32Array(positions), positionNumComponents));
+geometry.setAttribute(
+ 'normal',
+ new THREE.BufferAttribute(new Float32Array(normals), normalNumComponents));
++geometry.setAttribute(
++ 'uv',
++ new THREE.BufferAttribute(new Float32Array(uvs), uvNumComponents));
+geometry.setIndex(indices);
+const mesh = new THREE.Mesh(geometry, material);
+scene.add(mesh);
+```
+
+๋ง์ง๋ง์ผ๋ก ๋ณต์
์ด ์๋ก ๋ค๋ฅธ ํ
์ค์ฒ๋ฅผ ์ฐ๋๋ก ์ค์ ํฉ๋๋ค.
+
+```js
+for (let y = 0; y < cellSize; ++y) {
+ for (let z = 0; z < cellSize; ++z) {
+ for (let x = 0; x < cellSize; ++x) {
+ const height = (Math.sin(x / cellSize * Math.PI * 2) + Math.sin(z / cellSize * Math.PI * 3)) * (cellSize / 6) + (cellSize / 2);
+ if (y < height) {
+- world.setVoxel(x, y, z, 1);
++ world.setVoxel(x, y, z, randInt(1, 17));
+ }
+ }
+ }
+}
+
++function randInt(min, max) {
++ return Math.floor(Math.random() * (max - min) + min);
++}
+```
+
+ํ ๋ฒ ์คํํด๋ณด์ฃ !
+
+{{{example url="../threejs-voxel-geometry-culled-faces-with-textures.html"}}}
+
+์ฝ๋๋ฅผ ์ข ๋ ๋ฐ์ ์์ผ ํ๋ ์ด์์ cell์ ์ถ๊ฐํ ์ ์๋๋ก ํด๋ด
์๋ค.
+
+๋จผ์ ๊ฐ cell์ id๋ฅผ ๋ถ์ฌํด ๊ฐ์ฒด ํํ๋ก ์ ์ฅํ๋๋ก ํฉ๋๋ค. ์ด id๋ ๊ฐ cell์ ์์น๊ฐ์ ์ผํ๋ก ๋ถํ ํ ๋ฌธ์์ด๋ก ์ง์ ํ ๊ฒ๋๋ค. ์๋ฅผ ๋ค์ด (35,0,0) ๋ณต์
์ cell (1,0,0)์ ์์ ํ
๋ ํด๋น cell์ id๋ `"1,0,0"`์ด ๋๊ฒ ์ฃ .
+
+```js
+class VoxelWorld {
+ constructor(options) {
+ this.cellSize = options.cellSize;
+ this.tileSize = options.tileSize;
+ this.tileTextureWidth = options.tileTextureWidth;
+ this.tileTextureHeight = options.tileTextureHeight;
+ const { cellSize } = this;
+ this.cellSliceSize = cellSize * cellSize;
+- this.cell = new Uint8Array(cellSize * cellSize * cellSize);
++ this.cells = {};
+ }
++ computeCellId(x, y, z) {
++ const { cellSize } = this;
++ const cellX = Math.floor(x / cellSize);
++ const cellY = Math.floor(y / cellSize);
++ const cellZ = Math.floor(z / cellSize);
++ return `${cellX},${cellY},${cellZ}`;
++ }
++ getCellForVoxel(x, y, z) {
+- const cellX = Math.floor(x / cellSize);
+- const cellY = Math.floor(y / cellSize);
+- const cellZ = Math.floor(z / cellSize);
+- if (cellX !== 0 || cellY !== 0 || cellZ !== 0) {
+- return null;
+- }
+- return this.cell;
++ return this.cells[this.computeCellId(x, y, z)];
+ }
+
+ ...
+}
+```
+
+๊ทธ๋ฆฌ๊ณ `setVoxel` ๋ฉ์๋๋ฅผ ์์ ํด ์กด์ฌํ์ง ์๋ cell์ ๋ณต์
์ ์ถ๊ฐํ ๋ ์๋ก์ด cell์ ์ถ๊ฐํ๋๋ก ํฉ๋๋ค.
+
+```js
+ setVoxel(x, y, z, v) {
+- const cell = this.getCellForVoxel(x, y, z);
++ let cell = this.getCellForVoxel(x, y, z);
+ if (!cell) {
+- return 0;
++ cell = this.addCellForVoxel(x, y, z);
+ }
+ const voxelOffset = this.computeVoxelOffset(x, y, z);
+ cell[voxelOffset] = v;
+ }
++ addCellForVoxel(x, y, z) {
++ const cellId = this.computeCellId(x, y, z);
++ let cell = this.cells[cellId];
++ if (!cell) {
++ const { cellSize } = this;
++ cell = new Uint8Array(cellSize * cellSize * cellSize);
++ this.cells[cellId] = cell;
++ }
++ return cell;
++ }
+```
+
+์ค๋น๋ฅผ ๋ง์ณค์ผ๋ ๋ณต์
์ ๋ง์๋๋ก ์์ ํ ์ ์๋๋ก ํด๋ด
์๋ค.
+
+๋จผ์ ๋ผ๋์ค ๋ฒํผ์ ์ด์ฉํด ํ์ผ์ 8x2์ง๋ฆฌ UI๋ก ๋ง๋ญ๋๋ค.
+
+```html
+<body>
+ <canvas id="c"></canvas>
++ <div id="ui">
++ <div class="tiles">
++ <input type="radio" name="voxel" id="voxel1" value="1"><label for="voxel1" style="background-position: -0% -0%"></label>
++ <input type="radio" name="voxel" id="voxel2" value="2"><label for="voxel2" style="background-position: -100% -0%"></label>
++ <input type="radio" name="voxel" id="voxel3" value="3"><label for="voxel3" style="background-position: -200% -0%"></label>
++ <input type="radio" name="voxel" id="voxel4" value="4"><label for="voxel4" style="background-position: -300% -0%"></label>
++ <input type="radio" name="voxel" id="voxel5" value="5"><label for="voxel5" style="background-position: -400% -0%"></label>
++ <input type="radio" name="voxel" id="voxel6" value="6"><label for="voxel6" style="background-position: -500% -0%"></label>
++ <input type="radio" name="voxel" id="voxel7" value="7"><label for="voxel7" style="background-position: -600% -0%"></label>
++ <input type="radio" name="voxel" id="voxel8" value="8"><label for="voxel8" style="background-position: -700% -0%"></label>
++ </div>
++ <div class="tiles">
++ <input type="radio" name="voxel" id="voxel9" value="9" ><label for="voxel9" style="background-position: -800% -0%"></label>
++ <input type="radio" name="voxel" id="voxel10" value="10"><label for="voxel10" style="background-position: -900% -0%"></label>
++ <input type="radio" name="voxel" id="voxel11" value="11"><label for="voxel11" style="background-position: -1000% -0%"></label>
++ <input type="radio" name="voxel" id="voxel12" value="12"><label for="voxel12" style="background-position: -1100% -0%"></label>
++ <input type="radio" name="voxel" id="voxel13" value="13"><label for="voxel13" style="background-position: -1200% -0%"></label>
++ <input type="radio" name="voxel" id="voxel14" value="14"><label for="voxel14" style="background-position: -1300% -0%"></label>
++ <input type="radio" name="voxel" id="voxel15" value="15"><label for="voxel15" style="background-position: -1400% -0%"></label>
++ <input type="radio" name="voxel" id="voxel16" value="16"><label for="voxel16" style="background-position: -1500% -0%"></label>
++ </div>
++ </div>
+</body>
+```
+
+UI๊ฐ ํ์ฌ ์ ํํ ํ์ผ์ ๋ณด์ฌ์ฃผ๋๋ก CSS๋ ์ถ๊ฐํฉ๋๋ค.
+
+```css
+body {
+ margin: 0;
+}
+#c {
+ width: 100vw;
+ height: 100vh;
+ display: block;
+}
++#ui {
++ position: absolute;
++ left: 10px;
++ top: 10px;
++ background: rgba(0, 0, 0, 0.8);
++ padding: 5px;
++}
++#ui input[type=radio] {
++ width: 0;
++ height: 0;
++ display: none;
++}
++#ui input[type=radio] + label {
++ background-image: url('resources/images/minecraft/flourish-cc-by-nc-sa.png');
++ background-size: 1600% 400%;
++ image-rendering: pixelated;
++ width: 64px;
++ height: 64px;
++ display: inline-block;
++}
++#ui input[type=radio]:checked + label {
++ outline: 3px solid red;
++}
++@media (max-width: 600px), (max-height: 600px) {
++ #ui input[type=radio] + label {
++ width: 32px;
++ height: 32px;
++ }
++}
+```
+
+๊ธฐ๋ฅ์ ๋ค์์ฒ๋ผ ๊ตฌํํ ๊ฒ๋๋ค. ์ ํํ ํ์ผ์ด ์๊ฑฐ๋ shift ํค๋ฅผ ๋๋ฅด๊ณ ์๋ ๊ฒฝ์ฐ, ๋ณต์
์ ํด๋ฆญํ๋ฉด ํด๋น ๋ณต์
์ด ์ง์์ง๋๋ค. ๋ฐ๋๋ก ์ ํํ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ ์ ํํ ํ์ผ์ด ์ถ๊ฐ๋์ฃ . ์ ํํ ํ์ผ์ ๋ค์ ํด๋ฆญํ๋ฉด ์ ํ์ ํด์ ํ ์ ์์ต๋๋ค.
+
+์๋๋ ์ฌ์ฉ์๊ฐ ์ ํํ ๋ผ๋์ค ๋ฒํผ์ ํด์ ํ ์ ์๊ฒ๋ ํด์ฃผ๋ ์ฝ๋์
๋๋ค.
+
+```js
+let currentVoxel = 0;
+let currentId;
+
+document.querySelectorAll('#ui .tiles input[type=radio][name=voxel]').forEach((elem) => {
+ elem.addEventListener('click', allowUncheck);
+});
+
+function allowUncheck() {
+ if (this.id === currentId) {
+ this.checked = false;
+ currentId = undefined;
+ currentVoxel = 0;
+ } else {
+ currentId = this.id;
+ currentVoxel = parseInt(this.value);
+ }
+}
+```
+
+์๋ ์ฝ๋๋ ์ฌ์ฉ์๊ฐ ํด๋ฆญํ ์ง์ ์ ๋ณต์
์ ์ถ๊ฐํ๋ ์ญํ ์
๋๋ค. [ํผํน์ ๊ดํ ๊ธ](threejs-picking.html)์์ ์ผ๋ ๊ฒ๊ณผ ๋น์ทํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋๋ฐ, Three.js์ ๋ด์ฅ `RayCaster`๊ฐ ์๋ ๊ต์ฐจํ๋ ์ง์ ์ ์ขํ์ ๊ต์ฐจํ ์ ์ ๋ฒ์ (normal)์ ๋ฐํํ๋ `VoxelWorld.intersectRay`๋ฅผ ์ฌ์ฉํฉ๋๋ค.
+
+```js
+function getCanvasRelativePosition(event) {
+ const rect = canvas.getBoundingClientRect();
+ return {
+ x: (event.clientX - rect.left) * canvas.width / rect.width,
+ y: (event.clientY - rect.top ) * canvas.height / rect.height,
+ };
+}
+
+function placeVoxel(event) {
+ const pos = getCanvasRelativePosition(event);
+ const x = (pos.x / canvas.width ) * 2 - 1;
+ const y = (pos.y / canvas.height) * -2 + 1; // Y์ถ์ ๋ค์ง์์
+
+ const start = new THREE.Vector3();
+ const end = new THREE.Vector3();
+ start.setFromMatrixPosition(camera.matrixWorld);
+ end.set(x, y, 1).unproject(camera);
+
+ const intersection = world.intersectRay(start, end);
+ if (intersection) {
+ const voxelId = event.shiftKey ? 0 : currentVoxel;
+ /**
+ * ๊ต์ฐจ์ ์ ๋ฉด ์์ ์์ต๋๋ค. ์ด๋ ์ํ์ ์ค์ฐจ๋ก ์ธํด ๊ต์ฐจ์ ์ด ๋ฉด์ ์๋ฉด
+ * ์ด๋๋ก ๋จ์ด์ง์ง ๋ชจ๋ฅธ๋ค๋ ์ด์ผ๊ธฐ์ฃ .
+ * ๊ทธ๋์ ๋ณต์
์ ์ ๊ฑฐํ๋ ๊ฒฝ์ฐ(currentVoxel = 0)๋ normal์ ๊ฐ์ ๋ฐ์ผ๋ก
+ * ์ค์ด๊ณ , ์ถ๊ฐํ๋ ๊ฒฝ์ฐ(currentVoxel > 0)์๋ ๋ฐฉํฅ์ ๋ฐ๊พผ ๋ค ๋ฐ๋งํผ ์ค์
๋๋ค.
+ **/
+ const pos = intersection.position.map((v, ndx) => {
+ return v + intersection.normal[ndx] * (voxelId > 0 ? 0.5 : -0.5);
+ });
+ world.setVoxel(...pos, voxelId);
+ updateVoxelGeometry(...pos);
+ requestRenderIfNotRequested();
+ }
+}
+
+const mouse = {
+ x: 0,
+ y: 0,
+};
+
+function recordStartPosition(event) {
+ mouse.x = event.clientX;
+ mouse.y = event.clientY;
+ mouse.moveX = 0;
+ mouse.moveY = 0;
+}
+function recordMovement(event) {
+ mouse.moveX += Math.abs(mouse.x - event.clientX);
+ mouse.moveY += Math.abs(mouse.y - event.clientY);
+}
+function placeVoxelIfNoMovement(event) {
+ if (mouse.moveX < 5 && mouse.moveY < 5) {
+ placeVoxel(event);
+ }
+ window.removeEventListener('mousemove', recordMovement);
+ window.removeEventListener('mouseup', placeVoxelIfNoMovement);
+}
+canvas.addEventListener('mousedown', (event) => {
+ event.preventDefault();
+ recordStartPosition(event);
+ window.addEventListener('mousemove', recordMovement);
+ window.addEventListener('mouseup', placeVoxelIfNoMovement);
+}, { passive: false });
+canvas.addEventListener('touchstart', (event) => {
+ event.preventDefault();
+ recordStartPosition(event.touches[0]);
+}, { passive: false });
+canvas.addEventListener('touchmove', (event) => {
+ event.preventDefault();
+ recordMovement(event.touches[0]);
+}, { passive: false });
+canvas.addEventListener('touchend', () => {
+ placeVoxelIfNoMovement({
+ clientX: mouse.x,
+ clientY: mouse.y,
+ });
+});
+```
+
+๋ง์ฐ์ค๋ ๋ ๊ฐ์ง ์ฉ๋๋ก ์ฌ์ฉํฉ๋๋ค. ํ๋๋ ์นด๋ฉ๋ผ๋ฅผ ์์ง์ด๋ ์ฉ๋์ด๊ณ , ๋ค๋ฅธ ํ๋๋ ๋ณต์
์ ์์ ํ๋ ์ฉ๋์ด์ฃ . ๋ณต์
์ ์ถ๊ฐ/์ ๊ฑฐ ์ก์
์ ๋ง์ฐ์ค๋ฅผ ๋๋ฅด๊ณ ์ ํ ์์ง์ด์ง ์์์ ๋๋ง ๋ฐ์ํฉ๋๋ค. ๋ง์ฐ์ค๋ฅผ ๋๋ฅธ ๋ค ์์ง์๋ค๋ฉด ์นด๋ฉ๋ผ๋ฅผ ๋๋ฆฌ๋ ค๋ ์๋๋ก ๊ฐ์ฃผํ ๊ฒ์ด์ฃ . `moveX`์ `moveY`๋ ์ ๋๊ฐ์ผ๋ก, ์ผ์ชฝ์ผ๋ก 10ํฝ์
, ์ค๋ฅธ์ชฝ์ผ๋ก ๋ค์ 10ํฝ์
์ ์์ง์๋ค๋ฉด `moveX`๋ 20ํฝ์
์ด ๋ฉ๋๋ค. ์ด๋ฌ๋ฉด ํ๋ฉด์ ๋๋ ธ๋ค๊ฐ ๋ค์ ์ ์๋ฆฌ์ ๋๋ ๊ฒฝ์ฐ์๋ ๋ณต์
์ ์ถ๊ฐ/์ ๊ฑฐ ์ก์
์ด ๋ฐ์ํ์ง ์์ ๊ฒ๋๋ค. 5ํฝ์
์ด์ ์์ง์ด์ง ์์์ ๊ฒฝ์ฐ ํด๋ฆญ์ผ๋ก ๊ฐ์ฃผํ๋๋ฐ, ๋ณ๋ ํ
์คํธ๋ ์งํํ์ง ์์ ์์์ ๊ฐ์ด๋ ์ฐธ๊ณ ๋ฐ๋๋๋ค.
+
+์ ์ฝ๋์์๋ `world.setVoxel`๋ก ๋ณต์
์ ์ถ๊ฐํ ๋ค `updateVoxelGeometry`๋ฅผ ํธ์ถํด Three.js๊ฐ ๋ณ๊ฒฝ๋ geometry๋ฅผ ๋ฐ์ํ๋๋ก ํ์ต๋๋ค.
+
+์ด์ ์ด `updateVoxelGeometry`๋ฅผ ๋ง๋ค์ด์ผ ํฉ๋๋ค. ์ฌ์ฉ์๊ฐ cell ๊ฐ์ฅ์๋ฆฌ์ ๋ณต์
์ ํด๋ฆญํ๋ค๋ฉด ์๋ก์ด cell geometry๋ฅผ ๋ง๋ค์ด์ผ ํ ์๋ ์์ฃ . ๋๋ฌธ์ ๋ฐฉ๊ธ ์ถ๊ฐํ ๋ณต์
๋ฟ๋ง ์๋๋ผ ํด๋น ๋ณต์
์ cell ์ฃผ๋ณ cell๋ค๋ ์ ๋ถ ํ์ธํด์ผ ํฉ๋๋ค.
+
+```js
+const neighborOffsets = [
+ [ 0, 0, 0], // ์์
+ [-1, 0, 0], // ์ผ์ชฝ
+ [ 1, 0, 0], // ์ค๋ฅธ์ชฝ
+ [ 0, -1, 0], // ์๋
+ [ 0, 1, 0], // ์
+ [ 0, 0, -1], // ๋ค
+ [ 0, 0, 1], // ์
+];
+function updateVoxelGeometry(x, y, z) {
+ const updatedCellIds = {};
+ for (const offset of neighborOffsets) {
+ const ox = x + offset[0];
+ const oy = y + offset[1];
+ const oz = z + offset[2];
+ const cellId = world.computeCellId(ox, oy, oz);
+ if (!updatedCellIds[cellId]) {
+ updatedCellIds[cellId] = true;
+ updateCellGeometry(ox, oy, oz);
+ }
+ }
+}
+```
+
+์ฒ์์๋ ์๋์ฒ๋ผ ์ธ์ ํ cell์ ๊ฒ์ฌํ๋ ค ํ์ต๋๋ค.
+
+```js
+const voxelX = THREE.MathUtils.euclideanModulo(x, cellSize) | 0;
+if (voxelX === 0) {
+ // cell์ ์ผ์ชฝ์ ์ถ๊ฐํฉ๋๋ค.
+} else if (voxelX === cellSize - 1) {
+ // cell์ ์ค๋ฅธ์ชฝ์ ์ถ๊ฐํฉ๋๋ค.
+}
+```
+
+์ฌ๊ธฐ์ ๋ค๋ฅธ 4๋ฐฉํฅ์ ๊ฒ์ฌํ๋ ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ ค ํ์ง๋ง, ์ด๋ ๊ทธ๋ฅ ์ขํ๊ฐ ๋ฐฐ์ด์ ๋ง๋ค์ด ์ด๋ฏธ ๋ง๋ cell์ id๋ก ์ฌ์ฉํ๋ ๊ฒ ๋ ๋ซ๋ค๋ ์๊ฐ์ด ๋ค์์ต๋๋ค. ์ถ๊ฐํ ๋ณต์
์ด cell์ ์์ ์๋ ๊ฒ ์๋๋ผ๋ฉด ํด๋น ๋ณต์
์ ์ถ๊ฐํ๊ธธ ๊ฑฐ๋ถํ๋ ๊ฒ ๋ ๋น ๋ฅผ ํ
๋๊น์.
+
+`updateCellGeometry`๋ ๊ฐ๋จํ ์ด์ ์ cell์ ๋ง๋ค์๋ ์ฝ๋๋ฅผ ๊ฐ์ ธ์ ์ฌ๋ฌ cell์ ๋ง๋ค ์ ์๋๋ก ์์ ํ์ต๋๋ค.
+
+```js
+const cellIdToMesh = {};
+function updateCellGeometry(x, y, z) {
+ const cellX = Math.floor(x / cellSize);
+ const cellY = Math.floor(y / cellSize);
+ const cellZ = Math.floor(z / cellSize);
+ const cellId = world.computeCellId(x, y, z);
+ let mesh = cellIdToMesh[cellId];
+ const geometry = mesh ? mesh.geometry : new THREE.BufferGeometry();
+
+ const { positions, normals, uvs, indices } = world.generateGeometryDataForCell(cellX, cellY, cellZ);
+ const positionNumComponents = 3;
+ geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), positionNumComponents));
+ const normalNumComponents = 3;
+ geometry.setAttribute('normal', new THREE.BufferAttribute(new Float32Array(normals), normalNumComponents));
+ const uvNumComponents = 2;
+ geometry.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(uvs), uvNumComponents));
+ geometry.setIndex(indices);
+ geometry.computeBoundingSphere();
+
+ if (!mesh) {
+ mesh = new THREE.Mesh(geometry, material);
+ mesh.name = cellId;
+ cellIdToMesh[cellId] = mesh;
+ scene.add(mesh);
+ mesh.position.set(cellX * cellSize, cellY * cellSize, cellZ * cellSize);
+ }
+}
+```
+
+์ ํจ์๋ ์ธ๋ฑ์ค ๋งต๊ณผ cell์ id๋ก ๋ฏธ๋ฆฌ ๋ง๋ mesh๊ฐ ์๋์ง ํ์ธํฉ๋๋ค. ๋ง์ฝ ํด๋น id(์ขํ)์ ํด๋นํ๋ cell์ด ์๋ค๋ฉด ์๋ก์ด cell mesh๋ฅผ ๋ง๋ค์ด ์ฅ๋ฉด์ ์ถ๊ฐํ ๋ค mesh์ ์์ฑ๊ณผ ์ธ๋ฑ์ค ๋งต์ ์
๋ฐ์ดํธํฉ๋๋ค.
+
+{{{example url="../threejs-voxel-geometry-culled-faces-ui.html"}}}
+
+์ฐธ๊ณ :
+
+์์ ์ ๋ฐฉ๋ฒ ๋์ `RayCaster`๋ฅผ ์จ๋ ๊ด์ฐฎ์ ๊ฒฐ๊ณผ๊ฐ ๋์ฌ ์ ์์ต๋๋ค. ๋ฐ๋ก ํ
์คํธ๋ฅผ ํด๋ณด์ง ์์์ง๋ง, ๋์ [๋ณต์
์ ์ต์ ํ๋ raycaster](http://www.cse.chalmers.se/edu/year/2010/course/TDA361/grid.pdf)๋ฅผ ์ฐพ์ ์ด๊ฑธ ์ ์ฉํ์ต๋๋ค.
+
+`intersectRay`๋ฅผ VoxelWorld์ ๋ฉ์๋๋ก ๋ง๋ ๊ฑด ์ฑ๋ฅ ๋๋ฌธ์
๋๋ค. ๋ณต์
๋จ์๋ก ์ฒดํฌํ๋ ๊ฒ ๋๋ฌด ๋๋ฆด ๊ฒฝ์ฐ cell ๋จ์๋ก ๋จผ์ ์ฒดํฌํด ์ฑ๋ฅ์ ์ข ๋ ๋ํ๋ณด๋ ค๋ ๊ณํ์ด์์ฃ .
+
+ํ์ฌ raycaster์ ๊ธธ์ด๋ z-far๊น์ง์ธ๋ฐ, ์ด ๊ฐ์ ๋ฐ๊ฟ๋ ๋ฉ๋๋ค. ์ด๊ฑด ์ ๊ฐ ์์ ๋ฅผ ๋ง๋ค ๋ 1-2ํฝ์
์ ๋๋ก ๋ณด์ด๋ ๋จผ ๊ณณ์๋ ๋ณต์
์ ๋ง๋ค ์ผ์ด ์๋ค๊ณ ์๊ฐํ๊ธฐ ๋๋ฌธ์ด๋๊น์.
+
+`geometry.computeBoundingSphere` ๋ฉ์๋์ ์ฑ๋ฅ์ ๋ค์ ๋๋ฆด ์ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ cell์ ์ ๋ถ ํฌํจํ๋ ๊ฒฝ๊ณ ๊ตฌ์ฒด๋ฅผ ์ง์ ๋ง๋ค ์ ์์ฃ .
+
+์ค์ ํ๋ก์ ํธ์๋ค๋ฉด ์๋ง ๋ณต์
์ด ์์ ์๋ cell๋ ์ ๊ฑฐํ๋ ๊ฒ ์ข์์ ๊ฒ๋๋ค.
+
+์ด ๋ฐฉ๋ฒ์ด ๊ฐ์ฅ ๋ณ๋ก์ผ ๊ฒฝ์ฐ๋ ๋น์ฐํ ์ฒดํฌํ ํํ๋ก ๋ณต์
์ ๋ฐฐ์นํ๋ ๊ฒฝ์ฐ(์๋ฅผ ๋ค์ด ์ฒดํฌํ์ ํฐ์ ์นธ์๋ง ๋ฐฐ์น)์ผ ๊ฒ๋๋ค. ๋น์ฅ์ ์ด๋ฐ ๊ฒฝ์ฐ์ ์ด๋ป๊ฒ ์ฑ๋ฅ์ ํฅ์์ํฌ์ง ์๊ฐ๋๋ ๋ฐฉ๋ฒ์ด ์๋ค์. ์๋ง ์ฌ์ฉ์๊ฐ ์ฑ๋ฅ ๋๋ฌธ์ ๊ฑฐ๋ํ ์ฒดํฌํ ๋ง๋ค๊ธฐ๋ฅผ ํฌ๊ธฐํ๋ ๊ฒ ๋ ๋น ๋ฅผ ๊ฒ๋๋ค.
+
+์์ ์์๋ ๊ฐ๋จํ ํํ๋ง ๊ตฌํํ๊ธฐ ์ํด ํ
์ค์ฒ ์ํ๋ผ์ค๋ฅผ ํ
์ค์ฒ ํ ์ข
๋ฅ๋น ํ ์ด์ฉ๋ง ๋ง๋ค์์ต๋๋ค. ๊ฐ ๋ณต์
์ ๋ฉด์ ๋ค๋ฅธ ํ
์ค์ฒ๋ฅผ ์ง์ ํ ์ ์๋๋ก ๋ณ๋์ ํ
์ด๋ธ์ ๋ง๋ค๋ฉด ์ข ๋ ๋ฒ์ฉ์ฑ์ ์ถ๊ตฌํ ์ ์๊ฒ ์ฃ . ์์ ์์๋ ๋ถํ์ํ ๋ญ๋น๋ผ๊ณ ์๊ฐํด ํด๋น ๋ถ๋ถ์ ์ ์ธํ์ต๋๋ค.
+
+์ค์ ๋ง์ธํฌ๋ํํธ์๋ ๋ณต์
๋, ์ ์ก๋ฉด์ฒด๋ ์๋ ํ์ผ(tile)์ด๋ผ๋ ๊ฒ์ด ์์ต๋๋ค. ์ธํ๋ฆฌ๋ ๊ฝ ๊ฐ์ ๊ฒ์ด ์ฌ๊ธฐ์ ํด๋นํ์ฃ . ์ด๊ฑธ ๊ตฌํํ๋ ค๋ฉด ๊ฐ ๋ณต์
์ด ์ ์ก๋ฉด์ฒด์ธ์ง, ๋ค๋ฅธ geometry์ธ์ง ํ๋ณํ๋ ํ
์ด๋ธ์ ๋ง๋ค์ด ๋ณต์
์ด ์ ์ก๋ฉด์ฒด๊ฐ ์๋ ๊ฒฝ์ฐ, ๋ง๋ฟ๋ ๋ฉด์ ์ ๊ฑฐํ์ง ์๋๋ก ํด์ผ ํฉ๋๋ค. ๊ฝ ๋ณต์
์๋์ ์๋ ๋
๋ณต์
์ด ์ง์์ ธ์๋ ์ ๋๋๊น์.
+
+์ด ๊ธ์ด Three.js๋ก ๋ง์ธํฌ๋ํํธ ๊ฐ์ ๊ทธ๋ํฝ์ ๊ตฌํํ ๋ ์ข์ ์์์ ์ ๋ง๋ จํ๊ณ , geometry๋ฅผ ์ต์ ํํ๋ ๋ฐ ๋์์ด ๋์์ผ๋ฉด ํฉ๋๋ค.
+
+<canvas id="c"></canvas>
+<script type="module" src="../resources/threejs-voxel-geometry.js"></script> | false |
Other | mrdoob | three.js | 1f3f78f42d008cb920b44930aedf5f55ec87ffbe.json | add translation kr/threejs-cleanup.md | threejs/lessons/kr/threejs-cleanup.md | @@ -0,0 +1,412 @@
+Title: Three.js ๋ฉ๋ชจ๋ฆฌ ํด์ ํ๊ธฐ
+Description: Three.js๋ฅผ ์ฌ์ฉํ ๋ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํด์ ํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ๋ฉ๋ชจ๋ฆฌ ํด์ ํ๊ธฐ
+
+Three.js ์ฑ์ ์๊ฐ๋ณด๋ค ๋ง์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค. 3D ๋ชจ๋ธ์ ์ ์ ๋ฐ์ดํฐ๋ ๋ณดํต 1MB์์ 20MB ์ ๋์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฐจ์งํ์ฃ . ํ
์ค์ฒ๋ก JPG ํ์ผ์ ์ฌ์ฉํ๋ ๋ชจ๋ธ์ ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด JPG ํ์ผ์ ์์ถ์ ์์ ํ ํ์ด์ผ ํ๋๋ฐ, ์ด ํ
์ค์ฒ๋ 1024x1024๋น ์ฝ 4์์ 6MB ์ ๋์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
+
+๋๋ค์์ Three.js ์ฑ์ ์์์ ํ ๋ฒ ๋ถ๋ฌ์ค๋ฉด ํ์ด์ง๊ฐ ๋ซํ๊ธฐ ์ ๊น์ง ํด๋น ์์์ ๋ฒ๋ฆด ์ผ์ด ์์ต๋๋ค. ํ์ง๋ง ์๊ฐ์ด ์ง๋จ์ ๋ฐ๋ผ ๋ฐ์ดํฐ๋ฅผ ๋ฐ๊ฟ์ผ ํ๋ค๋ฉด ์ด๋จ๊น์?
+
+Three.js๋ ์๋ฐ์คํฌ๋ฆฝํธ์ ๋ฌ๋ฆฌ ํ ๋นํ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์์์ ๋น์ฐ์ง ๋ชปํฉ๋๋ค. ํ์ด์ง๋ฅผ ์ ํํ๋ ๊ฒฝ์ฐ์ผ ๋ธ๋ผ์ฐ์ ๊ฐ ์์์ ํด๋น ์์์ ๋ฉ๋ชจ๋ฆฌ์์ ์ง์ฐ๊ฒ ์ง๋ง, ๊ทธ ๋ฐ์ ๊ฒฝ์ฐ ๋ฉ๋ชจ๋ฆฌ ํด์ ๋ ์ ์ ์ผ๋ก ๊ฐ๋ฐ์์๊ฒ ๋ฌ๋ ธ์ต๋๋ค.
+
+Three.js์์๋ [textures](threejs-textures.html), [geometries](threejs-primitives.html), [materials](threejs-materials.html)์ `dispose` ๋ฉ์๋๋ฅผ ํธ์ถํด ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํด์ ํ ์ ์์ต๋๋ค.
+
+๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ ์ผ์ผ์ด ํธ์ถํ๋ ๊ฒ๋๋ค. ์ด๊ธฐํ ์์ ์๋์ ๊ฐ์ด ์ง์์ ๋ฉ๋ชจ๋ฆฌ์ ํ ๋นํ๊ณ
+
+```js
+const boxGeometry = new THREE.BoxBufferGeometry(...);
+const boxTexture = textureLoader.load(...);
+const boxMaterial = new THREE.MeshPhongMaterial({ map: texture });
+```
+
+์๋์ ๊ฐ์ด ์ง์ ๋ฉ์๋๋ฅผ ํธ์ถํด ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํด์ ํ ์ ์์ฃ .
+
+```js
+boxGeometry.dispose();
+boxTexture.dispose();
+boxMaterial.dispose();
+```
+
+ํ์ง๋ง ์์์ด ๋ง์์ง์๋ก ์ฝ๋๋ ์ง์ ๋ถํด์ง ๊ฒ๋๋ค.
+
+์์์ ์ถ์ ํ๋ ํด๋์ค๋ฅผ ํ๋ ๋ง๋๋ ๊ฒ ์ข๊ฒ ๋ค์. ํด๋์ค์ ์์์ ์ง์ ํ๊ณ ํ ๋ฒ์ ๋ฒ๋ฆฌ๋๋ก ํด๋ณด๊ฒ ์ต๋๋ค.
+
+```js
+class ResourceTracker {
+ constructor() {
+ this.resources = new Set();
+ }
+ track(resource) {
+ if (resource.dispose) {
+ this.resources.add(resource);
+ }
+ return resource;
+ }
+ untrack(resource) {
+ this.resources.delete(resource);
+ }
+ dispose() {
+ for (const resource of this.resources) {
+ resource.dispose();
+ }
+ this.resources.clear();
+ }
+}
+```
+
+[ํ
์ค์ฒ์ ๊ดํ ๊ธ](threejs-textures.html)์ ์ฒซ ๋ฒ์งธ ์์ ์ ์ด ํด๋์ค๋ฅผ ์จ ๋ด
์๋ค. ๋จผ์ ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+const resTracker = new ResourceTracker();
+```
+
+์ข ๋ ๊ฐ๋จํ ํํ๋ก ์ฐ๊ธฐ ์ํด `track` ๋ฉ์๋๋ฅผ ํจ์๋ก ๋ง๋ญ๋๋ค.
+
+```js
+const resTracker = new ResourceTracker();
++const track = resTracker.track.bind(resTracker);
+```
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ geometry, ํ
์ค์ฒ, ์ฌ์ง(material)์ `track` ํจ์๋ฅผ ํธ์ถํฉ๋๋ค.
+
+```js
+const boxWidth = 1;
+const boxHeight = 1;
+const boxDepth = 1;
+-const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
++const geometry = track(new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth));
+
+const cubes = []; // ์ ์ก๋ฉด์ฒด๋ฅผ ํ์ ์ํค๊ธฐ ์ํ ๋ฐฐ์ด
+const loader = new THREE.TextureLoader();
+
+-const material = new THREE.MeshBasicMaterial({
+- map: loader.load('resources/images/wall.jpg'),
+-});
++const material = track(new THREE.MeshBasicMaterial({
++ map: track(loader.load('resources/images/wall.jpg')),
++}));
+const cube = new THREE.Mesh(geometry, material);
+scene.add(cube);
+cubes.push(cube); // ํ์ ์ ๋๋ฉ์ด์
์ ์ํด ๋ฐฐ์ด์ ์ถ๊ฐ
+```
+
+์์์ ํด์ ํ ๋ ์ ์ก๋ฉด์ฒด๋ฅผ ์ฅ๋ฉด์์ ์ ๊ฑฐํ๊ณ `resTracker.dispose` ๋ฉ์๋๋ฅผ ํธ์ถํ๋๋ก ํฉ๋๋ค.
+
+```js
+for (const cube of cubes) {
+ scene.remove(cube);
+}
+cubes.length = 0; // ์ ์ก๋ฉด์ฒด ๋ฐฐ์ด์ ๋น์๋๋ค
+resTracker.dispose();
+```
+
+ํ์ง๋ง ์ค์ ๋ก ํ
์คํธํด๋ณด๋ ๊ท์ฐฎ์ ์์
์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. `ResourceTracker`์ ์ฝ๋๋ฅผ ์ถ๊ฐํ๊ฒ ์ต๋๋ค.
+
+```js
+class ResourceTracker {
+ constructor() {
+ this.resources = new Set();
+ }
+ track(resource) {
+- if (resource.dispose) {
++ if (resource.dispose || resource instanceof THREE.Object3D) {
+ this.resources.add(resource);
+ }
+ return resource;
+ }
+ untrack(resource) {
+ this.resources.delete(resource);
+ }
+ dispose() {
+ for (const resource of this.resources) {
+- resource.dispose();
++ if (resource instanceof THREE.Object3D) {
++ if (resource.parent) {
++ resource.parent.remove(resource);
++ }
++ }
++ if (resource.dispose) {
++ resource.dispose();
++ }
++ }
+ this.resources.clear();
+ }
+}
+```
+
+์ด์ ์ ์ก๋ฉด์ฒด๋ฅผ ์ถ์ ํ ์ ์์ต๋๋ค.
+
+```js
+const material = track(new THREE.MeshBasicMaterial({
+ map: track(loader.load('resources/images/wall.jpg')),
+}));
+const cube = track(new THREE.Mesh(geometry, material));
+scene.add(cube);
+cubes.push(cube); // ํ์ ์ ๋๋ฉ์ด์
์ ์ํด ๋ฐฐ์ด์ ์ถ๊ฐ
+```
+
+๋ณ๋๋ก ์ ์ก๋ฉด์ฒด๋ฅผ ์ ๊ฑฐํด์ผํ ํ์๊ฐ ์์ผ๋ ์ฝ๋๋ฅผ ์ญ์ ํฉ๋๋ค.
+
+```js
+-for (const cube of cubes) {
+- scene.remove(cube);
+-}
+cubes.length = 0; // ์ ์ก๋ฉด์ฒด ๋ฐฐ์ด์ ๋น์๋๋ค
+resTracker.dispose();
+```
+
+์ฝ๋๋ฅผ ์ ๋ฆฌํด ์ ์ก๋ฉด์ฒด, ํ
์ค์ฒ, ์ฌ์ง์ ๋ค์ ์ถ๊ฐํ ์ ์๋๋ก ๋ง๋ค๊ณ
+
+```js
+const scene = new THREE.Scene();
+*const cubes = []; // ์ ์ก๋ฉด์ฒด๋ฅผ ํ์ ์ํค๊ธฐ ์ํ ๋ฐฐ์ด
+
++function addStuffToScene() {
+ const resTracker = new ResourceTracker();
+ const track = resTracker.track.bind(resTracker);
+
+ const boxWidth = 1;
+ const boxHeight = 1;
+ const boxDepth = 1;
+ const geometry = track(new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth));
+
+ const loader = new THREE.TextureLoader();
+
+ const material = track(new THREE.MeshBasicMaterial({
+ map: track(loader.load('resources/images/wall.jpg')),
+ }));
+ const cube = track(new THREE.Mesh(geometry, material));
+ scene.add(cube);
+ cubes.push(cube); // ํ์ ์ ๋๋ฉ์ด์
์ ์ํด ๋ฐฐ์ด์ ์ถ๊ฐ
++ return resTracker;
++}
+```
+
+์๊ฐ์ ์ง๋จ์ ๋ฐ๋ผ ๋ฌผ์ฒด๋ค์ ์ฌ๋ผ์ง๊ณ ๋ํ๋๊ฒ ํฉ๋๋ค.
+
+```js
+function waitSeconds(seconds = 0) {
+ return new Promise(resolve => setTimeout(resolve, seconds * 1000));
+}
+
+async function process() {
+ for (;;) {
+ const resTracker = addStuffToScene();
+ await wait(2);
+ cubes.length = 0; // ์ ์ก๋ฉด์ฒด ๋ฐฐ์ด์ ๋น์๋๋ค
+ resTracker.dispose();
+ await wait(1);
+ }
+}
+process();
+```
+
+์๋ ์์ ๋ ์ ์ก๋ฉด์ฒด, ํ
์ค์ฒ, ์ฌ์ง์ ๋ ๋๋งํ ๋ค 2์ด ํ์ ํด๋น ์์์ ๋ฒ๋ฆฌ๊ณ , ๋ค์ 1์ด ํ์ ์์ฑํ๊ธฐ๋ฅผ ๋ฐ๋ณตํฉ๋๋ค.
+
+{{{example url="../threejs-cleanup-simple.html" }}}
+
+๋ฑํ ์ค๋ฅ๋ ์๋ค์.
+
+๋ถ๋ฌ์จ ํ์ผ์ ํด์ ํ๋ ค๋ฉด ์ฝ๋๋ฅผ ์ข ๋ ์ถ๊ฐํด์ผ ํฉ๋๋ค. Three.js์ ๋ก๋๋ ๋๋ถ๋ถ ์ต์์ `Object3D`๋ง์ ๋ฐํํ๊ธฐ์ ์ด๋ค ์์์ ์ฌ์ฉํ๋์ง ์ฒดํฌํ๋ ค๋ฉด ์ผ์ผ์ด ํ์ ์์๋ฅผ ๋ค์ ธ๋ด์ผ ํฉ๋๋ค.
+
+`ResourceTracker`๋ฅผ ์
๋ฐ์ดํธํด ์ ์ญํ ์ ๋งก๊ฒจ๋ณด์ฃ .
+
+๋จผ์ ์์์ด `Object3D`์ธ์ง ํ์ธํด ํด๋น ์์์ geometry, ์ฌ์ง, ํ์ ์์๋ฅผ ์ถ์ ํ๋๋ก ํฉ๋๋ค.
+
+```js
+class ResourceTracker {
+ constructor() {
+ this.resources = new Set();
+ }
+ track(resource) {
+ if (resource.dispose || resource instanceof THREE.Object3D) {
+ this.resources.add(resource);
+ }
++ if (resource instanceof THREE.Object3D) {
++ this.track(resource.geometry);
++ this.track(resource.material);
++ this.track(resource.children);
++ }
+ return resource;
+ }
+ ...
+}
+```
+
+๊ทธ๋ฆฌ๊ณ `resource.geometry`, `resource.material`, `resource.children`์ด null์ด๋ undefined์ผ ์ ์์ผ๋ฏ๋ก `track` ๋ฉ์๋ ์๋จ์์ ์ฒดํฌํด์ค๋๋ค.
+
+```js
+class ResourceTracker {
+ constructor() {
+ this.resources = new Set();
+ }
+ track(resource) {
++ if (!resource) {
++ return resource;
++ }
+
+ if (resource.dispose || resource instanceof THREE.Object3D) {
+ this.resources.add(resource);
+ }
+ if (resource instanceof THREE.Object3D) {
+ this.track(resource.geometry);
+ this.track(resource.material);
+ this.track(resource.children);
+ }
+ return resource;
+ }
+ ...
+}
+```
+
+`resource.children`์ด๋ `resource.material`์ ๋ฐฐ์ด ํ์์ผ ์ ์์ต๋๋ค. ๋ฐฐ์ด์ผ ๊ฒฝ์ฐ ๋ฐฐ์ด์ ์์๋ฅผ ์ถ์ ํ๋๋ก ํฉ๋๋ค.
+
+```js
+class ResourceTracker {
+ constructor() {
+ this.resources = new Set();
+ }
+ track(resource) {
+ if (!resource) {
+ return resource;
+ }
+
++ // ํ์ ์์ ๋๋ ์ฌ์ง์ด ๋ฐฐ์ด์ผ ๊ฒฝ์ฐ
++ if (Array.isArray(resource)) {
++ resource.forEach(resource => this.track(resource));
++ return resource;
++ }
+
+ if (resource.dispose || resource instanceof THREE.Object3D) {
+ this.resources.add(resource);
+ }
+ if (resource instanceof THREE.Object3D) {
+ this.track(resource.geometry);
+ this.track(resource.material);
+ this.track(resource.children);
+ }
+ return resource;
+ }
+ ...
+}
+```
+
+๊ทธ๋ฆฌ๊ณ ์ฌ์ง์ ์์ฑ ์ค ํ
์ค์ฒ์ ๊ท ๋ฑ ๋ณ์(uniform)๋ฅผ ์ฒ๋ฆฌํด์ค๋๋ค.
+
+```js
+class ResourceTracker {
+ constructor() {
+ this.resources = new Set();
+ }
+ track(resource) {
+ if (!resource) {
+ return resource;
+ }
+
+* // ํ์ ์์ ๋๋ ์ฌ์ง์ด ๋ฐฐ์ด์ผ ๊ฒฝ์ฐ,
+* // ๊ท ๋ฑ ๋ณ์๊ฐ ํ
์ค์ฒ ๋ฐฐ์ด์ผ ๊ฒฝ์ฐ
+ if (Array.isArray(resource)) {
+ resource.forEach(resource => this.track(resource));
+ return resource;
+ }
+
+ if (resource.dispose || resource instanceof THREE.Object3D) {
+ this.resources.add(resource);
+ }
+ if (resource instanceof THREE.Object3D) {
+ this.track(resource.geometry);
+ this.track(resource.material);
+ this.track(resource.children);
+- }
++ } else if (resource instanceof THREE.Material) {
++ // ์ฌ์ง์ ํ
์ค์ฒ๊ฐ ์๋์ง ๊ฒ์ฌํด ์ถ์ ํฉ๋๋ค.
++ for (const value of Object.values(resource)) {
++ if (value instanceof THREE.Texture) {
++ this.track(value);
++ }
++ }
++ // ๊ท ๋ฑ ๋ณ์๊ฐ ํ
์ค์ฒ ๋๋ ํ
์ค์ฒ์ ๋ฐฐ์ด์ธ์ง ์ฒดํฌํฉ๋๋ค.
++ if (resource.uniforms) {
++ for (const value of Object.values(resource.uniforms)) {
++ if (value) {
++ const uniformValue = value.value;
++ if (uniformValue instanceof THREE.Texture ||
++ Array.isArray(uniformValue)) {
++ this.track(uniformValue);
++ }
++ }
++ }
++ }
++ }
+ return resource;
+ }
+ ...
+}
+```
+
+์์ ํ ํด๋์ค๋ฅผ [glTF ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html)์์ ์ผ๋ ์์ ์ ์ ์ฉํด ๋ฌด๋ฃ glTF ํ์ผ์ ๋ถ๋ฌ์๋ณด๋๋ก ํฉ์๋ค.
+
+```js
+const gltfLoader = new GLTFLoader();
+function loadGLTF(url) {
+ return new Promise((resolve, reject) => {
+ gltfLoader.load(url, resolve, undefined, reject);
+ });
+}
+
+function waitSeconds(seconds = 0) {
+ return new Promise(resolve => setTimeout(resolve, seconds * 1000));
+}
+
+const fileURLs = [
+ 'resources/models/cartoon_lowpoly_small_city_free_pack/scene.gltf',
+ 'resources/models/3dbustchallange_submission/scene.gltf',
+ 'resources/models/mountain_landscape/scene.gltf',
+ 'resources/models/simple_house_scene/scene.gltf',
+];
+
+async function loadFiles() {
+ for (;;) {
+ for (const url of fileURLs) {
+ const resMgr = new ResourceTracker();
+ const track = resMgr.track.bind(resMgr);
+ const gltf = await loadGLTF(url);
+ const root = track(gltf.scene);
+ scene.add(root);
+
+ // ํด๋น ์์์ ๋ชจ๋ ํ์ ๋ฌผ์ฒด๋ฅผ ํฌํจํ๋ ์ก๋ฉด์ฒด๋ฅผ ๊ณ์ฐํฉ๋๋ค.
+ const box = new THREE.Box3().setFromObject(root);
+
+ const boxSize = box.getSize(new THREE.Vector3()).length();
+ const boxCenter = box.getCenter(new THREE.Vector3());
+
+ // ์นด๋ฉ๋ผ๊ฐ ํ๋ฉด์ ์ ๋ถ ๋ด๋๋ก ์ค์ ํฉ๋๋ค.
+ frameArea(boxSize * 1.1, boxSize, boxCenter, camera);
+
+ await waitSeconds(2);
+ renderer.render(scene, camera);
+
+ resMgr.dispose();
+
+ await waitSeconds(1);
+
+ }
+ }
+}
+loadFiles();
+```
+
+{{{example url="../threejs-cleanup-loaded-files.html"}}}
+
+์ฝ๋์ ๋ํด ๋ช ๊ฐ์ง ์ค๋ช
ํ๊ณ ๋๋ด๊ฒ ์ต๋๋ค.
+
+๋ง์ฝ 2๊ฐ ์ด์์ ํ์ผ์ ํ ๋ฒ์ ๋ถ๋ฌ์ค๊ณ ๋์ค์ ๋ฐ๋ก ํด์ ํ๋ ค๋ฉด `ResourceTracker`๋ฅผ ํ์ผ๋ณ๋ก ์์ฑํ๋ฉด ๋ฉ๋๋ค.
+
+์ ์์ ์์๋ `gltf.scene`์๋ง `track` ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ์ด๊ฒ๋ง์ผ๋ก ์ง๊ธ `ResourceTracker`๋ ํฌํจ๋ ๋ชจ๋ ์์๋ฅผ ์ถ์ ํ๊ฒ ์ฃ . ํ๋ฉด์ ๋ญ๊ฐ๋ฅผ ๋ ์ถ๊ฐํ๋ ค๋ฉด ํด๋น ์์์ ์ถ์ ํ ์ง ๋ง์ง๋ฅผ ๋จผ์ ๊ฒฐ์ ํด์ผ ํฉ๋๋ค.
+
+ํน์ ๋๊ตฌ๋ฅผ ์บ๋ฆญํฐ์ ์์ ์์๋ก ์ถ๊ฐํด ์์ ์ฅ์ด ์ฃผ๋ ๊ฒฝ์ฐ๋ฅผ ์๋ก ๋ค ์ ์์ต๋๋ค. ๊ทธ๋ฅ ๋๊ตฌ๋ง ์ถ๊ฐํด์๋ ํด๋น ์์๋ฅผ ์ถ์ ํ ์ ์์ ํ
๋๊น์. ๋ชจ๋ฅด๊ธด ํด๋ ๊ฝค๋ ํํ ๊ฒฝ์ฐ์ผ ๊ฑฐ๋ผ ์๊ฐํฉ๋๋ค.
+
+์ฒ์์ `ResourceTracker`๋ฅผ ์์ฑํ์ ๋๋ ๋ชจ๋ ๊ฒ์ `track`์ด ์๋๋ผ `dispose` ๋ฉ์๋ ์์์ ํด๊ฒฐํ๋ ค๊ณ ํ์ต๋๋ค. ํ์ง๋ง ์บ๋ฆญํฐ์ ์์ ๋๊ตฌ๋ฅผ ์ฅ์ด ์ฃผ๋ ๊ฒฝ์ฐ๋ฅผ ์๊ฐํด๋ณด๋ `track`์ ํตํด ๋ฑ๋กํ ์์์ ํด์ ํ๋ ๊ฒ ํ์ฅ์ฑ ๋ฉด์์๋ ๊ทธ๋ ๊ณ ๋ ๋์ ๋ฐฉ๋ฒ ๊ฐ๋๊ตฐ์. ์ฌ ๊ทธ๋ํ ์ ์ฒด๋ฅผ ํด์ ์ํค๋ ๊ฒ๋ณด๋ค๋ ๋ถ๋ฌ์จ ํ์ผ๋ง ํด์ ์ํค๋ ๊ฒ ๋์ ํ
๋๊น์.
+
+`ResourceTracker`๋ฅผ ๋ง๋ค๊ธด ํ์ง๋ง 100% ๋ง์กฑ์ค๋ฝ์ง ์์ต๋๋ค. 3D ์์ง์์ ์์์ ์ด๋ฐ ์์ผ๋ก ๊ด๋ฆฌํ๋ ๊ฑด ํํ ์ผ์ด ์๋๊ฑฐ๋ ์. ์ด๋ค ์์์ด ์ฌ๋ผ์ฌ์ง ์ถ์ธกํ๋ ๊ฒ ์๋๋ผ ๋ฏธ๋ฆฌ ์๊ณ ์์ด์ผ ํ๋ ์ชฝ์ด ๋ง์ต๋๋ค. Three.js์ ํ์ผ ๋ก๋๊ฐ ๋ถ๋ฌ์จ ์์์ ์ฃผ์๊ฐ์ ์ ๋ถ ๋ฐํํ๋๋ก ๋ฐ๋๋ค๋ฉด ์ข๊ฒ ์ง๋ง, ์ง๊ธ์ ์ฅ๋ฉด(scene)์ ๋ถ๋ฌ์ฌ ๋ ๋ค๋ฅธ ์ ํ์ง๊ฐ ์๊ธฐ์ ์ด ํด๊ฒฐ์ฑ
์ด ์ต์ ์ด๊ฒ ์ฃ .
+
+์ด ์์๊ฐ Three.js์์ ์์์ ํด์ ํ๋ ๋ฐ ์กฐ๊ธ์ด๋๋ง ๋์์ด ๋์์ผ๋ฉด ํฉ๋๋ค. | false |
Other | mrdoob | three.js | 2a76908bcf50c966146e593ea6efd174382adf6a.json | add translation kr/threejs-billboards.md | threejs/lessons/kr/threejs-billboards.md | @@ -0,0 +1,286 @@
+Title: Three.js ๋น๋ณด๋(Billboards)
+Description: ๋ฌผ์ฒด๊ฐ ํญ์ ์นด๋ฉ๋ผ๋ฅผ ๋ฐ๋ผ๋ณด๋๋ก ํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ๋น๋ณด๋์ ํ์ฌ๋
+
+[์ด์ ๊ธ](threejs-canvas-textures.html)์์๋ `CanvasTexture`๋ฅผ ์ด์ฉํด ์บ๋ฆญํฐ์ ์ด๋ฆํ/๋ช
์ฐฐ์ ๋ถ์ด๋ ๋ฒ์ ์์๋ดค์ต๋๋ค. ๋๋ก๋ ์ด ์ด๋ฆํ๊ฐ ํญ์ ์นด๋ฉ๋ผ๋ฅผ ํฅํ๊ฒ ํด์ผ ํ ๊ฒฝ์ฐ๋ ์๊ฒ ์ฃ . Three.js์ `Sprite`์ `SpriteMaterial`์ ์ฌ์ฉํ๋ฉด ์ด๊ฑธ ์ฝ๊ฒ ๊ตฌํํ ์ ์์ต๋๋ค.
+
+[์บ๋ฒ์ค ํ
์ค์ฒ์ ๊ดํ ๊ธ](threejs-canvas-textures.html)์ ๋ช
์ฐฐ ์์ ๋ฅผ ๊ฐ์ ธ์ ์ฌ๊ธฐ์ `Sprite`์ `SpriteMaterial`์ ์ฌ์ฉํด๋ด
์๋ค.
+
+```js
+function makePerson(x, labelWidth, size, name, color) {
+ const canvas = makeLabelCanvas(labelWidth, size, name);
+ const texture = new THREE.CanvasTexture(canvas);
+ // ํ
์ค์ฒ์ฉ ์บ๋ฒ์ค๋ 2D์ด๋ฏ๋ก ํฝ์
์ด ๋ชจ์๋ ๊ฒฝ์ฐ ๋๋ต์ ์ผ๋ก
+ // ํํฐ๋งํ๊ฒ๋ ์ค์ ํฉ๋๋ค.
+ texture.minFilter = THREE.LinearFilter;
+ texture.wrapS = THREE.ClampToEdgeWrapping;
+ texture.wrapT = THREE.ClampToEdgeWrapping;
+
+- const labelMaterial = new THREE.MeshBasicMaterial({
++ const labelMaterial = new THREE.SpriteMaterial({
+ map: texture,
+- side: THREE.DoubleSide,
+ transparent: true,
+ });
+
+ const root = new THREE.Object3D();
+ root.position.x = x;
+
+ const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
+ root.add(body);
+ body.position.y = bodyHeight / 2;
+
+ const head = new THREE.Mesh(headGeometry, bodyMaterial);
+ root.add(head);
+ head.position.y = bodyHeight + headRadius * 1.1;
+
+- const label = new THREE.Mesh(labelGeometry, labelMaterial);
++ const label = new THREE.Sprite(labelMaterial);
+ root.add(label);
+ label.position.y = bodyHeight * 4 / 5;
+ label.position.z = bodyRadiusTop * 1.01;
+
+```
+
+์ด์ ๋ช
์ฐฐ์ด ํญ์ ์นด๋ฉ๋ผ๋ฅผ ๋ฐ๋ผ๋ด
๋๋ค.
+
+{{{example url="../threejs-billboard-labels-w-sprites.html" }}}
+
+ํ์ง๋ง ํน์ ๊ฐ๋์์ ๋ณด๋ ๋ช
์ฐฐ์ด ์ฌ๋๊ณผ ๊ฒน์ณ ๋ณด์
๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/billboard-label-z-issue.png" style="width: 455px;"></div>
+
+๊ฐ๋จํ ๋ช
์ฐฐ์ ์์น๋ฅผ ์ฎ๊ฒจ๋ฒ๋ฆฌ๋ฉด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์๊ฒ ์ฃ .
+
+```js
++// ๋ช
์ฐฐ์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํฉ๋๋ค.
++const labelBaseScale = 0.01;
+const label = new THREE.Sprite(labelMaterial);
+root.add(label);
+-label.position.y = bodyHeight * 4 / 5;
+-label.position.z = bodyRadiusTop * 1.01;
++label.position.y = head.position.y + headRadius + size * labelBaseScale;
+
+-// ๋ช
์ฐฐ์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํฉ๋๋ค.
+-const labelBaseScale = 0.01;
+label.scale.x = canvas.width * labelBaseScale;
+label.scale.y = canvas.height * labelBaseScale;
+```
+
+{{{example url="../threejs-billboard-labels-w-sprites-adjust-height.html" }}}
+
+์ถ๊ฐ๋ก ์ด ๋น๋ณด๋(billboard, ๊ด๊ณ ํ)*์ ํ์ฌ๋๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค.
+
+> โป ๋งฅ๋ฝ์ ๋ช
์ฐฐ์ด ๊ฐ์๊ธฐ ๋น๋ณด๋๊ฐ ๋๋ ๊ฒ ์ด์ํ์ง๋ง, ์๋ฌธ์ ํ๋ฆ ์์ฒด๋ฅผ ์์ ํ ์ ์์ด ๊ทธ๋๋ก ๋ฒ์ญํฉ๋๋ค. ๋ํ ๊ด๊ณ ํ์ผ๋ก ๋ฒ์ญํ ์๋ ์์ผ๋, ์ฐ๋ฆฌ๋๋ผ ์ฌ๋๋ค์๊ฒ ๊ด๊ณ ํ์ด๋ผ๋ ๊ฒ ์ ์๋ฟ์ง ์์ ๊ฒ์ด๊ธฐ์ ๊ทธ๋ฅ ์๋ฌธ์ ๊ทธ๋๋ก ์ฎ๊ฒจ ํ๊ธฐํ์์ต๋๋ค. ์ญ์ฃผ.
+
+3D ๋ฌผ์ฒด๋ฅผ ๊ทธ๋ฆฌ๋ ๋์ 3D ๋ฌผ์ฒด์ ์ด๋ฏธ์ง๋ก 2D ํ๋ฉด์ ๋ ๋๋งํ๋ ๊ธฐ๋ฒ์
๋๋ค. ๊ฝค ๋ง์ ๊ฒฝ์ฐ 3D ๋ฌผ์ฒด๋ฅผ ๊ทธ๋ฅ ๋ ๋๋งํ๋ ๊ฒ๋ณด๋ค ๋น ๋ฅด์ฃ .
+
+์์ ๋ก ๋๋ฌด๊ฐ ๊ทธ๋ฆฌ๋ ํํ๋ก ๋ฐฐ์น๋ ์ฅ๋ฉด(scene)์ ๋ง๋ค์ด๋ด
์๋ค. ๊ฐ ๋๋ฌด์ ์ค๊ธฐ๋ ์ํต, ์๋ถ๋ถ์ ์๋ฟ๋ก ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+๋จผ์ ๋ชจ๋ ๋๋ฌด๊ฐ ๊ณตํต์ผ๋ก ์ฌ์ฉํ ์๋ฟ, ์ํต์ geometry์ ์ฌ์ง(material)์ ๋ง๋ญ๋๋ค.
+
+```js
+const trunkRadius = .2;
+const trunkHeight = 1;
+const trunkRadialSegments = 12;
+const trunkGeometry = new THREE.CylinderBufferGeometry(
+ trunkRadius, trunkRadius, trunkHeight, trunkRadialSegments);
+
+const topRadius = trunkRadius * 4;
+const topHeight = trunkHeight * 2;
+const topSegments = 12;
+const topGeometry = new THREE.ConeBufferGeometry(
+ topRadius, topHeight, topSegments);
+
+const trunkMaterial = new THREE.MeshPhongMaterial({ color: 'brown' });
+const topMaterial = new THREE.MeshPhongMaterial({ color: 'green' });
+```
+
+๋ค์์ผ๋ก ํจ์๋ฅผ ํ๋ ๋ง๋ญ๋๋ค. ์ด ํจ์๋ ๋๋ฌด ์ค๊ธฐ `Mesh`์ ์๋ถ๋ถ `Mesh`๋ฅผ ๋ง๋ค๊ณ ์ด ๋์ `Object3D`์ ์์์ผ๋ก ๋ฃ๋ ์ญํ ์
๋๋ค.
+
+```js
+function makeTree(x, z) {
+ const root = new THREE.Object3D();
+ const trunk = new THREE.Mesh(trunkGeometry, trunkMaterial);
+ trunk.position.y = trunkHeight / 2;
+ root.add(trunk);
+
+ const top = new THREE.Mesh(topGeometry, topMaterial);
+ top.position.y = trunkHeight + topHeight / 2;
+ root.add(top);
+
+ root.position.set(x, 0, z);
+ scene.add(root);
+
+ return root;
+}
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ฐ๋ณต๋ฌธ์ ๋๋ ค ๋๋ฌด๋ฅผ ๊ทธ๋ฆฌ๋ ํํ๋ก ๋ฐฐ์นํฉ๋๋ค.
+
+```js
+for (let z = -50; z <= 50; z += 10) {
+ for (let x = -50; x <= 50; x += 10) {
+ makeTree(x, z);
+ }
+}
+```
+
+๋
์ญํ ์ ํ ํ๋ฉด๋ ๋ฐฐ์นํฉ๋๋ค.
+
+```js
+// ๋
์ ์ถ๊ฐํฉ๋๋ค.
+{
+ const size = 400;
+ const geometry = new THREE.PlaneBufferGeometry(size, size);
+ const material = new THREE.MeshPhongMaterial({ color: 'gray' });
+ const mesh = new THREE.Mesh(geometry, material);
+ mesh.rotation.x = Math.PI * -0.5;
+ scene.add(mesh);
+}
+```
+
+๋ฐฐ๊ฒฝ์ ํ๋์์ผ๋ก ๋ฐ๊ฟ์ค๋๋ค.
+
+```js
+const scene = new THREE.Scene();
+-scene.background = new THREE.Color('white');
++scene.background = new THREE.Color('lightblue');
+```
+
+{{{example url="../threejs-billboard-trees-no-billboards.html" }}}
+
+๋๋ฌด๋ 11x11, ์ด 121๊ทธ๋ฃจ์
๋๋ค. ๊ฐ ๋๋ฌด๋ 12๊ฐํ ์๋ฟ๊ณผ 48๊ฐํ ์ํต์ผ๋ก ์ด๋ฃจ์ด์ก์ผ๋, ๋๋ฌด ํ๋ ๋น ์ผ๊ฐํ์ด 60๊ฐ์ธ ์
์
๋๋ค. 121 * 60์ด๋ฉด ์ด ์ผ๊ฐํ 7260๊ฐ๋ค์. ๋ฌผ๋ก ๊ทธ๋ค์ง ๋ง์ ์๋ ์๋์ง๋ง ๋ ์ธ๋ฐํ 3์ฐจ์ ๋๋ฌด๋ ํ๋๋น 1000-3000๊ฐ์ ์ผ๊ฐํ์ด ํ์ํ ๊ฒ๋๋ค. ๋๋ฌด ํ๋๋น 3000๊ฐ๋ฉด ์ด 36300๊ฐ์ ์ผ๊ฐํ์ ๊ทธ๋ ค์ผ ํ๋ ์
์ด์ฃ .
+
+ํ์ฌ๋(facade)๋ฅผ ์ด์ฉํ๋ฉด ์ผ๊ฐํ์ ์์ ์ค์ผ ์ ์์ต๋๋ค.
+
+๊ทธ๋ํฝ ํ๋ก๊ทธ๋จ์ผ๋ก ํ์ฌ๋๋ฅผ ๋ง๋ค ์๋ ์์ง๋ง, ์ฝ๋๋ฅผ ์์ฑํด ์ง์ ํ๋๋ฅผ ๋ง๋ค์ด๋ด
์๋ค.
+
+`RenderTarget`์ ์ด์ฉํด 3D ๋ฌผ์ฒด๋ฅผ ํ
์ค์ฒ๋ก ๋ฐ๊พธ๋ ์ฝ๋๋ฅผ ์์ฑํฉ๋๋ค. `RenderTarget`์ ๋ ๋๋งํ๋ ๋ฒ์ [์ด์ ๊ธ](threejs-rendertargets.html)์์ ๋ค๋ฃจ์์ผ๋ ์ฐธ๊ณ ๋ฐ๋๋๋ค.
+
+```js
+function frameArea(sizeToFitOnScreen, boxSize, boxCenter, camera) {
+ const halfSizeToFitOnScreen = sizeToFitOnScreen * 0.5;
+ const halfFovY = THREE.MathUtils.degToRad(camera.fov * .5);
+ const distance = halfSizeToFitOnScreen / Math.tan(halfFovY);
+
+ camera.position.copy(boxCenter);
+ camera.position.z += distance;
+
+ // ์ ๋์ฒด๊ฐ ์ก๋ฉด์ฒด๋ฅผ ํฌํจํ๋๋ก near์ far ๊ฐ์ ์กฐ์ ํฉ๋๋ค.
+ camera.near = boxSize / 100;
+ camera.far = boxSize * 100;
+
+ camera.updateProjectionMatrix();
+}
+
+function makeSpriteTexture(textureSize, obj) {
+ const rt = new THREE.WebGLRenderTarget(textureSize, textureSize);
+
+ const aspect = 1; // ๋ ๋ ํ๊ฒ์ด ์ ์ฌ๊ฐํ์ด๋ฏ๋ก
+ const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+
+ scene.add(obj);
+
+ // ๋ฌผ์ฒด๋ฅผ ๊ฐ์ผ ์ก๋ฉด์ฒด๋ฅผ ๊ณ์ฐํฉ๋๋ค.
+ const box = new THREE.Box3().setFromObject(obj);
+
+ const boxSize = box.getSize(new THREE.Vector3());
+ const boxCenter = box.getCenter(new THREE.Vector3());
+
+ // ์นด๋ฉ๋ผ๊ฐ ์ก๋ฉด์ฒด๋ฅผ ๊ฐ์ธ๋๋ก ์ค์ ํฉ๋๋ค.
+ const fudge = 1.1;
+ const size = Math.max(...boxSize.toArray()) * fudge;
+ frameArea(size, size, boxCenter, camera);
+
+ renderer.autoClear = false;
+ renderer.setRenderTarget(rt);
+ renderer.render(scene, camera);
+ renderer.setRenderTarget(null);
+ renderer.autoClear = true;
+
+ scene.remove(obj);
+
+ return {
+ position: boxCenter.multiplyScalar(fudge),
+ scale: size,
+ texture: rt.texture,
+ };
+}
+```
+
+์ ์์ ์์ ์ฃผ์ ๊น๊ฒ ๋ด์ผํ๋ ๋ถ๋ถ:
+
+์ ์์ ๋ ์ฝ๋ ๋ฐ์์ ์ ์ธํ ์์ผ๊ฐ (field of view, `fov`)์ ์ฌ์ฉํ์ต๋๋ค.
+
+[.obj ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-obj.html)์์ ์ผ๋ ๋ฐฉ๋ฒ์ ์ฝ๊ฐ ์์ ํด ๋๋ฌด๋ฅผ ๊ฐ์ผ ์ก๋ฉด์ฒด๋ฅผ ๊ณ์ฐํ์ต๋๋ค.
+
+[.obj ํ์ผ ๋ถ๋ฌ์ค๊ธฐ](threejs-load-obj.html)์์ ์ผ๋ `frameArea`๋ ๊ฐ์ ธ์์ต๋๋ค. ์ด๋ฒ์๋ ์ฃผ์ด์ง ์์๊ฐน์ ํด๋น ๋ฌผ์ฒด๊ฐ ํฌํจ๋๊ฒ ํ๋ ค๋ฉด ์ผ๋ง๋ ๋จ์ด์ ธ์ผ ํ๋์ง ๊ณ์ฐํ ๋ ์ฌ์ฉํ์ฃ . ๊ทธ๋ฆฌ๊ณ ์ด ๊ฒฐ๊ณผ๊ฐ์ผ๋ก ์นด๋ฉ๋ผ๋ฅผ ๋ฌผ์ฒด๋ฅผ ๊ฐ์ผ ์ก๋ฉด์ฒด ์ค์ฌ์์ -z์ถ ๋ฐฉํฅ์ผ๋ก ์ฎ๊ฒผ์ต๋๋ค.
+
+์ ๋์ฒด์ ํฌ๊ธฐ๋ฅผ 1.1 (`fudge(์์์)`)๋งํผ ํค์ ๋๋ฌด๊ฐ ๋ ๋ ํ๊ฒ์ ์์ ํ ๋ค์ด๊ฐ๋๋ก ํ์ต๋๋ค. ๋ฌผ์ฒด๊ฐ ์ ๋์ฒด ์์ ์๋์ง ๊ณ์ฐํ ๊ฒฐ๊ณผ๋ ๋ฌผ์ฒด์ ๊ฐ์ฅ์๋ฆฌ๋ฅผ ํฌํจํ์ง ์๊ธฐ์ ๊ทธ๋๋ก ๋๋ค๋ฉด ๋ฌผ์ฒด๊ฐ ์นด๋ฉ๋ผ ๋ฐ์ผ๋ก ๋ฒ์ด๋ ๋ณด์์ ๊ฒ๋๋ค. ์นด๋ฉ๋ผ๊ฐ ์์ ํ ๋ฌผ์ฒด๋ฅผ ๋ด๋ ๊ฐ์ ๊ณ์ฐํ ์๋ ์์ง๋ง, ๊ทธ๊ฑด ๊ณต๊ฐ ๋ญ๋น์ด๊ธฐ๋ ํ๊ธฐ์ ๋จ์ํ *์์์*๋ฅผ ์ฌ์ฉํ ๊ฒ์ด์ฃ .
+
+๊ทธ๋ฆฌ๊ณ ๋ ๋ ํ๊ฒ์ ์ฅ๋ฉด์ ๋ ๋๋งํ ๋ค ๋๋ฌด๋ฅผ ์ฅ๋ฉด์์ ์ ๊ฑฐํ์ต๋๋ค.
+
+์ฌ๊ธฐ์ ์ค์ํ ๊ฑด ์กฐ๋ช
์ ๋ฐ๋ก ๋ฃ์ด์ผ ํ๋, ๋ค๋ฅธ ์์๋ ์๋๋ก ํด์ผ ํ๋ค๋ ๊ฒ๋๋ค.
+
+์ผ๋จ ์ฅ๋ฉด์์ ๋ฐฐ๊ฒฝ์๋ ์ ๊ฑฐํฉ๋๋ค.
+
+```js
+const scene = new THREE.Scene();
+-scene.background = new THREE.Color('lightblue');
+```
+
+๋ง์ง๋ง์ผ๋ก ํจ์์์ ๋ฐ์ ํ
์ค์ฒ์ ์์น์ ์ค์ผ์ผ์ ์กฐ์ ํด ํ์ฌ๋๊ฐ ๊ฐ์ ์์น์ ๋ํ๋๋๋ก ํด์ผ ํฉ๋๋ค.
+
+๋จผ์ ๋๋ฌด๋ฅผ ๋ง๋ค์ด ์์์ ๋ง๋ ํจ์์ ๋๊ฒจ์ค๋๋ค.
+
+```js
+// ๋น๋ณด๋ ํ
์ค์ฒ๋ฅผ ๋ง๋ญ๋๋ค.
+const tree = makeTree(0, 0);
+const facadeSize = 64;
+const treeSpriteInfo = makeSpriteTexture(facadeSize, tree);
+```
+
+๋ค์์ผ๋ก ๋๋ฌด ๋์ ํ์ฌ๋๋ฅผ ๊ทธ๋ฆฌ๋ ํํ๋ก ๋ฐฐ์นํฉ๋๋ค.
+
+```js
++function makeSprite(spriteInfo, x, z) {
++ const { texture, offset, scale } = spriteInfo;
++ const mat = new THREE.SpriteMaterial({
++ map: texture,
++ transparent: true,
++ });
++ const sprite = new THREE.Sprite(mat);
++ scene.add(sprite);
++ sprite.position.set(
++ offset.x + x,
++ offset.y,
++ offset.z + z);
++ sprite.scale.set(scale, scale, scale);
++}
+
+for (let z = -50; z <= 50; z += 10) {
+ for (let x = -50; x <= 50; x += 10) {
+- makeTree(x, z);
++ makeSprite(treeSpriteInfo, x, z);
+ }
+}
+```
+
+์ ์ฝ๋์์๋ ํ์ฌ๋์ ์์น๊ฐ๊ณผ ์ค์ผ์ผ๊ฐ์ ์ง์ ํด ์๋ ๋๋ฌด๊ฐ ์์ด์ผํ ์์น์ ํ์ฌ๋๊ฐ ๋ํ๋๋๋ก ํ์ต๋๋ค.
+
+์ด์ ํ์ฌ๋๊ฐ ์ ์๋ฆฌ์ ์์นํ์ผ๋ ๋ฐฐ๊ฒฝ์์ ๋ค์ ์ง์ ํฉ๋๋ค.
+
+```js
+scene.background = new THREE.Color('lightblue');
+```
+
+๋๋ฌด ํ์ฌ๋๋ก ์ด๋ฃจ์ด์ง ์ฅ๋ฉด์ ์์ฑํ์ต๋๋ค.
+
+{{{example url="../threejs-billboard-trees-static-billboards.html" }}}
+
+์๊น ๋ง๋ค์๋ ์์ ์ ๋น๊ตํด๋ณด๋ฉด ๊ฝค ๋น์ทํ ๊ฒ๋๋ค. ์์ ์์๋ ์ -ํด์๋ ํ
์ค์ฒ, 64x64 ํฝ์
ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ๊ธฐ์ ํ์ฌ๋๊ฐ ๊ฐ์ ธ ๋ณด์
๋๋ค. ํด์๋๋ฅผ ๋์ผ ์๋ ์์ง๋ง, ํ์ฌ๋๋ ๋๊ฒ ๋จผ ๊ฑฐ๋ฆฌ์์ ์๊ฒ ๋ณด์ด๋ ๋ฌผ์ฒด์ ์ฌ์ฉํ๊ธฐ์ ์ -ํด์๋๋ก ์ฌ์ฉํด๋ ๊ทธ๋ค์ง ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๊ฒ๋ค๊ฐ ๋ช ํฝ์
๋์ง๋ ์๋ ๋๋ฌด๋ฅผ ๋ ๋๋งํ๋ ๋ฐ ๋ญ๋น๋๋ ์์์ ์ ์ฝํ ์ ์์ฃ .
+
+๋ค๋ฅธ ๋ฌธ์ ๋ ๋๋ฌด๋ฅผ ํ ๊ฐ๋์์ ๋ฐ์ ๋ณผ ์ ์๋ค๋ ๊ฒ๋๋ค. ์ด ๋ฌธ์ ๋ ๋๊ฒ ๋ ๋ง์ ํ์ฌ๋๋ฅผ ๋ ๋๋งํด ํด๊ฒฐํ ์ ์์ฃ . ์๋ฅผ ๋ค์ด 8๊ฐ์ ํ์ฌ๋๋ฅผ ๋ง๋ค์ด ์นด๋ฉ๋ผ๊ฐ ๋ฌผ์ฒด๋ฅผ ๋ฐ๋ผ๋ณด๋ ๊ฐ๋์ ๋ฐ๋ผ ๋ค๋ฅธ ํ์ฌ๋๋ฅผ ๋ณด์ฌ์ค ์ ์์ ๊ฒ๋๋ค.
+
+ํ์ฌ๋๋ฅผ ์ธ ์ง๋ ์ ์ ์ผ๋ก ์ ํ์ด์ง๋ง, ์ด ๊ธ์ด ํ์ฌ๋์ ํ์ฉ์ ๋์์ด ๋์์ผ๋ฉด ํฉ๋๋ค. | false |
Other | mrdoob | three.js | 5349e13eee8458491a664a63e5873b18d6687ed2.json | add translation kr/threejs-canvas-texture.md | threejs/lessons/kr/threejs-canvas-textures.md | @@ -0,0 +1,381 @@
+Title: Three.js ์บ๋ฒ์ค ํ
์ค์ฒ
+Description: ์บ๋ฒ์ค๋ฅผ Three.js ํ
์ค์ฒ๋ก ์ฐ๋ ๋ฐฉ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ์บ๋ฒ์ค๋ก ๋์ ํ
์ค์ฒ ๋ง๋ค๊ธฐ
+
+โป ์ด ๊ธ์ [ํ
์ค์ฒ์ ๊ดํ ๊ธ](threejs-textures.html)์์ ์ด์ด์ง๋๋ค. ์ด์ ๊ธ์ ์ฝ์ง ์์๋ค๋ฉด ๋จผ์ ์ฝ๊ณ ์ค๊ธฐ ๋ฐ๋๋๋ค.
+
+[์ด์ ๊ธ](threejs-textures.html)์์ ํ
์ค์ฒ๋ฅผ ๋ค๋ฃฐ ๋๋ ์ฃผ๋ก ์ด๋ฏธ์ง ํ์ผ๋ก ํ
์ค์ฒ๋ฅผ ๋ง๋ค์์ต๋๋ค. ํ์ง๋ง ๊ฒฝ์ฐ์ ๋ฐ๋ผ์๋ ๋ฐํ์์ ํ
์ค์ฒ๋ฅผ ๋ง๋ค์ด์ผ ํ ์๋ ์์ฃ . `CanvasTexture`๋ฅผ ์ฌ์ฉํ๋ฉด ์บ๋ฒ์ค๋ฅผ ํ
์ค์ฒ๋ก ํ์ฉํ ์ ์์ต๋๋ค.
+
+์บ๋ฒ์ค ํ
์ค์ฒ๋ `<canvas>` ์์๋ฅผ ์ธ์๋ก ๋ฐ์ต๋๋ค. 2D ์บ๋ฒ์ค API์ ๋ํด ์ ๋ชจ๋ฅธ๋ค๋ฉด [MDN์ ํํ ๋ฆฌ์ผ](https://developer.mozilla.org/ko/docs/Web/API/Canvas_API/Tutorial)์ ์ฐธ๊ณ ํ์ธ์.
+
+๊ฐ๋จํ 2D ์บ๋ฒ์ค ์ฑ์ ๋ง๋ค์ด๋ด
์๋ค. ์๋๋ ํฌ๊ธฐ, ์, ์์น ๋ชจ๋ ๋ฌด์์์ธ ์ ์ ๋ฐ๋ณตํด์ ๋ ๋๋งํ๋ ์์ ์
๋๋ค.
+
+```js
+const ctx = document.createElement('canvas').getContext('2d');
+document.body.appendChild(ctx.canvas);
+ctx.canvas.width = 256;
+ctx.canvas.height = 256;
+ctx.fillStyle = '#FFF';
+ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+
+function randInt(min, max) {
+ if (max === undefined) {
+ max = min;
+ min = 0;
+ }
+ return Math.random() * (max - min) + min | 0;
+}
+
+function drawRandomDot() {
+ ctx.fillStyle = `#${ randInt(0x1000000).toString(16).padStart(6, '0') }`;
+ ctx.beginPath();
+
+ const x = randInt(256);
+ const y = randInt(256);
+ const radius = randInt(10, 64);
+ ctx.arc(x, y, radius, 0, Math.PI * 2);
+ ctx.fill();
+}
+
+function render() {
+ drawRandomDot();
+ requestAnimationFrame(render);
+}
+requestAnimationFrame(render);
+```
+
+{{{example url="../canvas-random-dots.html" }}}
+
+์ด์ ์ ์บ๋ฒ์ค๋ฅผ ํ
์ค์ฒ๋ก ๋ง๋ค์ด๋ด
์๋ค. [์ด์ ๊ธ](threejs-textures.html)์์ ์ ์ก๋ฉด์ฒด์ ํ
์ค์ฒ๋ฅผ ์
ํ๋ ์์ ๋ฅผ ๊ฐ์ ธ์ค๊ฒ ์ต๋๋ค. ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์ค๋ ์ฝ๋๋ฅผ ์ ๊ฑฐํ๊ณ ๋์ `CanvasTexture`์ ๋ฐฉ๊ธ ๋ง๋ ์บ๋ฒ์ค๋ฅผ ๋๊ฒจ ์ธ์คํด์ค๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
+const cubes = []; // ์ ์ก๋ฉด์ฒด๋ฅผ ํ์ ์ํค๊ธฐ ์ํ ๋ฐฐ์ด์
๋๋ค.
+-const loader = new THREE.TextureLoader();
+-
++const ctx = document.createElement('canvas').getContext('2d');
++ctx.canvas.width = 256;
++ctx.canvas.height = 256;
++ctx.fillStyle = '#FFF';
++ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
++const texture = new THREE.CanvasTexture(ctx.canvas);
+
+const material = new THREE.MeshBasicMaterial({
+- map: loader.load('resources/images/wall.jpg'),
++ map: texture,
+});
+const cube = new THREE.Mesh(geometry, material);
+scene.add(cube);
+cubes.push(cube); // ์ ์ก๋ฉด์ฒด ๋ฐฐ์ด์ ์ถ๊ฐํด ์ ๋๋ฉ์ด์
์ด ์ ์ฉ๋๋๋ก ํฉ๋๋ค.
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ ๋๋ง ๋ฃจํ์์ ๋ฌด์์ ์ ์ ์ฐ๋๋ก ํฉ๋๋ค.
+
+```js
+function render(time) {
+ time *= 0.001;
+
+ if (resizeRendererToDisplaySize(renderer)) {
+ const canvas = renderer.domElement;
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
+ camera.updateProjectionMatrix();
+ }
+
++ drawRandomDot();
++ texture.needsUpdate = true;
+
+ cubes.forEach((cube, ndx) => {
+ const speed = .2 + ndx * .1;
+ const rot = time * speed;
+ cube.rotation.x = rot;
+ cube.rotation.y = rot;
+ });
+
+ renderer.render(scene, camera);
+
+ requestAnimationFrame(render);
+}
+```
+
+์ถ๊ฐ๋ก `CanvasTexture`๊ฐ ๋ณ๊ฒฝ๋์์ ๋ Three.js๊ฐ ํ
์ค์ฒ๋ฅผ ์
๋ฐ์ดํธํ๋๋ก `needsUpdate` ์์ฑ์ `true`๋ก ์ค์ ํฉ๋๋ค.
+
+์ด์ ์ ์ก๋ฉด์ฒด์ ์บ๋ฒ์ค ํ
์ค์ฒ๊ฐ ์ ์ฉ๋์์ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-canvas-textured-cube.html" }}}
+
+Three.js๊ฐ ์บ๋ฒ์ค ํ
์ค์ฒ๋ฅผ ๋ ๋๋งํ ๋๋ ์ด์ ์ [๋ณ๋์ ๊ธ](threejs-rendertargets.html)์์ ์ค๋ช
ํ๋ `RenderTarget`์ ์ฐ๋ ๊ฒ ๋ ์ข์ต๋๋ค.
+
+์บ๋ฒ์ค ํ
์ค์ฒ๋ ์ฃผ๋ก ์ฅ๋ฉด์ ํ
์คํธ๋ฅผ ์ฝ์
ํ ๋ ์ฌ์ฉํฉ๋๋ค. ์๋ฅผ ๋ค์ด ์บ๋ฆญํฐ์ ๋ช
์ฐฐ์ ์ด๋ฆ์ ํ๊ธฐํ๋ ๊ฒฝ์ฐ ์บ๋ฒ์ค ํ
์ค์ฒ๋ฅผ ๋ช
์ฐฐ์ ํ
์ค์ฒ๋ก ์ฌ์ฉํ ์ ์๊ฒ ์ฃ .
+
+ํ ๋ฒ 3๋ช
์ ์ฌ๋์ด ์๋ ์ฅ๋ฉด์ ๋ง๋ค์ด ๊ฐ ์ฌ๋์๊ฒ ๋ช
์ฐฐ์ ๋ฌ์๋ด
์๋ค.
+
+์ ์์ ๋ฅผ ๊ทธ๋๋ก ๊ฐ์ ธ์ ์ ์ก๋ฉด์ฒด ๊ด๋ จ ์ฝ๋๋ฅผ ์ง์๋๋ค. ๋ฐฐ๊ฒฝ์ ํ์์์ผ๋ก ๋ฐ๊พธ๊ณ ๋ ๊ฐ์ [์กฐ๋ช
](threejs-lights.html)์ ๋ฃ์ต๋๋ค.
+
+```js
+const scene = new THREE.Scene();
++scene.background = new THREE.Color('white');
++
++function addLight(position) {
++ const color = 0xFFFFFF;
++ const intensity = 1;
++ const light = new THREE.DirectionalLight(color, intensity);
++ light.position.set(...position);
++ scene.add(light);
++ scene.add(light.target);
++}
++addLight([-3, 1, 1]);
++addLight([ 2, 1, .5]);
+```
+
+2D ์บ๋ฒ์ค๋ฅผ ์ด์ฉํด ๋ช
์ฐฐ์ ๋ง๋๋ ํจ์๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
++function makeLabelCanvas(size, name) {
++ const borderSize = 2;
++ const ctx = document.createElement('canvas').getContext('2d');
++ const font = `${ size }px bold sans-serif`;
++ ctx.font = font;
++ // ์ด๋ฆ์ ๊ธธ์ด๋ฅผ ์์ธกํฉ๋๋ค.
++ const doubleBorderSize = borderSize * 2;
++ const width = ctx.measureText(name).width + doubleBorderSize;
++ const height = size + doubleBorderSize;
++ ctx.canvas.width = width;
++ ctx.canvas.height = height;
++
++ // ์บ๋ฒ์ค ํฌ๊ธฐ๋ฅผ ๋ฐ๊ฟจ์ ๋ ํฐํธ๋ฅผ ๋ค์ ์ค์ ํด์ค์ผ ํฉ๋๋ค.
++ ctx.font = font;
++ ctx.textBaseline = 'top';
++
++ ctx.fillStyle = 'blue';
++ ctx.fillRect(0, 0, width, height);
++ ctx.fillStyle = 'white';
++ ctx.fillText(name, borderSize, borderSize);
++
++ return ctx.canvas;
++}
+```
+
+๋ค์์ผ๋ก ์ํต์ด ๋ชธ, ๊ตฌ์ฒด๊ฐ ๋จธ๋ฆฌ, ํ๋ฉด์ด ๋ช
์ฐฐ์ธ ๊ฐ๋จํ ์ฌ๋์ ๋ง๋ค์ด์ผ ํฉ๋๋ค.
+
+๋จผ์ ๊ณตํต์ผ๋ก ์ฌ์ฉํ geometry๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
++const bodyRadiusTop = .4;
++const bodyRadiusBottom = .2;
++const bodyHeight = 2;
++const bodyRadialSegments = 6;
++const bodyGeometry = new THREE.CylinderBufferGeometry(
++ bodyRadiusTop, bodyRadiusBottom, bodyHeight, bodyRadialSegments);
++
++const headRadius = bodyRadiusTop * 0.8;
++const headLonSegments = 12;
++const headLatSegments = 5;
++const headGeometry = new THREE.SphereBufferGeometry(
++ headRadius, headLonSegments, headLatSegments);
++
++const labelGeometry = new THREE.PlaneBufferGeometry(1, 1);
+```
+
+๋ค์์ผ๋ก ์ด geometry๋ค์ ์ด์ฉํด ์ฌ๋์ ๋ง๋๋ ํจ์๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
++function makePerson(x, size, name, color) {
++ const canvas = makeLabelCanvas(size, name);
++ const texture = new THREE.CanvasTexture(canvas);
++ // ํ
์ค์ฒ์ฉ ์บ๋ฒ์ค๋ 2D์ด๋ฏ๋ก ํฝ์
์ด ๋ชจ์๋ ๊ฒฝ์ฐ ๋๋ต์ ์ผ๋ก
++ // ํํฐ๋งํ๊ฒ๋ ์ค์ ํฉ๋๋ค.
++ texture.minFilter = THREE.LinearFilter;
++ texture.wrapS = THREE.ClampToEdgeWrapping;
++ texture.wrapT = THREE.ClampToEdgeWrapping;
++
++ const labelMaterial = new THREE.MeshBasicMaterial({
++ map: texture,
++ side: THREE.DoubleSide,
++ transparent: true,
++ });
++ const bodyMaterial = new THREE.MeshPhongMaterial({
++ color,
++ flatShading: true,
++ });
++
++ const root = new THREE.Object3D();
++ root.position.x = x;
++
++ const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
++ root.add(body);
++ body.position.y = bodyHeight / 2;
++
++ const head = new THREE.Mesh(headGeometry, bodyMaterial);
++ root.add(head);
++ head.position.y = bodyHeight + headRadius * 1.1;
++
++ const label = new THREE.Mesh(labelGeometry, labelMaterial);
++ root.add(label);
++ label.position.y = bodyHeight * 4 / 5;
++ label.position.z = bodyRadiusTop * 1.01;
++
++ // ๋ช
์ฐฐ์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํฉ๋๋ค.
++ const labelBaseScale = 0.01;
++ label.scale.x = canvas.width * labelBaseScale;
++ label.scale.y = canvas.height * labelBaseScale;
++
++ scene.add(root);
++ return root;
++}
+```
+
+์ ์ฝ๋์์๋ ๋ชธ, ๋จธ๋ฆฌ, ๋ช
์ฐฐ์ ํ๋์ `Object3D`์ ๋ฃ๊ณ ์์น๋ฅผ ์กฐ์ ํ์ต๋๋ค. ์ด๋ฌ๋ฉด `Object3D`๋ง ์์ง์ฌ ํด๋น ์ฌ๋์ ์์ง์ผ ์ ์๊ฒ ์ฃ . ๋ชธ์ 2์นธ์ผ๋ก, ์บ๋ฒ์ค ์ฌ์ด์ฆ๊ฐ ํฝ์
๋จ์์ด๊ณ ๊ฑฐ์ ์์ญ ํฝ์
์ด๊ธฐ์ ์ฌ๊ธฐ์ 0.01์ ๊ณฑํด ์ฌ์ด์ฆ๋ฅผ ์ ๋นํ ํฌ๊ธฐ๋ก ์กฐ์ ํ์ต๋๋ค.
+
+์ด์ ์ฌ๋๊ณผ ๋ช
์ฐฐ์ ๋ง๋ญ๋๋ค.
+
+```js
++makePerson(-3, 32, 'Purple People Eater', 'purple');
++makePerson(-0, 32, 'Green Machine', 'green');
++makePerson(+3, 32, 'Red Menace', 'red');
+```
+
+๋ง์ง๋ง์ผ๋ก `OrbitControls`๋ฅผ ๋ฃ์ด ์นด๋ฉ๋ผ๋ฅผ ์์ง์ผ ์ ์๋๋ก ํฉ๋๋ค.
+
+```js
+import * as THREE from './resources/three/r115/build/three.module.js';
++import { OrbitControls } from './resources/threejs/r115/examples/jsm/controls/OrbitControls.js';
+```
+
+```js
+const fov = 75;
+const aspect = 2; // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+const near = 0.1;
+-const far = 5;
++const far = 50;
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+-camera.position.z = 2;
++camera.position.set(0, 2, 5);
+
++const controls = new OrbitControls(camera, canvas);
++controls.target.set(0, 2, 0);
++controls.update();
+```
+
+์ฌ๋ ์์ ๊ฐ๋จํ ๋ช
์ฐฐ์ด ๋ถ์์ต๋๋ค.
+
+{{{example url="../threejs-canvas-textured-labels.html" }}}
+
+๋์์ง ์์ ์์ ์ด์ง๋ง ๋ช ๊ฐ์ง ์ง๊ณ ๋์ด๊ฐ์ผ ํ ๊ฒ๋ค์ด ์์ต๋๋ค.
+
+* ๋ช
์ฐฐ์ ํ๋ํ์ ๋ ํด์๋๊ฐ ๋ฎ์ ๋ณด์ธ๋ค.
+
+์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฑด ์๊ฐ๋ณด๋ค ๊น๋ค๋กญ์ต๋๋ค. ๊ณ ๊ธ ํฐํธ ๋ ๋๋ง ๊ธฐ๋ฒ์ด ์๊ธด ํ๋ ์ ๊ฐ ์๋ ํ ํ๋ฌ๊ทธ์ธ์ผ๋ก ๊ตฌํ๋์ด ์์ง ์์ต๋๋ค. ๊ฑฐ๊ธฐ๋ค ํฐํธ ๋ฐ์ดํฐ๋ฅผ ๋ค์ด ๋ฐ์์ผ ํ๋ ์๋์ ์ผ๋ก ๋๋ฆฌ๊ฒ ์ฃ .
+
+๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ช
์ฐฐ์ ํด์๋๋ฅผ ๋์ด๋ ๊ฒ๋๋ค. ํ
์ค์ฒ์ฉ ์บ๋ฒ์ค์ ์ฌ์ด์ฆ๋ฅผ ๋ ๋ฐฐ๋ก ์ค์ ํ๊ณ `labelBaseScale`์ ๋ฐ์ผ๋ก ๋ฎ์ถ๋ฉด ์ง๊ธ๊ณผ ๊ฐ์ ํฌ๊ธฐ์ ํด์๋๋ง ๋์ผ ์ ์๊ฒ ์ฃ .
+
+* ์ด๋ฆ์ ๊ธธ์ด๊ฐ ๊ธธ์๋ก ๋ช
์ฐฐ๋ ๊ธธ์ด์ง๋ค.
+
+์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ๋ช
์ฐฐ ํฌ๊ธฐ๋ฅผ ๊ณ ์ ํ๊ณ ํ
์คํธ๋ฅผ ์ฐ๊ฒจ๋ฃ์ผ๋ฉด ๋ฉ๋๋ค.
+
+์ด๊ฑด ์๋์ ์ผ๋ก ๊ตฌํํ๊ธฐ ์ฝ์ต๋๋ค. ๋ช
์ฐฐ์ ๋์ด๋ฅผ ๋๊ฒจ์ฃผ๊ณ ํ
์คํธ์ ์ค์ผ์ผ์ ํด๋น ๋์ด์ ๋ง์ถฐ ์กฐ์ ํ๋ฉด ๋์ฃ .
+
+```js
+-function makeLabelCanvas(size, name) {
++function makeLabelCanvas(baseWidth, size, name) {
+ const borderSize = 2;
+ const ctx = document.createElement('canvas').getContext('2d');
+ const font = `${ size }px bold sans-serif`;
+ ctx.font = font;
+ // ์ด๋ฆ์ ๊ธธ์ด๋ฅผ ์์ธกํฉ๋๋ค.
++ const textWidth = ctx.measureText(name).width;
+
+ const doubleBorderSize = borderSize * 2;
+- const width = ctx.measureText(name).width + doubleBorderSize;
++ const width = baseWidth + doubleBorderSize;
+ const height = size + doubleBorderSize;
+ ctx.canvas.width = width;
+ ctx.canvas.height = height;
+
+ // ์บ๋ฒ์ค ํฌ๊ธฐ๋ฅผ ๋ฐ๊ฟจ์ ๋ ํฐํธ๋ฅผ ๋ค์ ์ค์ ํด์ค์ผ ํฉ๋๋ค.
+ ctx.font = font;
+- ctx.textBaseline = 'top';
++ ctx.textBaseline = 'middle';
++ ctx.textAlign = 'center';
+
+ ctx.fillStyle = 'blue';
+ ctx.fillRect(0, 0, width, height);
+
++ // ๋ช
์ฐฐ์ ํฌ๊ธฐ์ ๋ง์ถฐ ์กฐ์ ํ๋ ๋์ด๋์ง ์๋๋ก ํฉ๋๋ค.
++ const scaleFactor = Math.min(1, baseWidth / textWidth);
++ ctx.translate(width / 2, height / 2);
++ ctx.scale(scaleFactor, 1);
+ ctx.fillStyle = 'white';
+ ctx.fillText(name, borderSize, borderSize);
+
+ return ctx.canvas;
+}
+```
+
+์ฌ๋์ ๋ง๋ค ๋ ๋ช
์ฐฐ์ ๋์ด๋ ๊ฐ์ด ๋ฐ๋๋ก ๋ฐ๊ฟ๋๋ค.
+
+```js
+-function makePerson(x, size, name, color) {
+- const canvas = makeLabelCanvas(size, name);
++function makePerson(x, labelWidth, size, name, color) {
++ const canvas = makeLabelCanvas(labelWidth, size, name);
+
+...
+
+}
+
+-makePerson(-3, 32, 'Purple People Eater', 'purple');
+-makePerson(-0, 32, 'Green Machine', 'green');
+-makePerson(+3, 32, 'Red Menace', 'red');
++makePerson(-3, 150, 32, 'Purple People Eater', 'purple');
++makePerson(-0, 150, 32, 'Green Machine', 'green');
++makePerson(+3, 150, 32, 'Red Menace', 'red');
+```
+
+์ด์ ๋ช
์ฐฐ์ ํ
์คํธ๊ฐ ํฌ๊ธฐ์ ๋ง์ถฐ์ง๊ณ ๊ฐ์ด๋ฐ ์ ๋ ฌ๋ฉ๋๋ค.
+
+{{{example url="../threejs-canvas-textured-labels-scale-to-fit.html" }}}
+
+์ ์์ ์์๋ ํ
์ค์ฒ๋ง๋ค ์บ๋ฒ์ค๋ฅผ ๋ฐ๋ก ์ผ์ต๋๋ค. ํ
์ค์ฒ๋ง๋ค ์บ๋ฒ์ค๋ฅผ ๋ฐ๋ก ์ธ์ง๋ ์ฌ๋ฌ๋ถ์ ์ ํ์ ๋ฌ๋ ธ์ต๋๋ค. ๋ง์ฝ ์บ๋ฒ์ค๋ฅผ ์์ฃผ ์
๋ฐ์ดํธํด์ผ ํ๋ค๋ฉด ํ
์ค์ฒ๋ง๋ค ์บ๋ฒ์ค๋ฅผ ๋ฐ๋ก ๋๋ ๊ฒ ์ข๊ฒ ์ฃ . ๋ฐ๋๋ก ์์, ๋๋ ๊ฐ๋ ์
๋ฐ์ดํธํ ๊ฑฐ๋ผ๋ฉด ํ๋์ ์บ๋ฒ์ค๋ฅผ ๋๋ ค ์ฐ๋ ๊ฒ ๋ ๋์ ๊ฒ๋๋ค. ๋ช
์ฐฐ์ ์
๋ฐ์ดํธํ ์ผ์ด ์์ผ๋ ์ ์ฝ๋๋ฅผ ๊ณ ์ณ ํ๋์ ์บ๋ฒ์ค๋ฅผ ์ฐ๋๋ก ํด๋ณด์ฃ .
+
+```js
++const ctx = document.createElement('canvas').getContext('2d');
+
+function makeLabelCanvas(baseWidth, size, name) {
+ const borderSize = 2;
+- const ctx = document.createElement('canvas').getContext('2d');
+ const font = `${ size }px bold sans-serif`;
+
+ ...
+
+}
+
++const forceTextureInitialization = function() {
++ const material = new THREE.MeshBasicMaterial();
++ const geometry = new THREE.PlaneBufferGeometry();
++ const scene = new THREE.Scene();
++ scene.add(new THREE.Mesh(geometry, material));
++ const camera = new THREE.Camera();
++
++ return function forceTextureInitialization(texture) {
++ material.map = texture;
++ renderer.render(scene, camera);
++ };
++}();
+
+function makePerson(x, labelWidth, size, name, color) {
+ const canvas = makeLabelCanvas(labelWidth, size, name);
+ const texture = new THREE.CanvasTexture(canvas);
+ // ํ
์ค์ฒ์ฉ ์บ๋ฒ์ค๋ 2D์ด๋ฏ๋ก ํฝ์
์ด ๋ชจ์๋ ๊ฒฝ์ฐ ๋๋ต์ ์ผ๋ก
+ // ํํฐ๋งํ๊ฒ๋ ์ค์ ํฉ๋๋ค.
+ texture.minFilter = THREE.LinearFilter;
+ texture.wrapS = THREE.ClampToEdgeWrapping;
+ texture.wrapT = THREE.ClampToEdgeWrapping;
++ forceTextureInitialization(texture);
+
+ ...
+```
+
+{{{example url="../threejs-canvas-textured-labels-one-canvas.html" }}}
+
+์์ง ์ธ๊ธํ์ง ์์ ๋ค๋ฅธ ๋ฌธ์ ์ ์ด ์์ต๋๋ค. ์นด๋ฉ๋ผ๋ฅผ ์ฌ๋ ๋ค๋ก ๋๋ฆฌ๋ฉด ๋ช
์ฐฐ์ด ๋ค์งํ ๋ณด์ธ๋ค๋ ๊ฑฐ์ฃ . ๋ง์ฝ ๋ช
์ฐฐ์ ๋ฐฐ์ง ํํ๋ก ์ฌ์ฉํ ๊ฑฐ๋ผ๋ฉด ํฌ๊ฒ ๋ฌธ์ ๋ ์ผ์ ์์ต๋๋ค. ํ์ง๋ง ๋ช
์ฐฐ์ 3D ๊ฒ์ ์บ๋ฆญํฐ์ ์ด๋ฆํ๋ก ์ฌ์ฉํ ๊ฑฐ๋ผ๋ฉด ์ด๋ฆํ๊ฐ ํญ์ ์นด๋ฉ๋ผ๋ฅผ ํฅํด์ผ ํ๊ฒ ์ฃ . ์ด ๋ฐฉ๋ฒ์ ๋ํด์๋ [๋น๋ณด๋์ ํ์ฌ๋](threejs-billboards.html)์์ ๋ค๋ฃจ๊ฒ ์ต๋๋ค.
+
+๋จ์ํ ์ด๋ฆํ๋ฅผ ๊ตฌํํ๋ ๊ฒฝ์ฐ๋ผ๋ฉด [HTML์ ์ด์ฉํ ๋ฐฉ๋ฒ](threejs-align-html-elements-to-3d.html)์ ์ฌ์ฉํ ์๋ ์์ต๋๋ค. ๋ค๋ง [HTML ์ด๋ฆํ](threejs-align-html-elements-to-3d.html)๋ ํญ์ 3D ์์ ์์ ์์ฃ . ์์ ์ ๋ช
์ฐฐ์ *3์ฐจ์ ์ธ๊ณ ์*์ ์๊ธฐ์ ๋ค๋ฅธ ๋ฌผ์ฒด์ ์ํด ๊ฐ๋ ค์ง๊ธธ ์ํ ๊ฒฝ์ฐ ์ ์ฉํฉ๋๋ค. | false |
Other | mrdoob | three.js | c99ad7363cb220d8851dd818f5b33c31f5b477b5.json | add translation kr/threejs-indexed-textures.md | threejs/lessons/kr/threejs-indexed-textures.md | @@ -0,0 +1,594 @@
+Title: ํผํน๊ณผ ์์์ ์ธ๋ฑ์ค ํ
์ค์ฒ ์ฌ์ฉํ๊ธฐ
+Description: ์ธ๋ฑ์ค ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํด ํผํน์ ๊ตฌํํ๊ณ , ์์์ ์ ํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ํผํน๊ณผ ์์์ ์ธ๋ฑ์ค ํ
์ค์ฒ ์ฌ์ฉํ๊ธฐ
+
+โป ์ด ๊ธ์ [HTML ์์๋ฅผ 3D๋ก ์ ๋ ฌํ๊ธฐ](threejs-align-html-elements-to-3d.html)์์ ์ด์ด์ง๋๋ค. ์ด์ ๊ธ์ ์ฝ์ง ์์๋ค๋ฉด ๋จผ์ ์ฝ๊ณ ์ค๊ธฐ ๋ฐ๋๋๋ค.
+
+
+Three.js๋ฅผ ์ฐ๋ค๋ณด๋ฉด ์ฐฝ์์ ์ธ ํด๊ฒฐ๋ฒ์ด ํ์ํ ๋๊ฐ ์์ต๋๋ค. ์ ๋ ๋๋ฆ ์๋ฆฌ์ฆ๋ฅผ ์งํํ๋ฉฐ ๋๋ฆ ๋ง์ ํด๊ฒฐ๋ฒ์ ์ฐพ๊ณ , ์ ์ด ๋์์ฃ . ํน ํ์ํ ๊ฒ ์๋ค๋ฉด ํ์ธํด๋ณด๊ธฐ ๋ฐ๋๋๋ค. ๋ฌผ๋ก ๊ทธ๊ฒ ์ต์ ์ ํด๊ฒฐ๋ฒ์ด๋ผ๊ณ ๋จ์ธํ ์๋ ์์ง๋ง์.
+
+[์ด์ ๊ธ](threejs-align-html-elements-to-3d.html)์์๋ 3D ์ง๊ตฌ๋ณธ ์ฃผ์์ ๋๋ผ ์ด๋ฆ์ ํ๊ธฐํ์ต๋๋ค. ์ฌ๊ธฐ์ ๋ ๋์๊ฐ ์ฌ์ฉ์๊ฐ ๋๋ผ๋ฅผ ์ ํํ๊ณ ์๊ธฐ๊ฐ ์ ํํ ๋๋ผ๋ฅผ ๋ณด๊ฒ ํ๋ค๋ฉด ์ด๋จ๊น์? ๋ ์ด๋ป๊ฒ ๊ตฌํํ ์ ์์๊น์?
+
+๊ฐ์ฅ ์ฝ๊ฒ ๋ ์ค๋ฅด๋ ๋ฐฉ๋ฒ์ ๊ฐ ๋๋ผ๋ง๋ค geometry๋ฅผ ๋ง๋๋ ๊ฒ๋๋ค. ์ด์ ์ ํ๋ ๊ฒ์ฒ๋ผ [ํผํน(picking)](threejs-picking.html)์ ์จ์ ๊ตฌํํ ์ ์๊ฒ ์ฃ . ์ด๋ฏธ ๊ฐ ๋๋ผ์ 3D geometry๋ ๋ง๋ค์์ผ๋ ์ฌ์ฉ์๊ฐ mesh๋ฅผ ํด๋ฆญํ์ ๋ ์ด๋ค ๋๋ผ๋ฅผ ํด๋ฆญํ๋์ง ์ ์ ์์ ๊ฒ๋๋ค.
+
+์ํ์ผ์ [์ด์ ๊ธ](threejs-align-html-elements-to-3d.html)์์ ์ค๊ณฝ์ ์ ๋ง๋ค๊ธฐ ์ํด ์ฌ์ฉํ๋ ๋ฐ์ดํฐ๋ก ๊ฐ ๋๋ผ๋ง๋ค 3D mesh๋ฅผ ๋ง๋ค์ด๋ดค์ต๋๋ค. ๊ฒฐ๊ณผ๋ก 15.5MB์ง๋ฆฌ GLTF(.glb) ํ์ผ์ด ๋์์ฃ . ์ฌ์ฉ์๊ฐ ๊ฐ๋จํ ์ง๊ตฌ๋ณธ์ ๋ณด๋ ค๊ณ 15.5MB๋ ๋ค์ด ๋ฐ์์ผ ํ๋ค๋, ๊ฐ์ธ์ ์ธ ์๊ฒฌ์ด์ง๋ง ๋๋ฌด ๊ณผํ ๋ฏํฉ๋๋ค.
+
+๋ฐ์ดํฐ๋ฅผ ์์ถํ ์ ์๋ ๋ฐฉ๋ฒ์ด์ผ ๋ง์ต๋๋ค. ์๋ฅผ ๋ค์ด ํน์ ์๊ณ ๋ฆฌ์ฆ์ ๋์
ํด ์ค๊ณฝ์ ์ ํด์๋๋ฅผ ๋ฎ์ถ ์ ์์ฃ . ์ด ๊ธ์์๋ ์๋ํ์ง ์์ ํ
๋ฐ, ์ด์ ๋ ๋ฏธ๊ตญ์ ๊ฒฝ์ฐ ๋ฐ์ดํฐ๋ฅผ ๋ง์ด ์ค์ผ ์ ์๊ฒ ์ง๋ง ์บ๋๋ค๋ ์ฌ์ด ๋ง์ ๋๋ผ๋ ๊ทธ๋ ์ง ์์ ๊ฒ์ด๊ธฐ ๋๋ฌธ์
๋๋ค.
+
+๋ค๋ฅธ ๋ฐฉ๋ฒ์ ์ค์ ๋ฐ์ดํฐ๋ฅผ ์ ๋ถ ์์ถํ๋ ๊ฒ๋๋ค. ์์ถ ํ๋ก๊ทธ๋จ์ ๋๋ ค ์์ถํ๋ ์ฉ๋์ด 11MB๊น์ง ์ค๋๊ตฐ์. 30% ์ ๋ ์ค๊ธด ํ์ง๋ง ์ฌ์ ํ ํฐ ํ์ผ์
๋๋ค.
+
+32๋นํธ ๋ถ๋ ์์ ๋์ 16๋นํธ ๋ฐฉ์์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ์๋ ์์ต๋๋ค. ๋๋ [๋๋ ์ด์ฝ ์์ถ๊ธฐ](https://google.github.io/draco/) ๊ฐ์ ํ๋ก๊ทธ๋จ์ ์ฌ์ฉํ๋ ๊ฒ๋ง์ผ๋ก ์ถฉ๋ถํ ๋ฐ์ดํฐ๋ฅผ ์ค์ผ ์ ์์์ง๋ ๋ชจ๋ฅด์ฃ . ์ ๋ฐ๋ก ๋๋ ์ด์ฝ ์์ถ๊ธฐ๋ฅผ ์ฌ์ฉํด๋ณด์ง ์์์ผ๋ ์ฌ๋ฌ๋ถ์ด ํ ๋ฒ ์จ๋ณด์๊ณ ์๋ ค์ฃผ์ ๋ค๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค ๐
.
+
+์ด ๊ธ์์๋ [ํผํน์ ๊ดํ ๊ธ](threejs-picking.html) ๋ง์ง๋ง์์ ๋ค๋ค๋ [GPU ํผํน](threejs-picking.html)์ ์ฌ์ฉํด๋ณด๊ฒ ์ต๋๋ค. ๊ฐ mesh์ id ์ญํ ์ ํ ๊ณ ์ ํ ์์ ๋ถ์ฌํ๊ณ ํด๋น mesh๋ฅผ ํด๋ฆญํ์ ๋ ํด๋น ํฝ์
์ ์์๊ฐ์ผ๋ก ์ฌ์ฉ์๊ฐ ์ด๋ค mesh๋ฅผ ํด๋ฆญํ๋์ง ์์๋ด๋ ๋ฐฉ๋ฒ์ด์ฃ .
+
+์ผ๋จ ๊ฐ ๋๋ผ์ ๊ณ ์ ํ ์์์ ๋ถ์ฌํ ๋ค, ์ด ์์๊ฐ์ ์ธ๋ฑ์ค๋ก ๋๋ผ ๋ฐฐ์ด์ ๋ง๋ญ๋๋ค. ๊ทธ๋ฆฌ๊ณ ํผํน์ฉ ํ
์ค์ฒ๋ฅผ ๋ง๋ ๋ค ์ด๊ฑธ๋ก ์ง๊ตฌ๋ณธ์ ๋ ๋๋งํฉ๋๋ค. ์ด๋ฌ๋ฉด ์ฌ์ฉ์๊ฐ ํด๋ฆญํ ํฝ์
์ ํ์ธํด ์ด๋ค ๋๋ผ๋ฅผ ํด๋ฆญํ๋์ง ์ ์ ์๊ฒ ์ฃ .
+
+๋จผ์ [์ฝ๊ฐ์ ์ฝ๋](https://github.com/gfxfundamentals/threejsfundamentals/blob/master/threejs/lessons/tools/geo-picking/)๋ฅผ ์์ฑํด ์๋์ ํ
์ค์ฒ๋ฅผ ๋ง๋ค์์ต๋๋ค.
+
+<div class="threejs_center"><img src="../resources/data/world/country-index-texture.png" style="width: 700px;"></div>
+
+> ์ฐธ๊ณ : ์ด ํ
์คํธ๋ฅผ ๋ง๋๋ ๋ฐ ์ฌ์ฉํ ๋ฐ์ดํฐ๋ ์ด [์น์ฌ์ดํธ](http://thematicmapping.org/downloads/world_borders.php)์ด๋ฉฐ, ๋ผ์ด์ ์ค๋ [CC-BY-SA](http://creativecommons.org/licenses/by-sa/3.0/)์
๋๋ค.
+
+์ด ์ด๋ฏธ์ง๋ 271KB ์ ๋๋ฐ์ ๋์ง ์์ต๋๋ค. ๋๋ผ๋ค์ mesh๊ฐ 14MB๊ฐ ๋์๋ ๊ฒ์ ๋นํ๋ฉด ํจ์ฌ ๋ซ๋ค์. ๋ฌผ๋ก ํด์๋๋ฅผ ๋ ๋ฎ์ถ ์๋ ์์ง๋ง ์ด ์ ๋๋ฉด ์ถฉ๋ถํ ๊ฒ ๊ฐ๋ค์.
+
+์ด์ ๋๋ผ์ ํผํน์ ์ ์ฉํด ๋ด
์๋ค.
+
+[GPU ํผํน ์์ ](threejs-picking.html)์ ์ฝ๋๋ฅผ ๊ฐ์ ธ์ ํผํน์ฉ ์ฅ๋ฉด(scene)์ ๋ฐ๋ก ๋ง๋ญ๋๋ค.
+
+```js
+const pickingScene = new THREE.Scene();
+pickingScene.background = new THREE.Color(0);
+```
+
+ํผํน์ฉ ์ฅ๋ฉด์ ํผํน์ฉ ํ
์ค์ฒ๋ฅผ ์
ํ ์ง๊ตฌ๋ณธ์ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+{
+ const loader = new THREE.TextureLoader();
+ const geometry = new THREE.SphereBufferGeometry(1, 64, 32);
+
++ const indexTexture = loader.load('resources/data/world/country-index-texture.png', render);
++ indexTexture.minFilter = THREE.NearestFilter;
++ indexTexture.magFilter = THREE.NearestFilter;
++
++ const pickingMaterial = new THREE.MeshBasicMaterial({ map: indexTexture });
++ pickingScene.add(new THREE.Mesh(geometry, pickingMaterial));
+
+ const texture = loader.load('resources/data/world/country-outlines-4k.png', render);
+ const material = new THREE.MeshBasicMaterial({ map: texture });
+ scene.add(new THREE.Mesh(geometry, material));
+}
+```
+
+๋ค์์ผ๋ก `GPUPickHelper`๋ฅผ ํต์งธ๋ก ๊ฐ์ ธ์ ๋ช ๊ฐ์ง ์์ ํฉ๋๋ค.
+
+```js
+class GPUPickHelper {
+ constructor() {
+ // 1x1 ํฝ์
ํฌ๊ธฐ์ ๋ ๋ ํ๊ฒ์ ์์ฑํฉ๋๋ค
+ this.pickingTexture = new THREE.WebGLRenderTarget(1, 1);
+ this.pixelBuffer = new Uint8Array(4);
+- this.pickedObject = null;
+- this.pickedObjectSavedColor = 0;
+ }
+ pick(cssPosition, scene, camera) {
+ const { pickingTexture, pixelBuffer } = this;
+
+ // view offset์ ๋ง์ฐ์ค ํฌ์ธํฐ ์๋ 1ํฝ์
๋ก ์ค์ ํฉ๋๋ค
+ const pixelRatio = renderer.getPixelRatio();
+ camera.setViewOffset(
+ renderer.getContext().drawingBufferWidth, // ์ ์ฒด ๋๋น
+ renderer.getContext().drawingBufferHeight, // ์ ์ฒด ๋์ด
+ cssPosition.x * pixelRatio | 0, // ์ฌ๊ฐ x ์ขํ
+ cssPosition.y * pixelRatio | 0, // ์ฌ๊ฐ y ์ขํ
+ 1, // ์ฌ๊ฐ ์ขํ width
+ 1, // ์ฌ๊ฐ ์ขํ height
+ );
+ // ์ฅ๋ฉด์ ๋ ๋๋งํฉ๋๋ค
+ renderer.setRenderTarget(pickingTexture);
+ renderer.render(scene, camera);
+ renderer.setRenderTarget(null);
+ // view offset์ ์ ์์ผ๋ก ๋๋ ค ์๋์ ํ๋ฉด์ ๋ ๋๋งํ๋๋ก ํฉ๋๋ค
+ camera.clearViewOffset();
+ // ํฝ์
์ ๊ฐ์งํฉ๋๋ค
+ renderer.readRenderTargetPixels(
+ pickingTexture,
+ 0, // x
+ 0, // y
+ 1, // width
+ 1, // height
+ pixelBuffer);
+
++ const id =
++ (pixelBuffer[0] << 16) |
++ (pixelBuffer[1] << 8) |
++ (pixelBuffer[2] << 0);
++
++ return id;
+- const id =
+- (pixelBuffer[0] << 16) |
+- (pixelBuffer[1] << 8) |
+- (pixelBuffer[2] );
+- const intersectedObject = idToObject[id];
+- if (intersectedObject) {
+- // ์ฒซ ๋ฒ์งธ ๋ฌผ์ฒด๊ฐ ์ ์ผ ๊ฐ๊น์ฐ๋ฏ๋ก ํด๋น ๋ฌผ์ฒด๋ฅผ ๊ณ ๋ฆ
๋๋ค
+- this.pickedObject = intersectedObject;
+- // ๊ธฐ์กด ์์ ์ ์ฅํด๋ก๋๋ค
+- this.pickedObjectSavedColor = this.pickedObject.material.emissive.getHex();
+- // emissive ์์ ๋นจ๊ฐ/๋
ธ๋์ผ๋ก ๋น๋๊ฒ ๋ง๋ญ๋๋ค
+- this.pickedObject.material.emissive.setHex((time * 8) % 2 > 1 ? 0xFFFF00 : 0xFF0000);
+- }
+ }
+}
+```
+
+`GPUPickHelper`๋ฅผ ์ด์ฉํด ๋๋ผ๋ฅผ ์ ํํ๋๋ก ํฉ๋๋ค.
+
+```js
+const pickHelper = new GPUPickHelper();
+
+function getCanvasRelativePosition(event) {
+ const rect = canvas.getBoundingClientRect();
+ return {
+ x: (event.clientX - rect.left) * canvas.width / rect.width,
+ y: (event.clientY - rect.top ) * canvas.height / rect.height,
+ };
+}
+
+function pickCountry(event) {
+ // ์์ง ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค์ง ์์์ ๊ฒฝ์ฐ
+ if (!countryInfos) {
+ return;
+ }
+
+ const position = getCanvasRelativePosition(event);
+ const id = pickHelper.pick(position, pickingScene, camera);
+ if (id > 0) {
+ // ๋๋ผ๋ฅผ ์ ํํ์ ๋ ํด๋น ๋๋ผ์ 'selected' ์์ฑ์ ๋ฐ๊ฟ๋๋ค.
+ const countryInfo = countryInfos[id - 1];
+ const selected = !countryInfo.selected;
+ // ๋๋ผ๋ฅผ ํด๋ฆญํ์ ๋ ํน์ํค๋ฅผ ๋๋ฅด์ง ์์๋ค๋ฉด ๋ค๋ฅธ ๋๋ผ์ 'selected'
+ // ์์ฑ์ ์ ๋ถ ๋๋๋ค.
+ if (selected && !event.shiftKey && !event.ctrlKey && !event.metaKey) {
+ unselectAllCountries();
+ }
+ numCountriesSelected += selected ? 1 : -1;
+ countryInfo.selected = selected;
+ } else if (numCountriesSelected) {
+ // ๋ฐ๋ค๋ ํ๋์ ํด๋ฆญํ์ ๊ฒฝ์ฐ
+ unselectAllCountries();
+ }
+ requestRenderIfNotRequested();
+}
+
+function unselectAllCountries() {
+ numCountriesSelected = 0;
+ countryInfos.forEach((countryInfo) => {
+ countryInfo.selected = false;
+ });
+}
+
+canvas.addEventListener('mouseup', pickCountry);
+
+let lastTouch;
+canvas.addEventListener('touchstart', (event) => {
+ // ์คํฌ๋กค ์ด๋ฒคํธ๋ฅผ ๋ฐฉ์งํฉ๋๋ค.
+ event.preventDefault();
+ lastTouch = event.touches[0];
+}, { passive: false });
+canvas.addEventListener('touchmove', (event) => {
+ lastTouch = event.touches[0];
+});
+canvas.addEventListener('touchend', () => {
+ pickCountry(lastTouch);
+});
+```
+
+์ ์ฝ๋๋ ๋๋ผ ๋ฐฐ์ด์ ์ํ ๋๋ผ์ `selected` ์์ฑ์ ์ผ๊ณ ๋๋๋ค. `shift`, `ctrl`, `cmd` ์ค ํ๋๋ฅผ ๋๋ฅด๋ฉด ํ๋ ์ด์์ ๋๋ผ๋ฅผ ์ ํํ ์ ์์ฃ .
+
+์ด์ ์ ํํ ๋๋ผ๋ฅผ ๋ณด์ฌ์ค ์ผ๋ง ๋จ์์ต๋๋ค. ์ง๊ธ์ ์ผ๋จ ํด๋น ๋๋ผ์ ์ด๋ฆํ๋ฅผ ๋ณด์ฌ์ฃผ๊ธฐ๋ก ํ์ฃ .
+
+```js
+function updateLabels() {
+ // ์์ง ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค์ง ์์์ ๊ฒฝ์ฐ
+ if (!countryInfos) {
+ return;
+ }
+
+ const large = settings.minArea * settings.minArea;
+ // ์นด๋ฉ๋ผ์ ์๋ ๋ฐฉํฅ์ ๋ํ๋ด๋ ํ๋ ฌ ์ขํ๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
+ normalMatrix.getNormalMatrix(camera.matrixWorldInverse);
+ // ์นด๋ฉ๋ผ์ ์์น๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
+ camera.getWorldPosition(cameraPosition);
+ for (const countryInfo of countryInfos) {
+- const { position, elem, area } = countryInfo;
+- // ์์ญ์ด ํน์ ๊ฐ๋ณด๋ค ์๋ค๋ฉด ์ด๋ฆํ๋ฅผ ํ์ํ์ง ์์ต๋๋ค.
+- if (area < large) {
++ const { position, elem, area, selected } = countryInfo;
++ const largeEnough = area >= large;
++ const show = selected || (numCountriesSelected === 0 && largeEnough);
++ if (!show) {
+ elem.style.display = 'none';
+ continue;
+ }
+
+ ...
+```
+
+์ด์ ๋๋ผ๋ฅผ ์ ํํด ๋ณผ ์ ์์ต๋๋ค.
+
+{{{example url="../threejs-indexed-textures-picking.html" }}}
+
+์ ์์ ๋ ์ฌ์ ํ ์์ญ ํฌ๊ธฐ์ ๋ฐ๋ผ ๋๋ผ ์ด๋ฆ์ ๋ณด์ฌ์ฃผ๊ธด ํ๋, ํน์ ๋๋ผ๋ฅผ ํด๋ฆญํ๋ฉด ํด๋น ๋๋ผ์ ์ด๋ฆ๋ง ๋ณด์ฌ์ค ๊ฒ๋๋ค.
+
+์ด๋งํ๋ฉด ๊ฐ ๋๋ผ๋ฅผ ํผํนํ๋ ์์ ๋ก ์ถฉ๋ถํด ๋ณด์ด์ง๋ง... ์ ํํ ๋๋ผ์ ์์ ๋ฐ๊พธ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํ ๊น์?
+
+*์ปฌ๋ฌ ํ๋ ํธ(color palette)*๋ฅผ ์ฌ์ฉํ๋ฉด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค.
+
+[์ปฌ๋ฌ ํ๋ ํธ](https://ko.wikipedia.org/wiki/%ED%8C%94%EB%A0%88%ED%8A%B8_(%EC%BB%B4%ED%93%A8%ED%8C%85)) ํน์ [์ธ๋ฑ์ค ํ๋ ํธ](https://en.wikipedia.org/wiki/Indexed_color)๋ ์ํ๋ฆฌ 800, Amiga, NES, ์ํผ ๋ํ
๋, ๊ตฌํ IBM PC ๋ฑ ๊ตฌํ ์์คํ
์์ ์ฌ์ฉํ๋ ๊ธฐ๋ฒ์
๋๋ค. ๋นํธ๋งต์ ์์๋น 8๋นํธ ํน์ 24๋ฐ์ดํธ ์ด์์ RGB ์์์ผ๋ก ์ ์ฉํ๋ ๋์ ๋นํธ๋งต์ 8๋นํธ ์ดํ์ ๊ฐ์ผ๋ก ์ ์ฅํ๋ ๊ธฐ๋ฒ์ด์ฃ . ๊ฐ ํฝ์
์ ์์๊ฐ์ ํ๋ ํธ์ ์ธ๋ฑ์ค ๊ฐ์ผ๋ก, ํฝ์
์ ์์๊ฐ์ด 3์ด๋ผ๋ฉด ํน์ "ํ๋ ํธ"์ 3๋ฒ ์์์ ์ฌ์ฉํ๋ค๋ ์๋ฏธ์
๋๋ค.
+
+์๋ฐ์คํฌ๋ฆฝํธ๋ก ์ค๋ช
ํ์๋ฉด ์๋์ ๊ฐ์ ํ์์ ์๊ฐํ ์ ์์ต๋๋ค.
+
+```js
+const face7x7PixelImageData = [
+ 0, 1, 1, 1, 1, 1, 0,
+ 1, 0, 0, 0, 0, 0, 1,
+ 1, 0, 2, 0, 2, 0, 1,
+ 1, 0, 0, 0, 0, 0, 1,
+ 1, 0, 3, 3, 3, 0, 1,
+ 1, 0, 0, 0, 0, 0, 1,
+ 0, 1, 1, 1, 1, 1, 1,
+];
+
+const palette = [
+ [255, 255, 255], // white
+ [ 0, 0, 0], // black
+ [ 0, 255, 255], // cyan
+ [255, 0, 0], // red
+];
+```
+
+์ด๋ฏธ์ง ๋ฐ์ดํฐ์ ๊ฐ ํฝ์
์ ํ๋ ํธ์ ์ธ๋ฑ์ค๋ฅผ ๊ฐ๋ฆฌํต๋๋ค. ์ ๋ฐ์ดํฐ๋ฅผ ์ ํ๋ ํธ๋ก ํด์ํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ์ด๋ฏธ์ง๊ฐ ๋์ค๊ฒ ์ฃ .
+
+<div class="threejs_center"><img src="resources/images/7x7-indexed-face.png"></div>
+
+์์ ์ ๊ฒฝ์ฐ ์ด๋ฏธ ๊ฐ ๋๋ผ๋ณ๋ก ๊ณ ์ ์์ ๋ถ์ฌํ ํ
์ค์ฒ๊ฐ ์์ต๋๋ค. ์ด ํ
์ค์ฒ์ ํ๋ ํธ๋ฅผ ์ ์ฉํ๋ฉด ๊ฐ ๋๋ผ์ ๋ค๋ฅธ ์์ ๋ถ์ฌํ ์ ์๊ฒ ์ฃ . ๋ ์ด ํ๋ ํธ์ ์์ ๋ฐ๊พธ๋ฉด ๊ฐ ๋๋ผ์ ์๋ ๋ฐ๋ ๊ฒ๋๋ค. ๊ทธ๋ฌ๋ ํ๋ ํธ์ ์์ ์ ๋ถ ๊ฒ์ ์ผ๋ก ๋ฐ๊พผ ๋ค, ์ ํํ ๋๋ผ๋ง ๋ค๋ฅธ ์์ผ๋ก ๋ฐ๊พธ๋ฉด ํด๋น ๋๋ผ๋ฅผ ์ ํํ๋ค๋ ๊ฒ์ ์๊ฐ์ ์ผ๋ก ๋ํ๋ผ ์ ์์ ๊ฒ๋๋ค.
+
+์ปฌ๋ฌ ํ๋ ํธ ๊ธฐ๋ฒ์ ์ฌ์ฉํ๋ ค๋ฉด ์์ด๋๋ฅผ ์ง์ ๋ง๋ค์ด์ผ ํฉ๋๋ค. Three.js์ ๋ด์ฅ ์์ด๋๋ฅผ ์์ ํด์ ์ฌ์ฉํ๋ฉด ์กฐ๋ช
์ด๋ ๋ค๋ฅธ ๊ธฐ๋ฅ๋ ๋์ค์ ์ฌ์ฉํ ์ ์์ผ๋ ์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋๋ก ํ์ฃ .
+
+[๋ค์ค ์ ๋๋ฉ์ด์
์์ ์ต์ ํํ๊ธฐ](threejs-optimize-lots-of-objects-animated.html)์์ ๋ค๋ค๋ฏ ์ฌ์ง์ `onBeforeCompile` ์์ฑ์ ํจ์๋ฅผ ์ง์ ํ๋ฉด ๋ด์ฅ ์์ด๋๋ฅผ ์์ ํ ์ ์์ต๋๋ค.
+
+์๋๋ ๋ด์ฅ fragment ์์ด๋๋ฅผ ์์ ํ๊ธฐ ์ ์
๋๋ค.
+
+```glsl
+#include <common>
+#include <color_pars_fragment>
+#include <uv_pars_fragment>
+#include <uv2_pars_fragment>
+#include <map_pars_fragment>
+#include <alphamap_pars_fragment>
+#include <aomap_pars_fragment>
+#include <lightmap_pars_fragment>
+#include <envmap_pars_fragment>
+#include <fog_pars_fragment>
+#include <specularmap_pars_fragment>
+#include <logdepthbuf_pars_fragment>
+#include <clipping_planes_pars_fragment>
+void main() {
+ #include <clipping_planes_fragment>
+ vec4 diffuseColor = vec4( diffuse, opacity );
+ #include <logdepthbuf_fragment>
+ #include <map_fragment>
+ #include <color_fragment>
+ #include <alphamap_fragment>
+ #include <alphatest_fragment>
+ #include <specularmap_fragment>
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
+ #ifdef USE_LIGHTMAP
+ reflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
+ #else
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
+ #endif
+ #include <aomap_fragment>
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
+ #include <envmap_fragment>
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );
+ #include <premultiplied_alpha_fragment>
+ #include <tonemapping_fragment>
+ #include <encodings_fragment>
+ #include <fog_fragment>
+}
+```
+
+[์ ์ฝ๋์ ์์ด๋ ์กฐ๊ฐ](https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderChunk)์ ์ผ์ผ์ด ๋ค์ ธ ๋ณด๋ Three.js๋ `diffuseColor`๋ผ๋ ๋ณ์๋ก ์ฌ์ง(material)์ ์์๊ฐ์ ์ ์ดํฉ๋๋ค. ์ด ๋ณ์๋ `<color_fragment>`๋ผ๋ [์์ด๋ ์กฐ๊ฐ](https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js)์์ ์ ์ธํ๋ ๋ณ์ ์ ์ธ ํ์ ์์๊ฐ์ ์์ ํ๋ฉด ๋๊ฒ ๋ค์.
+
+์ ๋ `diffuseColor`๋ ์๊น ๋ง๋ค์๋ ์ค๊ณฝ์ ํ
์ค์ฒ์์ ์์์ ๊ฐ์ ธ์จ ์ํ์ผ ํ
๋, ์ด ์์๊ฐ์ผ๋ก ํ๋ ํธ ํ
์ค์ฒ์์ ์๋ก์ด ์์๊ฐ์ ๊ฐ์ ธ ์ฌ ์ ์์ ๊ฒ๋๋ค.
+
+[์ด์ ์ ํ๋ ๊ฒ](threejs-optimize-lots-of-objects-animated.html)์ฒ๋ผ ๋ฐ๊ฟ ๋ฌธ์์ด ์ ๋ณด๋ฅผ ๋ฐฐ์ด๋ก ๋ง๋ค์ด `Material.onBeforeCompile`์์ ์์ด๋๋ฅผ ์์ ํ๊ฒ ์ต๋๋ค.
+
+```js
+{
+ const loader = new THREE.TextureLoader();
+ const geometry = new THREE.SphereBufferGeometry(1, 64, 32);
+
+ const indexTexture = loader.load('resources/data/world/country-index-texture.png', render);
+ indexTexture.minFilter = THREE.NearestFilter;
+ indexTexture.magFilter = THREE.NearestFilter;
+
+ const pickingMaterial = new THREE.MeshBasicMaterial({ map: indexTexture });
+ pickingScene.add(new THREE.Mesh(geometry, pickingMaterial));
+
++ const fragmentShaderReplacements = [
++ {
++ from: '#include <common>',
++ to: `
++ #include <common>
++ uniform sampler2D indexTexture;
++ uniform sampler2D paletteTexture;
++ uniform float paletteTextureWidth;
++ `,
++ },
++ {
++ from: '#include <color_fragment>',
++ to: `
++ #include <color_fragment>
++ {
++ vec4 indexColor = texture2D(indexTexture, vUv);
++ float index = indexColor.r * 255.0 + indexColor.g * 255.0 * 256.0;
++ vec2 paletteUV = vec2((index + 0.5) / paletteTextureWidth, 0.5);
++ vec4 paletteColor = texture2D(paletteTexture, paletteUV);
++ // diffuseColor.rgb += paletteColor.rgb; // ํ์ ์ค๊ณฝ์
++ diffuseColor.rgb = paletteColor.rgb - diffuseColor.rgb; // ๊ฒ์ ์ค๊ณฝ์
++ }
++ `,
++ },
++ ];
+
+ const texture = loader.load('resources/data/world/country-outlines-4k.png', render);
+ const material = new THREE.MeshBasicMaterial({ map: texture });
++ material.onBeforeCompile = function(shader) {
++ fragmentShaderReplacements.forEach((rep) => {
++ shader.fragmentShader = shader.fragmentShader.replace(rep.from, rep.to);
++ });
++ };
+ scene.add(new THREE.Mesh(geometry, material));
+}
+```
+
+์ ์ฝ๋์์๋ `indexTexture`, `paletteTexture`, `paletteTextureWidth`, ์ด 3๊ฐ์ ๊ท ๋ฑ ๋ณ์(uniform)๋ฅผ ์ฌ์ฉํ์ต๋๋ค. `indexTexture`๋ ์์๊ฐ์ ๋ถ๋ฌ์ ์ธ๋ฑ์ค๋ก ๋ณํํ๊ธฐ ์ํ ๊ฒ์ผ๋ก, ์ด๋ ์ฌ์ฉํ `vUv`๋ Three.js๊ฐ ๋๊ฒจ์ฃผ๋ ํ
์ค์ฒ ์ขํ์ด์ฃ . ๊ทธ๋ฆฌ๊ณ ์ด ์ธ๋ฑ์ค ๊ฐ์ผ๋ก ์ปฌ๋ฌ ํ๋ ํธ์์ ์๋ก์ด ์์๊ฐ์ ๊ฐ์ ธ ์ `diffuseColor`์ ์์์ต๋๋ค. ์ด๋ `diffuseColor`๋ ๊ฒ์๋ฐํ์ ํ์์ ์ค๊ณฝ์ ํ
์ค์ฒ์ด๋ ๋ ์์ ๋ํด๋ ํ์ ์ค๊ณฝ์ ์ด ๋์ฌ ๊ฒ๋๋ค. ๋์ ์๋ก์ด ์์์ `diffuseColor`๋ฅผ ๋บ๋ค๋ฉด ๊ฒ์ ์ค๊ณฝ์ ์ด ๋์ค๊ฒ ์ฃ .
+
+๋ค์์ผ๋ก ๋ ๋๋ง ์ ์ ํ๋ ํธ ํ
์ค์ฒ์ 3๊ฐ์ ๊ท ๋ฑ ๋ณ์๋ฅผ ์ง์ ํด์ผ ํฉ๋๋ค.
+
+ํ๋ ํธ ํ
์ค์ฒ์๋ ๋๋ผ๋น ํ๋์ ์์๊ณผ ๋ฐ๋ค์ ์์(id = 0) ํ๋๋ง ํ์ํฉ๋๋ค. ์ ์ธ๊ณ์ ์ผ๋ก ์ฝ 240์ฌ ๊ฐ์ ๋๋ผ๊ฐ ์์ฃ . ๋๋ผ ๋ฐฐ์ด์ ๋ถ๋ฌ์ฌ ๋๊น์ง ๊ธฐ๋ค๋ ธ๋ค๊ฐ ์ ํํ ๊ฐ์๋ฅผ ๋ฐ์์ฌ ์๋ ์์ ๊ฒ๋๋ค. ํ์ง๋ง ๋น์ฅ ์ซ์๊ฐ ํฌ๋ค๊ณ ๋ฌธ์ ๊ฐ ๋ ๊ฒ ๊ฐ์ง๋ ์์ผ๋ 512 ์ ๋์ ํฐ ์ซ์๋ฅผ ๊ณ ๋ฅด๊ธฐ๋ก ํฉ์๋ค.
+
+์๋๋ ํ๋ ํธ ํ
์ค์ฒ๋ฅผ ๋ง๋๋ ์ฝ๋์
๋๋ค.
+
+```js
+const maxNumCountries = 512;
+const paletteTextureWidth = maxNumCountries;
+const paletteTextureHeight = 1;
+const palette = new Uint8Array(paletteTextureWidth * 3);
+const paletteTexture = new THREE.DataTexture(
+ palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+paletteTexture.minFilter = THREE.NearestFilter;
+paletteTexture.magFilter = THREE.NearestFilter;
+```
+
+`DataTexture`๋ฅผ ์ฐ๋ฉด ํ
์ค์ฒ๋ฅผ ๋ก์ฐ-๋ฐ์ดํฐ(raw data) ํ์์ผ๋ก ๋๊ธธ ์ ์์ต๋๋ค. ์์ ์ ๊ฒฝ์ฐ์๋ 512 RGB ์์์ ๋๊ฒจ์ฃผ๋ฉด ๋๊ฒ ์ฃ . ๊ฐ ๊ฐ์ 3๋ฐ์ดํธ๋ก, ์ด ๋ฐ์ดํธ๋ ๊ฐ๊ฐ red, green, blue์ 0๋ถํฐ 255๊น์ง์ ์ซ์๋ก ๋ํ๋
๋๋ค.
+
+์ผ๋จ์ ๋ฌด์์๋ก ์์ ์ง์ ํด ์ ์๋ํ๋์ง ํ
์คํธํด๋ด
์๋ค.
+
+```js
+for (let i = 1; i < palette.length; ++i) {
+ palette[i] = Math.random() * 256;
+}
+// ๋ฐ๋ค์ ์์ ์ง์ ํฉ๋๋ค. (index #0)
+palette.set([100, 200, 255], 0);
+paletteTexture.needsUpdate = true;
+```
+
+`palette` ๋ฐฐ์ด๋ก ํ๋ ํธ ํ
์ค์ฒ๋ฅผ ์
๋ฐ์ดํธํ ๋๋ง๋ค ์ฅ๋ฉด์ ์
๋ฐ์ดํธํด์ผ ํ๋ `paletteTexture.needsUpdate`๋ฅผ `true`๋ก ์ค์ ํฉ๋๋ค.
+
+๋ค์์ผ๋ก ์ฌ์ง์ ๊ท ๋ฑ ๋ณ์๋ฅผ ์ค์ ํด์ค๋๋ค.
+
+```js
+const geometry = new THREE.SphereBufferGeometry(1, 64, 32);
+const material = new THREE.MeshBasicMaterial({ map: texture });
+material.onBeforeCompile = function(shader) {
+ fragmentShaderReplacements.forEach((rep) => {
+ shader.fragmentShader = shader.fragmentShader.replace(rep.from, rep.to);
+ });
++ shader.uniforms.paletteTexture = { value: paletteTexture };
++ shader.uniforms.indexTexture = { value: indexTexture };
++ shader.uniforms.paletteTextureWidth = { value: paletteTextureWidth };
+};
+scene.add(new THREE.Mesh(geometry, material));
+```
+
+์ด์ ์์ ๋ฅผ ์คํํ๋ฉด ๊ฐ ๋๋ผ์ ์์์ด ๋ฌด์์๋ก ์ง์ ๋ ๊ฒ์ด ๋ณด์ผ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-indexed-textures-random-colors.html" }}}
+
+์ธ๋ฑ์ฑ๊ณผ ํ๋ ํธ ํ
์ค์ฒ๊ฐ ์ ์๋ํ๋ ๊ฒ์ ํ์ธํ์ผ๋, ์ด์ ํ๋ ํธ๋ฅผ ์กฐ์ํด ์ ํํ ๋๋ผ์ ์์๋ง ๋ฐ๊พธ๋๋ก ํด๋ด
์๋ค.
+
+๋จผ์ ํจ์๋ฅผ ํ๋ ๋ง๋ญ๋๋ค. ์ด ํจ์๋ Three.js์ `Color`๋ฅผ ๋งค๊ฐ๋ณ์๋ก ๋ฐ์ ํ๋ ํธ ํ
์ค์ฒ์ ์ง์ ํ ์ ์๋ ๊ฐ์ ๋ฐํํ ๊ฒ๋๋ค.
+
+```js
+const tempColor = new THREE.Color();
+function get255BasedColor(color) {
+ tempColor.set(color);
+ return tempColor.toArray().map(v => v * 255);
+}
+```
+
+์ ํจ์๋ฅผ `color = get255BasedColor('red')`์ ๊ฐ์ ์์ผ๋ก ํธ์ถํ๋ฉด `[255, 0, 0]` ์ด๋ฐ ์์ ๋ฐฐ์ด์ ๋ฐํํฉ๋๋ค.
+
+๋ค์์ผ๋ก ์ ํจ์๋ฅผ ์ด์ฉํด ๋ช ๊ฐ์ง ์์ ๋ง๋ค์ด ํ๋ ํธ๋ฅผ ์ฑ์๋๋ค.
+
+```js
+const selectedColor = get255BasedColor('red');
+const unselectedColor = get255BasedColor('#444');
+const oceanColor = get255BasedColor('rgb(100,200,255)');
+resetPalette();
+
+function setPaletteColor(index, color) {
+ palette.set(color, index * 3);
+}
+
+function resetPalette() {
+ // ๋ชจ๋ ํ๋ ํธ์ ์์์ unselectedColor๋ก ๋ฐ๊ฟ๋๋ค.
+ for (let i = 1; i < maxNumCountries; ++i) {
+ setPaletteColor(i, unselectedColor);
+ }
+
+ // ๋ฐ๋ค์ ์์ ์ง์ ํฉ๋๋ค. (index #0)
+ setPaletteColor(0, oceanColor);
+ paletteTexture.needsUpdate = true;
+}
+```
+
+์ด์ `resetPalette` ํจ์๋ฅผ ์ด์ฉํด ๋๋ผ๋ฅผ ์ ํํ์ ๋ ํ๋ ํธ๋ฅผ ์
๋ฐ์ดํธํฉ๋๋ค.
+
+```js
+function getCanvasRelativePosition(event) {
+ const rect = canvas.getBoundingClientRect();
+ return {
+ x: (event.clientX - rect.left) * canvas.width / rect.width,
+ y: (event.clientY - rect.top ) * canvas.height / rect.height,
+ };
+}
+
+function pickCountry(event) {
+ // ์์ง ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค์ง ์์์ ๊ฒฝ์ฐ
+ if (!countryInfos) {
+ return;
+ }
+
+ const position = getCanvasRelativePosition(event);
+ const id = pickHelper.pick(position, pickingScene, camera);
+ if (id > 0) {
+ const countryInfo = countryInfos[id - 1];
+ const selected = !countryInfo.selected;
+ if (selected && !event.shiftKey && !event.ctrlKey && !event.metaKey) {
+ unselectAllCountries();
+ }
+ numCountriesSelected += selected ? 1 : -1;
+ countryInfo.selected = selected;
++ setPaletteColor(id, selected ? selectedColor : unselectedColor);
++ paletteTexture.needsUpdate = true;
+ } else if (numCountriesSelected) {
+ unselectAllCountries();
+ }
+ requestRenderIfNotRequested();
+}
+
+function unselectAllCountries() {
+ numCountriesSelected = 0;
+ countryInfos.forEach((countryInfo) => {
+ countryInfo.selected = false;
+ });
++ resetPalette();
+}
+```
+
+์ด์ ์ ํํ ๋๋ผ๊ฐ ๊ฐ์กฐ๋์ด ๋ณด์ผ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-indexed-textures-picking-and-highlighting.html" }}}
+
+์ ์๋ํ๋ ๊ฒ ๊ฐ๋ค์!
+
+๋ค๋ง ์ง๊ตฌ๋ณธ์ ๋๋ฆด ๋๋ ๋๋ผ๊ฐ ์ ํ๋๋ค๋ ๊ฒ ๊ฑฐ์ฌ๋ฆฝ๋๋ค. ๋ ๋๋ผ๋ฅผ ์ ํํ๊ณ ์ง๊ตฌ๋ณธ์ ๋๋ฆฌ๋ฉด ํด๋น ์ ํ์ด ํ๋ ค๋ฒ๋ฆฌ๋ค์.
+
+๋ง์ง๋ง์ผ๋ก ์ด๊ฒ๊น์ง ๊ณ ์ณ๋ด
์๋ค. 2๊ฐ์ง ์ ๋๋ฅผ ํ์ธํ๋ฉด ์ถฉ๋ถํ ๊ฒ ๊ฐ๋ค์. ํ๋๋ ํฌ์ธํฐ๋ฅผ ๋๋ฅธ ํ ๋ผ๊ธฐ๊น์ง ์ผ๋ง๋ ์๊ฐ์ด ํ๋ ๋์ง๋ฅผ ํ์ดํ๋ ๊ฒ์ด๊ณ , ๋ค๋ฅธ ํ๋๋ ํฌ์ธํฐ๊ฐ ์์ง์๋์ง ํ์ธํ๋ ๊ฒ๋๋ค. ๋ง์ฐ์ค๋ฅผ ๋ผ๋ ๋ฐ ์๊ฐ์ด ์ผ๋ง ์ ๊ฑธ๋ ธ๊ณ ํฌ์ธํฐ๊ฐ ์์ง์ด์ง ์์๋ค๋ฉด ํด๋ฆญ์ผ๋ก ๊ฐ์ฃผํ๋ ๊ฒ์ด์ฃ .
+
+```js
++const maxClickTimeMs = 200;
++const maxMoveDeltaSq = 5 * 5;
++const startPosition = {};
++let startTimeMs;
++
++function recordStartTimeAndPosition(event) {
++ startTimeMs = performance.now();
++ const pos = getCanvasRelativePosition(event);
++ startPosition.x = pos.x;
++ startPosition.y = pos.y;
++}
+
+function getCanvasRelativePosition(event) {
+ const rect = canvas.getBoundingClientRect();
+ return {
+ x: (event.clientX - rect.left) * canvas.width / rect.width,
+ y: (event.clientY - rect.top ) * canvas.height / rect.height,
+ };
+}
+
+function pickCountry(event) {
+ // ์์ง ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์ค์ง ์์์ ๊ฒฝ์ฐ
+ if (!countryInfos) {
+ return;
+ }
+
++ // ํฌ์ธํฐ๋ฅผ ๋๋ฅธ ํ ๋ผ๊ธฐ๊น์ง ์ผ์ ์๊ฐ ์ด์ ๊ฑธ๋ ธ๋ค๋ฉด
++ // ์ ํ ์ก์
์ด ์๋ ๋๋๊ทธ ์ก์
์ผ๋ก ๊ฐ์ฃผํฉ๋๋ค.
++ const clickTimeMs = performance.now() - startTimeMs;
++ if (clickTimeMs > maxClickTimeMs) {
++ return;
++ }
++
++ // ํฌ์ธํฐ๊ฐ ์์ง์๋ค๋ฉด ๋๋๊ทธ๋ก ๊ฐ์ฃผํฉ๋๋ค.
++ const position = getCanvasRelativePosition(event);
++ const moveDeltaSq = (startPosition.x - position.x) ** 2 +
++ (startPosition.y - position.y) ** 2;
++ if (moveDeltaSq > maxMoveDeltaSq) {
++ return;
++ }
+
+- const position = { x: event.clientX, y: event.clientY };
+ const id = pickHelper.pick(position, pickingScene, camera);
+ if (id > 0) {
+ const countryInfo = countryInfos[id - 1];
+ const selected = !countryInfo.selected;
+ if (selected && !event.shiftKey && !event.ctrlKey && !event.metaKey) {
+ unselectAllCountries();
+ }
+ numCountriesSelected += selected ? 1 : -1;
+ countryInfo.selected = selected;
+ setPaletteColor(id, selected ? selectedColor : unselectedColor);
+ paletteTexture.needsUpdate = true;
+ } else if (numCountriesSelected) {
+ unselectAllCountries();
+ }
+ requestRenderIfNotRequested();
+}
+
+function unselectAllCountries() {
+ numCountriesSelected = 0;
+ countryInfos.forEach((countryInfo) => {
+ countryInfo.selected = false;
+ });
+ resetPalette();
+}
+
++canvas.addEventListener('mousedown', recordStartTimeAndPosition);
+canvas.addEventListener('mouseup', pickCountry);
+
+let lastTouch;
+canvas.addEventListener('touchstart', (event) => {
+ // ์คํฌ๋กค ์ด๋ฒคํธ๋ฅผ ๋ฐฉ์งํฉ๋๋ค.
+ event.preventDefault();
+ lastTouch = event.touches[0];
++ recordStartTimeAndPosition(event.touches[0]);
+}, { passive: false });
+canvas.addEventListener('touchmove', (event) => {
+ lastTouch = event.touches[0];
+});
+```
+
+์ ๊ธฐ์ค์์๋ ์ด ์ ๋๋ฉด ์ถฉ๋ถํ *๋ฏํ๋ค์*.
+
+{{{example url="../threejs-indexed-textures-picking-debounced.html" }}}
+
+์ ๋ UX ์ ๋ฌธ๊ฐ๊ฐ ์๋๋ ๋ ๋์ ๋ฐฉ๋ฒ์ด ์์ ๊ฒฝ์ฐ ์๋ ค์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค.
+
+์ด ๊ธ์ด ์ธ๋ฑ์ค(indexed) ๊ทธ๋ํฝ์ ํ์ฉํ๊ณ , Three.js์ ์์ด๋๋ฅผ ์์ ํด ๊ฐ๋จํ ํจ๊ณผ๋ฅผ ๊ตฌํํ๋ ๋ฐ ๋์์ด ๋์๋ค๋ฉด ์ข๊ฒ ๋ค์. ์์ด๋๋ฅผ ์์ฑํ ๋ ์ด GLSL์ ๋ํด ๋ค๋ฃจ๊ธฐ์๋ ๋๋ฌด ๋ด์ฉ์ด ๋ฐฉ๋ํ๋ [ํ์ฒ๋ฆฌ์ ๊ดํ ๊ธ](threejs-post-processing.html)์ ์๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ๊ธฐ ๋ฐ๋๋๋ค. | false |
Other | mrdoob | three.js | a511e81b9b8d3339c77f04d4e027b05507bfcdb6.json | Fix sun positioning in sky shader example (#21575)
* Fix sun positioning in sky shader example
* Fix sun positioning in ocean shader example
* Update webgl_shaders_ocean.html
Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org> | examples/webgl_shaders_ocean.html | @@ -94,20 +94,20 @@
skyUniforms[ 'mieDirectionalG' ].value = 0.8;
const parameters = {
- inclination: 0.49,
- azimuth: 0.205
+ inclination: 0.02,
+ azimuth: 0.045
};
const pmremGenerator = new THREE.PMREMGenerator( renderer );
function updateSun() {
- const theta = Math.PI * ( parameters.inclination - 0.5 );
+ const theta = 0.5 * Math.PI * ( 1 - parameters.inclination );
const phi = 2 * Math.PI * ( parameters.azimuth - 0.5 );
- sun.x = Math.cos( phi );
- sun.y = Math.sin( phi ) * Math.sin( theta );
- sun.z = Math.sin( phi ) * Math.cos( theta );
+ sun.x = Math.sin( theta ) * Math.sin( phi );
+ sun.y = Math.cos( theta );
+ sun.z = Math.sin( theta ) * Math.cos( phi );
sky.material.uniforms[ 'sunPosition' ].value.copy( sun );
water.material.uniforms[ 'sunDirection' ].value.copy( sun ).normalize();
@@ -145,7 +145,7 @@
const gui = new GUI();
const folderSky = gui.addFolder( 'Sky' );
- folderSky.add( parameters, 'inclination', 0, 0.5, 0.0001 ).onChange( updateSun );
+ folderSky.add( parameters, 'inclination', - 1, 1, 0.0001 ).onChange( updateSun );
folderSky.add( parameters, 'azimuth', 0, 1, 0.0001 ).onChange( updateSun );
folderSky.open();
| true |
Other | mrdoob | three.js | a511e81b9b8d3339c77f04d4e027b05507bfcdb6.json | Fix sun positioning in sky shader example (#21575)
* Fix sun positioning in sky shader example
* Fix sun positioning in ocean shader example
* Update webgl_shaders_ocean.html
Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org> | examples/webgl_shaders_sky.html | @@ -42,8 +42,8 @@
rayleigh: 3,
mieCoefficient: 0.005,
mieDirectionalG: 0.7,
- inclination: 0.49, // elevation / inclination
- azimuth: 0.25, // Facing front,
+ inclination: 0.02, // elevation / inclination
+ azimuth: 0, // Facing front
exposure: renderer.toneMappingExposure
};
@@ -55,12 +55,12 @@
uniforms[ "mieCoefficient" ].value = effectController.mieCoefficient;
uniforms[ "mieDirectionalG" ].value = effectController.mieDirectionalG;
- const theta = Math.PI * ( effectController.inclination - 0.5 );
+ const theta = 0.5 * Math.PI * ( 1 - effectController.inclination );
const phi = 2 * Math.PI * ( effectController.azimuth - 0.5 );
- sun.x = Math.cos( phi );
- sun.y = Math.sin( phi ) * Math.sin( theta );
- sun.z = Math.sin( phi ) * Math.cos( theta );
+ sun.x = Math.sin( theta ) * Math.sin( phi );
+ sun.y = Math.cos( theta );
+ sun.z = Math.sin( theta ) * Math.cos( phi );
uniforms[ "sunPosition" ].value.copy( sun );
@@ -75,7 +75,7 @@
gui.add( effectController, "rayleigh", 0.0, 4, 0.001 ).onChange( guiChanged );
gui.add( effectController, "mieCoefficient", 0.0, 0.1, 0.001 ).onChange( guiChanged );
gui.add( effectController, "mieDirectionalG", 0.0, 1, 0.001 ).onChange( guiChanged );
- gui.add( effectController, "inclination", 0, 1, 0.0001 ).onChange( guiChanged );
+ gui.add( effectController, "inclination", -1, 1, 0.0001 ).onChange( guiChanged );
gui.add( effectController, "azimuth", 0, 1, 0.0001 ).onChange( guiChanged );
gui.add( effectController, "exposure", 0, 1, 0.0001 ).onChange( guiChanged );
| true |
Other | mrdoob | three.js | b2ed7e9aa9144e9ecc8841b915c3745b494050da.json | add bumpthree grunt task | Gruntfile.js | @@ -3,6 +3,8 @@
'use strict';
const fs = require('fs');
+const path = require('path');
+const semver = require('semver');
module.exports = function(grunt) {
@@ -66,7 +68,61 @@ module.exports = function(grunt) {
}).done();
});
- grunt.registerTask('build', ['clean', 'copy', 'buildlessons']);
+ grunt.task.registerMultiTask('fixthreepaths', 'fix three paths', function() {
+ const options = this.options({});
+ const oldVersionRE = new RegExp(`/${options.oldVersionStr}/`, 'g');
+ const newVersionReplacement = `/${options.newVersionStr}/`;
+ this.files.forEach((files) => {
+ files.src.forEach((filename) => {
+ const oldContent = fs.readFileSync(filename, {encoding: 'utf8'});
+ const newContent = oldContent.replace(oldVersionRE, newVersionReplacement);
+ if (oldContent !== newContent) {
+ grunt.log.writeln(`updating ${filename} to ${options.newVersionStr}`);
+ fs.writeFileSync(filename, newContent);
+ }
+ });
+ });
+ });
+
+ grunt.registerTask('bumpthree', function() {
+ const lessonInfo = JSON.parse(fs.readFileSync('package.json', {encoding: 'utf8'}));
+ const oldVersion = lessonInfo.threejsfundamentals.threeVersion;
+ const oldVersionStr = `r${oldVersion}`;
+ const threePath = path.join(__dirname, '..', 'three.js');
+ const threeInfo = JSON.parse(fs.readFileSync(path.join(threePath, 'package.json'), {encoding: 'utf8'}));
+ const newVersion = semver.minor(threeInfo.version);
+ const newVersionStr = `r${newVersion}`;
+ const basePath = path.join('threejs', 'resources', 'threejs', newVersionStr);
+ grunt.config.merge({
+ copy: {
+ threejs: {
+ files: [
+ { expand: true, cwd: `${threePath}/build/`, src: 'three.js', dest: `${basePath}/`, },
+ { expand: true, cwd: `${threePath}/build/`, src: 'three.min.js', dest: `${basePath}/`, },
+ { expand: true, cwd: `${threePath}/examples/js/`, src: '**', dest: `${basePath}/js/`, },
+ ],
+ },
+ },
+ fixthreepaths: {
+ options: {
+ oldVersionStr,
+ newVersionStr,
+ },
+ src: [
+ 'threejs/**/*.html',
+ 'threejs/**/*.md',
+ 'threejs/**/*.js',
+ '!threejs/resources/threejs/**',
+ ],
+ },
+ });
+
+ lessonInfo.threejsfundamentals.threeVersion = newVersion;
+ fs.writeFileSync('package.json', JSON.stringify(lessonInfo, null, 2));
+ grunt.task.run(['copy:threejs', 'fixthreepaths']);
+ });
+
+ grunt.registerTask('build', ['clean', 'copy:main', 'buildlessons']);
grunt.registerTask('default', ['eslint', 'build']);
}; | false |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/lessons/threejs-lights.md | @@ -156,7 +156,7 @@ And here's our code setting up dat.GUI
```javascript
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
-gui.add(light, 'intensity', 0, 2);
+gui.add(light, 'intensity', 0, 2, 0.01);
```
And here's the result
@@ -204,7 +204,7 @@ const gui = new dat.GUI();
-gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
+gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('skyColor');
+gui.addColor(new ColorGUIHelper(light, 'groundColor'), 'value').name('groundColor');
-gui.add(light, 'intensity', 0, 2);
+gui.add(light, 'intensity', 0, 2, 0.01);
```
The result:
@@ -242,7 +242,7 @@ our GUI.
```javascript
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
-gui.add(light, 'intensity', 0, 2);
+gui.add(light, 'intensity', 0, 2, 0.01);
gui.add(light.target.position, 'x', -10, 10);
gui.add(light.target.position, 'z', -10, 10);
gui.add(light.target.position, 'y', 0, 10);
@@ -294,7 +294,7 @@ and the target's position like this
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
-gui.add(light, 'intensity', 0, 2);
+gui.add(light, 'intensity', 0, 2, 0.01);
+makeXYZGUI(gui, light.position, 'position', updateLight);
+makeXYZGUI(gui, light.target.position, 'target', updateLight);
@@ -359,7 +359,7 @@ Let's setup the GUI so we can adjust the distance.
```javascript
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
-gui.add(light, 'intensity', 0, 2);
+gui.add(light, 'intensity', 0, 2, 0.01);
+gui.add(light, 'distance', 0, 40).onChange(updateLight);
makeXYZGUI(gui, light.position, 'position', updateLight);
@@ -416,7 +416,7 @@ outer cone. When `penumbra` is .5 then the light fades starting from 50% between
the center of the outer cone.
```javascript
-gui.add(light, 'penumbra', 0, 1);
+gui.add(light, 'penumbra', 0, 1, 0.01);
```
{{{example url="../threejs-lights-spot-w-helper.html" }}}
@@ -507,7 +507,7 @@ its `width` and `height`
```javascript
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
-gui.add(light, 'intensity', 0, 10);
+gui.add(light, 'intensity', 0, 10, 0.01);
gui.add(light, 'width', 0, 20).onChange(updateLight);
gui.add(light, 'height', 0, 20).onChange(updateLight);
gui.add(new DegRadHelper(light.rotation, 'x'), 'value', -180, 180).name('x rotation').onChange(updateLight);
@@ -558,7 +558,7 @@ and we'll add gui so we can change the `power` and `decay`
```javascript
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
-gui.add(light, 'decay', 0, 4);
+gui.add(light, 'decay', 0, 4, 0.01);
gui.add(light, 'power', 0, 2000);
```
| true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-ambient.html | @@ -106,7 +106,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'intensity', 0, 2);
+ gui.add(light, 'intensity', 0, 2, 0.01);
}
function resizeRendererToDisplaySize(renderer) { | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-directional-w-helper.html | @@ -126,7 +126,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'intensity', 0, 2);
+ gui.add(light, 'intensity', 0, 2, 0.01);
makeXYZGUI(gui, light.position, 'position', updateLight);
makeXYZGUI(gui, light.target.position, 'target', updateLight); | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-directional.html | @@ -109,7 +109,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'intensity', 0, 2);
+ gui.add(light, 'intensity', 0, 2, 0.01);
gui.add(light.target.position, 'x', -10, 10);
gui.add(light.target.position, 'z', -10, 10);
gui.add(light.target.position, 'y', 0, 10); | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-hemisphere.html | @@ -109,7 +109,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('skyColor');
gui.addColor(new ColorGUIHelper(light, 'groundColor'), 'value').name('groundColor');
- gui.add(light, 'intensity', 0, 2);
+ gui.add(light, 'intensity', 0, 2, 0.01);
}
function resizeRendererToDisplaySize(renderer) { | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-point-physically-correct.html | @@ -122,7 +122,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'decay', 0, 4);
+ gui.add(light, 'decay', 0, 4, 0.01);
gui.add(light, 'power', 0, 1220);
makeXYZGUI(gui, light.position, 'position'); | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-point.html | @@ -122,7 +122,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'intensity', 0, 2);
+ gui.add(light, 'intensity', 0, 2, 0.01);
gui.add(light, 'distance', 0, 40).onChange(updateLight);
makeXYZGUI(gui, light.position, 'position'); | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-rectarea.html | @@ -139,7 +139,7 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'intensity', 0, 10);
+ gui.add(light, 'intensity', 0, 10, 0.01);
gui.add(light, 'width', 0, 20).onChange(updateLight);
gui.add(light, 'height', 0, 20).onChange(updateLight);
gui.add(new DegRadHelper(light.rotation, 'x'), 'value', -180, 180).name('x rotation').onChange(updateLight); | true |
Other | mrdoob | three.js | e145b6f4f84852c947173d52fe6cf46b3dd75342.json | fix intensity gui | threejs/threejs-lights-spot-w-helper.html | @@ -139,10 +139,10 @@
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
- gui.add(light, 'intensity', 0, 2);
+ gui.add(light, 'intensity', 0, 2, 0.01);
gui.add(light, 'distance', 0, 40).onChange(updateLight);
gui.add(new DegRadHelper(light, 'angle'), 'value', 0, 90).name('angle').onChange(updateLight);
- gui.add(light, 'penumbra', 0, 1);
+ gui.add(light, 'penumbra', 0, 1, 0.01);
makeXYZGUI(gui, light.position, 'position', updateLight);
makeXYZGUI(gui, light.target.position, 'target', updateLight); | true |
Other | mrdoob | three.js | d0665689979805ab3e0e15572f3e5e0d231ceb48.json | change onChange to updateLight | threejs/lessons/threejs-lights.md | @@ -286,18 +286,18 @@ Then we can use that for both the light's position
and the target's position like this
```javascript
-+const onChange = () => {
++function updateLight{
+ light.target.updateMatrixWorld();
+ helper.update();
-+};
-+onChange();
++}
++updateLight();
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
gui.add(light, 'intensity', 0, 2);
-+makeXYZGUI(gui, light.position, 'position', onChange);
-+makeXYZGUI(gui, light.target.position, 'target', onChange);
++makeXYZGUI(gui, light.position, 'position', updateLight);
++makeXYZGUI(gui, light.target.position, 'target', updateLight);
```
Now we can move the light, and its target
@@ -337,12 +337,11 @@ scene.add(helper);
and as there is no target the `onChange` function can be simpler.
```javascript
--const onChange = () => {
+function updateLight{
- light.target.updateMatrixWorld();
-- helper.update();
--};
--onChange();
-+const onChange = helper.update.bind(helper);
+ helper.update();
+}
+-updateLight();
```
Note that at some level a `PointLightHelper` has no um, point.
@@ -361,10 +360,10 @@ Let's setup the GUI so we can adjust the distance.
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
gui.add(light, 'intensity', 0, 2);
-+gui.add(light, 'distance', 0, 40).onChange(onChange);
++gui.add(light, 'distance', 0, 40).onChange(updateLight);
-makeXYZGUI(gui, light.position, 'position', onChange);
--makeXYZGUI(gui, light.target.position, 'target', onChange);
+makeXYZGUI(gui, light.position, 'position', updateLight);
+-makeXYZGUI(gui, light.target.position, 'target', updateLight);
```
And now try it out.
@@ -406,7 +405,7 @@ property in radians. We'll use our `DegRadHelper` from the
degrees.
```javascript
-gui.add(new DegRadHelper(light, 'angle'), 'value', 0, 90).name('angle').onChange(onChange);
+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
@@ -509,13 +508,13 @@ its `width` and `height`
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
gui.add(light, 'intensity', 0, 10);
-gui.add(light, 'width', 0, 20).onChange(onChange);
-gui.add(light, 'height', 0, 20).onChange(onChange);
-gui.add(new DegRadHelper(light.rotation, 'x'), 'value', -180, 180).name('x rotation').onChange(onChange);
-gui.add(new DegRadHelper(light.rotation, 'y'), 'value', -180, 180).name('y rotation').onChange(onChange);
-gui.add(new DegRadHelper(light.rotation, 'z'), 'value', -180, 180).name('z rotation').onChange(onChange);
+gui.add(light, 'width', 0, 20).onChange(updateLight);
+gui.add(light, 'height', 0, 20).onChange(updateLight);
+gui.add(new DegRadHelper(light.rotation, 'x'), 'value', -180, 180).name('x rotation').onChange(updateLight);
+gui.add(new DegRadHelper(light.rotation, 'y'), 'value', -180, 180).name('y rotation').onChange(updateLight);
+gui.add(new DegRadHelper(light.rotation, 'z'), 'value', -180, 180).name('z rotation').onChange(updateLight);
-makeXYZGUI(gui, light.position, 'position', onChange);
+makeXYZGUI(gui, light.position, 'position', updateLight);
```
And here is that. | true |
Other | mrdoob | three.js | d0665689979805ab3e0e15572f3e5e0d231ceb48.json | change onChange to updateLight | threejs/threejs-lights-directional-w-helper.html | @@ -118,18 +118,18 @@
const helper = new THREE.DirectionalLightHelper(light);
scene.add(helper);
- const onChange = () => {
+ function updateLight() {
light.target.updateMatrixWorld();
helper.update();
- };
- onChange();
+ }
+ updateLight();
const gui = new dat.GUI();
gui.addColor(new ColorGUIHelper(light, 'color'), 'value').name('color');
gui.add(light, 'intensity', 0, 2);
- makeXYZGUI(gui, light.position, 'position', onChange);
- makeXYZGUI(gui, light.target.position, 'target', onChange);
+ makeXYZGUI(gui, light.position, 'position', updateLight);
+ makeXYZGUI(gui, light.target.position, 'target', updateLight);
}
function resizeRendererToDisplaySize(renderer) { | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.