Browse Source

Manual: Fix remaining RGBFormat issues. (#23390)

Michael Herzog 3 years ago
parent
commit
f31cb9ec8b

+ 31 - 29
manual/en/indexed-textures.html

@@ -40,10 +40,10 @@ displayed country names around a 3d globe. How would we go about letting
 the user select a country and show their selection?</p>
 the user select a country and show their selection?</p>
 <p>The first idea that comes to mind is to generate geometry for each country.
 <p>The first idea that comes to mind is to generate geometry for each country.
 We could <a href="picking.html">use a picking solution</a> like we covered before.
 We could <a href="picking.html">use a picking solution</a> like we covered before.
-We'd build 3D geometry for each country. If the user clicks on the mesh for 
+We'd build 3D geometry for each country. If the user clicks on the mesh for
 that country we'd know what country was clicked.</p>
 that country we'd know what country was clicked.</p>
 <p>So, just to check that solution I tried generating 3D meshes of all the countries
 <p>So, just to check that solution I tried generating 3D meshes of all the countries
-using the same data I used to generate the outlines 
+using the same data I used to generate the outlines
 <a href="align-html-elements-to-3d.html">in the previous article</a>.
 <a href="align-html-elements-to-3d.html">in the previous article</a>.
 The result was a 15.5meg binary GLTF (.glb) file. Making the user download 15.5meg
 The result was a 15.5meg binary GLTF (.glb) file. Making the user download 15.5meg
 sounds like too much to me.</p>
 sounds like too much to me.</p>
@@ -53,11 +53,11 @@ any time pursuing that solution. For borders of the USA that's probably a huge
 win. For a borders of Canada probably much less. </p>
 win. For a borders of Canada probably much less. </p>
 <p>Another solution would be to use just actual data compression. For example gzipping
 <p>Another solution would be to use just actual data compression. For example gzipping
 the file brought it down to 11meg. That's 30% less but arguably not enough.</p>
 the file brought it down to 11meg. That's 30% less but arguably not enough.</p>
-<p>We could store all the data as 16bit ranged values instead of 32bit float values. 
+<p>We could store all the data as 16bit ranged values instead of 32bit float values.
 Or we could use something like <a href="https://google.github.io/draco/">draco compression</a>
 Or we could use something like <a href="https://google.github.io/draco/">draco compression</a>
-and maybe that would be enough. I didn't check and I would encourage you to check 
+and maybe that would be enough. I didn't check and I would encourage you to check
 yourself and tell me how it goes as I'd love to know. ๐Ÿ˜…</p>
 yourself and tell me how it goes as I'd love to know. ๐Ÿ˜…</p>
-<p>In my case I thought about <a href="picking.html">the GPU picking solution</a> 
+<p>In my case I thought about <a href="picking.html">the GPU picking solution</a>
 we covered at the end of <a href="picking.html">the article on picking</a>. In
 we covered at the end of <a href="picking.html">the article on picking</a>. In
 that solution we drew every mesh with a unique color that represented that
 that solution we drew every mesh with a unique color that represented that
 mesh's id. We then drew all the meshes and looked at the color that was clicked
 mesh's id. We then drew all the meshes and looked at the color that was clicked
@@ -65,13 +65,13 @@ on.</p>
 <p>Taking inspiration from that we could pre-generate a map of countries where
 <p>Taking inspiration from that we could pre-generate a map of countries where
 each country's color is its index number in our array of countries. We could
 each country's color is its index number in our array of countries. We could
 then use a similar GPU picking technique. We'd draw the globe off screen using
 then use a similar GPU picking technique. We'd draw the globe off screen using
-this index texture. Looking at the color of the pixel the user clicks would 
+this index texture. Looking at the color of the pixel the user clicks would
 tell us the country id.</p>
 tell us the country id.</p>
-<p>So, I <a href="https://github.com/mrdoob/three.js/blob/master/manual/resources/tools/geo-picking/">wrote some code</a> 
+<p>So, I <a href="https://github.com/mrdoob/three.js/blob/master/manual/resources/tools/geo-picking/">wrote some code</a>
 to generate such a texture. Here it is. </p>
 to generate such a texture. Here it is. </p>
 <div class="threejs_center"><img src="../examples/resources/data/world/country-index-texture.png" style="width: 700px;"></div>
 <div class="threejs_center"><img src="../examples/resources/data/world/country-index-texture.png" style="width: 700px;"></div>
 
 
-<p>Note: The data used to generate this texture comes from <a href="http://thematicmapping.org/downloads/world_borders.php">this website</a> 
+<p>Note: The data used to generate this texture comes from <a href="http://thematicmapping.org/downloads/world_borders.php">this website</a>
 and is therefore licensed as <a href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>.</p>
 and is therefore licensed as <a href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>.</p>
 <p>It's only 217k, much better than the 14meg for the country meshes. In fact we could probably
 <p>It's only 217k, much better than the 14meg for the country meshes. In fact we could probably
 even lower the resolution but 217k seems good enough for now.</p>
 even lower the resolution but 217k seems good enough for now.</p>
@@ -244,14 +244,14 @@ let's just update the labels.</p>
 <p></p>
 <p></p>
 <p>The code stills shows countries based on their area but if you
 <p>The code stills shows countries based on their area but if you
 click one just that one will have a label.</p>
 click one just that one will have a label.</p>
-<p>So that seems like a reasonable solution for picking countries 
+<p>So that seems like a reasonable solution for picking countries
 but what about highlighting the selected countries?</p>
 but what about highlighting the selected countries?</p>
 <p>For that we can take inspiration from <em>paletted graphics</em>.</p>
 <p>For that we can take inspiration from <em>paletted graphics</em>.</p>
 <p><a href="https://en.wikipedia.org/wiki/Palette_%28computing%29">Paletted graphics</a>
 <p><a href="https://en.wikipedia.org/wiki/Palette_%28computing%29">Paletted graphics</a>
-or <a href="https://en.wikipedia.org/wiki/Indexed_color">Indexed Color</a> is 
-what older systems like the Atari 800, Amiga, NES, 
+or <a href="https://en.wikipedia.org/wiki/Indexed_color">Indexed Color</a> is
+what older systems like the Atari 800, Amiga, NES,
 Super Nintendo, and even older IBM PCs used. Instead of storing bitmaps
 Super Nintendo, and even older IBM PCs used. Instead of storing bitmaps
-as RGB colors 8bits per color, 24 bytes per pixel or more, they stored 
+as RGBA colors 8bits per color, 32 bytes per pixel or more, they stored
 bitmaps as 8bit values or less. The value for each pixel was an index
 bitmaps as 8bit values or less. The value for each pixel was an index
 into a palette. So for example a value
 into a palette. So for example a value
 of 3 in the image means "display color 3". What color color#3 is is
 of 3 in the image means "display color 3". What color color#3 is is
@@ -259,7 +259,7 @@ defined somewhere else called a "palette".</p>
 <p>In JavaScript you can think of it like this</p>
 <p>In JavaScript you can think of it like this</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const face7x7PixelImageData = [
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const face7x7PixelImageData = [
   0, 1, 1, 1, 1, 1, 0,
   0, 1, 1, 1, 1, 1, 0,
-  1, 0, 0, 0, 0, 0, 1, 
+  1, 0, 0, 0, 0, 0, 1,
   1, 0, 2, 0, 2, 0, 1,
   1, 0, 2, 0, 2, 0, 1,
   1, 0, 0, 0, 0, 0, 1,
   1, 0, 0, 0, 0, 0, 1,
   1, 0, 3, 3, 3, 0, 1,
   1, 0, 3, 3, 3, 0, 1,
@@ -284,8 +284,8 @@ texture to give each country its own color. By changing the palette
 texture we can color each individual country. For example by setting
 texture we can color each individual country. For example by setting
 the entire palette texture to black and then for one country's entry
 the entire palette texture to black and then for one country's entry
 in the palette a different color, we can highlight just that country.</p>
 in the palette a different color, we can highlight just that country.</p>
-<p>To do paletted index graphics requires some custom shader code. 
-Let's modify the default shaders in three.js. 
+<p>To do paletted index graphics requires some custom shader code.
+Let's modify the default shaders in three.js.
 That way we can use lighting and other features if we want.</p>
 That way we can use lighting and other features if we want.</p>
 <p>Like we covered in <a href="optimize-lots-of-objects-animated.html">the article on animating lots of objects</a>
 <p>Like we covered in <a href="optimize-lots-of-objects-animated.html">the article on animating lots of objects</a>
 we can modify the default shaders by adding a function to a material's
 we can modify the default shaders by adding a function to a material's
@@ -331,14 +331,14 @@ void main() {
 }
 }
 </pre>
 </pre>
 <p><a href="https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderChunk">Digging through all those snippets</a>
 <p><a href="https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderChunk">Digging through all those snippets</a>
-we find that three.js uses a variable called <code class="notranslate" translate="no">diffuseColor</code> to manage the 
+we find that three.js uses a variable called <code class="notranslate" translate="no">diffuseColor</code> to manage the
 base material color. It sets this in the <code class="notranslate" translate="no">&lt;color_fragment&gt;</code> <a href="https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js">snippet</a>
 base material color. It sets this in the <code class="notranslate" translate="no">&lt;color_fragment&gt;</code> <a href="https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js">snippet</a>
 so we should be able to modify it after that point.</p>
 so we should be able to modify it after that point.</p>
-<p><code class="notranslate" translate="no">diffuseColor</code> at that point in the shader should already be the color from 
-our outline texture so we can look up the color from a palette texture 
+<p><code class="notranslate" translate="no">diffuseColor</code> at that point in the shader should already be the color from
+our outline texture so we can look up the color from a palette texture
 and mix them for the final result.</p>
 and mix them for the final result.</p>
 <p>Like we <a href="optimize-lots-of-objects-animated.html">did before</a> we'll make an array
 <p>Like we <a href="optimize-lots-of-objects-animated.html">did before</a> we'll make an array
-of search and replacement strings and apply them to the shader in 
+of search and replacement strings and apply them to the shader in
 <a href="/docs/#api/en/materials/Material.onBeforeCompile"><code class="notranslate" translate="no">Material.onBeforeCompile</code></a>.</p>
 <a href="/docs/#api/en/materials/Material.onBeforeCompile"><code class="notranslate" translate="no">Material.onBeforeCompile</code></a>.</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">{
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">{
   const loader = new THREE.TextureLoader();
   const loader = new THREE.TextureLoader();
@@ -389,7 +389,7 @@ of search and replacement strings and apply them to the shader in
 </pre>
 </pre>
 <p>Above can see above we add 3 uniforms, <code class="notranslate" translate="no">indexTexture</code>, <code class="notranslate" translate="no">paletteTexture</code>,
 <p>Above can see above we add 3 uniforms, <code class="notranslate" translate="no">indexTexture</code>, <code class="notranslate" translate="no">paletteTexture</code>,
 and <code class="notranslate" translate="no">paletteTextureWidth</code>. We get a color from the <code class="notranslate" translate="no">indexTexture</code>
 and <code class="notranslate" translate="no">paletteTextureWidth</code>. We get a color from the <code class="notranslate" translate="no">indexTexture</code>
-and convert it to an index. <code class="notranslate" translate="no">vUv</code> is the texture coordinates provided by 
+and convert it to an index. <code class="notranslate" translate="no">vUv</code> is the texture coordinates provided by
 three.js. We then use that index to get a color out of the palette texture.
 three.js. We then use that index to get a color out of the palette texture.
 We then mix the result with the current <code class="notranslate" translate="no">diffuseColor</code>. The <code class="notranslate" translate="no">diffuseColor</code>
 We then mix the result with the current <code class="notranslate" translate="no">diffuseColor</code>. The <code class="notranslate" translate="no">diffuseColor</code>
 at this point is our black and white outline texture so if we add the 2 colors
 at this point is our black and white outline texture so if we add the 2 colors
@@ -407,21 +407,21 @@ let's choose 512.</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const maxNumCountries = 512;
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const maxNumCountries = 512;
 const paletteTextureWidth = maxNumCountries;
 const paletteTextureWidth = maxNumCountries;
 const paletteTextureHeight = 1;
 const paletteTextureHeight = 1;
-const palette = new Uint8Array(paletteTextureWidth * 3);
+const palette = new Uint8Array(paletteTextureWidth * 4);
 const paletteTexture = new THREE.DataTexture(
 const paletteTexture = new THREE.DataTexture(
-    palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+    palette, paletteTextureWidth, paletteTextureHeight);
 paletteTexture.minFilter = THREE.NearestFilter;
 paletteTexture.minFilter = THREE.NearestFilter;
 paletteTexture.magFilter = THREE.NearestFilter;
 paletteTexture.magFilter = THREE.NearestFilter;
 </pre>
 </pre>
 <p>A <a href="/docs/#api/en/textures/DataTexture"><code class="notranslate" translate="no">DataTexture</code></a> let's us give a texture raw data. In this case
 <p>A <a href="/docs/#api/en/textures/DataTexture"><code class="notranslate" translate="no">DataTexture</code></a> let's us give a texture raw data. In this case
-we're giving it 512 RGB colors, 3 bytes each where each byte is
+we're giving it 512 RGBA colors, 4 bytes each where each byte is
 red, green, and blue respectively using values that go from 0 to 255.</p>
 red, green, and blue respectively using values that go from 0 to 255.</p>
 <p>Let's fill it with random colors just to see it work</p>
 <p>Let's fill it with random colors just to see it work</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">for (let i = 1; i &lt; palette.length; ++i) {
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">for (let i = 1; i &lt; palette.length; ++i) {
   palette[i] = Math.random() * 256;
   palette[i] = Math.random() * 256;
 }
 }
 // set the ocean color (index #0)
 // set the ocean color (index #0)
-palette.set([100, 200, 255], 0);
+palette.set([100, 200, 255, 255], 0);
 paletteTexture.needsUpdate = true;
 paletteTexture.needsUpdate = true;
 </pre>
 </pre>
 <p>Anytime we want three.js to update the palette texture with
 <p>Anytime we want three.js to update the palette texture with
@@ -454,11 +454,13 @@ style color and give us values we can put in the palette texture.</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const tempColor = new THREE.Color();
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const tempColor = new THREE.Color();
 function get255BasedColor(color) {
 function get255BasedColor(color) {
   tempColor.set(color);
   tempColor.set(color);
-  return tempColor.toArray().map(v =&gt; v * 255);
+  const base = tempColor.toArray().map(v =&gt; v * 255);
+  base.push(255); // alpha
+  return base;
 }
 }
 </pre>
 </pre>
 <p>Calling it like this <code class="notranslate" translate="no">color = get255BasedColor('red')</code> will
 <p>Calling it like this <code class="notranslate" translate="no">color = get255BasedColor('red')</code> will
-return an array like <code class="notranslate" translate="no">[255, 0, 0]</code>.</p>
+return an array like <code class="notranslate" translate="no">[255, 0, 0, 255]</code>.</p>
 <p>Next let's use it to make a few colors and fill out the
 <p>Next let's use it to make a few colors and fill out the
 palette.</p>
 palette.</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const selectedColor = get255BasedColor('red');
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const selectedColor = get255BasedColor('red');
@@ -467,7 +469,7 @@ const oceanColor = get255BasedColor('rgb(100,200,255)');
 resetPalette();
 resetPalette();
 
 
 function setPaletteColor(index, color) {
 function setPaletteColor(index, color) {
-  palette.set(color, index * 3);
+  palette.set(color, index * 4);
 }
 }
 
 
 function resetPalette() {
 function resetPalette() {
@@ -628,11 +630,11 @@ this article. There are a few links to some info in
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
-  
+
   <script src="/manual/resources/prettify.js"></script>
   <script src="/manual/resources/prettify.js"></script>
   <script src="/manual/resources/lesson.js"></script>
   <script src="/manual/resources/lesson.js"></script>
 
 
 
 
 
 
 
 
-</body></html>
+</body></html>

+ 7 - 6
manual/examples/indexed-textures-picking-and-highlighting.html

@@ -99,17 +99,19 @@ function main() {
   pickingScene.background = new THREE.Color(0);
   pickingScene.background = new THREE.Color(0);
 
 
   const tempColor = new THREE.Color();
   const tempColor = new THREE.Color();
-  function get255BasedColor(color) {
+	function get255BasedColor(color) {
     tempColor.set(color);
     tempColor.set(color);
-    return tempColor.toArray().map(v => v * 255);
+    const base = tempColor.toArray().map(v => v * 255);
+    base.push(255); // alpha
+    return base;
   }
   }
 
 
   const maxNumCountries = 512;
   const maxNumCountries = 512;
   const paletteTextureWidth = maxNumCountries;
   const paletteTextureWidth = maxNumCountries;
   const paletteTextureHeight = 1;
   const paletteTextureHeight = 1;
-  const palette = new Uint8Array(paletteTextureWidth * 3);
+  const palette = new Uint8Array(paletteTextureWidth * 4);
   const paletteTexture = new THREE.DataTexture(
   const paletteTexture = new THREE.DataTexture(
-      palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+      palette, paletteTextureWidth, paletteTextureHeight);
   paletteTexture.minFilter = THREE.NearestFilter;
   paletteTexture.minFilter = THREE.NearestFilter;
   paletteTexture.magFilter = THREE.NearestFilter;
   paletteTexture.magFilter = THREE.NearestFilter;
 
 
@@ -119,7 +121,7 @@ function main() {
   resetPalette();
   resetPalette();
 
 
   function setPaletteColor(index, color) {
   function setPaletteColor(index, color) {
-    palette.set(color, index * 3);
+    palette.set(color, index * 4);
   }
   }
 
 
   function resetPalette() {
   function resetPalette() {
@@ -441,4 +443,3 @@ function main() {
 main();
 main();
 </script>
 </script>
 </html>
 </html>
-

+ 6 - 6
manual/examples/indexed-textures-picking-debounced.html

@@ -102,15 +102,16 @@ function main() {
   const tempColor = new THREE.Color();
   const tempColor = new THREE.Color();
   function get255BasedColor(color) {
   function get255BasedColor(color) {
     tempColor.set(color);
     tempColor.set(color);
-    return tempColor.toArray().map(v => v * 255);
+    const base = tempColor.toArray().map(v => v * 255);
+    base.push(255); // alpha
+    return base;
   }
   }
 
 
   const maxNumCountries = 512;
   const maxNumCountries = 512;
   const paletteTextureWidth = maxNumCountries;
   const paletteTextureWidth = maxNumCountries;
   const paletteTextureHeight = 1;
   const paletteTextureHeight = 1;
-  const palette = new Uint8Array(paletteTextureWidth * 3);
-  const paletteTexture = new THREE.DataTexture(
-      palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+  const palette = new Uint8Array(paletteTextureWidth * 4);
+  const paletteTexture = new THREE.DataTexture(palette, paletteTextureWidth, paletteTextureHeight);
   paletteTexture.minFilter = THREE.NearestFilter;
   paletteTexture.minFilter = THREE.NearestFilter;
   paletteTexture.magFilter = THREE.NearestFilter;
   paletteTexture.magFilter = THREE.NearestFilter;
 
 
@@ -120,7 +121,7 @@ function main() {
   resetPalette();
   resetPalette();
 
 
   function setPaletteColor(index, color) {
   function setPaletteColor(index, color) {
-    palette.set(color, index * 3);
+    palette.set(color, index * 4);
   }
   }
 
 
   function resetPalette() {
   function resetPalette() {
@@ -469,4 +470,3 @@ function main() {
 main();
 main();
 </script>
 </script>
 </html>
 </html>
-

+ 3 - 5
manual/examples/indexed-textures-random-colors.html

@@ -101,16 +101,15 @@ function main() {
   const maxNumCountries = 512;
   const maxNumCountries = 512;
   const paletteTextureWidth = maxNumCountries;
   const paletteTextureWidth = maxNumCountries;
   const paletteTextureHeight = 1;
   const paletteTextureHeight = 1;
-  const palette = new Uint8Array(paletteTextureWidth * 3);
-  const paletteTexture = new THREE.DataTexture(
-      palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+  const palette = new Uint8Array(paletteTextureWidth * 4);
+  const paletteTexture = new THREE.DataTexture(palette, paletteTextureWidth, paletteTextureHeight);
   paletteTexture.minFilter = THREE.NearestFilter;
   paletteTexture.minFilter = THREE.NearestFilter;
   paletteTexture.magFilter = THREE.NearestFilter;
   paletteTexture.magFilter = THREE.NearestFilter;
   for (let i = 1; i < palette.length; ++i) {
   for (let i = 1; i < palette.length; ++i) {
     palette[i] = Math.random() * 256;
     palette[i] = Math.random() * 256;
   }
   }
   // set the ocean color (index #0)
   // set the ocean color (index #0)
-  palette.set([100, 200, 255], 0);
+  palette.set([100, 200, 255, 255], 0);
   paletteTexture.needsUpdate = true;
   paletteTexture.needsUpdate = true;
 
 
   {
   {
@@ -418,4 +417,3 @@ function main() {
 main();
 main();
 </script>
 </script>
 </html>
 </html>
-

+ 12 - 10
manual/ja/indexed-textures.html

@@ -235,14 +235,14 @@ canvas.addEventListener('pointerup', pickCountry);
 <p>ๅ›ฝใ‚’้ธๆŠžใ™ใ‚‹ๅˆ็†็š„ใช่งฃๆฑบ็ญ–ใฎใ‚ˆใ†ใซๆ€ใˆใพใ™ใŒใ€้ธๆŠžใ•ใ‚ŒใŸๅ›ฝใ‚’ๅผท่ชฟ่กจ็คบใ™ใ‚‹ใซใฏใฉใ†ใงใ—ใ‚‡ใ†ใ‹๏ผŸ</p>
 <p>ๅ›ฝใ‚’้ธๆŠžใ™ใ‚‹ๅˆ็†็š„ใช่งฃๆฑบ็ญ–ใฎใ‚ˆใ†ใซๆ€ใˆใพใ™ใŒใ€้ธๆŠžใ•ใ‚ŒใŸๅ›ฝใ‚’ๅผท่ชฟ่กจ็คบใ™ใ‚‹ใซใฏใฉใ†ใงใ—ใ‚‡ใ†ใ‹๏ผŸ</p>
 <p><em>ใƒ‘ใƒฌใƒƒใƒˆใ‚ฐใƒฉใƒ•ใ‚ฃใƒƒใ‚ฏใ‚น</em> ใ‹ใ‚‰ใ‚คใƒณใ‚นใƒ”ใƒฌใƒผใ‚ทใƒงใƒณใ‚’ๅพ—ใ‚‹ไบ‹ใŒใงใใพใ™ใ€‚</p>
 <p><em>ใƒ‘ใƒฌใƒƒใƒˆใ‚ฐใƒฉใƒ•ใ‚ฃใƒƒใ‚ฏใ‚น</em> ใ‹ใ‚‰ใ‚คใƒณใ‚นใƒ”ใƒฌใƒผใ‚ทใƒงใƒณใ‚’ๅพ—ใ‚‹ไบ‹ใŒใงใใพใ™ใ€‚</p>
 <p><a href="https://en.wikipedia.org/wiki/Palette_%28computing%29">ใƒ‘ใƒฌใƒƒใƒˆใ‚ฐใƒฉใƒ•ใ‚ฃใƒƒใ‚ฏใ‚น</a>ใ‚„<a href="https://en.wikipedia.org/wiki/Indexed_color">ใ‚คใƒณใƒ‡ใƒƒใ‚ฏใ‚นใ‚ซใƒฉใƒผ</a>ใฏAtari 800ใ€Amigaใ€ใƒ•ใ‚กใƒŸใ‚ณใƒณใ€ใ‚นใƒผใƒ‘ใƒผใƒ•ใ‚กใƒŸใ‚ณใƒณใ€IBMใฎๅคใ„PCใชใฉใฎๅคใ„ใ‚ทใ‚นใƒ†ใƒ ใงไฝฟใ‚ใ‚Œใฆใ„ใพใ—ใŸใ€‚
 <p><a href="https://en.wikipedia.org/wiki/Palette_%28computing%29">ใƒ‘ใƒฌใƒƒใƒˆใ‚ฐใƒฉใƒ•ใ‚ฃใƒƒใ‚ฏใ‚น</a>ใ‚„<a href="https://en.wikipedia.org/wiki/Indexed_color">ใ‚คใƒณใƒ‡ใƒƒใ‚ฏใ‚นใ‚ซใƒฉใƒผ</a>ใฏAtari 800ใ€Amigaใ€ใƒ•ใ‚กใƒŸใ‚ณใƒณใ€ใ‚นใƒผใƒ‘ใƒผใƒ•ใ‚กใƒŸใ‚ณใƒณใ€IBMใฎๅคใ„PCใชใฉใฎๅคใ„ใ‚ทใ‚นใƒ†ใƒ ใงไฝฟใ‚ใ‚Œใฆใ„ใพใ—ใŸใ€‚
-ใƒ“ใƒƒใƒˆใƒžใƒƒใƒ—ใ‚’RGBใ‚ซใƒฉใƒผ8ใƒ“ใƒƒใƒˆใ€1ใƒ”ใ‚ฏใ‚ปใƒซ24ใƒใ‚คใƒˆไปฅไธŠใงๆ ผ็ดใ™ใ‚‹ใฎใงใฏใชใใ€ใƒ“ใƒƒใƒˆใƒžใƒƒใƒ—ใ‚’8ใƒ“ใƒƒใƒˆไปฅไธ‹ใฎๅ€คใงๆ ผ็ดใ—ใฆใ„ใพใ—ใŸใ€‚
+ใƒ“ใƒƒใƒˆใƒžใƒƒใƒ—ใ‚’RGBAใ‚ซใƒฉใƒผ8ใƒ“ใƒƒใƒˆใ€1ใƒ”ใ‚ฏใ‚ปใƒซ32ใƒใ‚คใƒˆไปฅไธŠใงๆ ผ็ดใ™ใ‚‹ใฎใงใฏใชใใ€ใƒ“ใƒƒใƒˆใƒžใƒƒใƒ—ใ‚’8ใƒ“ใƒƒใƒˆไปฅไธ‹ใฎๅ€คใงๆ ผ็ดใ—ใฆใ„ใพใ—ใŸใ€‚
 ๅ„ใƒ”ใ‚ฏใ‚ปใƒซใฎๅ€คใฏใƒ‘ใƒฌใƒƒใƒˆใธใฎใ‚คใƒณใƒ‡ใƒƒใ‚ฏใ‚นใงใ™ใ€‚
 ๅ„ใƒ”ใ‚ฏใ‚ปใƒซใฎๅ€คใฏใƒ‘ใƒฌใƒƒใƒˆใธใฎใ‚คใƒณใƒ‡ใƒƒใ‚ฏใ‚นใงใ™ใ€‚
 ใใฎใŸใ‚ไพ‹ใˆใฐ็”ปๅƒๅ†…ใฎๅ€คใŒ3ใงใ‚ใ‚Œใฐ "color 3ใ‚’่กจ็คบใ™ใ‚‹" ใจใ„ใ†ไบ‹ใซใชใ‚Šใพใ™ใ€‚
 ใใฎใŸใ‚ไพ‹ใˆใฐ็”ปๅƒๅ†…ใฎๅ€คใŒ3ใงใ‚ใ‚Œใฐ "color 3ใ‚’่กจ็คบใ™ใ‚‹" ใจใ„ใ†ไบ‹ใซใชใ‚Šใพใ™ใ€‚
 color 3ใŒไฝ•่‰ฒใ‹ใฏ "ใƒ‘ใƒฌใƒƒใƒˆ" ใจๅ‘ผใฐใ‚Œใ‚‹ๅˆฅใฎๅ ดๆ‰€ใงๅฎš็พฉใ•ใ‚Œใฆใ„ใพใ™ใ€‚</p>
 color 3ใŒไฝ•่‰ฒใ‹ใฏ "ใƒ‘ใƒฌใƒƒใƒˆ" ใจๅ‘ผใฐใ‚Œใ‚‹ๅˆฅใฎๅ ดๆ‰€ใงๅฎš็พฉใ•ใ‚Œใฆใ„ใพใ™ใ€‚</p>
 <p>JavaScriptใงใฏๆฌกใฎใ‚ˆใ†ใชใ‚ณใƒผใƒ‰ใซใงใใพใ™ใ€‚</p>
 <p>JavaScriptใงใฏๆฌกใฎใ‚ˆใ†ใชใ‚ณใƒผใƒ‰ใซใงใใพใ™ใ€‚</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const face7x7PixelImageData = [
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const face7x7PixelImageData = [
   0, 1, 1, 1, 1, 1, 0,
   0, 1, 1, 1, 1, 1, 0,
-  1, 0, 0, 0, 0, 0, 1, 
+  1, 0, 0, 0, 0, 0, 1,
   1, 0, 2, 0, 2, 0, 1,
   1, 0, 2, 0, 2, 0, 1,
   1, 0, 0, 0, 0, 0, 1,
   1, 0, 0, 0, 0, 0, 1,
   1, 0, 3, 3, 3, 0, 1,
   1, 0, 3, 3, 3, 0, 1,
@@ -377,20 +377,20 @@ void main() {
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const maxNumCountries = 512;
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const maxNumCountries = 512;
 const paletteTextureWidth = maxNumCountries;
 const paletteTextureWidth = maxNumCountries;
 const paletteTextureHeight = 1;
 const paletteTextureHeight = 1;
-const palette = new Uint8Array(paletteTextureWidth * 3);
+const palette = new Uint8Array(paletteTextureWidth * 4);
 const paletteTexture = new THREE.DataTexture(
 const paletteTexture = new THREE.DataTexture(
-    palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+    palette, paletteTextureWidth, paletteTextureHeight);
 paletteTexture.minFilter = THREE.NearestFilter;
 paletteTexture.minFilter = THREE.NearestFilter;
 paletteTexture.magFilter = THREE.NearestFilter;
 paletteTexture.magFilter = THREE.NearestFilter;
 </pre>
 </pre>
 <p><a href="/docs/#api/ja/textures/DataTexture"><code class="notranslate" translate="no">DataTexture</code></a> ใฏใƒ†ใ‚ฏใ‚นใƒใƒฃใฎ็”Ÿใƒ‡ใƒผใ‚ฟใ‚’ไธŽใˆใ‚‹ไบ‹ใŒใงใใพใ™ใ€‚
 <p><a href="/docs/#api/ja/textures/DataTexture"><code class="notranslate" translate="no">DataTexture</code></a> ใฏใƒ†ใ‚ฏใ‚นใƒใƒฃใฎ็”Ÿใƒ‡ใƒผใ‚ฟใ‚’ไธŽใˆใ‚‹ไบ‹ใŒใงใใพใ™ใ€‚
-ไปŠๅ›žใฏใฏ512ใฎRGBใ‚ซใƒฉใƒผใ‚’3ใƒใ‚คใƒˆใšใคไธŽใˆใ€ใใ‚Œใžใ‚Œใฎใƒใ‚คใƒˆใŒ่ตคใ€็ท‘ใ€้’ใง0ใ€œ255ใฎๅ€คใ‚’ไฝฟ็”จใ—ใพใ™ใ€‚</p>
+ไปŠๅ›žใฏใฏ512ใฎRGBAใ‚ซใƒฉใƒผใ‚’4ใƒใ‚คใƒˆใšใคไธŽใˆใ€ใใ‚Œใžใ‚Œใฎใƒใ‚คใƒˆใŒ่ตคใ€็ท‘ใ€้’ใง0ใ€œ255ใฎๅ€คใ‚’ไฝฟ็”จใ—ใพใ™ใ€‚</p>
 <p>ใƒฉใƒณใƒ€ใƒ ใชใ‚ซใƒฉใƒผใงๅก—ใ‚Šใคใถใ—ใพใ—ใ‚‡ใ†๏ผ</p>
 <p>ใƒฉใƒณใƒ€ใƒ ใชใ‚ซใƒฉใƒผใงๅก—ใ‚Šใคใถใ—ใพใ—ใ‚‡ใ†๏ผ</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">for (let i = 1; i &lt; palette.length; ++i) {
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">for (let i = 1; i &lt; palette.length; ++i) {
   palette[i] = Math.random() * 256;
   palette[i] = Math.random() * 256;
 }
 }
 // set the ocean color (index #0)
 // set the ocean color (index #0)
-palette.set([100, 200, 255], 0);
+palette.set([100, 200, 255, 255], 0);
 paletteTexture.needsUpdate = true;
 paletteTexture.needsUpdate = true;
 </pre>
 </pre>
 <p>ใƒ‘ใƒฌใƒƒใƒˆใƒ†ใ‚ฏใ‚นใƒใƒฃใ‚’ <code class="notranslate" translate="no">palette</code> ้…ๅˆ—ใฎๅ†…ๅฎนใงๆ›ดๆ–ฐใ—ใŸใ„ๆ™‚ใฏใ€ๅธธใซ  <code class="notranslate" translate="no">paletteTexture.needsUpdate</code> ใ‚’ <code class="notranslate" translate="no">true</code> ใซใ™ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚Šใพใ™ใ€‚</p>
 <p>ใƒ‘ใƒฌใƒƒใƒˆใƒ†ใ‚ฏใ‚นใƒใƒฃใ‚’ <code class="notranslate" translate="no">palette</code> ้…ๅˆ—ใฎๅ†…ๅฎนใงๆ›ดๆ–ฐใ—ใŸใ„ๆ™‚ใฏใ€ๅธธใซ  <code class="notranslate" translate="no">paletteTexture.needsUpdate</code> ใ‚’ <code class="notranslate" translate="no">true</code> ใซใ™ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚Šใพใ™ใ€‚</p>
@@ -419,7 +419,9 @@ scene.add(new THREE.Mesh(geometry, material));
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const tempColor = new THREE.Color();
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const tempColor = new THREE.Color();
 function get255BasedColor(color) {
 function get255BasedColor(color) {
   tempColor.set(color);
   tempColor.set(color);
-  return tempColor.toArray().map(v =&gt; v * 255);
+  const base = tempColor.toArray().map(v =&gt; v * 255);
+  base.push(255); // alpha
+  return base;
 }
 }
 </pre>
 </pre>
 <p>ใ“ใฎใ‚ˆใ†ใซ <code class="notranslate" translate="no">color = get255BasedColor('red')</code> ใ‚’ๅ‘ผใณๅ‡บใ™ใจ <code class="notranslate" translate="no">[255, 0, 0]</code> ใฎใ‚ˆใ†ใช้…ๅˆ—ใŒ่ฟ”ใ•ใ‚Œใพใ™ใ€‚</p>
 <p>ใ“ใฎใ‚ˆใ†ใซ <code class="notranslate" translate="no">color = get255BasedColor('red')</code> ใ‚’ๅ‘ผใณๅ‡บใ™ใจ <code class="notranslate" translate="no">[255, 0, 0]</code> ใฎใ‚ˆใ†ใช้…ๅˆ—ใŒ่ฟ”ใ•ใ‚Œใพใ™ใ€‚</p>
@@ -430,7 +432,7 @@ const oceanColor = get255BasedColor('rgb(100,200,255)');
 resetPalette();
 resetPalette();
 
 
 function setPaletteColor(index, color) {
 function setPaletteColor(index, color) {
-  palette.set(color, index * 3);
+  palette.set(color, index * 4);
 }
 }
 
 
 function resetPalette() {
 function resetPalette() {
@@ -586,11 +588,11 @@ canvas.addEventListener('pointerup', pickCountry);
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
-  
+
   <script src="/manual/resources/prettify.js"></script>
   <script src="/manual/resources/prettify.js"></script>
   <script src="/manual/resources/lesson.js"></script>
   <script src="/manual/resources/lesson.js"></script>
 
 
 
 
 
 
 
 
-</body></html>
+</body></html>

+ 12 - 10
manual/ko/indexed-textures.html

@@ -212,11 +212,11 @@ canvas.addEventListener('pointerup', pickCountry);
 <p>์œ„ ์˜ˆ์ œ๋Š” ์—ฌ์ „ํžˆ ์˜์—ญ ํฌ๊ธฐ์— ๋”ฐ๋ผ ๋‚˜๋ผ ์ด๋ฆ„์„ ๋ณด์—ฌ์ฃผ๊ธด ํ•˜๋‚˜, ํŠน์ • ๋‚˜๋ผ๋ฅผ ํด๋ฆญํ•˜๋ฉด ํ•ด๋‹น ๋‚˜๋ผ์˜ ์ด๋ฆ„๋งŒ ๋ณด์—ฌ์ค„ ๊ฒ๋‹ˆ๋‹ค.</p>
 <p>์œ„ ์˜ˆ์ œ๋Š” ์—ฌ์ „ํžˆ ์˜์—ญ ํฌ๊ธฐ์— ๋”ฐ๋ผ ๋‚˜๋ผ ์ด๋ฆ„์„ ๋ณด์—ฌ์ฃผ๊ธด ํ•˜๋‚˜, ํŠน์ • ๋‚˜๋ผ๋ฅผ ํด๋ฆญํ•˜๋ฉด ํ•ด๋‹น ๋‚˜๋ผ์˜ ์ด๋ฆ„๋งŒ ๋ณด์—ฌ์ค„ ๊ฒ๋‹ˆ๋‹ค.</p>
 <p>์ด๋งŒํ•˜๋ฉด ๊ฐ ๋‚˜๋ผ๋ฅผ ํ”ผํ‚นํ•˜๋Š” ์˜ˆ์ œ๋กœ ์ถฉ๋ถ„ํ•ด ๋ณด์ด์ง€๋งŒ... ์„ ํƒํ•œ ๋‚˜๋ผ์˜ ์ƒ‰์„ ๋ฐ”๊พธ๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ์š”?</p>
 <p>์ด๋งŒํ•˜๋ฉด ๊ฐ ๋‚˜๋ผ๋ฅผ ํ”ผํ‚นํ•˜๋Š” ์˜ˆ์ œ๋กœ ์ถฉ๋ถ„ํ•ด ๋ณด์ด์ง€๋งŒ... ์„ ํƒํ•œ ๋‚˜๋ผ์˜ ์ƒ‰์„ ๋ฐ”๊พธ๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ์š”?</p>
 <p><em>์ปฌ๋Ÿฌ ํŒ”๋ ˆํŠธ(color palette)</em>๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.</p>
 <p><em>์ปฌ๋Ÿฌ ํŒ”๋ ˆํŠธ(color palette)</em>๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.</p>
-<p><a href="https://ko.wikipedia.org/wiki/%ED%8C%94%EB%A0%88%ED%8A%B8_(%EC%BB%B4%ED%93%A8%ED%8C%85">์ปฌ๋Ÿฌ ํŒ”๋ ˆํŠธ</a>) ํ˜น์€ <a href="https://en.wikipedia.org/wiki/Indexed_color">์ธ๋ฑ์Šค ํŒ”๋ ˆํŠธ</a>๋Š” ์•„ํƒ€๋ฆฌ 800, Amiga, NES, ์Šˆํผ ๋‹Œํ…๋„, ๊ตฌํ˜• IBM PC ๋“ฑ ๊ตฌํ˜• ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉํ•˜๋˜ ๊ธฐ๋ฒ•์ž…๋‹ˆ๋‹ค. ๋น„ํŠธ๋งต์„ ์ƒ‰์ƒ๋‹น 8๋น„ํŠธ ํ˜น์€ 24๋ฐ”์ดํŠธ ์ด์ƒ์˜ RGB ์ƒ‰์ƒ์œผ๋กœ ์ ์šฉํ•˜๋Š” ๋Œ€์‹  ๋น„ํŠธ๋งต์„ 8๋น„ํŠธ ์ดํ•˜์˜ ๊ฐ’์œผ๋กœ ์ €์žฅํ•˜๋Š” ๊ธฐ๋ฒ•์ด์ฃ . ๊ฐ ํ”ฝ์…€์˜ ์ƒ‰์ƒ๊ฐ’์€ ํŒ”๋ ˆํŠธ์˜ ์ธ๋ฑ์Šค ๊ฐ’์œผ๋กœ, ํ”ฝ์…€์˜ ์ƒ‰์ƒ๊ฐ’์ด 3์ด๋ผ๋ฉด ํŠน์ • "ํŒ”๋ ˆํŠธ"์˜ 3๋ฒˆ ์ƒ‰์ƒ์„ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.</p>
+<p><a href="https://ko.wikipedia.org/wiki/%ED%8C%94%EB%A0%88%ED%8A%B8_(%EC%BB%B4%ED%93%A8%ED%8C%85">์ปฌ๋Ÿฌ ํŒ”๋ ˆํŠธ</a>) ํ˜น์€ <a href="https://en.wikipedia.org/wiki/Indexed_color">์ธ๋ฑ์Šค ํŒ”๋ ˆํŠธ</a>๋Š” ์•„ํƒ€๋ฆฌ 800, Amiga, NES, ์Šˆํผ ๋‹Œํ…๋„, ๊ตฌํ˜• IBM PC ๋“ฑ ๊ตฌํ˜• ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉํ•˜๋˜ ๊ธฐ๋ฒ•์ž…๋‹ˆ๋‹ค. ๋น„ํŠธ๋งต์„ ์ƒ‰์ƒ๋‹น 8๋น„ํŠธ ํ˜น์€ 32๋ฐ”์ดํŠธ ์ด์ƒ์˜ RGBA ์ƒ‰์ƒ์œผ๋กœ ์ ์šฉํ•˜๋Š” ๋Œ€์‹  ๋น„ํŠธ๋งต์„ 8๋น„ํŠธ ์ดํ•˜์˜ ๊ฐ’์œผ๋กœ ์ €์žฅํ•˜๋Š” ๊ธฐ๋ฒ•์ด์ฃ . ๊ฐ ํ”ฝ์…€์˜ ์ƒ‰์ƒ๊ฐ’์€ ํŒ”๋ ˆํŠธ์˜ ์ธ๋ฑ์Šค ๊ฐ’์œผ๋กœ, ํ”ฝ์…€์˜ ์ƒ‰์ƒ๊ฐ’์ด 3์ด๋ผ๋ฉด ํŠน์ • "ํŒ”๋ ˆํŠธ"์˜ 3๋ฒˆ ์ƒ‰์ƒ์„ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.</p>
 <p>์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ์„ค๋ช…ํ•˜์ž๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ํ˜•์‹์„ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.</p>
 <p>์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ์„ค๋ช…ํ•˜์ž๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ํ˜•์‹์„ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const face7x7PixelImageData = [
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const face7x7PixelImageData = [
   0, 1, 1, 1, 1, 1, 0,
   0, 1, 1, 1, 1, 1, 0,
-  1, 0, 0, 0, 0, 0, 1, 
+  1, 0, 0, 0, 0, 0, 1,
   1, 0, 2, 0, 2, 0, 1,
   1, 0, 2, 0, 2, 0, 1,
   1, 0, 0, 0, 0, 0, 1,
   1, 0, 0, 0, 0, 0, 1,
   1, 0, 3, 3, 3, 0, 1,
   1, 0, 3, 3, 3, 0, 1,
@@ -334,19 +334,19 @@ void main() {
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const maxNumCountries = 512;
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const maxNumCountries = 512;
 const paletteTextureWidth = maxNumCountries;
 const paletteTextureWidth = maxNumCountries;
 const paletteTextureHeight = 1;
 const paletteTextureHeight = 1;
-const palette = new Uint8Array(paletteTextureWidth * 3);
+const palette = new Uint8Array(paletteTextureWidth * 4);
 const paletteTexture = new THREE.DataTexture(
 const paletteTexture = new THREE.DataTexture(
-    palette, paletteTextureWidth, paletteTextureHeight, THREE.RGBFormat);
+    palette, paletteTextureWidth, paletteTextureHeight);
 paletteTexture.minFilter = THREE.NearestFilter;
 paletteTexture.minFilter = THREE.NearestFilter;
 paletteTexture.magFilter = THREE.NearestFilter;
 paletteTexture.magFilter = THREE.NearestFilter;
 </pre>
 </pre>
-<p><a href="/docs/#api/ko/textures/DataTexture"><code class="notranslate" translate="no">DataTexture</code></a>๋ฅผ ์“ฐ๋ฉด ํ…์Šค์ฒ˜๋ฅผ ๋กœ์šฐ-๋ฐ์ดํ„ฐ(raw data) ํ˜•์‹์œผ๋กœ ๋„˜๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์ œ์˜ ๊ฒฝ์šฐ์—๋Š” 512 RGB ์ƒ‰์ƒ์„ ๋„˜๊ฒจ์ฃผ๋ฉด ๋˜๊ฒ ์ฃ . ๊ฐ ๊ฐ’์€ 3๋ฐ”์ดํŠธ๋กœ, ์ด ๋ฐ”์ดํŠธ๋Š” ๊ฐ๊ฐ red, green, blue์„ 0๋ถ€ํ„ฐ 255๊นŒ์ง€์˜ ์ˆซ์ž๋กœ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.</p>
+<p><a href="/docs/#api/ko/textures/DataTexture"><code class="notranslate" translate="no">DataTexture</code></a>๋ฅผ ์“ฐ๋ฉด ํ…์Šค์ฒ˜๋ฅผ ๋กœ์šฐ-๋ฐ์ดํ„ฐ(raw data) ํ˜•์‹์œผ๋กœ ๋„˜๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์ œ์˜ ๊ฒฝ์šฐ์—๋Š” 512 RGBA ์ƒ‰์ƒ์„ ๋„˜๊ฒจ์ฃผ๋ฉด ๋˜๊ฒ ์ฃ . ๊ฐ ๊ฐ’์€ 3๋ฐ”์ดํŠธ๋กœ, ์ด ๋ฐ”์ดํŠธ๋Š” ๊ฐ๊ฐ red, green, blue์„ 0๋ถ€ํ„ฐ 255๊นŒ์ง€์˜ ์ˆซ์ž๋กœ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.</p>
 <p>์ผ๋‹จ์€ ๋ฌด์ž‘์œ„๋กœ ์ƒ‰์„ ์ง€์ •ํ•ด ์ž˜ ์ž‘๋™ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธํ•ด๋ด…์‹œ๋‹ค.</p>
 <p>์ผ๋‹จ์€ ๋ฌด์ž‘์œ„๋กœ ์ƒ‰์„ ์ง€์ •ํ•ด ์ž˜ ์ž‘๋™ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธํ•ด๋ด…์‹œ๋‹ค.</p>
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">for (let i = 1; i &lt; palette.length; ++i) {
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">for (let i = 1; i &lt; palette.length; ++i) {
   palette[i] = Math.random() * 256;
   palette[i] = Math.random() * 256;
 }
 }
 // ๋ฐ”๋‹ค์˜ ์ƒ‰์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. (index #0)
 // ๋ฐ”๋‹ค์˜ ์ƒ‰์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. (index #0)
-palette.set([100, 200, 255], 0);
+palette.set([100, 200, 255, 255], 0);
 paletteTexture.needsUpdate = true;
 paletteTexture.needsUpdate = true;
 </pre>
 </pre>
 <p><code class="notranslate" translate="no">palette</code> ๋ฐฐ์—ด๋กœ ํŒ”๋ ˆํŠธ ํ…์Šค์ฒ˜๋ฅผ ์—…๋ฐ์ดํŠธํ•  ๋•Œ๋งˆ๋‹ค ์žฅ๋ฉด์„ ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ•˜๋‹ˆ <code class="notranslate" translate="no">paletteTexture.needsUpdate</code>๋ฅผ <code class="notranslate" translate="no">true</code>๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.</p>
 <p><code class="notranslate" translate="no">palette</code> ๋ฐฐ์—ด๋กœ ํŒ”๋ ˆํŠธ ํ…์Šค์ฒ˜๋ฅผ ์—…๋ฐ์ดํŠธํ•  ๋•Œ๋งˆ๋‹ค ์žฅ๋ฉด์„ ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ•˜๋‹ˆ <code class="notranslate" translate="no">paletteTexture.needsUpdate</code>๋ฅผ <code class="notranslate" translate="no">true</code>๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.</p>
@@ -375,7 +375,9 @@ scene.add(new THREE.Mesh(geometry, material));
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const tempColor = new THREE.Color();
 <pre class="prettyprint showlinemods notranslate lang-js" translate="no">const tempColor = new THREE.Color();
 function get255BasedColor(color) {
 function get255BasedColor(color) {
   tempColor.set(color);
   tempColor.set(color);
-  return tempColor.toArray().map(v =&gt; v * 255);
+  const base = tempColor.toArray().map(v =&gt; v * 255);
+  base.push(255); // alpha
+  return base;
 }
 }
 </pre>
 </pre>
 <p>์œ„ ํ•จ์ˆ˜๋ฅผ <code class="notranslate" translate="no">color = get255BasedColor('red')</code>์™€ ๊ฐ™์€ ์‹์œผ๋กœ ํ˜ธ์ถœํ•˜๋ฉด <code class="notranslate" translate="no">[255, 0, 0]</code> ์ด๋Ÿฐ ์‹์˜ ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.</p>
 <p>์œ„ ํ•จ์ˆ˜๋ฅผ <code class="notranslate" translate="no">color = get255BasedColor('red')</code>์™€ ๊ฐ™์€ ์‹์œผ๋กœ ํ˜ธ์ถœํ•˜๋ฉด <code class="notranslate" translate="no">[255, 0, 0]</code> ์ด๋Ÿฐ ์‹์˜ ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.</p>
@@ -386,7 +388,7 @@ const oceanColor = get255BasedColor('rgb(100,200,255)');
 resetPalette();
 resetPalette();
 
 
 function setPaletteColor(index, color) {
 function setPaletteColor(index, color) {
-  palette.set(color, index * 3);
+  palette.set(color, index * 4);
 }
 }
 
 
 function resetPalette() {
 function resetPalette() {
@@ -534,11 +536,11 @@ canvas.addEventListener('pointerup', pickCountry);
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
-  
+
   <script src="/manual/resources/prettify.js"></script>
   <script src="/manual/resources/prettify.js"></script>
   <script src="/manual/resources/lesson.js"></script>
   <script src="/manual/resources/lesson.js"></script>
 
 
 
 
 
 
 
 
-</body></html>
+</body></html>