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 | 2b64f57cb1a75d156e7fdc0cf87207adb4cf38d0.json | add translation kr/threejs-offscreencanvas.md | threejs/lessons/kr/threejs-offscreencanvas.md | @@ -0,0 +1,1057 @@
+Title: Three.js OffscreenCanvas
+Description: Three.js์์ ์น ์์ปค๋ฅผ ํ์ฉํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ์น ์์ปค์์ OffscreenCanvas ์ฌ์ฉํ๊ธฐ
+
+[`OffscreenCanvas`](https://developer.mozilla.org/ko/docs/Web/API/OffscreenCanvas)๋ ๋น๊ต์ ์ต๊ทผ ๋์
๋ ๋ธ๋ผ์ฐ์ API๋ก ์์ง ํฌ๋ก๋ฏธ์ ๊ธฐ๋ฐ ๋ธ๋ผ์ฐ์ ์์๋ง ์ฌ์ฉ๊ฐ๋ฅํ์ง๋ง, ๊ฐ์๋ก ๋๋ถ๋ถ์ ๋ธ๋ผ์ฐ์ ์์ ์ด API๋ฅผ ์ฌ์ฉํ ์ ์์ ๊ฒ๋๋ค. `OffscreenCanvas`๋ฅผ ์ด์ฉํ๋ฉด [์น ์์ปค(Web Worker)](https://developer.mozilla.org/ko/docs/Web/API/Web_Workers_API)์์ ์บ๋ฒ์ค๋ฅผ ๋ ๋๋งํด ๋ณต์กํ 3D ์ฅ๋ฉด ๋ฑ์ ๋ฌด๊ฑฐ์ด ์์
์ ๋ณ๋ ํ๋ก์ธ์ค์์ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค. ์ด๋ฌ๋ฉด ๋ฌด๊ฑฐ์ด ์์
์ ์ฒ๋ฆฌํ ๋ ๋ธ๋ผ์ฐ์ ๊ฐ ๋ ๋ฒ๋ฒ
์ด๋๋ก ํ ์ ์์ฃ . ๋ํ ๋ฐ์ดํฐ๋ ์์ปค์์ ๋ถ๋ฌ์ ์ฒ๋ฆฌํ๋ฏ๋ก ํ์ด์ง ์ด๊ธฐ ๋ก๋ ์ ๋ฒ๋ฒ
์์ ํจ์ฌ ์ค์ผ ์ ์์ต๋๋ค.
+
+OffscreenCanvas์ ๋ฌธ์ ์ ์ค ํ๋๋ ์น ์์ปค๊ฐ ์์ง ES ๋ชจ๋(import, export ํค์๋ ๋ฑ)์ ์ง์ํ์ง ์๋๋ค๋ ๊ฒ๋๋ค. ๋๋ฌธ์ ๋ค๋ฅธ ์์ ์ ๋ฌ๋ฆฌ ์ด ๊ธ์์๋ ํด๋์ค ์คํฌ๋ฆฝํธ ๋ฐฉ์์ ์ฌ์ฉํ ๊ฒ๋๋ค.
+
+์ฌ์ฉ๋ฒ์ ๊ฝค๋ ์ง๊ด์ ์
๋๋ค. ๋จผ์ [๋ฐ์ํ ๋์์ธ์ ๊ดํ ๊ธ](threejs-responsive.html)์์ ์ผ๋ ์์ ๋ฅผ ๊ฐ์ ธ์ค๋๋ก ํ์ฃ .
+
+์ด ์ฌ์ดํธ ๋๋ถ๋ถ์ ์์ ๋ ์คํฌ๋ฆฝํธ๋ฅผ ํด๋น HTML ํ์ผ์ ์ธ๋ผ์ธ์ผ๋ก ์์ฑํ์ต๋๋ค. ๋ฐ๋ฉด์ ์์ปค๋ ์ผ๋ฐ์ ์ผ๋ก ๋ณ๋์ ์คํฌ๋ฆฝํธ ํ์ผ๋ก ๋ถ๋ฆฌํด ์์ฑํฉ๋๋ค.
+
+์ด ๊ธ์์๋ `offscreencanvas-cubes.js`๋ผ๋ ๋ณ๋ ํ์ผ์ ๋ง๋ค์ด [๋ฐ์ํ ๋์์ธ์์ ๊ฐ์ ธ์จ ์์ ](threejs-responsive.html)์ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋๋ฅผ ์ ๋ถ ๋ณต์ฌํด ๋ฃ์ ๊ฒ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ฐ๊ฟ์ผํ ๋ถ๋ถ์ ๋ฐ๊ฟ๋ณด๋๋ก ํ์ฃ .
+
+ํ์ง๋ง ์ฌ์ ํ HTML ํ์ผ์ ์ฝ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋๊ฐ ํ์ํฉ๋๋ค. ์บ๋ฒ์ค ์์๋ฅผ ์ฐธ์กฐํ๊ณ `canvas.transferControlToOffscreen` ๋ฉ์๋๋ฅผ ํธ์ถํด ์บ๋ฒ์ค์ ์ ์ด๊ถ์ `offscreen`์ ๋๊ฒจ์ค๋๋ค.
+
+```js
+function main() {
+ const canvas = document.querySelector('#c');
+ const offscreen = canvas.transferControlToOffscreen();
+
+ ...
+```
+
+๊ทธ๋ฆฌ๊ณ `new Worker(์์ปค ์คํฌ๋ฆฝํธ ๊ฒฝ๋ก)`๋ก ์์ปค๋ฅผ ์์ฑํ ๋ค, ์์ปค์ `offscreen` ๊ฐ์ฒด๋ฅผ ๋๊น๋๋ค.
+
+```js
+function main() {
+ const canvas = document.querySelector('#c');
+ const offscreen = canvas.transferControlToOffscreen();
+ const worker = new Worker('offscreencanvas-cubes.js');
+ worker.postMessage({ type: 'main', canvas: offscreen }, [ offscreen ]);
+}
+main();
+```
+
+์คํฌ๋ฆฝํธ๋ฅผ ๋ฐ๋ก ์จ์ผ ํ๋ ์ด์ ๋ ์์ปค ์์์๋ `DOM`์ ์ ๊ทผํ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค. HTML ์์๋ฅผ ์ฐธ์กฐํ๊ฑฐ๋ DOM ์์์ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ ์๋ ์์ฃ . ์ผ๋ฐ์ ์ผ๋ก ๋ฉ์์ง ์ด๋ฒคํธ๋ฅผ ํตํด์๋ง ๋ค๋ฅธ ์คํฌ๋ฆฝํธ์ ํต์ ํ ์ ์์ต๋๋ค.
+
+์์ปค์ ๋ฉ์์ง๋ฅผ ๋ณด๋ด๋ ค๋ฉด [`worker.postMessage`](https://developer.mozilla.org/ko/docs/Web/API/Worker/postMessage)์ ํ๋ ๋๋ ๋ ๊ฐ์ ์ธ์๋ฅผ ๋๊ฒจ์ฃผ์ด ํธ์ถํ๋ฉด ๋ฉ๋๋ค. ์ฒซ ๋ฒ์งธ ์ธ์๋ ์์ปค์ ์ ๋ฌํ ๊ฐ์ฒด๋ก, ์ด ๊ฐ์ฒด๋ ๊ทธ๋๋ก ์ ๋ฌ๋์ง ์๊ณ [๋ณต์ฌ๋ฉ๋๋ค](https://developer.mozilla.org/ko/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). ๋ ๋ฒ์งธ ์ธ์๋ ์ต์
์ผ๋ก ์ฒซ ๋ฒ์งธ ์ธ์ ์ค ๊ทธ๋๋ก *์ ๋ฌํ๊ธฐ* ์ํ๋ ๊ฐ์ฒด๋ฅผ ๋ฐฐ์ด๋ก ์ง์ ํฉ๋๋ค. ์ฌ๊ธฐ์ ์ง์ ํ ๊ฐ์ฒด๋ ๋ณต์ฌ๋์ง ์์ฃ . ๊ทธ๋๋ก ์์ปค์ *์ ๋ฌ๋์ง๋ง* ๊ฐ์ฒด๋ฅผ ๋ณด๋ธ ์คํฌ๋ฆฝํธ์์๋ ๋ ์ด์ ์ฌ์ฉ์ด ๋ถ๊ฐ๋ฅํด์ง๋๋ค. ์ด๊ฒ๋ ๋ชจ๋ ๊ฐ์ฒด๋ฅผ ์ ๋ฌํ ์ ์๋ ๊ฒ ์๋๋ผ ํน์ ํ์
์ ๊ฐ์ฒด๋ง์ ์ ๋ฌํ ์ ์์ฃ . ๋น์ฐํ๊ฒ๋ ์ด ์ค์๋ `OffscreenCanvas`๋ ์์ต๋๋ค. ์ ๋ฆฌํ์๋ฉด `offscreen` ๊ฐ์ฒด๋ฅผ ์ ๋ฌํ๊ณ ๋๋ฉด ์ด ๊ฐ์ฒด๋ ์ด ์คํฌ๋ฆฝํธ์์ ๋ ์ด์ ์ธ๋ชจ๊ฐ ์์ด์ง๋๋ค.
+
+์์ปค์ `message` ์ด๋ฒคํธ๋ฅผ ์ด์ฉํ๋ฉด ๋ฉ์์ง๋ฅผ ๋ฐ์ ์ ์์ต๋๋ค. `postMessage`์์ ๋๊ธด ๊ฐ์ฒด๋ `event.data`์ ๋ด๊ฒจ ๋ฆฌ์ค๋์ ์ ๋ฌ๋์ฃ . ์๊น ์ ์ฝ๋์์๋ `type: 'main'` ์์ฑ์ ๊ฐ์ฒด์ ์ ์ธํด ์์ปค์ ๋๊ฒจ์คฌ์ต๋๋ค. ์ด `type` ์์ฑ์ผ๋ก ์์ปค ๋ด์ ๋ค๋ฅธ ํจ์๋ฅผ ํธ์ถํ๋๋ก ํด๋ด
์๋ค. ์ด๋ฌ๋ฉด ๋ฉ์ธ ์คํฌ๋ฆฝํธ์์ ์์ปค ๋ด์ ํจ์๋ฅผ ํธ์ถํ๊ธฐ๊ฐ ํจ์ฌ ์ฌ์์ง ๊ฒ๋๋ค.
+
+```js
+const handlers = {
+ main,
+};
+
+self.onmessage = function(e) {
+ const fn = handlers[e.data.type];
+ if (!fn) {
+ throw new Error('no handler for type: ' + e.data.type);
+ }
+ fn(e.data);
+};
+```
+
+`type` ๊ฐ์ ํตํด ํธ์ถํ ํจ์๋ฅผ ์ฐพ๊ณ , ํจ์๊ฐ ์๋ค๋ฉด ๋ฉ์ธ ์คํฌ๋ฆฝํธ์์ ๋์ด์จ `data`๋ฅผ ์ธ์๋ก ๋๊ฒจ ํธ์ถํ๋๋ก ํ์ต๋๋ค.
+
+์ด์ [๋ฐ์ํ ๋์์ธ์ ๊ดํ ๊ธ](threejs-responsive.html)์์ ๊ฐ์ ธ์จ ์์ ์ `main` ํจ์๋ฅผ ์์ ํด์ผ ํฉ๋๋ค.
+
+๋ฌผ๋ก ๊ทธ์ ์ ๋จผ์ Three.js๋ฅผ `offscreencanvas-cubes.js`์ ๋ถ๋ฌ์์ผ๊ฒ ์ฃ .
+
+```js
+importScripts('resources/threejs/r115/build/three.min.js');
+```
+
+DOM์์ ์บ๋ฒ์ค์ ์ ๊ทผํ๋ ๋์ ์ด๋ฒคํธ์ `data`์์ ์บ๋ฒ์ค๋ฅผ ๋ฐ์ต๋๋ค.
+
+```js
+-function main() {
+- const canvas = document.querySelector('#c');
++function main(data) {
++ const { canvas } = data;
+ const renderer = new THREE.WebGLRenderer({ canvas });
+
+ ...
+
+```
+
+์์ปค์์๋ DOM์ ์ ๊ทผํ ์ ์๋ค๊ณ ํ์์ฃ . ๋ง์ฐฌ๊ฐ์ง๋ก DOM ์์ฑ์ธ `canvas.clientWidth`๋ `canvas.clientHeight`์๋ ์ ๊ทผํ ์ ์์ต๋๋ค. `resizeRendererToDisplaySize`๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉํ ์ ์๋ ๊ฒ์ด์ฃ .
+
+```js
+function resizeRendererToDisplaySize(renderer) {
+ const canvas = renderer.domElement;
+ const width = canvas.clientWidth;
+ const height = canvas.clientHeight;
+ const needResize = canvas.width !== width || canvas.height !== height;
+ if (needResize) {
+ renderer.setSize(width, height, false);
+ }
+ return needResize;
+}
+```
+
+๋์ ์บ๋ฒ์ค ํฌ๊ธฐ๊ฐ ๋ณ๊ฒฝ๋ ๋๋ง๋ค ์์ปค์ ๋ฉ์์ง๋ฅผ ๋ณด๋ผ ๊ฒ๋๋ค. ์์ปค์ ์ ์ญ ๋ณ์๋ฅผ ํ๋ ์์ฑํด ์ฌ๊ธฐ์ width์ height ๊ฐ์ ์ง์ ํ๋๋ก ํ์ฃ .
+
+```js
+const state = {
+ width: 300, // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+ height: 150, // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+};
+```
+
+๊ทธ๋ฆฌ๊ณ `size`๋ผ๋ ํจ์๋ฅผ ๋ง๋ค์ด ํด๋น ๊ฐ์ ์
๋ฐ์ดํธํ๋๋ก ํฉ๋๋ค.
+
+```js
++function size(data) {
++ state.width = data.width;
++ state.height = data.height;
++}
+
+const handlers = {
+ main,
++ size,
+};
+```
+
+`resizeRendererToDisplaySize`๊ฐ `state.width`์ `state.height`๋ฅผ ์ฐ๋๋ก ๋ณ๊ฒฝํฉ๋๋ค.
+
+```js
+function resizeRendererToDisplaySize(renderer) {
+ const canvas = renderer.domElement;
+- const width = canvas.clientWidth;
+- const height = canvas.clientHeight;
++ const width = state.width;
++ const height = state.height;
+ const needResize = canvas.width !== width || canvas.height !== height;
+ if (needResize) {
+ renderer.setSize(width, height, false);
+ }
+ return needResize;
+}
+```
+
+๋ง์ฐฌ๊ฐ์ง๋ก ์ข
ํก๋น๋ฅผ ๊ณ์ฐํ๋ ์ฝ๋๋ DOM ์์ฑ ๋์ `state`๋ฅผ ์ฐ๋๋ก ๋ณ๊ฒฝํฉ๋๋ค.
+
+```js
+function render(time) {
+ time *= 0.001;
+
+ if (resizeRendererToDisplaySize(renderer)) {
+- camera.aspect = canvas.clientWidth / canvas.clientHeight;
++ camera.aspect = state.width / state.height;
+ camera.updateProjectionMatrix();
+ }
+
+ ...
+```
+
+๋ฉ์ธ ์คํฌ๋ฆฝํธ๋ก ๋์์ ํ์ด์ง ํฌ๊ธฐ๊ฐ ๋ฐ๋ ๋๋ง๋ค ์์ปค์ `size` ํจ์๋ฅผ ์คํํ๋๋ก ํฉ๋๋ค.
+
+```js
+const worker = new Worker('offscreencanvas-picking.js');
+worker.postMessage({ type: 'main', canvas: offscreen }, [ offscreen ]);
+
++function sendSize() {
++ worker.postMessage({
++ type: 'size',
++ width: canvas.clientWidth,
++ height: canvas.clientHeight,
++ });
++}
++
++window.addEventListener('resize', sendSize);
++sendSize();
+```
+
+๋ํ ์ง์ ํธ์ถํด ์ต์ด์ ํ ๋ฒ ๊ฐ์ ๋ณด๋ด๋๋ก ํฉ๋๋ค.
+
+์ฌ๋ฌ๋ถ์ ๋ธ๋ผ์ฐ์ ๊ฐ `OffscreenCanvas`๋ฅผ ์๋ฒฝํ ์ง์ํ๋ค๋ฉด ์ด์ ๋ฌธ์ ์์ด ์๋ํ ๊ฒ๋๋ค. ๊ทธ๋ ๊ฒ ๋ง์ด ๋ฐ๊พผ ๊ฒ์ด ์๋๋ฐ๋ ๋ง์ด์ฃ . ํน์ ๋ชจ๋ฅด๋ ๋ธ๋ผ์ฐ์ ๊ฐ `OffscreenCanvas`๋ฅผ ์ง์ํ์ง ์์ ๊ฒฝ์ฐ ์๋ฌ ๋ฉ์์ง๋ฅผ ๋ณด์ฌ์ฃผ๋๋ก ํ๊ฒ ์ต๋๋ค. ๋จผ์ ์๋ฌ ๋ฉ์์ง๋ฅผ ํ์ํ HTML์ ์์ฑํฉ๋๋ค.
+
+```html
+<body>
+ <canvas id="c"></canvas>
++ <div id="noOffscreenCanvas" style="display:none;">
++ <div>no OffscreenCanvas support</div>
++ </div>
+</body>
+```
+
+๊ฐ๋จํ ์คํ์ผ๋ ๋ฃ์ด์ฃผ๋๋ก ํ์ฃ .
+
+```css
+#noOffscreenCanvas {
+ display: flex;
+ width: 100vw;
+ height: 100vh;
+ align-items: center;
+ justify-content: center;
+ background: red;
+ color: white;
+}
+```
+
+๊ทธ๋ฆฌ๊ณ ์บ๋ฒ์ค ์์์ `transferControlToOffscreen` ๋ฉ์๋๊ฐ ์๋์ง ํ์ธํด `OffscreenCanvas`์ ์ง์ ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค.
+
+```js
+function main() {
+ const canvas = document.querySelector('#c');
++ if (!canvas.transferControlToOffscreen) {
++ canvas.style.display = 'none';
++ document.querySelector('#noOffscreenCanvas').style.display = '';
++ return;
++ }
+ const offscreen = canvas.transferControlToOffscreen();
+ const worker = new Worker('offscreencanvas-picking.js');
+ worker.postMessage({ type: 'main', canvas: offscreen }, [ offscreen ]);
+
+ ...
+```
+
+๋ธ๋ผ์ฐ์ ๊ฐ `OffscreenCanvas`๋ฅผ ์ง์ํ๋ค๋ฉด ๋ฌธ์ ์์ด ์๋ํ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-offscreencanvas.html" }}}
+
+ํ์ง๋ง ํ์ฌ ๋ชจ๋ ๋ธ๋ผ์ฐ์ ๊ฐ `OffscreenCanvas`๋ฅผ ์ง์ํ๋ ๊ฒ์ ์๋๋๋ค. `OffscreenCanvas`๋ฅผ ์ง์ํ ๊ฒฝ์ฐ์๋ง ์์ปค๋ฅผ ์ฌ์ฉํ๋๋ก ํ๊ณ , ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ์๋ ๊ธฐ์กด์ฒ๋ผ ๋ฉ์ธ ์คํฌ๋ฆฝํธ์์ ๋ ๋๋ง์ ์ฒ๋ฆฌํ๋๋ก ํ๊ฒ ์ต๋๋ค.
+
+> OffscreenCanvas๋ฅผ ๋จ์ํ ํ์ด์ง๋ฅผ ๋ฐ์ํ์ผ๋ก ๋ง๋๋ ๋ฐ ์ฌ์ฉํ๋ ๊ฑด ์๋ฏธ์์ด ๋ณด์ผ ์ ์์ต๋๋ค. ๋ฉ์ธ ์คํฌ๋ฆฝํธ์์ ๋ฐ์ํ์ ์ฒ๋ฆฌํ ๋๋ณด๋ค ์์ปค์์ ์ฒ๋ฆฌํ ๋ ์คํ๋ ค ์์
์ด ๋ ๋ง์ด ๋ค ์ ์๊ฑฐ๋ ์. ํ์ง๋ง ๋ฉ์ธ ์คํฌ๋ฆฝํธ๋ง ์ฌ์ฉํ ๋๋ณด๋ค ์์ปค๋ฅผ ์ฌ์ฉํ ๋ ์์์ ๋ ๋๋ํ๊ฒ ํ์ฉํ ์ ์๋ค๋ ๊ฑด ๋ถ๋ช
ํฉ๋๋ค. ์ ์ ์ผ๋ก ์ฌ๋ฌ๋ถ์ด ์ํฉ์ ๋ฐ๋ผ ๊ฒฐ์ ํ ๋ฌธ์ ๋ผ๋ ๊ฒ์ด์ฃ .
+
+๋จผ์ Three.js ๊ด๋ จ ์ฝ๋๋ฅผ ๋ถ๋ฆฌํด ์์ปค ๊ด๋ จ ์ฝ๋์ ๊ทธ๋ ์ง ์์ ์ฝ๋๋ก ๋๋ ์ผ ํฉ๋๋ค. ๊ฐ์ ์ฝ๋๋ฅผ ๋ฉ์ธ ์คํฌ๋ฆฝํธ์ ์์ปค์์ ๋ชจ๋ ์ธ ์ ์๋๋ก ๋ง์ด์ฃ . ์๋์ ๊ฐ์ด 3๊ฐ์ ํ์ผ๋ก ๋๋ ๊ฒ๋๋ค.
+
+1. html ํ์ผ.
+
+ `threejs-offscreencanvas-w-fallback.html`
+
+2. three.js ๊ด๋ จ ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ.
+
+ `shared-cubes.js`
+
+3. ์์ปค์ฉ ์คํฌ๋ฆฝํธ
+
+ `offscreencanvas-worker-cubes.js`
+
+`shared-cubes.js`์ `offscreencanvas-worker-cubes.js`๋ ๋จ์ํ ์ด์ `offscreencanvas-cubes.js` ํ์ผ์ ์ชผ๊ฐ ๊ฒ์
๋๋ค. ๋ฉ์ธ HTML ํ์ผ์ `main`์ด๋ผ๋ ํจ์๊ฐ ์์ด `main` ํจ์๋ง `init`์ผ๋ก ๋ฐ๊ฟจ์ฃ .
+
+`offscreencanvas-worker-cubes.js`์ ๊ตฌ์กฐ๋ ์์ฃผ ๋จ์ํฉ๋๋ค.
+
+```js
+'use strict';
+
+/* global importScripts, init, state */
+
+importScripts('resources/threejs/r115/build/three.min.js');
++importScripts('shared-cubes.js');
+
+function size(data) {
+ state.width = data.width;
+ state.height = data.height;
+}
+
+const handlers = {
+- main,
++ init,
+ size,
+};
+
+self.onmessage = function(e) {
+ const fn = handlers[e.data.type];
+ if (!fn) {
+ throw new Error('no handler for type: ' + e.data.type);
+ }
+ fn(e.data);
+};
+```
+
+์ ์ฝ๋์์๋ Three.js ๊ด๋ จ ์คํฌ๋ฆฝํธ์ธ `shared-cubes.js`๋ฅผ ๋ถ๋ฌ์์ต๋๋ค.
+
+๋ฉ์ธ ํ์ด์ง์์๋ ๋ง์ฐฌ๊ฐ์ง๋ก Three.js์ `shared-cubes.js`๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```html
+<script src="resources/threejs/r115/build/three.min.js"></script>
+<script src="shared-cubes.js"><script>
+```
+
+์ด์ ์ ์ถ๊ฐํ๋ ์๋ฌ ๋ฉ์์ง์ฉ HTML๊ณผ CSS๋ฅผ ์ ๊ฑฐํฉ๋๋ค.
+
+```html
+<body>
+ <canvas id="c"></canvas>
+- <div id="noOffscreenCanvas" style="display:none;">
+- <div>no OffscreenCanvas support</div>
+- </div>
+</body>
+```
+
+```css
+-#noOffscreenCanvas {
+- display: flex;
+- width: 100vw;
+- height: 100vh;
+- align-items: center;
+- justify-content: center;
+- background: red;
+- color: white;
+-}
+```
+
+๊ทธ๋ฆฌ๊ณ `OffscreenCanvas`์ ์ง์ ์ฌ๋ถ์ ๋ฐ๋ผ ๋ค๋ฅธ ํจ์๋ฅผ ์คํํ๋๋ก ํฉ๋๋ค.
+
+```js
+function main() {
+ const canvas = document.querySelector('#c');
+- if (!canvas.transferControlToOffscreen) {
+- canvas.style.display = 'none';
+- document.querySelector('#noOffscreenCanvas').style.display = '';
+- return;
+- }
+- const offscreen = canvas.transferControlToOffscreen();
+- const worker = new Worker('offscreencanvas-picking.js');
+- worker.postMessage({ type: 'main', canvas: offscreen }, [ offscreen ]);
++ if (canvas.transferControlToOffscreen) {
++ startWorker(canvas);
++ } else {
++ startMainPage(canvas);
++ }
+ ...
+```
+
+์์ปค๋ฅผ ๋ง๋ค๊ธฐ ์ํด ์ฌ์ฉํ๋ ์ฝ๋๋ฅผ ์ ๋ถ `startWorker` ํจ์๋ก ์ฎ๊น๋๋ค.
+
+```js
+function startWorker(canvas) {
+ const offscreen = canvas.transferControlToOffscreen();
+ const worker = new Worker('offscreencanvas-worker-cubes.js');
+ worker.postMessage({type: 'init', canvas: offscreen}, [offscreen]);
+
+ function sendSize() {
+ worker.postMessage({
+ type: 'size',
+ width: canvas.clientWidth,
+ height: canvas.clientHeight,
+ });
+ }
+
+ window.addEventListener('resize', sendSize);
+ sendSize();
+
+ console.log('using OffscreenCanvas');
+}
+```
+
+์์ปค๋ฅผ ์ฌ์ฉํ ์ ์๋ ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ด ์คํํฉ๋๋ค.
+
+```js
+function startMainPage(canvas) {
+ init({ canvas });
+
+ function sendSize() {
+ state.width = canvas.clientWidth;
+ state.height = canvas.clientHeight;
+ }
+ window.addEventListener('resize', sendSize);
+ sendSize();
+
+ console.log('using regular canvas');
+}
+```
+
+์ด์ `OffscreenCanvas๋ฅผ` ์ง์ํ๋ ๊ฒฝ์ฐ์๋ง `OffscreenCanvas`๋ฅผ ์ฌ์ฉํ๊ณ , ์ง์ํ์ง ์๋ ๊ฒฝ์ฐ์๋ ๋ฉ์ธ ์ค๋ ๋์์ ์ง์ ๋ ๋๋งํฉ๋๋ค.
+
+{{{example url="../threejs-offscreencanvas-w-fallback.html" }}}
+
+์ด๋ค๊ฐ์? ์๊ฐํ๋ ๊ฒ๋ณด๋ค ์ฝ์ง ์๋์? ์ฌ๊ธฐ์ ํผํน(picking)์ ์ถ๊ฐํด๋ด
์๋ค. [ํผํน์ ๊ดํ ๊ธ](threejs-picking.html)์ `RayCaster` ์์ ์์ ์ฝ๋ ์ผ๋ถ๋ฅผ ๊ฐ์ ธ์ค๋๋ก ํ๊ฒ ์ต๋๋ค.
+
+๋จผ์ `shared-cube.js`์ ์ฝ๋๋ฅผ `shared-picking.js`๋ก ๋ณต์ฌํ ๋ค, ํผํน ์์ ์์ `PickHelper`๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
+
+```js
+class PickHelper {
+ constructor() {
+ this.raycaster = new THREE.Raycaster();
+ this.pickedObject = null;
+ this.pickedObjectSavedColor = 0;
+ }
+ pick(normalizedPosition, scene, camera, time) {
+ // ์ด๋ฏธ ๋ค๋ฅธ ๋ฌผ์ฒด๋ฅผ ํผํนํ๋ค๋ฉด ์์ ๋ณต์ํฉ๋๋ค
+ if (this.pickedObject) {
+ this.pickedObject.material.emissive.setHex(this.pickedObjectSavedColor);
+ this.pickedObject = undefined;
+ }
+
+ // ์ ๋์ฒด ์์ ๊ด์ ์ ์ฉ๋๋ค
+ this.raycaster.setFromCamera(normalizedPosition, camera);
+ // ๊ด์ ๊ณผ ๊ต์ฐจํ๋ ๋ฌผ์ฒด๋ค์ ๋ฐฐ์ด๋ก ๋ง๋ญ๋๋ค
+ const intersectedObjects = this.raycaster.intersectObjects(scene.children);
+ if (intersectedObjects.length) {
+ // ์ฒซ ๋ฒ์งธ ๋ฌผ์ฒด๊ฐ ์ ์ผ ๊ฐ๊น์ฐ๋ฏ๋ก ํด๋น ๋ฌผ์ฒด๋ฅผ ๊ณ ๋ฆ
๋๋ค
+ this.pickedObject = intersectedObjects[0].object;
+ // ๊ธฐ์กด ์์ ์ ์ฅํด๋ก๋๋ค
+ this.pickedObjectSavedColor = this.pickedObject.material.emissive.getHex();
+ // emissive ์์ ๋นจ๊ฐ/๋
ธ๋์ผ๋ก ๋น๋๊ฒ ๋ง๋ญ๋๋ค
+ this.pickedObject.material.emissive.setHex((time * 8) % 2 > 1 ? 0xFFFF00 : 0xFF0000);
+ }
+ }
+}
+
+const pickPosition = { x: 0, y: 0 };
+const pickHelper = new PickHelper();
+```
+
+`pickPosition`์ ๋ง์ฐ์ค ํฌ์ธํฐ์ ์ขํ๋ฅผ ๊ธฐ๋กํ๋ ์ญํ ์
๋๋ค. ์ด๋ฒคํธ๋ฅผ ํตํด ํด๋น ์์ฑ์ ์
๋ฐ์ดํธํ๋๋ก ํ์์ฃ .
+
+```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 setPickPosition(event) {
+ const pos = getCanvasRelativePosition(event);
+ pickPosition.x = (pos.x / canvas.width ) * 2 - 1;
+ pickPosition.y = (pos.y / canvas.height) * -2 + 1; // Y์ถ์ ๋ค์ง์์
+}
+window.addEventListener('mousemove', setPickPosition);
+```
+
+์์ปค๋ ํฌ์ธํฐ ์ขํ์ ์ง์ ์ ๊ทผํ ์ ์๊ธฐ์, ๋ฐ์ํ ์ฒ๋ฆฌ์ ์ฌ์ฉํ๋ ์ฝ๋์ฒ๋ผ ํฌ์ธํฐ ์ขํ๋ฅผ ๋ฉ์์ง๋ก ๋ณด๋ด์ผ ํฉ๋๋ค. ๋จผ์ `size` ํจ์์ ๋ง์ฐฌ๊ฐ์ง๋ก `mouse` ํจ์๋ฅผ ๋ง๋ค์ด `pickPosition`์ ์
๋ฐ์ดํธํ๋๋ก ํฉ๋๋ค.
+
+```js
+function size(data) {
+ state.width = data.width;
+ state.height = data.height;
+}
+
++function mouse(data) {
++ pickPosition.x = data.x;
++ pickPosition.y = data.y;
++}
+
+const handlers = {
+ init,
++ mouse,
+ size,
+};
+
+self.onmessage = function(e) {
+ const fn = handlers[e.data.type];
+ if (!fn) {
+ throw new Error('no handler for type: ' + e.data.type);
+ }
+ fn(e.data);
+};
+```
+
+๊ทธ๋ฆฌ๊ณ ๋ฉ์ธ ํ์ด์ง์ ๋ถ๊ธฐ ํจ์๋ฅผ ๋ง๋ค์ด ์์ปค ๋๋ ๋ฉ์ธ ํ์ด์ง๋ก ์ขํ ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ด๋๋ก ํฉ๋๋ค.
+
+```js
++let sendMouse;
+
+function startWorker(canvas) {
+ const offscreen = canvas.transferControlToOffscreen();
+ const worker = new Worker('offscreencanvas-worker-picking.js');
+ worker.postMessage({ type: 'init', canvas: offscreen }, [ offscreen ]);
+
++ sendMouse = (x, y) => {
++ worker.postMessage({
++ type: 'mouse',
++ x,
++ y,
++ });
++ };
+
+ function sendSize() {
+ worker.postMessage({
+ type: 'size',
+ width: canvas.clientWidth,
+ height: canvas.clientHeight,
+ });
+ }
+
+ window.addEventListener('resize', sendSize);
+ sendSize();
+
+ console.log('using OffscreenCanvas'); /* eslint-disable-line no-console */
+}
+
+function startMainPage(canvas) {
+ init({ canvas });
+
++ sendMouse = (x, y) => {
++ pickPosition.x = x;
++ pickPosition.y = y;
++ };
+
+ function sendSize() {
+ state.width = canvas.clientWidth;
+ state.height = canvas.clientHeight;
+ }
+ window.addEventListener('resize', sendSize);
+ sendSize();
+
+ console.log('using regular canvas'); /* eslint-disable-line no-console */
+}
+
+```
+
+๋ค์์ผ๋ก ๋ง์ฐ์ค ์ด๋ฒคํธ ๊ด๋ จ ์ฝ๋๋ฅผ ๋ฉ์ธ ํ์ด์ง๋ก ์ฎ๊ธด ๋ค `sendMouse` ํจ์๋ฅผ ์ฐ๋๋ก ์์ ํฉ๋๋ค.
+
+```js
+function setPickPosition(event) {
+ const pos = getCanvasRelativePosition(event);
+- pickPosition.x = (pos.x / canvas.clientWidth ) * 2 - 1;
+- pickPosition.y = (pos.y / canvas.clientHeight) * -2 + 1; // Y์ถ์ ๋ค์ง์์
++ sendMouse(
++ (pos.x / canvas.clientWidth ) * 2 - 1,
++ (pos.y / canvas.clientHeight) * -2 + 1); // Y์ถ์ ๋ค์ง์์
+}
+
+function clearPickPosition() {
+ /**
+ * ๋ง์ฐ์ค์ ๊ฒฝ์ฐ๋ ํญ์ ์์น๊ฐ ์์ด ๊ทธ๋ค์ง ํฐ
+ * ์๊ด์ด ์์ง๋ง, ํฐ์น ๊ฐ์ ๊ฒฝ์ฐ ์ฌ์ฉ์๊ฐ ์๊ฐ๋ฝ์
+ * ๋ผ๋ฉด ํผํน์ ๋ฉ์ถฐ์ผ ํฉ๋๋ค. ์ง๊ธ์ ์ผ๋จ ์ด๋ค ๊ฒ๋
+ * ์ ํํ ์ ์๋ ๊ฐ์ผ๋ก ์ง์ ํด๋์์ต๋๋ค
+ **/
+- pickPosition.x = -100000;
+- pickPosition.y = -100000;
++ sendMouse(-100000, -100000);
+}
+window.addEventListener('mousemove', setPickPosition);
+window.addEventListener('mouseout', clearPickPosition);
+window.addEventListener('mouseleave', clearPickPosition);
+
+window.addEventListener('touchstart', (event) => {
+ event.preventDefault(); // ์คํฌ๋กค ์ด๋ฒคํธ ๋ฐฉ์ง
+ setPickPosition(event.touches[0]);
+}, { passive: false });
+
+window.addEventListener('touchmove', (event) => {
+ setPickPosition(event.touches[0]);
+});
+
+window.addEventListener('touchend', clearPickPosition);
+```
+
+์ด์ `OffscreenCanvas`์์๋ ํผํน์ด ์ ์์ ์ผ๋ก ์๋ํ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-offscreencanvas-w-picking.html" }}}
+
+์ข ๋ ์์ฌ์ ๋ด `OrbitControls`๊น์ง ์ถ๊ฐํด๋ด
์๋ค. `OrbitControls`๋ DOM์ ๊ฝค ๋ค์ํ๊ฒ ์ ๊ทผํ๊ธฐ์ ์ฒ๋ฆฌํด์ค์ผ ํ ๊ฒ์ด ์ข ๋ง์ต๋๋ค. ์ ๋๋ก ์๋ํ๋ ค๋ฉด ๋ง์ฐ์ค ์ด๋ฒคํธ, ํฐ์น ์ด๋ฒคํธ, ํค๋ณด๋ ์ด๋ฒคํธ๋ฅผ ๋ชจ๋ ์ฒ๋ฆฌํด์ค์ผ ํ์ฃ .
+
+์ฌํ๊น์ง๋ ์ ์ญ `state` ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ์ง๋ง, `OrbitControls`์ ๊ฒฝ์ฐ๋ ๊ฐ์ฒด ์์ฑ์ด ๋๋ฌด ๋ง์ ๊ทธ๊ฑธ ์ ๋ถ ๋ค ํ๋ ์ฝ๋ฉํ๋ ๊ฑด ๋๋ฌด ๋ฒ๊ฑฐ๋กญ์ต๋๋ค. `OrbitControls`๋ ํ์ํ DOM ์ด๋ฒคํธ์ ๋๋ถ๋ถ์ ์ธ์๋ก ๋ฐ๋ HTML ์์์ ๋ฐ์ธ๋ฉํฉ๋๋ค. ์ด๋ฅผ ์ด์ฉํด DOM ์์์ ๊ฐ์ ๊ตฌ์กฐ์ ๊ฐ์ฒด๋ฅผ ๋๊ฒจ์ค๋ค๋ฉด ์ด๋จ๊น์? `OrbitControls`์ ํ์ํ ๊ธฐ๋ฅ๋ง ์ด๋ ค์ ๋ง์ด์ฃ .
+
+[`OrbitControls`์ ์์ค ์ฝ๋](https://github.com/gfxfundamentals/threejsfundamentals/blob/master/threejs/resources/threejs/r115/examples/js/controls/OrbitControls.js)๋ฅผ ๋ถ์ํด๋ณด๋ ์๋์ ์ด๋ฒคํธ๋ง ์ง์ํ๋ฉด ๋ ๋ฏํฉ๋๋ค.
+
+* contextmenu
+* mousedown
+* mousemove
+* mouseup
+* touchstart
+* touchmove
+* touchend
+* wheel
+* keydown
+
+๋ง์ฐ์ค ์ด๋ฒคํธ ์ค `OrbitControls`๊ฐ ์ฌ์ฉํ๋ ์์ฑ์ `ctrlKey`, `metaKey`, `shiftKey`, `button`, `clientX`, `clientY`, `pageX`, `pageY`์ด๊ณ ,
+
+keydown ์ด๋ฒคํธ์ ๊ฒฝ์ฐ๋ `ctrlKey`, `metaKey`, `shiftKey`, `keyCode` ์์ฑ,
+
+wheel ์ด๋ฒคํธ๋ `deltaY` ์์ฑ๋ง,
+
+ํฐ์น ์ด๋ฒคํธ์ ๊ฒฝ์ฐ๋ `touches` ์์ฑ์ `pageX`, `pageY` ์์ฑ์ด ํ์ํ๋ค์.
+
+์ด๋ฅผ ์ฒ๋ฆฌํ ๊ฒฝ์ (proxy) ๊ฐ์ฒด๋ฅผ ํ ์ ๋ง๋ค์ด๋ด
์๋ค. ํ์ชฝ์ ๋ฉ์ธ ํ์ด์ง์์ ์ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ ํ์ํ ์์ฑ์ ์์ปค์ ๋๊ฒจ์ฃผ๋ ์ญํ ์ ํ ๊ฒ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ค๋ฅธ ํ์ชฝ์ ์์ปค ์์์ ์ด ์ด๋ฒคํธ๋ฅผ ๋ฐ์ `OrbitControls`์ ๋๊ฒจ์ค ๊ฒ๋๋ค. ์ด๋ฒคํธ ๊ฐ์ฒด๊ฐ DOM ์ด๋ฒคํธ์ ๊ฐ์ ๊ตฌ์กฐ์ด๊ธฐ์ `OrbitControls`๋ ์ด ์ด๋ฒคํธ๊ฐ DOM ์ด๋ฒคํธ๊ฐ ์๋๋ ๊ฑธ ๋์น์ฑ์ง ๋ชปํ๊ฒ ์ฃ .
+
+์๋๋ ์์ปค ์์ ์ฝ๋์
๋๋ค.
+
+```js
+class ElementProxyReceiver extends THREE.EventDispatcher {
+ constructor() {
+ super();
+ }
+ handleEvent(data) {
+ this.dispatchEvent(data);
+ }
+}
+```
+
+์ ์ฝ๋๋ ๋จ์ํ ๋ฉ์์ง๋ฅผ ๋ฐ์์ ๋ ๊ทธ๊ฑธ ๋ค์ ๋ด๋ณด๋ด๋(dispatch) ์ญํ ์ ํฉ๋๋ค. ๋ถ๋ชจ ํด๋์ค์ธ `EventDispatcher`๋ DOM ์์์ฒ๋ผ `addEventListener`๋ `removeEventListener` ๋ฉ์๋๋ฅผ ์ ๊ณตํ๊ธฐ์ HTML ์์ ๋์ ์ด ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ๋๊ฒจ์ค๋ ๋ฌธ์ ์์ด ์๋ํ ๊ฒ๋๋ค.
+
+`ElementProxyReceiver`๋ ํ๋์ ์์๋ง ๋์ ํ ์ ์์ต๋๋ค. ์์ ์ ๊ฒฝ์ฐ ํ๋๋ง ํ์ํ๊ธฐ๋ ํ๋ ๋์ค์ ์บ๋ฒ์ค๋ฅผ ์ฌ๋ฌ ๊ฐ ์ฌ์ฉํ ์๋ ์์ผ๋ ์ฌ๋ฌ `ElementProxyReceiver`๋ฅผ ๊ด๋ฆฌํ๋ ํด๋์ค๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+class ProxyManager {
+ constructor() {
+ this.targets = {};
+ this.handleEvent = this.handleEvent.bind(this);
+ }
+ makeProxy(data) {
+ const { id } = data;
+ const proxy = new ElementProxyReceiver();
+ this.targets[id] = proxy;
+ }
+ getProxy(id) {
+ return this.targets[id];
+ }
+ handleEvent(data) {
+ this.targets[data.id].handleEvent(data.data);
+ }
+}
+```
+
+`ProxyManager`์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค๊ณ id๊ฐ๊ณผ ํจ๊ป `makeProxy` ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด ํด๋น id์๋ง ์๋ตํ๋ `ElementProxyReceiver`๊ฐ ์์ฑ๋ฉ๋๋ค.
+
+์ด์ ์ด ํด๋์ค๋ฅผ ๊ธฐ์กด ์์ปค ์ฝ๋์ ์ฐ๋ํด๋ด
์๋ค.
+
+```js
+const proxyManager = new ProxyManager();
+
+function start(data) {
+ const proxy = proxyManager.getProxy(data.canvasId);
+ init({
+ canvas: data.canvas,
+ inputElement: proxy,
+ });
+}
+
+function makeProxy(data) {
+ proxyManager.makeProxy(data);
+}
+
+...
+
+const handlers = {
+- init,
+- mouse,
++ start,
++ makeProxy,
++ event: proxyManager.handleEvent,
+ size,
+};
+
+self.onmessage = function(e) {
+ const fn = handlers[e.data.type];
+ if (!fn) {
+ throw new Error('no handler for type: ' + e.data.type);
+ }
+ fn(e.data);
+};
+```
+
+`OrbitControls` ๋ชจ๋๋ ๋ถ๋ฌ์์ผ๊ฒ ์ฃ .
+
+```js
+importScripts('resources/threejs/r115/build/three.min/js');
++importScripts('resources/threejs/r115/examples/js/controls/OrbitControls.js');
+*importScripts('shared-orbitcontrols.js');
+```
+
+๊ทธ๋ฆฌ๊ณ ๊ณตํต Three.js ์ฝ๋๋ฅผ ์๋์ ๊ฐ์ด ์์ ํฉ๋๋ค.
+
+```js
+function init(data) {
+- const { canvas } = data;
++ const { canvas, inputElement } = data;
+ const renderer = new THREE.WebGLRenderer({ canvas });
+
++ const controls = new OrbitControls(camera, inputElement);
++ controls.target.set(0, 0, 0);
++ controls.update();
+```
+
+์ ์ฝ๋์์๋ ์ด์ ๊ณผ ๋ฌ๋ฆฌ `inputElement`๋ก ๊ฒฝ์ ๊ฐ์ฒด๋ฅผ `OrbitControls`์ ๋๊ฒจ์คฌ์ต๋๋ค.
+
+ํ๋ ๊น์ ํผํน ์ด๋ฒคํธ๋ ๊ฒฝ์ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋๋ก ๋ฐ๊ฟ๋๋ค.
+
+```js
+function getCanvasRelativePosition(event) {
+- const rect = canvas.getBoundingClientRect();
++ const rect = inputElement.getBoundingClientRect();
+ return {
+ x: event.clientX - rect.left,
+ y: event.clientY - rect.top,
+ };
+}
+
+function setPickPosition(event) {
+ const pos = getCanvasRelativePosition(event);
+- sendMouse(
+- (pos.x / canvas.clientWidth ) * 2 - 1,
+- (pos.y / canvas.clientHeight) * -2 + 1); // Y์ถ์ ๋ค์ง์์
++ pickPosition.x = (pos.x / inputElement.clientWidth ) * 2 - 1;
++ pickPosition.y = (pos.y / inputElement.clientHeight) * -2 + 1; // Y์ถ์ ๋ค์ง์์
+}
+
+function clearPickPosition() {
+ /**
+ * ๋ง์ฐ์ค์ ๊ฒฝ์ฐ๋ ํญ์ ์์น๊ฐ ์์ด ๊ทธ๋ค์ง ํฐ
+ * ์๊ด์ด ์์ง๋ง, ํฐ์น ๊ฐ์ ๊ฒฝ์ฐ ์ฌ์ฉ์๊ฐ ์๊ฐ๋ฝ์
+ * ๋ผ๋ฉด ํผํน์ ๋ฉ์ถฐ์ผ ํฉ๋๋ค. ์ง๊ธ์ ์ผ๋จ ์ด๋ค ๊ฒ๋
+ * ์ ํํ ์ ์๋ ๊ฐ์ผ๋ก ์ง์ ํด๋์์ต๋๋ค
+ **/
+- sendMouse(-100000, -100000);
++ pickPosition.x = -100000;
++ pickPosition.y = -100000;
+}
+
+*inputElement.addEventListener('mousemove', setPickPosition);
+*inputElement.addEventListener('mouseout', clearPickPosition);
+*inputElement.addEventListener('mouseleave', clearPickPosition);
+
+*inputElement.addEventListener('touchstart', (event) => {
+ event.preventDefault(); // ์คํฌ๋กค ์ด๋ฒคํธ ๋ฐฉ์ง
+ setPickPosition(event.touches[0]);
+}, { passive: false });
+
+*inputElement.addEventListener('touchmove', (event) => {
+ setPickPosition(event.touches[0]);
+});
+
+*inputElement.addEventListener('touchend', clearPickPosition);
+```
+
+๋ฉ์ธ ํ์ด์ง์์ ์์ ์ด๊ฑฐํ ๋ชจ๋ ์ด๋ฒคํธ๊ฐ ์์ปค๋ก ๋ฉ์์ง๋ฅผ ๋ณด๋ด๋๋ก ํฉ๋๋ค.
+
+```js
+let nextProxyId = 0;
+class ElementProxy {
+ constructor(element, worker, eventHandlers) {
+ this.id = nextProxyId++;
+ this.worker = worker;
+ const sendEvent = (data) => {
+ this.worker.postMessage({
+ type: 'event',
+ id: this.id,
+ data,
+ });
+ };
+
+ // id๋ฅผ ๋ฑ๋กํฉ๋๋ค.
+ worker.postMessage({
+ type: 'makeProxy',
+ id: this.id,
+ });
+ for (const [eventName, handler] of Object.entries(eventHandlers)) {
+ element.addEventListener(eventName, function(event) {
+ handler(event, sendEvent);
+ });
+ }
+ }
+}
+```
+
+`ElementProxy`๋ ์ด๋ฒคํธ๋ฅผ ์ฐํํ ์์(element)๋ฅผ ์ธ์๋ก ๋ฐ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ณ ์ id๋ฅผ ์์ฑํด ์์ปค์ `makeProxy` ๋ฉ์์ง๋ก id๋ฅผ ๋ฑ๋กํฉ๋๋ค. ๊ทธ๋ฌ๋ฉด ์๊น ๋ง๋ค์๋ฏ ์์ปค๋ ์ด id์ ์๋ก์ด `ElementProxyReceiver`๋ฅผ ์์ฑํ๊ฒ ์ฃ .
+
+๋ค์์ผ๋ก ์ด๋ฒคํธ๋ฅผ ์ฒ๋ฆฌํ ํธ๋ค๋ฌ ๋งต(`eventHandlers`)์ ๋ง๋ญ๋๋ค. ์ด๋ฌ๋ฉด ํด๋น ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋๋ง ์์ปค์ ๋ฉ์์ง๋ฅผ ๋ณด๋ผ ์ ์์ฃ .
+
+์์ปค๋ฅผ ์์ฑํ ๋ `ElementProxy`์ ์ด ํธ๋ค๋ฌ ๋งต์ ๋๊ฒจ ์ ์ฐํ ์์๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
+function startWorker(canvas) {
+ const offscreen = canvas.transferControlToOffscreen();
+ const worker = new Worker('offscreencanvas-worker-orbitcontrols.js');
+
++ const eventHandlers = {
++ contextmenu: preventDefaultHandler,
++ mousedown: mouseEventHandler,
++ mousemove: mouseEventHandler,
++ mouseup: mouseEventHandler,
++ touchstart: touchEventHandler,
++ touchmove: touchEventHandler,
++ touchend: touchEventHandler,
++ wheel: wheelEventHandler,
++ keydown: filteredKeydownEventHandler,
++ };
++ const proxy = new ElementProxy(canvas, worker, eventHandlers);
+ worker.postMessage({
+ type: 'start',
+ canvas: offscreen,
++ canvasId: proxy.id,
+ }, [ offscreen ]);
+ console.log('using OffscreenCanvas'); /* eslint-disable-line no-console */
+}
+```
+
+ํธ๋ค๋ฌ ๋งต์ ํธ๋ค๋ฌ๋ ๋๊ฒจ ๋ฐ์ ์ด๋ฒคํธ์ ์์ฑ ์ค ๋๊ฒจ ๋ฐ์ ํค ๋ฐฐ์ด์ ํด๋นํ๋ ์์ฑ๋ง ๋ณต์ฌํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ `ElementProxy`์์ ๋๊ฒจ ๋ฐ์ `sendEvent` ํจ์๋ฅผ ๋ณต์ฌํ ๋ฐ์ดํฐ์ ํจ๊ป ํธ์ถํ์ฃ . ๊ทธ๋ฌ๋ฉด `sendEvent` ํจ์๋ ํด๋นํ๋ id์ ๋ฐ์ดํฐ๋ฅผ ์์ปค์ ๋ณด๋
๋๋ค.
+
+```js
+const mouseEventHandler = makeSendPropertiesHandler([
+ 'ctrlKey',
+ 'metaKey',
+ 'shiftKey',
+ 'button',
+ 'clientX',
+ 'clientY',
+ 'pageX',
+ 'pageY',
+]);
+const wheelEventHandlerImpl = makeSendPropertiesHandler([
+ 'deltaX',
+ 'deltaY',
+]);
+const keydownEventHandler = makeSendPropertiesHandler([
+ 'ctrlKey',
+ 'metaKey',
+ 'shiftKey',
+ 'keyCode',
+]);
+
+function wheelEventHandler(event, sendFn) {
+ event.preventDefault();
+ wheelEventHandlerImpl(event, sendFn);
+}
+
+function preventDefaultHandler(event) {
+ event.preventDefault();
+}
+
+function copyProperties(src, properties, dst) {
+ for (const name of properties) {
+ dst[name] = src[name];
+ }
+}
+
+function makeSendPropertiesHandler(properties) {
+ return function sendProperties(event, sendFn) {
+ const data = { type: event.type };
+ copyProperties(event, properties, data);
+ sendFn(data);
+ };
+}
+
+function touchEventHandler(event, sendFn) {
+ const touches = [];
+ const data = { type: event.type, touches };
+ for (let i = 0; i < event.touches.length; ++i) {
+ const touch = event.touches[i];
+ touches.push({
+ pageX: touch.pageX,
+ pageY: touch.pageY,
+ });
+ }
+ sendFn(data);
+}
+
+// ํค๋ณด๋์ ํ์ดํ ํค
+const orbitKeys = {
+ '37': true, // ์ผ์ชฝ
+ '38': true, // ์์ชฝ
+ '39': true, // ์ค๋ฅธ์ชฝ
+ '40': true, // ์๋์ชฝ
+};
+function filteredKeydownEventHandler(event, sendFn) {
+ const { keyCode } = event;
+ if (orbitKeys[keyCode]) {
+ event.preventDefault();
+ keydownEventHandler(event, sendFn);
+ }
+}
+```
+
+๊ฑฐ์ ๋ค ๋ ๋ฏํฉ๋๋ค. ํ์ง๋ง ์ค์ ๋ก ์์ ๋ฅผ ์คํํด๋ณด๋ ์์ง ์ฒ๋ฆฌํด์ค์ผ ํ ๊ฒ๋ค์ด ๋ช ๊ฐ ๋ ์๋ค์.
+
+`OrbitControls`๋ `element.focus` ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค. ์ด๋ ์์ปค์์ ๊ทธ๋ค์ง ์ธ๋ชจ๊ฐ ์์ผ๋ ๋น ํจ์๋ก ๋์ฒดํ๊ฒ ์ต๋๋ค.
+
+```js
+class ElementProxyReceiver extends THREE.EventDispatcher {
+ constructor() {
+ super();
+ }
+ handleEvent(data) {
+ this.dispatchEvent(data);
+ }
++ focus() {
++ // ๋น ํจ์(no-operation)
++ }
+}
+```
+
+`event.preventDefault`์ `event.stopPropagation`๋ ์ฌ์ฉํฉ๋๋ค. ์ด๋ ์ด๋ฏธ ๋ฉ์ธ ํ์ด์ง์์ ์ฒ๋ฆฌํ์ผ๋ ์ด ์ญ์ ๋น ํจ์๋ก ๋์ฒดํฉ๋๋ค.
+
+```js
++function noop() {
++}
+
+class ElementProxyReceiver extends THREE.EventDispatcher {
+ constructor() {
+ super();
+ }
+ handleEvent(data) {
++ data.preventDefault = noop;
++ data.stopPropagation = noop;
+ this.dispatchEvent(data);
+ }
+ focus() {
+ // ๋น ํจ์(no-operation)
+ }
+}
+```
+
+๋ `clientWidth`์ `clientHeight`๋ ์ฌ์ฉํฉ๋๋ค. ์ด์ ์๋ ์บ๋ฒ์ค์ ํฌ๊ธฐ๊ฐ์ ๋ฐ๋ก ๋๊ฒจ์คฌ์๋๋ฐ, ๊ฒฝ์ ๊ฐ์ฒด๋ค์ด ์ด ๊ฐ๋ ์ฃผ๊ณ ๋ฐ๋๋ก ์์ ํ๊ฒ ์ต๋๋ค.
+
+์์ปค์ ๊ฒฝ์ฐ ๋ค์์ฒ๋ผ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+class ElementProxyReceiver extends THREE.EventDispatcher {
+ constructor() {
+ super();
+ }
++ get clientWidth() {
++ return this.width;
++ }
++ get clientHeight() {
++ return this.height;
++ }
++ getBoundingClientRect() {
++ return {
++ left: this.left,
++ top: this.top,
++ width: this.width,
++ height: this.height,
++ right: this.left + this.width,
++ bottom: this.top + this.height,
++ };
++ }
+ handleEvent(data) {
++ if (data.type === 'size') {
++ this.left = data.left;
++ this.top = data.top;
++ this.width = data.width;
++ this.height = data.height;
++ return;
++ }
+ data.preventDefault = noop;
+ data.stopPropagation = noop;
+ this.dispatchEvent(data);
+ }
+ focus() {
+ // ๋น ํจ์(no-operation)
+ }
+}
+```
+
+์ด์ ๋ฉ์ธ ํ์ด์ง์์ ์บ๋ฒ์ค์ ํฌ๊ธฐ์ ์์น ์ขํ๋ฅผ ๋๊ฒจ์ค์ผ ํฉ๋๋ค. ํ๋ ์ธ๊ธํ๊ณ ์ถ์ ๊ฑด ์์ ์์๋ ์บ๋ฒ์ค์ ํฌ๊ธฐ๊ฐ ๋ฐ๋๋ ๊ฒฝ์ฐ๋ง ๊ฐ์ ํ์ง, ์บ๋ฒ์ค๊ฐ ์์ง์ด๋ ๊ฒฝ์ฐ๋ ๊ฐ์ ํ์ง ์์๋ค๋ ์ ์
๋๋ค. ์บ๋ฒ์ค๊ฐ ์์ง์ด๋ ๊ฒฝ์ฐ๋ฅผ ์ฒ๋ฆฌํ๋ ค๋ฉด ์บ๋ฒ์ค๊ฐ ์์ง์์ ๋ `sendSize`๋ฅผ ํธ์ถํ๋ฉด ๋ฉ๋๋ค.
+
+```js
+class ElementProxy {
+ constructor(element, worker, eventHandlers) {
+ this.id = nextProxyId++;
+ this.worker = worker;
+ const sendEvent = (data) => {
+ this.worker.postMessage({
+ type: 'event',
+ id: this.id,
+ data,
+ });
+ };
+
+ // id๋ฅผ ๋ฑ๋กํฉ๋๋ค.
+ worker.postMessage({
+ type: 'makeProxy',
+ id: this.id,
+ });
++ sendSize();
+ for (const [eventName, handler] of Object.entries(eventHandlers)) {
+ element.addEventListener(eventName, function(event) {
+ handler(event, sendEvent);
+ });
+ }
+
++ function sendSize() {
++ const rect = element.getBoundingClientRect();
++ sendEvent({
++ type: 'size',
++ left: rect.left,
++ top: rect.top,
++ width: element.clientWidth,
++ height: element.clientHeight,
++ });
++ }
++
++ window.addEventListener('resize', sendSize);
+ }
+}
+```
+
+์ด์ ๊ณตํต Three.js ์ฝ๋์์ `state` ์ ์ญ ๋ณ์๋ฅผ ์ฐ์ง ์์ผ๋ ์ญ์ ํฉ๋๋ค.
+
+```js
+-const state = {
+- width: 300, // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+- height: 150, // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+-};
+
+...
+
+function resizeRendererToDisplaySize(renderer) {
+ const canvas = renderer.domElement;
+- const width = state.width;
+- const height = state.height;
++ const width = inputElement.clientWidth;
++ const height = inputElement.clientHeight;
+ const needResize = canvas.width !== width || canvas.height !== height;
+ if (needResize) {
+ renderer.setSize(width, height, false);
+ }
+ return needResize;
+}
+
+function render(time) {
+ time *= 0.001;
+
+ if (resizeRendererToDisplaySize(renderer)) {
+- camera.aspect = state.width / state.height;
++ camera.aspect = inputElement.clientWidth / inputElement.clientHeight;
+ camera.updateProjectionMatrix();
+ }
+
+ ...
+```
+
+`OrbitControls`๋ ํค๋ณด๋ ์ด๋ฒคํธ๋ฅผ ๊ฐ์งํ๊ธฐ ์ํด `window`์ ์ด๋ฒคํธ ๋ฆฌ์ค๋๋ฅผ ๋ฐ์ธ๋ฉํฉ๋๋ค. ์ด๊ฒ ์ข์ ๋ฐฉ์์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ง๋ง, ์์ค ์ฝ๋๋ฅผ ์ง์ ์์ ํ์ง ์๋ ํ ์ด ๋์์ ๊ณ ์น ์๋ ์์ต๋๋ค. ์์ปค์๋ `window` ๊ฐ์ฒด๊ฐ ์กด์ฌํ์ง ์๊ฑฐ๋ ์.
+
+๋ `document`์ `mousemove`์ `mouseup` ์ด๋ฒคํธ๋ ์ฌ์ฉํฉ๋๋ค. ์ด๋ ๋ง์ฐ์ค๊ฐ ์ฐฝ ๋ฐ์ผ๋ก ๋๊ฐ๋ค๋ ๊ฐ ํ๋ ๊ฒฝ์ฐ์๋ ๋ง์ฐ์ค์ ์์ง์์ ๊ฐ์งํ๊ธฐ ์ํ ๊ฒ์ด์ง๋ง, `window`์ ๋ง์ฐฌ๊ฐ์ง๋ก ์์ปค์๋ `document` ๊ฐ์ฒด๊ฐ ์์ต๋๋ค.
+
+๊ฑฐ๊ธฐ๋ค `OrbitControls`์ ๋๊ฒจ์ค ์์๊ฐ `document`์ ์ผ์นํ๋์ง์ ์ฌ๋ถ๋ ๊ฒ์ฌํฉ๋๋ค.
+
+์ด ๋ฌธ์ ๋ ๊ฐ๋จํ ํธ๋ฒ(hack)์ ์จ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ค์ ํ ๋ฒ ์์ปค์ ๊ฒฝ์ ๊ฐ์ฒด๋ฅผ ์ด์ฉํ๋๋ก ํ์ฃ .
+
+```js
+function start(data) {
+ const proxy = proxyManager.getProxy(data.canvasId);
++ self.window = proxy; // HACK!
++ self.document = { // HACK!
++ addEventListener: proxy.addEventListener.bind(proxy),
++ removeEventListener: proxy.removeEventListener.bind(proxy),
++ };
+ init({
+ canvas: data.canvas,
+ inputElement: proxy,
+ });
+}
+```
+
+์ด๋ฌ๋ฉด `OrbitControls`๊ฐ ์๋ฌ๋ฅผ ๋์ง์ง ์์ ๊ฒ๋๋ค.
+
+์์ ๊ฐ ๋ณต์กํด ์ดํดํ๊ธฐ ์ด๋ ค์ ์ ์ ์์ต๋๋ค. ๋์์ ์์ฝํ์๋ฉด `ElementProxy`๊ฐ ๋ฉ์ธ ํ์ด์ง์ DOM ์ด๋ฒคํธ๋ฅผ ์์ปค์ `ElementProxyReceiver`์ ๋๊ธฐ๊ณ , `ElementProxyReceiver`๋ `HTMLElement`๋ฅผ ๊ฐ์ฅํด `OrbitControls`์ ๊ณตํต ์ฝ๋์์ ์ธ ์ ์๋ ๋์ฒด DOM ์์๋ก ๊ธฐ๋ฅํฉ๋๋ค.
+
+๋ง์ง๋ง์ผ๋ก `OffscreenCanvas`๋ฅผ ์ง์ํ์ง ์๋ ๊ฒฝ์ฐ์ ์์ธ ์ฝ๋๋ง ์์ ํด์ฃผ๋ฉด ๋์
๋๋ค. ๊ฐ๋จํ `inputElement`์ ์บ๋ฒ์ค ์์์์ฒด๋ฅผ ๋๊ฒจ์ฃผ๊ธฐ๋ง ํ๋ฉด ๋์ฃ .
+
+```js
+function startMainPage(canvas) {
+- init({ canvas });
++ init({ canvas, inputElement: canvas });
+ console.log('using regular canvas');
+}
+```
+
+์ด์ `OffscreenCanvas`์์๋ `OrbitControls`๊ฐ ์ ์๋ํฉ๋๋ค.
+
+{{{example url="../threejs-offscreencanvas-w-orbitcontrols.html" }}}
+
+์๋ง ์ด ์์ ๊ฐ ์ด ์๋ฆฌ์ฆ๋ฅผ ํตํ์ด ๊ฐ์ฅ ๋ณต์กํ ์์ ์ผ ๊ฒ๋๋ค. ๊ฐ ์์ ๋ง๋ค HTML ํ์ผ, ์์ปค ํ์ผ, ๊ณตํต Three.js ์ฝ๋ ํ์ผ, ์ด๋ ๊ฒ ํ์ผ 3๊ฐ๊ฐ ์๋ก ์ฐ๋๋๋ ๊ทธ๋ด๋ง ํ์ฃ .
+
+์ด ๊ธ์ด ๋๋ฌด ์ด๋ ต๊ฒ ๋๊ปด์ง์ง ์์๋ค๋ฉด ์ข๊ฒ ์ต๋๋ค. ๋ํ Three.js์์ OffscreenCanvas์ ์น ์์ปค๋ฅผ ํ์ฉํ๋ ์ข์ ์๊ฐ ๋์๊ธธ ๋ฐ๋๋๋ค. | false |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-multiple-scenes.md | @@ -0,0 +1,696 @@
+Title: Three.js๋ก ์บ๋ฒ์ค, ์ฅ๋ฉด ์ฌ๋ฌ ๊ฐ ๋ง๋ค๊ธฐ
+Description: THREE.js๋ก ๋ค์์ ์ฅ๋ฉด์ ๋ ๋๋งํด๋ด
๋๋ค
+TOC: ๋ค์ค ์บ๋ฒ์ค, ๋ค์ค ์ฅ๋ฉด ๋ง๋ค๊ธฐ
+
+์ฌ๋๋ค์ด ์์ฃผ ํ๋ ์ง๋ฌธ ์ค ํ๋๋ Three.js๋ก ์ฌ๋ฌ ๊ฐ์ ์บ๋ฒ์ค(canvas)๋ฅผ ๋ ๋๋งํ๋ ค๋ฉด
+์ด๋ป๊ฒ ํด์ผ ํ๋์?"์
๋๋ค. ์ผํ๋ชฐ ์ฌ์ดํธ๋ 3D ๋ํ๊ฐ ์ฌ๋ฌ ๊ฐ ์๋ ์น ํ์ด์ง๋ฅผ
+์ ์ํ๋ค๊ณ ํด๋ด
์๋ค. ์ผํ ๊ทธ๋ฆฌ ์ด๋ ค์ธ ๊ฑด ์์ด ๋ณด์
๋๋ค. ๊ทธ๋ฅ ๋ํ๊ฐ ๋ค์ด๊ฐ ๊ณณ๋ง๋ค
+๊ฐ๊ฐ ์บ๋ฒ์ค๋ฅผ ๋ง๋ค๊ณ , ๊ฐ ์บ๋ฒ์ค๋ง๋ค `Renderer`๋ฅผ ์์ฑํ๋ฉด ๋์ง ์์๊น์?
+
+ํ์ง๋ง ์ด ๋ฐฉ๋ฒ์ ์ ์ฉํ์๋ง์ ๋ฌธ์ ๊ฐ ์๊น๋๋ค.
+
+1. ๋ธ๋ผ์ฐ์ ์ WebGL ์ปจํ
์คํธ(context)๋ ์ ํ์ ์ด๋ค.
+
+ ์ผ๋ฐ์ ์ผ๋ก ์ฝ 8๊ฐ๊ฐ ์ต๋์
๋๋ค. 9๋ฒ์งธ ์ปจํ
์คํธ๋ฅผ ๋ง๋ค๋ฉด ์ ์ผ ์ฒ์์ ๋ง๋ค์๋
+ ์ปจํ
์คํธ๊ฐ ์ฌ๋ผ์ง์ฃ .
+
+2. WebGL ์์์ ์ปจํ
์คํธ๋ผ๋ฆฌ ๊ณต์ ํ ์ ์๋ค.
+
+ 10MB์ง๋ฆฌ ๋ชจ๋ธ์ ์บ๋ฒ์ค ๋ ๊ฐ์์ ์ฌ์ฉํ๋ ค๋ฉด ๋ชจ๋ธ์ ๊ฐ๊ฐ ์ด ๋ ๋ฒ ๋ก๋ํด์ผ ํ๊ณ ,
+ ์๋์ ๋ ๋ฐฐ์ธ 20MB์ ์์์ ์ฌ์ฉํ๋ค๋ ์๋ฏธ์
๋๋ค. ์ปจํ
์คํธ๋ผ๋ฆฌ๋ ์ด๋ค ๊ฒ๋ ๊ณต์ ํ
+ ์ ์์ฃ . ๋ํ ์ด๊ธฐํ๋ ๋ ๋ฒ, ์์ด๋ ์ปดํ์ผ๋ ๋ ๋ฒ, ๊ฐ์ ๋์์ ๋ชจ๋ ๋ ๋ฒ์ฉ
+ ์คํํด์ผ ํฉ๋๋ค. ์บ๋ฒ์ค์ ๊ฐ์๊ฐ ๋ง์์ง์๋ก ์ฑ๋ฅ์ ๋ฌธ์ ๊ฐ ์๊ธฐ๊ฒ ์ฃ .
+
+๊ทธ๋ ๋ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํ ๊น์?
+
+๋ฐฉ๋ฒ ์ค ํ๋๋ ์บ๋ฒ์ค ํ๋๋ก ํ๋ฉด ์ ์ฒด๋ฅผ ์ฑ์ฐ๊ณ , ๊ฐ "๊ฐ์" ์บ๋ฒ์ค๋ฅผ ๋์ ํ HTML ์์(element)๋ฅผ
+๋๋ ๊ฒ๋๋ค. `Renderer`๋ ํ๋๋ง ๋ง๋ค๋ ๊ฐ์ ์บ๋ฒ์ค์ ๊ฐ๊ฐ `Scene`์ ๋ง๋๋ ๊ฑฐ์ฃ . ๊ทธ๋ฆฌ๊ณ
+๊ฐ์ HTML ์์์ ์ขํ๋ฅผ ๊ณ์ฐํด ์์๊ฐ ํ๋ฉด์ ๋ณด์ธ๋ค๋ฉด Three.js๊ฐ ํด๋น ์ฅ๋ฉด(scene)์ ๊ฐ์
+์์์ ์ขํ์ ๋ง์ถฐ ๋ ๋๋งํ๋๋ก ํฉ๋๋ค.
+
+์ด ๋ฐฉ๋ฒ์ ์บ๋ฒ์ค๋ฅผ ํ๋๋ง ์ฌ์ฉํ๋ฏ๋ก ์ 1๋ฒ๊ณผ 2๋ฒ ๋ฌธ์ ๋ชจ๋ ํด๊ฒฐํ ์ ์์ต๋๋ค. ์ปจํ
์คํธ๋ฅผ
+ํ๋๋ง ์ฌ์ฉํ๋ WebGL ์ปจํ
์คํธ ์ ํ์ ๊ฑฑ์ ํ ์ผ๋ ์๊ณ , ์์์ ๋ช ๋ฐฐ์ฉ ๋ ์ฌ์ฉํ ์ผ๋ ์์ฃ .
+
+2๊ฐ์ ์ฅ๋ฉด๋ง ๋ง๋ค์ด ๊ฐ๋จํ ํ
์คํธ๋ฅผ ํด๋ณด๊ฒ ์ต๋๋ค. ๋จผ์ HTML์ ์์ฑํฉ๋๋ค.
+
+```html
+<canvas id="c"></canvas>
+<p>
+ <span id="box" class="diagram left"></span>
+ I love boxes. Presents come in boxes.
+ When I find a new box I'm always excited to find out what's inside.
+</p>
+<p>
+ <span id="pyramid" class="diagram right"></span>
+ When I was a kid I dreamed of going on an expedition inside a pyramid
+ and finding a undiscovered tomb full of mummies and treasure.
+</p>
+```
+
+๋ค์์ผ๋ก CSS๋ฅผ ์์ฑํฉ๋๋ค.
+
+```css
+#c {
+ position: fixed;
+ left: 0;
+ top: 0;
+ width: 100vw;
+ height: 100vh;
+ display: block;
+ z-index: -1;
+}
+.diagram {
+ display: inline-block;
+ width: 5em;
+ height: 3em;
+ border: 1px solid black;
+}
+.left {
+ float: left;
+ margin-right: .25em;
+}
+.right {
+ float: right;
+ margin-left: .25em;
+}
+```
+
+์บ๋ฒ์ค๊ฐ ํ๋ฉด ์ ์ฒด๋ฅผ ์ฑ์ฐ๋๋ก ํ๊ณ `z-index`๋ฅผ -1๋ก ์ค์ ํด ๋ค๋ฅธ ์์ ๋ค๋ก ๊ฐ๋๋ก ํ์ต๋๋ค.
+๊ฐ์ ์์์ ์ปจํ
์ธ ๊ฐ ์์ด ํฌ๊ธฐ๊ฐ 0์ด๋ ๋ณ๋์ width์ height๋ ์ง์ ํด์คฌ์ต๋๋ค.
+
+์ด์ ๊ฐ๊ฐ์ ์นด๋ฉ๋ผ์ ์กฐ๋ช
์ด ์๋ ์ฅ๋ฉด 2๊ฐ๋ฅผ ๋ง๋ญ๋๋ค. ํ๋์๋ ์ ์ก๋ฉด์ฒด, ๋ค๋ฅธ ํ๋์๋
+๋ค์ด์๋ชฌ๋ ๋ชจ์์ ๋ฃ์ ๊ฒ๋๋ค.
+
+```js
+function makeScene(elem) {
+ const scene = new THREE.Scene();
+
+ const fov = 45;
+ const aspect = 2; // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+ const near = 0.1;
+ const far = 5;
+ const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+ camera.position.z = 2;
+ camera.position.set(0, 1, 2);
+ camera.lookAt(0, 0, 0);
+
+ {
+ const color = 0xFFFFFF;
+ const intensity = 1;
+ const light = new THREE.DirectionalLight(color, intensity);
+ light.position.set(-1, 2, 4);
+ scene.add(light);
+ }
+
+ return { scene, camera, elem };
+}
+
+function setupScene1() {
+ const sceneInfo = makeScene(document.querySelector('#box'));
+ const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
+ const material = new THREE.MeshPhongMaterial({color: 'red'});
+ const mesh = new THREE.Mesh(geometry, material);
+ sceneInfo.scene.add(mesh);
+ sceneInfo.mesh = mesh;
+ return sceneInfo;
+}
+
+function setupScene2() {
+ const sceneInfo = makeScene(document.querySelector('#pyramid'));
+ const radius = .8;
+ const widthSegments = 4;
+ const heightSegments = 2;
+ const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ const material = new THREE.MeshPhongMaterial({
+ color: 'blue',
+ flatShading: true,
+ });
+ const mesh = new THREE.Mesh(geometry, material);
+ sceneInfo.scene.add(mesh);
+ sceneInfo.mesh = mesh;
+ return sceneInfo;
+}
+
+const sceneInfo1 = setupScene1();
+const sceneInfo2 = setupScene2();
+```
+
+์ด์ ๊ฐ ์์๊ฐ ํ๋ฉด์ ๋ณด์ผ ๋๋ง ์ฅ๋ฉด์ ๋ ๋๋งํ ํจ์๋ฅผ ๋ง๋ญ๋๋ค. `Renderer.setScissorTest`๋ฅผ
+ํธ์ถํด *๊ฐ์(scissor)* ํ
์คํธ๋ฅผ ํ์ฑํํ๋ฉด Three.js๊ฐ ์บ๋ฒ์ค์ ํน์ ๋ถ๋ถ๋ง ๋ ๋๋งํ๋๋ก
+ํ ์ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ `Renderer.setScissor`๋ก ๊ฐ์๋ฅผ ์ค์ ํ ๋ค `Renderer.setViewport`๋ก
+์ฅ๋ฉด์ ์ขํ๋ฅผ ์ค์ ํฉ๋๋ค.
+
+```js
+function renderSceneInfo(sceneInfo) {
+ const { scene, camera, elem } = sceneInfo;
+
+ // ํด๋น ์์์ ํ๋ฉด ๋๋น ์ขํ๋ฅผ ๊ฐ์ ธ์ต๋๋ค
+ const { left, right, top, bottom, width, height } =
+ elem.getBoundingClientRect();
+
+ const isOffscreen =
+ bottom < 0 ||
+ top > renderer.domElement.clientHeight ||
+ right < 0 ||
+ left > renderer.domElement.clientWidth;
+
+ if (isOffscreen) {
+ return;
+ }
+
+ camera.aspect = width / height;
+ camera.updateProjectionMatrix();
+
+ const positiveYUpBottom = canvasRect.height - bottom;
+ renderer.setScissor(left, positiveYUpBottom, width, height);
+ renderer.setViewport(left, positiveYUpBottom, width, height);
+
+ renderer.render(scene, camera);
+}
+```
+
+๋ค์์ผ๋ก `render` ํจ์ ์์์ ๋จผ์ ์บ๋ฒ์ค ์ ์ฒด๋ฅผ ๋น์ด ๋ค ๊ฐ ์ฅ๋ฉด์ ๋ ๋๋งํฉ๋๋ค.
+
+```js
+function render(time) {
+ time *= 0.001;
+
+ resizeRendererToDisplaySize(renderer);
+
+ renderer.setScissorTest(false);
+ renderer.clear(true, true);
+ renderer.setScissorTest(true);
+
+ sceneInfo1.mesh.rotation.y = time * .1;
+ sceneInfo2.mesh.rotation.y = time * .1;
+
+ renderSceneInfo(sceneInfo1);
+ renderSceneInfo(sceneInfo2);
+
+ requestAnimationFrame(render);
+}
+```
+
+๊ฒฐ๊ณผ๋ฅผ ํ์ธํด๋ณผ๊น์?
+
+{{{example url="../threejs-multiple-scenes-v1.html" }}}
+
+์ฒซ ๋ฒ์งธ `<span>` ์์๊ฐ ์๋ ๊ณณ์๋ ๋นจ๊ฐ ์ ์ก๋ฉด์ฒด๊ฐ, ๋ ๋ฒ์งธ `<span>` ์์๊ฐ ์๋ ๊ณณ์๋
+ํ๋ ๋ค์ด์๋ชฌ๋๊ฐ ๋ณด์ผ ๊ฒ๋๋ค.
+
+## ๋๊ธฐํํ๊ธฐ
+
+์ ์ฝ๋๋ ๋์์ง ์์ง๋ง ์์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋ณต์กํ ์ฅ๋ฉด ๋ฑ ๋ฌด์จ ์ด์ ๋ผ๋ ๋ ๋๋งํ๋
+๋ฐ ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆฐ๋ค๋ฉด, ์ฅ๋ฉด์ ์ขํ๋ ํ์ด์ง์ ๋ค๋ฅธ ์ปจํ
์ธ ์ ๋นํด ๋๋๊ฒ ๋ด๋ ค์ฌ ๊ฒ๋๋ค.
+
+๊ฐ ๊ฐ์ ์์์ ํ
๋๋ฆฌ๋ฅผ ๋ฃ๊ณ
+
+```css
+.diagram {
+ display: inline-block;
+ width: 5em;
+ height: 3em;
++ border: 1px solid black;
+}
+```
+
+๊ฐ ์ฅ๋ฉด์ ๋ฐฐ๊ฒฝ์๋ ๋ฃ์ด์ค๋๋ค.
+
+```js
+const scene = new THREE.Scene();
++scene.background = new THREE.Color('red');
+```
+
+๊ทธ๋ฐ ๋ค์ <a href="../threejs-multiple-scenes-v2.html" target="_blank">๋น ๋ฅด๊ฒ ์คํฌ๋กค์ ์์๋๋ก ๋ฐ๋ณตํด๋ณด๋ฉด</a>
+๋ฌธ์ ๊ฐ ๋ณด์ผ๊ฒ๋๋ค. ์๋๋ ์คํฌ๋กค ์ ๋๋ฉ์ด์
์บก์ณ๋ณธ์ ์๋๋ฅผ 10๋ฐฐ ๋ฎ์ถ ์์์
๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/multi-view-skew.gif"></div>
+
+์ถ๊ฐ๋ก ์ฒ๋ฆฌํด์ค์ผ ํ ๊ฒ์ด ์๊ธด ํ์ง๋ง, ์บ๋ฒ์ค์ CSS๋ฅผ `position: fixed`์์ `position: absolute`๋ก
+๋ฐ๊ฟ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค.
+
+```css
+#c {
+- position: fixed;
++ position: absolute;
+```
+
+๊ทธ๋ฆฌ๊ณ ํ์ด์ง ์คํฌ๋กค์ ์๊ด ์์ด ์บ๋ฒ์ค๊ฐ ํญ์ ํ๋ฉด์ ์๋จ์ ์์นํ ์ ์๋๋ก ์บ๋ฒ์ค์
+transform ์คํ์ผ์ ์ง์ ํด์ค๋๋ค.
+
+```js
+function render(time) {
+ ...
+
+ const transform = `translateY(${ window.scrollY }px)`;
+ renderer.domElement.style.transform = transform;
+
+```
+
+์บ๋ฒ์ค์ `position: fixed`๋ฅผ ์ ์ฉํ๋ฉด ์บ๋ฒ์ค๋ ์คํฌ๋กค์ ์ํฅ์ ๋ฐ์ง ์์ต๋๋ค. `position: absolute`๋ฅผ
+์ ์ฉํ๋ฉด ๋ ๋๋งํ๋ ๋ฐ ์๊ฐ์ด ๊ฑธ๋ฆฌ๋๋ผ๋ ์ผ๋จ ๋ค๋ฅธ ํ์ด์ง์ ๊ฐ์ด ์คํฌ๋กค์ด ๋๊ฒ ์ฃ . ๊ทธ๋ฆฌ๊ณ
+๋ ๋๋งํ๊ธฐ ์ ์ ์บ๋ฒ์ค๋ฅผ ๋ค์ ์์ง์ฌ ํ๋ฉด ์ ์ฒด์ ๋ง์ถ ๋ค ์บ๋ฒ์ค๋ฅผ ๋ ๋๋งํ๋ ๊ฒ๋๋ค. ์ด๋ฌ๋ฉด
+ํ๋ฉด์ ๊ฐ์ฅ์๋ฆฌ์ ์ด์ง ๋ ๋๋ง๋์ง ์์ ๋ถ๋ถ์ด ๋ณด์ผ ์๋ ์์ด๋ ๋๋จธ์ง ํ์ด์ง์ ์๋ ์์๋
+๋ฒ๋ฒ
์ด์ง ์๊ณ ์ ์๋ฆฌ์ ์์ ๊ฒ๋๋ค. ์๋๋ ํด๋น ์ฝ๋๋ฅผ ์ ์ฉํ ํ๋ฉด์ ์บก์ณ๋ณธ์ ์๊น์ ๋ง์ฐฌ๊ฐ์ง๋ก
+10๋ฐฐ ๋๋ฆฌ๊ฒ ๋ง๋ ๊ฒ์
๋๋ค.
+
+<div class="threejs_center"><img class="border" src="resources/images/multi-view-fixed.gif"></div>
+
+## ํ์ฅํ๊ธฐ ์ฝ๊ฒ ๋ง๋ค๊ธฐ
+
+์ฌ๋ฌ ์ฅ๋ฉด์ ๊ตฌํํ์ผ๋ ์ด์ ์ด ์์ ๋ฅผ ์ข ๋ ํ์ฅํ๊ธฐ ์ฝ๊ฒ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค.
+
+๋จผ์ ๊ธฐ์กด์ฒ๋ผ ์บ๋ฒ์ค ์ ์ฒด๋ฅผ ๋ ๋๋งํ๋ `render` ํจ์๋ฅผ ๋๊ณ , ๊ฐ ์ฅ๋ฉด์ ํด๋นํ๋ ๊ฐ์ ์์,
+ํด๋น ์ฅ๋ฉด์ ๋ ๋๋งํ๋ ํจ์๋ก ์ด๋ฃจ์ด์ง ๊ฐ์ฒด์ ๋ฐฐ์ด์ ๋ง๋ญ๋๋ค. `render` ํจ์์์ ๊ฐ์ ์์๊ฐ
+ํ๋ฉด์ ๋ณด์ด๋์ง ํ์ธํ ๋ค, ๊ฐ์ ์์๊ฐ ํ๋ฉด์ ๋ณด์ธ๋ค๋ฉด ์์ํ๋ ๋ ๋๋ง ํจ์๋ฅผ ํธ์ถํฉ๋๋ค. ์ด๋ฌ๋ฉด
+ํ์ฅ์ฑ์ ๋ฌผ๋ก ๊ฐ ์ฅ๋ฉด์ ๋ ๋๋ง ํจ์๋ฅผ ์์ฑํ ๋๋ ์ ์ฒด๋ฅผ ์ ๊ฒฝ์ธ ํ์๊ฐ ์์ฃ .
+
+์๋๋ ์ ์ฒด๋ฅผ ๋ด๋นํ๋ `render` ํจ์์
๋๋ค.
+
+```js
+const sceneElements = [];
+function addScene(elem, fn) {
+ sceneElements.push({ elem, fn });
+}
+
+function render(time) {
+ time *= 0.001;
+
+ resizeRendererToDisplaySize(renderer);
+
+ renderer.setScissorTest(false);
+ renderer.setClearColor(clearColor, 0);
+ renderer.clear(true, true);
+ renderer.setScissorTest(true);
+
+ const transform = `translateY(${ window.scrollY }px)`;
+ renderer.domElement.style.transform = transform;
+
+ for (const { elem, fn } of sceneElements) {
+ // ํด๋น ์์์ ํ๋ฉด ๋๋น ์ขํ๋ฅผ ๊ฐ์ ธ์ต๋๋ค
+ const rect = elem.getBoundingClientRect();
+ const {left, right, top, bottom, width, height} = rect;
+
+ const isOffscreen =
+ bottom < 0 ||
+ top > renderer.domElement.clientHeight ||
+ right < 0 ||
+ left > renderer.domElement.clientWidth;
+
+ if (!isOffscreen) {
+ const positiveYUpBottom = renderer.domElement.clientHeight - bottom;
+ renderer.setScissor(left, positiveYUpBottom, width, height);
+ renderer.setViewport(left, positiveYUpBottom, width, height);
+
+ fn(time, rect);
+ }
+ }
+
+ requestAnimationFrame(render);
+}
+```
+
+`render` ํจ์๋ `elem`๊ณผ `fn` ์์ฑ์ ๊ฐ์ฒด๋ก ์ด๋ฃจ์ด์ง `sceneElements` ๋ฐฐ์ด์ ์ํํฉ๋๋ค.
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ ์์๊ฐ ํ๋ฉด์ ๋ณด์ด๋์ง ํ์ธํ๊ณ , ํ๋ฉด์ ๋ณด์ธ๋ค๋ฉด `fn`์ ํด๋น ์ฅ๋ฉด์ด ๋ค์ด๊ฐ์ผํ
+์ฌ๊ฐ ์ขํ์ ํ์ฌ ์๊ฐ๊ฐ์ ๋๊ฒจ์ฃผ์ด ํธ์ถํฉ๋๋ค.
+
+์ด์ ๊ฐ ์ฅ๋ฉด์ ๋ง๋ค๊ณ ์์ํ๋ ์์์ ๋ ๋๋ง ํจ์๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+{
+ const elem = document.querySelector('#box');
+ const { scene, camera } = makeScene();
+ const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
+ const material = new THREE.MeshPhongMaterial({ color: 'red' });
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ addScene(elem, (time, rect) => {
+ camera.aspect = rect.width / rect.height;
+ camera.updateProjectionMatrix();
+ mesh.rotation.y = time * .1;
+ renderer.render(scene, camera);
+ });
+}
+
+{
+ const elem = document.querySelector('#pyramid');
+ const { scene, camera } = makeScene();
+ const radius = .8;
+ const widthSegments = 4;
+ const heightSegments = 2;
+ const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ const material = new THREE.MeshPhongMaterial({
+ color: 'blue',
+ flatShading: true,
+ });
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ addScene(elem, (time, rect) => {
+ camera.aspect = rect.width / rect.height;
+ camera.updateProjectionMatrix();
+ mesh.rotation.y = time * .1;
+ renderer.render(scene, camera);
+ });
+}
+```
+
+`sceneInfo1`, `sceneInfo2`๋ ๋ ์ด์ ํ์ ์์ผ๋ ์ ๊ฑฐํฉ๋๋ค. ๋์ ๊ฐ mesh์ ํ์ ์ ํด๋น
+์ฅ๋ฉด์์ ์ฒ๋ฆฌํด์ผ ํฉ๋๋ค.
+
+{{{example url="../threejs-multiple-scenes-generic.html" }}}
+
+## HTML Dataset ์ฌ์ฉํ๊ธฐ
+
+HTML์ [dataset](https://developer.mozilla.org/ko/docs/Web/API/HTMLElement/dataset)์
+์ด์ฉํ๋ฉด ์ข ๋ ํ์ฅํ๊ธฐ ์ฌ์ด ํ๊ฒฝ์ ๋ง๋ค ์ ์์ต๋๋ค. `id="..."` ๋์ `data-diagram="..."`์
+์ด์ฉํด ๋ฐ์ดํฐ๋ฅผ ์ง์ HTML ์์์ ์ง์ ํ๋ ๊ฑฐ์ฃ .
+
+```html
+<canvas id="c"></canvas>
+<p>
+- <span id="box" class="diagram left"></span>
++ <span data-diagram="box" class="left"></span>
+ I love boxes. Presents come in boxes.
+ When I find a new box I'm always excited to find out what's inside.
+</p>
+<p>
+- <span id="pyramid" class="diagram left"></span>
++ <span data-diagram="pyramid" class="right"></span>
+ When I was a kid I dreamed of going on an expedition inside a pyramid
+ and finding a undiscovered tomb full of mummies and treasure.
+</p>
+```
+
+์์์ id๋ฅผ ์ ๊ฑฐํ์ผ๋ CSS ์
๋ ํฐ๋ ๋ค์์ฒ๋ผ ๋ฐ๊พธ์ด์ผ ํฉ๋๋ค.
+
+```css
+-.diagram
++*[data-diagram] {
+ display: inline-block;
+ width: 5em;
+ height: 3em;
+}
+```
+
+๋ํ ๊ฐ ์ฅ๋ฉด์ ๋ง๋๋ ์ฝ๋๋ฅผ *scene initialization functions*๋ผ๋ ๋งต์ผ๋ก ๋ง๋ญ๋๋ค.
+์ด ๋งต์ ํค๊ฐ์ ๋์ํ๋ *์ฅ๋ฉด ๋ ๋๋ง ํจ์*๋ฅผ ๋ฐํํ ๊ฒ๋๋ค.
+
+```js
+const sceneInitFunctionsByName = {
+ 'box': () => {
+ const { scene, camera } = makeScene();
+ const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
+ const material = new THREE.MeshPhongMaterial({color: 'red'});
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ return (time, rect) => {
+ mesh.rotation.y = time * .1;
+ camera.aspect = rect.width / rect.height;
+ camera.updateProjectionMatrix();
+ renderer.render(scene, camera);
+ };
+ },
+ 'pyramid': () => {
+ const { scene, camera } = makeScene();
+ const radius = .8;
+ const widthSegments = 4;
+ const heightSegments = 2;
+ const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ const material = new THREE.MeshPhongMaterial({
+ color: 'blue',
+ flatShading: true,
+ });
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ return (time, rect) => {
+ mesh.rotation.y = time * .1;
+ camera.aspect = rect.width / rect.height;
+ camera.updateProjectionMatrix();
+ renderer.render(scene, camera);
+ };
+ },
+};
+```
+
+๊ทธ๋ฆฌ๊ณ `querySelectorAll`๋ก ๊ฐ์ ์์๋ฅผ ์ ๋ถ ๋ถ๋ฌ์ ํด๋น ์์์ ์์ํ๋ ๋ ๋๋ง ํจ์๋ฅผ
+์คํํฉ๋๋ค.
+
+```js
+document.querySelectorAll('[data-diagram]').forEach((elem) => {
+ const sceneName = elem.dataset.diagram;
+ const sceneInitFunction = sceneInitFunctionsByName[sceneName];
+ const sceneRenderFunction = sceneInitFunction(elem);
+ addScene(elem, sceneRenderFunction);
+});
+```
+
+์ด์ ์ฝ๋๋ฅผ ํ์ฅํ๊ธฐ๊ฐ ํ๊ฒฐ ํธํด์ก์ต๋๋ค.
+
+{{{examples url="../threejs-multiple-scenes-selector.html" }}}
+
+## ๊ฐ ์์์ ์ก์
์ถ๊ฐํ๊ธฐ
+
+์ฌ์ฉ์ ์ก์
, ์๋ฅผ ๋ค์ด `TrackballControls`๋ฅผ ์ถ๊ฐํ๋ ๊ฑด ์์ฃผ ๊ฐ๋จํฉ๋๋ค. ๋จผ์ ์คํฌ๋ฆฝํธ๋ฅผ
+๋ถ๋ฌ์ต๋๋ค.
+
+```js
+import { TrackballControls } from './resources/threejs/r115/examples/jsm/controls/TrackballControls.js';
+```
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ ์ฅ๋ฉด์ ๋์ํ๋ ์์์ `TrackballControls`๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+-function makeScene() {
++function makeScene(elem) {
+ const scene = new THREE.Scene();
+
+ const fov = 45;
+ const aspect = 2; // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+ const near = 0.1;
+ const far = 5;
+ const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+ camera.position.set(0, 1, 2);
+ camera.lookAt(0, 0, 0);
++ scene.add(camera);
+
++ const controls = new TrackballControls(camera, elem);
++ controls.noZoom = true;
++ controls.noPan = true;
+
+ {
+ const color = 0xFFFFFF;
+ const intensity = 1;
+ const light = new THREE.DirectionalLight(color, intensity);
+ light.position.set(-1, 2, 4);
+- scene.add(light);
++ camera.add(light);
+ }
+
+- return { scene, camera };
++ return { scene, camera, controls };
+}
+```
+
+์ ์ฝ๋์์๋ ์นด๋ฉ๋ผ๋ฅผ ์ฅ๋ฉด์ ์ถ๊ฐํ๊ณ , ์นด๋ฉ๋ผ์ ์กฐ๋ช
์ ์ถ๊ฐํ์ต๋๋ค. ์ด๋ฌ๋ฉด ์กฐ๋ช
์ด ์นด๋ฉ๋ผ๋ฅผ
+๋ฐ๋ผ๋ค๋๊ฒ ์ฃ . `TrackballControls`๋ ์นด๋ฉ๋ผ๋ฅผ ์กฐ์ ํ๊ธฐ ๋๋ฌธ์ ์ด๋ ๊ฒ ํด์ผ ๋น์ด ๊ณ์ ์ฐ๋ฆฌ๊ฐ
+๋ฐ๋ผ๋ณด๋ ๋ฐฉํฅ์์ ๋๊ฐ๋๋ค.
+
+๋ํ ์ปจํธ๋กค์ ๋ ๋๋ง ํจ์์์ ์
๋ฐ์ดํธํด์ค์ผ ํฉ๋๋ค.
+
+```js
+const sceneInitFunctionsByName = {
+- 'box': () => {
+- const {scene, camera} = makeScene();
++ 'box': (elem) => {
++ const { scene, camera, controls } = makeScene(elem);
+ const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
+ const material = new THREE.MeshPhongMaterial({color: 'red'});
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ return (time, rect) => {
+ mesh.rotation.y = time * .1;
+ camera.aspect = rect.width / rect.height;
+ camera.updateProjectionMatrix();
++ controls.handleResize();
++ controls.update();
+ renderer.render(scene, camera);
+ };
+ },
+- 'pyramid': () => {
+- const { scene, camera } = makeScene();
++ 'pyramid': (elem) => {
++ const { scene, camera, controls } = makeScene(elem);
+ const radius = .8;
+ const widthSegments = 4;
+ const heightSegments = 2;
+ const geometry = new THREE.SphereBufferGeometry(radius, widthSegments, heightSegments);
+ const material = new THREE.MeshPhongMaterial({
+ color: 'blue',
+ flatShading: true,
+ });
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+ return (time, rect) => {
+ mesh.rotation.y = time * .1;
+ camera.aspect = rect.width / rect.height;
+ camera.updateProjectionMatrix();
++ controls.handleResize();
++ controls.update();
+ renderer.render(scene, camera);
+ };
+ },
+};
+```
+
+์ด์ ๊ฐ ๋ฌผ์ฒด๋ฅผ ์์ ๋กญ๊ฒ ํ์ ์ํฌ ์ ์์ต๋๋ค.
+
+{{{example url="../threejs-multiple-scenes-controls.html" }}}
+
+์ด ๊ธฐ๋ฒ์ ์ด ์ฌ์ดํธ ์ ์ฒด์ ์ฌ์ฉํ ๊ธฐ๋ฒ์
๋๋ค. [์์ ๋ชจ๋ธ์ ๊ดํ ๊ธ](threejs-primitives.html)๊ณผ
+[์ฌ์ง์ ๊ดํ ๊ธ](threejs-materials.html)์์ ๋ค์ํ ์์๋ฅผ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ์ฌ์ฉํ์ฃ .
+
+๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก๋ ํ๋ฉด ๋ฐ์ ์บ๋ฒ์ค์์ ์ฅ๋ฉด์ ๋ ๋๋งํด ๊ฐ ์์์ 2D ์บ๋ฒ์ค ํํ๋ก ๋๊ฒจ์ฃผ๋
+๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ์ด ๋ฐฉ๋ฒ์ ์ฅ์ ์ ๊ฐ ์์ญ์ ์ด๋ป๊ฒ ๋ถ๋ฆฌํ ์ง ๊ณ ๋ฏผํ์ง ์์๋ ๋๋ค๋ ๊ฒ์ด์ฃ .
+์์์ ์ดํด๋ณธ ๋ฐฉ๋ฒ์ ์บ๋ฒ์ค๋ฅผ ํ๋ฉด ์ ์ฒด์ ๋ฐฐ๊ฒฝ์ผ๋ก ์จ์ผ ํ์ง๋ง, ์ด ๋ฐฉ๋ฒ์ ์ผ๋ฐ HTML ํํ๋ก
+์ฌ์ฉํ ์ ์์ต๋๋ค.
+
+ํ์ง๋ง ์ด ๋ฐฉ๋ฒ์ ๊ฐ ์์ญ์ ๋ณต์ฌํ๋ ๊ฒ์ด๊ธฐ์ ์ฑ๋ฅ์ด ๋ ๋๋ฆฝ๋๋ค. ์ผ๋ง๋ ๋๋ฆด์ง๋ ๋ธ๋ผ์ฐ์ ์
+GPU ์ฑ๋ฅ์ ๋ฐ๋ผ ๋ค๋ฅด์ฃ .
+
+๋ฐ๊ฟ์ผ ํ๋ ๊ฑด ์๊ฐ๋ณด๋ค ๋ง์ง ์์ต๋๋ค.
+
+๋จผ์ ๋ฐฐ๊ฒฝ์์ ์บ๋ฒ์ค ์์๋ฅผ ์ ๊ฑฐํฉ๋๋ค.
+
+```html
+<body>
+- <canvas id="c"></canvas>
+ ...
+</body>
+```
+
+CSS๋ ๋ฐ๊ฟ์ค๋๋ค.
+
+```css
+-#c {
+- position: absolute;
+- left: 0;
+- top: 0;
+- width: 100vw;
+- height: 100vh;
+- display: block;
+- z-index: -1;
+-}
+canvas {
+ width: 100%;
+ height: 100%;
+ display: block;
+}
+*[data-diagram] {
+ display: inline-block;
+ width: 5em;
+ height: 3em;
+}
+```
+
+์บ๋ฒ์ค ์์๊ฐ ๋ถ๋ชจ์ ๊ฝ ์ฐจ๋๋ก ๋ณ๊ฒฝํ์ต๋๋ค.
+
+์ด์ ์๋ฐ์คํฌ๋ฆฝํธ๋ฅผ ๋ณ๊ฒฝํด๋ด
์๋ค. ๋จผ์ ์บ๋ฒ์ค๋ฅผ ์ฐธ์กฐํ ํ์๊ฐ ์์ผ๋ ๋์ ์บ๋ฒ์ค ์์๋ฅผ
+์๋ก ๋ง๋ญ๋๋ค. ๋ํ ๊ฐ์ ํ
์คํธ๋ฅผ ์ฒ์์ ํ์ฑํํฉ๋๋ค.
+
+```js
+function main() {
+- const canvas = document.querySelector('#c');
++ const canvas = document.createElement('canvas');
+ const renderer = new THREE.WebGLRenderer({canvas, alpha: true});
++ renderer.setScissorTest(true);
+
+ ...
+```
+
+๋ค์์ผ๋ก ๊ฐ ์ฅ๋ฉด์ 2D ๋ ๋๋ง ์ปจํ
์คํธ๋ฅผ ์์ฑํ๊ณ ์ฅ๋ฉด์ ๋์ํ๋ ์์์ ์บ๋ฒ์ค๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+const sceneElements = [];
+function addScene(elem, fn) {
++ const ctx = document.createElement('canvas').getContext('2d');
++ elem.appendChild(ctx.canvas);
+- sceneElements.push({ elem, fn });
++ sceneElements.push({ elem, ctx, fn });
+}
+```
+
+๋ง์ฝ ๋ ๋๋ง ์ ๋ ๋๋ง์ฉ ์บ๋ฒ์ค์ ํฌ๊ธฐ๊ฐ ์ฅ๋ฉด์ ํฌ๊ธฐ๋ณด๋ค ์์ ๊ฒฝ์ฐ, ๋ ๋๋ง์ฉ ์บ๋ฒ์ค์ ํฌ๊ธฐ๋ฅผ
+ํค์๋๋ค. ๋ํ 2D ์บ๋ฒ์ค์ ํฌ๊ธฐ๊ฐ ๋ถ๋ชจ ์์์ ๋ค๋ฅด๋ค๋ฉด 2D ์บ๋ฒ์ค์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํฉ๋๋ค. ๋ง์ง๋ง์ผ๋ก
+๊ฐ์์ ํ๋ฉด์ ์ค์ ํ๊ณ , ํด๋น ์ฅ๋ฉด์ ๋ ๋๋งํ ๋ค, ์์์ ์บ๋ฒ์ค๋ก ๋ ๋๋ง ๊ฒฐ๊ณผ๋ฌผ์ ๋ณต์ฌํฉ๋๋ค.
+
+```js
+function render(time) {
+ time *= 0.001;
+
+- resizeRendererToDisplaySize(renderer);
+-
+- renderer.setScissorTest(false);
+- renderer.setClearColor(clearColor, 0);
+- renderer.clear(true, true);
+- renderer.setScissorTest(true);
+-
+- const transform = `translateY(${ window.scrollY }px)`;
+- renderer.domElement.style.transform = transform;
+
+- for (const { elem, fn } of sceneElements) {
++ for (const { elem, fn, ctx } of sceneElements) {
+ // ํด๋น ์์์ ํ๋ฉด ๋๋น ์ขํ๋ฅผ ๊ฐ์ ธ์ต๋๋ค
+ const rect = elem.getBoundingClientRect();
+ const { left, right, top, bottom, width, height } = rect;
++ const rendererCanvas = renderer.domElement;
+
+ const isOffscreen =
+ bottom < 0 ||
+- top > renderer.domElement.clientHeight ||
++ top > window.innerHeight ||
+ right < 0 ||
+- left > renderer.domElement.clientWidth;
++ left > window.innerWidth;
+
+ if (!isOffscreen) {
+- const positiveYUpBottom = renderer.domElement.clientHeight - bottom;
+- renderer.setScissor(left, positiveYUpBottom, width, height);
+- renderer.setViewport(left, positiveYUpBottom, width, height);
+
++ // ๋ ๋๋ง์ฉ ์บ๋ฒ์ค ํฌ๊ธฐ ์กฐ์
++ if (rendererCanvas.width < width || rendererCanvas.height < height) {
++ renderer.setSize(width, height, false);
++ }
++
++ // 2D ์บ๋ฒ์ค์ ํฌ๊ธฐ๊ฐ ์์์ ํฌ๊ธฐ์ ๊ฐ๋๋ก ์กฐ์
++ if (ctx.canvas.width !== width || ctx.canvas.height !== height) {
++ ctx.canvas.width = width;
++ ctx.canvas.height = height;
++ }
++
++ renderer.setScissor(0, 0, width, height);
++ renderer.setViewport(0, 0, width, height);
+
+ fn(time, rect);
+
++ // ๋ ๋๋ง๋ ์ฅ๋ฉด์ 2D ์บ๋ฒ์ค์ ๋ณต์ฌ
++ ctx.globalCompositeOperation = 'copy';
++ ctx.drawImage(
++ rendererCanvas,
++ 0, rendererCanvas.height - height, width, height, // ์๋ณธ ์ฌ๊ฐ ์ขํ
++ 0, 0, width, height); // ๊ฒฐ๊ณผ๋ฌผ ์ฌ๊ฐ ์ขํ
+ }
+ }
+
+ requestAnimationFrame(render);
+}
+```
+
+๊ฒฐ๊ณผ๋ฌผ์ ์์ ๋ค๋ฅด์ง ์์ต๋๋ค.
+
+{{{example url="../threejs-multiple-scenes-copy-canvas.html" }}}
+
+์ด ๊ธฐ๋ฒ์ ๋ค๋ฅธ ์ฅ์ ์ [`OffscreenCanvas`](https://developer.mozilla.org/ko/docs/Web/API/OffscreenCanvas)
+์น ์์ปค๋ฅผ ์ด์ฉํด ์ด ๊ธฐ๋ฅ์ ๋ณ๋ ์ค๋ ๋์์ ๊ตฌํํ ์ ์๋ค๋ ๊ฒ๋๋ค. ํ์ง๋ง ์์ฝ๊ฒ๋
+2020๋
7์์ ๊ธฐ์ค์ผ๋ก `OffscreenCanvas`๋ ์์ง ํฌ๋ก๋ฏธ์ ๊ธฐ๋ฐ ๋ธ๋ผ์ฐ์ ์์๋ง ์ง์ํฉ๋๋ค.
\ No newline at end of file | true |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-picking.md | @@ -0,0 +1,417 @@
+Title: Three.js ํผํน(Picking)
+Description: Three.js์์ ๋ง์ฐ์ค๋ก ์์๋ฅผ ์ ํํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ๋ฌผ์ฒด๋ฅผ ๋ง์ฐ์ค๋ก ํผํนํ๊ธฐ
+
+*ํผํน(picking)*์ด๋ ์ฌ์ฉ์๊ฐ ํด๋ฆญ ๋๋ ํฐ์นํ ๋ฌผ์ฒด๋ฅผ ๊ฐ๋ ค๋ด๋ ์์
์ ๋งํฉ๋๋ค. ํผํน์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ์์์ด ๋ง์ง๋ง, ๊ฐ์ ๋จ์ ์ด ์์ต๋๋ค. ์ด ๊ธ์์๋ ์ด ๋ฐฉ๋ฒ ์ค ํํ ์ฌ์ฉํ๋ 2๊ฐ์ง ๋ฐฉ๋ฒ๋ง ์ดํด๋ณด๊ฒ ์ต๋๋ค.
+
+์๋ง *ํผํน*์ ๊ตฌํํ๋ ๊ฐ์ฅ ํํ ๋ฐฉ๋ฒ์ ๊ด์ ํฌ์ฌ(ray casting)์ผ ๊ฒ๋๋ค. ๊ด์ ํฌ์ฌ๋ ํฌ์ธํฐ(์ปค์)์์ ์ฅ๋ฉด์ ์ ๋์ฒด๋ก ๊ด์ ์ ์ด ๊ด์ ์ด ๋ฟ๋ ๋ฌผ์ฒด๋ฅผ ๊ฐ์งํ๋ ๊ธฐ๋ฒ์ ๋งํ์ฃ . ์ด๋ก ์ ์ผ๋ก ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ์
๋๋ค.
+
+๋จผ์ ํฌ์ธํฐ์ ์ขํ๋ฅผ ๊ตฌํ ๋ค, ์ด ์ขํ๋ฅผ ์นด๋ฉ๋ผ์ ์์ ๊ณผ ๋ฐฉํฅ์ ๋ฐ๋ผ 3D ์ขํ๋ก ๋ณํํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ near ๋ฉด์์ far ๋ฉด๊น์ง์ ๊ด์ ์ ๊ตฌํด ์ด ๊ด์ ์ด ์ฅ๋ฉด ์ ๊ฐ ๋ฌผ์ฒด์ ์ผ๊ฐํ๊ณผ ๊ต์ฐจํ๋์ง ํ์ธํฉ๋๋ค. ๋ง์ฝ ์ฅ๋ฉด ์์ 1000๊ฐ์ ์ผ๊ฐํ์ ๊ฐ์ง ๋ฌผ์ฒด๊ฐ 1000๊ฐ ์๋ค๋ฉด ๋ฐฑ๋ง ๊ฐ์ ์ผ๊ฐํ์ ์ผ์ผ์ด ํ์ธํด์ผ ํ๋ ์
์ด์ฃ .
+
+์ด๋ฅผ ์ต์ ํํ๋ ค๋ฉด ๋ช ๊ฐ์ง ๋ฐฉ๋ฒ์ ์๋ํด๋ณผ ์ ์์ต๋๋ค. ํ๋๋ ๋จผ์ ๋ฌผ์ฒด๋ฅผ ๊ฐ์ผ ๊ฒฝ๊ณ(bounding) ์ขํ๊ฐ ๊ด์ ๊ณผ ๊ต์ฐจํ๋์ง ํ์ธํ๊ณ , ๊ต์ฐจํ์ง ์๋๋ค๋ฉด ํด๋น ๋ฌผ์ฒด์ ์ผ๊ฐํ์ ํ์ธํ์ง ์๋ ๊ฒ์ด์ฃ .
+
+Three.js์๋ ์ด๋ฐ ์์
์ ๋์ ํด์ฃผ๋ `RayCaster` ํด๋์ค๊ฐ ์์ต๋๋ค.
+
+ํ๋ฒ ๋ฌผ์ฒด 100๊ฐ๊ฐ ์๋ ์ฅ๋ฉด์ ๋ง๋ค์ด ์ฌ๊ธฐ์ ํผํน์ ๊ตฌํํด๋ด
์๋ค. ์์ ๋ [๋ฐ์ํ ๋์์ธ](threejs-responsive.html)์์ ์ผ๋ ์์ ๋ฅผ ๊ฐ์ ธ์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค.
+
+์ฐ์ ์นด๋ฉ๋ผ๋ฅผ ๋ณ๋ `Object3D`์ ์์์ผ๋ก ์ถ๊ฐํด ์นด๋ฉ๋ผ๊ฐ ์
์นด๋ด์ฒ๋ผ ์ฅ๋ฉด ์ฃผ์๋ฅผ ๋ ์ ์๋๋ก ํฉ๋๋ค.
+
+```js
+*const fov = 60;
+const aspect = 2; // ์บ๋ฒ์ค ๊ธฐ๋ณธ๊ฐ
+const near = 0.1;
+*const far = 200;
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+*camera.position.z = 30;
+
+const scene = new THREE.Scene();
++scene.background = new THREE.Color('white');
+
++// ์นด๋ฉ๋ผ๋ฅผ ๋ด(pole)์ ์ถ๊ฐํฉ๋๋ค.
++// ์ด๋ฌ๋ฉด ๋ด์ ํ์ ์์ผ ์นด๋ฉ๋ผ๊ฐ ์ฅ๋ฉด ์ฃผ์๋ฅผ ๋๋๋ก ํ ์ ์์ต๋๋ค
++const cameraPole = new THREE.Object3D();
++scene.add(cameraPole);
++cameraPole.add(camera);
+```
+
+๊ทธ๋ฆฌ๊ณ `render` ํจ์ ์์์ ์นด๋ฉ๋ผ ๋ด์ ๋๋ฆฝ๋๋ค.
+
+```js
+cameraPole.rotation.y = time * .1;
+```
+
+๋ํ ์นด๋ฉ๋ผ์ ์กฐ๋ช
์ ์ถ๊ฐํด ์กฐ๋ช
์ด ์นด๋ฉ๋ผ์ ๊ฐ์ด ์์ง์ด๋๋ก ํฉ๋๋ค.
+
+```js
+-scene.add(light);
++camera.add(light);
+```
+
+์ ์ก๋ฉด์ฒด 100๊ฐ์ ์์น, ๋ฐฉํฅ, ํฌ๊ธฐ๋ฅผ ๋ฌด์์๋ก ์ค์ ํด ์์ฑํฉ๋๋ค.
+
+```js
+const boxWidth = 1;
+const boxHeight = 1;
+const boxDepth = 1;
+const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
+
+function rand(min, max) {
+ if (max === undefined) {
+ max = min;
+ min = 0;
+ }
+ return min + (max - min) * Math.random();
+}
+
+function randomColor() {
+ return `hsl(${ rand(360) | 0 }, ${ rand(50, 100) | 0 }%, 50%)`;
+}
+
+const numObjects = 100;
+for (let i = 0; i < numObjects; ++i) {
+ const material = new THREE.MeshPhongMaterial({
+ color: randomColor(),
+ });
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+
+ cube.position.set(rand(-20, 20), rand(-20, 20), rand(-20, 20));
+ cube.rotation.set(rand(Math.PI), rand(Math.PI), 0);
+ cube.scale.set(rand(3, 6), rand(3, 6), rand(3, 6));
+}
+```
+
+์ด์ ํผํน์ ๊ตฌํํด๋ด
์๋ค.
+
+ํผํน์ ๊ด๋ฆฌํ ๊ฐ๋จํ ํด๋์ค๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+class PickHelper {
+ constructor() {
+ this.raycaster = new THREE.Raycaster();
+ this.pickedObject = null;
+ this.pickedObjectSavedColor = 0;
+ }
+ pick(normalizedPosition, scene, camera, time) {
+ // ์ด๋ฏธ ๋ค๋ฅธ ๋ฌผ์ฒด๋ฅผ ํผํนํ๋ค๋ฉด ์์ ๋ณต์ํฉ๋๋ค
+ if (this.pickedObject) {
+ this.pickedObject.material.emissive.setHex(this.pickedObjectSavedColor);
+ this.pickedObject = undefined;
+ }
+
+ // ์ ๋์ฒด ์์ ๊ด์ ์ ์ฉ๋๋ค
+ this.raycaster.setFromCamera(normalizedPosition, camera);
+ // ๊ด์ ๊ณผ ๊ต์ฐจํ๋ ๋ฌผ์ฒด๋ค์ ๋ฐฐ์ด๋ก ๋ง๋ญ๋๋ค
+ const intersectedObjects = this.raycaster.intersectObjects(scene.children);
+ if (intersectedObjects.length) {
+ // ์ฒซ ๋ฒ์งธ ๋ฌผ์ฒด๊ฐ ์ ์ผ ๊ฐ๊น์ฐ๋ฏ๋ก ํด๋น ๋ฌผ์ฒด๋ฅผ ๊ณ ๋ฆ
๋๋ค
+ this.pickedObject = intersectedObjects[0].object;
+ // ๊ธฐ์กด ์์ ์ ์ฅํด๋ก๋๋ค
+ this.pickedObjectSavedColor = this.pickedObject.material.emissive.getHex();
+ // emissive ์์ ๋นจ๊ฐ/๋
ธ๋์ผ๋ก ๋น๋๊ฒ ๋ง๋ญ๋๋ค
+ this.pickedObject.material.emissive.setHex((time * 8) % 2 > 1 ? 0xFFFF00 : 0xFF0000);
+ }
+ }
+}
+```
+
+์ ํด๋์ค๋ ๋จผ์ `RayCaster` ์ธ์คํด์ค๋ฅผ ๋ง๋ค๊ณ `pick` ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด ์ฅ๋ฉด์ ๊ด์ ์ ์ ์ ์๊ฒ ํด์ค๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ด์ ์ ๋ง๋ ์์๊ฐ ์์ผ๋ฉด ํด๋น ์์ ์ค ๊ฐ์ฅ ์ฒซ ๋ฒ์งธ ์์์ ์์ ๋ณ๊ฒฝํฉ๋๋ค.
+
+์ฌ์ฉ์๊ฐ ๋ง์ฐ์ค๋ฅผ ๋๋ ์ ๋(down)๋ง ์ด ํจ์๊ฐ ์๋ํ๋๋ก ํ ์๋ ์์ง๋ง, ์์ ์์๋ ๋ง์ฐ์ค ํฌ์ธํฐ ์๋์ ์๋ ์์๋ฅผ ํผํนํ๋๋ก ํ๊ฒ ์ต๋๋ค. ์ด๋ฅผ ๊ตฌํํ๋ ค๋ฉด ๋จผ์ ํฌ์ธํฐ๋ฅผ ์ถ์ ํด์ผ ํฉ๋๋ค.
+
+```js
+const pickPosition = { x: 0, y: 0 };
+clearPickPosition();
+
+...
+
+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 setPickPosition(event) {
+ const pos = getCanvasRelativePosition(event);
+ pickPosition.x = (pos.x / canvas.width ) * 2 - 1;
+ pickPosition.y = (pos.y / canvas.height) * -2 + 1; // Y ์ถ์ ๋ค์ง์์
+}
+
+function clearPickPosition() {
+ /**
+ * ๋ง์ฐ์ค์ ๊ฒฝ์ฐ๋ ํญ์ ์์น๊ฐ ์์ด ๊ทธ๋ค์ง ํฐ
+ * ์๊ด์ด ์์ง๋ง, ํฐ์น ๊ฐ์ ๊ฒฝ์ฐ ์ฌ์ฉ์๊ฐ ์๊ฐ๋ฝ์
+ * ๋ผ๋ฉด ํผํน์ ๋ฉ์ถฐ์ผ ํฉ๋๋ค. ์ง๊ธ์ ์ผ๋จ ์ด๋ค ๊ฒ๋
+ * ์ ํํ ์ ์๋ ๊ฐ์ผ๋ก ์ง์ ํด๋์์ต๋๋ค
+ **/
+ pickPosition.x = -100000;
+ pickPosition.y = -100000;
+}
+
+window.addEventListener('mousemove', setPickPosition);
+window.addEventListener('mouseout', clearPickPosition);
+window.addEventListener('mouseleave', clearPickPosition);
+```
+
+์ ์์ ์์๋ ๋ง์ฐ์ค์ ์ขํ๋ฅผ ์ ๊ทํ(normalize)ํ์ต๋๋ค. ์บ๋ฒ์ค์ ํฌ๊ธฐ์ ์๊ด์์ด ์ผ์ชฝ ๋์ด -1, ์ค๋ฅธ์ชฝ ๋์ด +1์ธ ๋ฒกํฐ๊ฐ์ด ํ์ํ๊ธฐ ๋๋ฌธ์ด์ฃ . ๋ง์ฐฌ๊ฐ์ง๋ก ์๋์ชฝ ๋์ -1, ์์ชฝ ๋์ +1์
๋๋ค.
+
+๋ชจ๋ฐ์ผ๋ ํ๊ฒฝ๋ ์ง์ํ๊ธฐ ์ํด ๋ฆฌ์ค๋๋ฅผ ๋ ์ถ๊ฐํ๊ฒ ์ต๋๋ค.
+
+```js
+window.addEventListener('touchstart', (event) => {
+ event.preventDefault(); // ์คํฌ๋กค ์ด๋ฒคํธ ๋ฐฉ์ง
+ setPickPosition(event.touches[0]);
+}, { passive: false });
+
+window.addEventListener('touchmove', (event) => {
+ setPickPosition(event.touches[0]);
+});
+
+window.addEventListener('touchend', clearPickPosition);
+```
+
+๋ง์ง๋ง์ผ๋ก `render` ํจ์์์ `PickHelper`์ `pick` ๋ฉ์๋๋ฅผ ํธ์ถํฉ๋๋ค.
+
+```js
++const pickHelper = new PickHelper();
+
+function render(time) {
+ time *= 0.001; // ์ด ๋จ์๋ก ๋ณํ
+
+ ...
+
++ pickHelper.pick(pickPosition, scene, camera, time);
+
+ renderer.render(scene, camera);
+
+ ...
+```
+
+๊ฒฐ๊ณผ๋ฅผ ๋ณผ๊น์?
+
+{{{example url="../threejs-picking-raycaster.html" }}}
+
+๋ฑํ ๋ฌธ์ ๋ ์์ด ๋ณด์
๋๋ค. ์ค์ ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๋ ๋๋ถ๋ถ ๋ฌธ์ ์์ด ์ ๋๊ฒ ์ง๋ง, ์ด ๋ฐฉ๋ฒ์๋ ๋ช ๊ฐ์ง ๋ฌธ์ ์ ์ด ์์ต๋๋ค.
+
+1. CPU์ ์์์ ์ฌ์ฉํ๋ค
+
+ ์๋ฐ์คํฌ๋ฆฝํธ ์์ง์ ๊ฐ ์์๋ฅผ ๋๋ฉฐ ๊ด์ ์ด ์์์ ๊ฒฝ๊ณ ์ขํ ์์ ๊ต์ฐจํ๋์ง ํ์ธํฉ๋๋ค. ๋ง์ฝ ๊ต์ฐจํ ๊ฒฝ์ฐ, ํด๋น ์์์ ์ผ๊ฐํ์ ์ ๋ถ ๋๋ฉฐ ๊ด์ ๊ณผ ๊ต์ฐจํ๋ ์ผ๊ฐํ์ด ์๋์ง ํ์ธํฉ๋๋ค.
+
+ ์ด ๋ฐฉ์์ ์ฅ์ ์ ์๋ฐ์คํฌ๋ฆฝํธ๊ฐ ๊ต์ฐจํ๋ ์ง์ ์ ์ ํํ ๊ณ์ฐํด ํด๋น ๋ฐ์ดํฐ๋ฅผ ๋๊ฒจ์ค ์ ์๋ค๋ ์ ์
๋๋ค. ์๋ฅผ ๋ค์ด ๊ต์ฐจ๊ฐ ๋ฐ์ํ ์ง์ ์ ํน์ ํ์๋ฅผ ํ ์ ์๊ฒ ์ฃ .
+
+ ๋์ CPU๊ฐ ํ ์ผ์ด ๋ ๋์ด๋๋ค๋ ์ ์ด ๋จ์ ์
๋๋ค. ์์๊ฐ ๊ฐ์ง ์ผ๊ฐํ์ด ๋ง์์๋ก ๋ ๋๋ ค์ง๊ฒ ์ฃ .
+
+2. ํน์ดํ ๋ฐฉ์์ ์์ด๋๋ ๋ณ์ด๋ฅผ ๊ฐ์งํ์ง ๋ชปํ๋ค
+
+ ๋ง์ฝ ์ฅ๋ฉด์์ geometry๋ฅผ ๋ณํํ๋ ์์ด๋๋ฅผ ์ฌ์ฉํ๋ค๋ฉด, ์๋ฐ์คํฌ๋ฆฝํธ๋ ์ด ๋ณํ์ ๊ฐ์งํ์ง ๋ชปํ๊ธฐ์ ์๋ชป๋ ๊ฐ์ ๋ด๋์ ๊ฒ๋๋ค. ์ ๊ฐ ํ
์คํธํด๋ณธ ๊ฒฐ๊ณผ ์คํจ์ด ์ ์ฉ๋ ์์์๋ ์ด ๋ฐฉ๋ฒ์ด ๋จนํ์ง ์์ต๋๋ค.
+
+3. ์์์ ํฌ๋ช
ํ ๊ตฌ๋ฉ์ ์ฒ๋ฆฌํ์ง ๋ชปํ๋ค.
+
+์์ ๋ฅผ ํ๋ ๋ง๋ค์ด๋ณด์ฃ . ์๋์ ๊ฐ์ ํ
์ค์ฒ๋ฅผ ์ ์ก๋ฉด์ฒด์ ์ ์ฉํด๋ด
์๋ค.
+
+<div class="threejs_center"><img class="checkerboard" src="../resources/images/frame.png"></div>
+
+๊ทธ๋ค์ง ์ถ๊ฐํ ๊ฑด ๋ง์ง ์์ต๋๋ค.
+
+```js
++const loader = new THREE.TextureLoader();
++const texture = loader.load('resources/images/frame.png');
+
+const numObjects = 100;
+for (let i = 0; i < numObjects; ++i) {
+ const material = new THREE.MeshPhongMaterial({
+ color: randomColor(),
+ +map: texture,
+ +transparent: true,
+ +side: THREE.DoubleSide,
+ +alphaTest: 0.1,
+ });
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+
+ ...
+```
+
+์์ ๋ฅผ ์คํ์ํค๋ฉด ๋ฐ๋ก ๋ฌธ์ ๊ฐ ๋ณด์ผ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-picking-raycaster-transparency.html" }}}
+
+์ ์ก๋ฉด์ฒด์ ๋น ๊ณต๊ฐ์ ํตํด ๋ฌด์ธ๊ฐ๋ฅผ ์ ํํ ์๊ฐ ์์ฃ .
+
+<div class="threejs_center"><img src="resources/images/picking-transparent-issue.jpg" style="width: 635px;"></div>
+
+์ด๋ ์๋ฐ์คํฌ๋ฆฝํธ๊ฐ ํ
์ค์ฒ๋ ์ฌ์ง์ ๋ณด๊ณ ํด๋น ์์๊ฐ ํฌ๋ช
ํ์ง ํ๋จํ๊ธฐ๊ฐ ์ด๋ ต๊ธฐ ๋๋ฌธ์
๋๋ค.
+
+์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด GPU ๊ธฐ๋ฐ ํผํน์ ๊ตฌํํด์ผ ํฉ๋๋ค. ์ด๋ก ์ ์ผ๋ก๋ ๊ฐ๋จํ์ง๋ง ์์์ ์ฌ์ฉํ ๊ด์ ํฌ์ฌ๋ฒ๋ณด๋ค๋ ์ข ๋ ๋ณต์กํ์ฃ .
+
+GPU ํผํน์ ๊ตฌํํ๋ ค๋ฉด ๊ฐ ์์๋ฅผ ๋ณ๋์ ํ๋ฉด์์ ๊ณ ์ ํ ์์์ผ๋ก ๋ ๋๋งํด์ผ ํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ํฌ์ธํฐ ์๋์ ์๋ ํฝ์
์ ์์ ๊ฐ์ ธ์ ํด๋น ์์๊ฐ ์ ํ๋๋์ง ํ์ธํ๋ ๊ฑฐ์ฃ .
+
+์ด๋ฌ๋ฉด ์์์ ์ธ๊ธํ ๋ฌธ์ ์ 2, 3๋ฒ์ด ํด๊ฒฐ๋ฉ๋๋ค. 1๋ฒ, ์ฑ๋ฅ์ ๊ฒฝ์ฐ๋ ์ํฉ์ ๋ฐ๋ผ ์ฒ์ฐจ๋ง๋ณ์ด์ฃ . ๋์ ๋ณด์ด๋ ํ๋ฉด์ ์ํด ํ ๋ฒ, ํผํน์ ์ํด ํ ๋ฒ, ์ด๋ ๊ฒ ๋งค ์์๋ฅผ ์ด ๋ ๋ฒ์ฉ ๋ ๋๋งํด์ผ ํฉ๋๋ค. ๋ ๋ณต์กํ ํด๊ฒฐ์ฑ
์ ์ฐ๋ฉด ๋ ๋๋ง์ ํ ๋ฒ๋ง ํ ์๋ ์์ง๋ง, ์ด ๊ธ์์๋ ์ผ๋จ ๋ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค.
+
+์ฑ๋ฅ ์ต์ ํ๋ฅผ ์ํด ์๋ํ ์ ์๋ ๋ฐฉ๋ฒ์ด ํ๋ ์์ต๋๋ค. ์ด์ฐจํผ ํฝ์
์ ํ๋๋ง ์ฝ์ ๊ฒ์ด๋, ์นด๋ฉ๋ผ๋ฅผ ํฝ์
ํ๋๋ง ๋ ๋๋งํ๋๋ก ์ค์ ํ๋ ๊ฒ์ด์ฃ . `PerspectiveCamera.setViewOffset` ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ฉด ์นด๋ฉ๋ผ์ ํน์ ๋ถ๋ถ๋ง ๋ ๋๋งํ๋๋ก ํ ์ ์์ต๋๋ค. ์ด๋ฌ๋ฉด ์ฑ๋ฅ ํฅ์์ ์กฐ๊ธ์ด๋๋ง ๋์์ด ๋๊ฒ ์ฃ .
+
+ํ์ฌ Three.js์์ ์ด ๊ธฐ๋ฒ์ ๊ตฌํํ๋ ค๋ฉด ์ฅ๋ฉด 2๊ฐ๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ํ๋๋ ๊ธฐ์กด mesh๋ฅผ ๊ทธ๋๋ก ์ฐ๊ณ , ๋๋จธ์ง ํ๋๋ ํผํน์ฉ ์ฌ์ง์ ์ ์ฉํ mesh๋ฅผ ์ธ ๊ฒ๋๋ค.
+
+๋จผ์ ๋ ๋ฒ์งธ ์ฅ๋ฉด์ ์ถ๊ฐํ๊ณ ๋ฐฐ๊ฒฝ์ ๊ฒ์ ์ผ๋ก ์ง์ ํฉ๋๋ค.
+
+```js
+const scene = new THREE.Scene();
+scene.background = new THREE.Color('white');
+const pickingScene = new THREE.Scene();
+pickingScene.background = new THREE.Color(0);
+```
+
+๊ฐ ์ ์ก๋ฉด์ฒด๋ฅผ ์ฅ๋ฉด์ ์ถ๊ฐํ ๋ `pickingScene`์ ๊ฐ์ ์์น์ "ํผํน์ฉ ์ ์ก๋ฉด์ฒด"๋ฅผ ์ถ๊ฐํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ฐ ํผํน์ฉ ์ ์ก๋ฉด์ฒด์๋ id๋ก ์ธ ๊ณ ์ ์์๊ฐ์ ์ง์ ํ ๋ค, ์ด id ์์๊ฐ์ผ๋ก ์ฌ์ง์ ๋ง๋ค์ด ์ถ๊ฐํฉ๋๋ค. id ์์๊ฐ์ ์ ์ก๋ฉด์ฒด์ ํค๊ฐ์ผ๋ก ๋งคํํด ๋์ผ๋ฉด ๋์ค์ ์์ํ๋ ์ ์ก๋ฉด์ฒด๋ฅผ ๋ฐ๋ก ๋ถ๋ฌ์ฌ ์ ์๊ฒ ์ฃ .
+
+```js
+const idToObject = {};
++const numObjects = 100;
+for (let i = 0; i < numObjects; ++i) {
++ const id = i + 1;
+ const material = new THREE.MeshPhongMaterial({
+ color: randomColor(),
+ map: texture,
+ transparent: true,
+ side: THREE.DoubleSide,
+ alphaTest: 0.1,
+ });
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
++ idToObject[id] = cube;
+
+ cube.position.set(rand(-20, 20), rand(-20, 20), rand(-20, 20));
+ cube.rotation.set(rand(Math.PI), rand(Math.PI), 0);
+ cube.scale.set(rand(3, 6), rand(3, 6), rand(3, 6));
+
++ const pickingMaterial = new THREE.MeshPhongMaterial({
++ emissive: new THREE.Color(id),
++ color: new THREE.Color(0, 0, 0),
++ specular: new THREE.Color(0, 0, 0),
++ map: texture,
++ transparent: true,
++ side: THREE.DoubleSide,
++ alphaTest: 0.5,
++ blending: THREE.NoBlending,
++ });
++ const pickingCube = new THREE.Mesh(geometry, pickingMaterial);
++ pickingScene.add(pickingCube);
++ pickingCube.position.copy(cube.position);
++ pickingCube.rotation.copy(cube.rotation);
++ pickingCube.scale.copy(cube.scale);
+}
+```
+
+์ ์ฝ๋์์๋ `MeshPhongMaterial`๋ก ํธ๋ฒ์ ์ฌ์ฉํ์ต๋๋ค. `emissive` ์์ฑ์ id ์์๊ฐ์ผ๋ก, `color`์ `specular` ์์ฑ์ 0์ผ๋ก ์ค์ ํ๋ฉด ํ
์ค์ฒ์ ์ํ๊ฐ์ด `alphaTest`๋ณด๋ค ํฐ ๋ถ๋ถ๋ง id ์์๊ฐ์ผ๋ก ๋ณด์ด๊ฒ ์ฃ . ๋ `blending` ์์ฑ์ `THREE.NoBlending`์ผ๋ก ์ค์ ํด id ์์๊ฐ์ด ์ํ๊ฐ์ ์ํฅ์ ๋ฐ์ง ์๋๋ก ํ์ต๋๋ค.
+
+์ ๊ฐ ์ฌ์ฉํ ํธ๋ฒ์ด ์ต์ ์ ํด๊ฒฐ์ฑ
์ ์๋๋๋ค. ์ฌ๋ฌ๊ฐ์ง ์ต์
์ ๊ป๋ค๊ณ ํด๋ ์ฌ์ ํ ์กฐ๋ช
๊ด๋ จ ์ฐ์ฐ์ ์คํํ ํ
๋๊น์. ์ฝ๋๋ฅผ ๋ ์ต์ ํํ๋ ค๋ฉด `alphaTest` ๊ฐ๋ณด๋ค ๋์ ๊ฒฝ์ฐ์๋ง id ์์์ ๋ ๋๋งํ๋ ์์ด๋๋ฅผ ์ง์ ๋ง๋ค์ด์ผ ํฉ๋๋ค.
+
+๊ด์ ํฌ์ฌ๋ฒ์ ์ธ ๋์ ๋ฌ๋ฆฌ ํฝ์
์ ํ๋๋ง ์ฌ์ฉํ๋ฏ๋ก ์์น๊ฐ์ด ํฝ์
ํ๋๋ง ๊ฐ๋ฆฌํค๊ฒ ๋ณ๊ฒฝํฉ๋๋ค.
+
+```js
+function setPickPosition(event) {
+ const pos = getCanvasRelativePosition(event);
+- pickPosition.x = (pos.x / canvas.clientWidth ) * 2 - 1;
+- pickPosition.y = (pos.y / canvas.clientHeight) * -2 + 1; // Y ์ถ์ ๋ค์ง์์
++ pickPosition.x = pos.x;
++ pickPosition.y = pos.y;
+}
+```
+
+`PickHelper` ํด๋์ค๋ `GPUPickHelper`๋ก ๋ณ๊ฒฝํฉ๋๋ค. [๋ ๋ ํ๊ฒ(render target)์ ๊ดํ ๊ธ](threejs-rendertargets.html)์์ ๋ค๋ฃฌ `WebGLRenderTarget`์ ์จ ๊ตฌํํ๋, ์ด๋ฒ ๋ ๋ ํ๊ฒ์ ํฌ๊ธฐ๋ 1x1, 1ํฝ์
์
๋๋ค.
+
+```js
+-class PickHelper {
++class GPUPickHelper {
+ constructor() {
+- this.raycaster = new THREE.Raycaster();
++ // 1x1 ํฝ์
ํฌ๊ธฐ์ ๋ ๋ ํ๊ฒ์ ์์ฑํฉ๋๋ค
++ this.pickingTexture = new THREE.WebGLRenderTarget(1, 1);
++ this.pixelBuffer = new Uint8Array(4);
+ this.pickedObject = null;
+ this.pickedObjectSavedColor = 0;
+ }
+ pick(cssPosition, scene, camera, time) {
++ const {pickingTexture, pixelBuffer} = this;
+
+ // ๊ธฐ์กด์ ์ ํ๋ ์์๊ฐ ์๋ ๊ฒฝ์ฐ ์์ ๋ณต์ํฉ๋๋ค
+ if (this.pickedObject) {
+ this.pickedObject.material.emissive.setHex(this.pickedObjectSavedColor);
+ this.pickedObject = undefined;
+ }
+
++ // 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] );
+
+ // ์ ๋์ฒด ์์ ๊ด์ ์ ์ฉ๋๋ค
+- this.raycaster.setFromCamera(normalizedPosition, camera);
+ // ๊ด์ ๊ณผ ๊ต์ฐจํ๋ ๋ฌผ์ฒด๋ค์ ๋ฐฐ์ด๋ก ๋ง๋ญ๋๋ค
+- const intersectedObjects = this.raycaster.intersectObjects(scene.children);
+- if (intersectedObjects.length) {
+ // ์ฒซ ๋ฒ์งธ ๋ฌผ์ฒด๊ฐ ์ ์ผ ๊ฐ๊น์ฐ๋ฏ๋ก ํด๋น ๋ฌผ์ฒด๋ฅผ ๊ณ ๋ฆ
๋๋ค
+- this.pickedObject = intersectedObjects[0].object;
+
++ 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);
+ }
+ }
+}
+```
+
+์ธ์คํด์ค๋ฅผ ๋ง๋๋ ์ชฝ๋ ์์ ํฉ๋๋ค.
+
+```js
+-const pickHelper = new PickHelper();
++const pickHelper = new GPUPickHelper();
+```
+
+`pick` ๋ฉ์๋๋ฅผ ํธ์ถํ ๋ `scene` ๋์ `pickScene`์ ๋๊ฒจ์ค๋๋ค.
+
+```js
+- pickHelper.pick(pickPosition, scene, camera, time);
++ pickHelper.pick(pickPosition, pickScene, camera, time);
+```
+
+์ด์ ํฌ๋ช
ํ ๋ถ๋ถ์ ๊ดํตํด ์์๋ฅผ ์ ํํ ์ ์์ต๋๋ค.
+
+{{{example url="../threejs-picking-gpu.html" }}}
+
+์ด ๊ธ์ด ํผํน์ ๊ตฌํํ๋ ๋ฐ ๋์์ด ๋์์ผ๋ฉด ์ข๊ฒ ๋ค์. ๋์ค์ ์์๋ฅผ ๋ง์ฐ์ค๋ก ์กฐ์ํ๋ ๋ฒ์ ๋ํด์๋ ํ ๋ฒ ์จ๋ณด๊ฒ ์ต๋๋ค.
\ No newline at end of file | true |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-post-processing-3dlut.md | @@ -0,0 +1,502 @@
+Title: 3DLUT๋ก ํ์ฒ๋ฆฌํ๊ธฐ
+Description: Three.js์์ 3DLUT๋ก ํ์ฒ๋ฆฌํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: LUT ํ์ผ๋ก ํ์ฒ๋ฆฌ ํจ๊ณผ ์ ์ฉํ๊ธฐ
+
+์ด์ ๊ธ์์๋ [ํ์ฒ๋ฆฌ(Post processing)](threejs-post-processing.html)์ ๊ดํด ์์๋ณด์์ต๋๋ค. ๋ณดํต ํ์ฒ๋ฆฌ๋ LUT ๋๋ 3DLUT๋ผ๊ณ ๋ถ๋ฅด๊ธฐ๋ ํฉ๋๋ค. LUT๋ ๋ฃฉ์
ํ
์ด๋ธ(Look-Up Table, ์๋ํ)์ ์ค์๋ง์ด๊ณ , 3DLUT๋ 3์ฐจ์ ๋ฃฉ์
ํ
์ด๋ธ์ ์ค์๋ง์
๋๋ค.
+
+3DLUT๋ 2D ์ด๋ฏธ์ง๋ฅผ ํน์ ํ ์์ ์ ์ก๋ฉด์ฒด๋ฅผ ๋งคํํ๋ค๊ณ ์๊ฐํ๋ฉด ์ฝ์ต๋๋ค. ๋จผ์ ์๋ณธ ์ด๋ฏธ์ง์ ์์์ ์ ์ก๋ฉด์ฒด์ ์ธ๋ฑ์ค ๊ฐ๊ณผ ๋งค์นญ์ํต๋๋ค. ์๋ณธ ์ด๋ฏธ์ง์ ํฝ์
ํ๋๋น ํด๋น ํฝ์
์์์ ๋นจ๊ฐ(red), ์ด๋ก(green), ํ๋(blue) ๊ฐ์ ์ด์ฉํด ์ ์ก๋ฉด์ฒด์ ํน์ ์ง์ ์ ๊ฐ๋ฆฌํค๋(look-up) 3D ๋ฒกํฐ ์ธ๋ฑ์ค๋ฅผ ๋ง๋๋ ๊ฒ์ด์ฃ . ์ด ์ธ๋ฑ์ค๋ฅผ ํตํด 3DLUT์์ ๋ฝ์๋ธ ๊ฐ์ ์๋ก์ด ์์ผ๋ก ์ฌ์ฉํ๋ ๊ฒ๋๋ค.
+
+์๋ฐ์คํฌ๋ฆฝํธ์ ๊ฒฝ์ฐ ์๋์ฒ๋ผ ๊ตฌํํ ์ ์์ต๋๋ค. RGB ๊ฐ ์์๊ฐ์ 0๋ถํฐ 255์ ์ ์๋ก ํํํ 3์ฐจ์ 256x256x256 ๋ฐฐ์ด๋ก ๋ฃฉ์
ํ
์ด๋ธ์ ๊ตฌํํ๊ณ , ์ด ๋ฃฉ์
ํ
์ด๋ธ์์ RGB ์์๊ฐ์ ์ด์ฉํด ์๋ก์ด ์์๊ฐ์ ์ ํํ๋ ๊ฑฐ์ฃ .
+
+```js
+const newColor = lut[origColor.red][origColor.green][origColor.blue]
+```
+
+๋ฌผ๋ก 256x256x256 ๋ฐฐ์ด์ ํฐ ๋ฐฐ์ด์
๋๋ค. [ํ
์ค์ฒ์ ๊ดํ ๊ธ](threejs-textures.html)์์ ๋ฐฐ์ ๋ฏ ํ
์ค์ฒ๋ ํฌ๊ธฐ์ ์๊ด ์์ด 0.0์์ 1.0๋ก ๊ฐ์ ์ง์ ํฉ๋๋ค.
+
+8x8x8 ์ ์ก๋ฉด์ฒด๋ฅผ ์๋ก ๋ค์ด๋ณด์ฃ .
+
+<div class="threejs_center"><img src="resources/images/3dlut-rgb.svg" class="noinvertdark" style="width: 500px"></div>
+
+๋จผ์ 0,0,0 ๋ถ๋ถ์ ๊ฒ์ ์์ผ๋ก ์ฑ์๋๋ค. ๋ง์ํธ์ 1,1,1 ๋ถ๋ถ์ ํ์์, 1,0,0 ๋ถ๋ถ์ <span style="color:red;">๋นจ๊ฐ</span>, 0,1,0์ <span style="color:green;">์ด๋ก</span>, 0,0,1์ <span style="color:blue;">ํ๋</span>์ผ๋ก ์ฑ์๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/3dlut-axis.svg" class="noinvertdark" style="width: 500px"></div>
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ ์ถ์ ๋ฐ๋ผ ์์ ์ฑ์๋ฃ์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/3dlut-edges.svg" class="noinvertdark" style="width: 500px"></div>
+
+๋น ๋ชจ์๋ฆฌ๋ฅผ 2๊ฐ ์ด์์ ์์ ์ฑ๋์ ์ฌ์ฉํ๋ ์์ผ๋ก ์ฑ์๋๋ค(์ด๋ก + ๋นจ๊ฐ, ํ๋ + ๋นจ๊ฐ ๋ฑ).
+
+<div class="threejs_center"><img src="resources/images/3dlut-standard.svg" class="noinvertdark" style="width: 500px"></div>
+
+๋ง์ง๋ง์ผ๋ก ๋น ๊ณต๊ฐ์ ์ฑ์๋๋ค. ์ด ํํ๊ฐ 3DLUT ๊ธฐ๋ณธ ๊ตฌ์กฐ์
๋๋ค. ์ง๊ธ์ ํจ๊ณผ๋ฅผ ์ฃผ๊ธฐ ์ ๊ณผ ํ์ ์ฐจ์ด๊ฐ ์์ต๋๋ค. ์์๊ฐ์ ์ธ๋ฑ์ค๋ก ์ฌ์ฉํด ์๋ก์ด ์์๊ฐ์ ์ ํํ๋ฉด, ์ ํํ ๊ฐ์ ์์๊ฐ์ด ๋์ค๊ธฐ ๋๋ฌธ์ด์ฃ .
+
+<div class="threejs_center"><object type="image/svg+xml" data="resources/images/3dlut-standard-lookup.svg" class="noinvertdark" data-diagram="lookup" style="width: 600px"></object></div>
+
+์ด ์ ์ก๋ฉด์ฒด๋ฅผ ํธ๋ฐ์ ์์ด๋๋ก ๋ฐ๊พธ๋ฉด ๊ฐ์ ์ธ๋ฑ์ค๋ฅผ ์ฐธ์กฐํ์ง๋ง ์ ํ ๋ค๋ฅธ ๊ฒฐ๊ณผ๊ฐ ๋์ต๋๋ค.
+
+<div class="threejs_center"><object type="image/svg+xml" data="resources/images/3dlut-amber-lookup.svg" class="noinvertdark" data-diagram="lookup" style="width: 600px"></object></div>
+
+์ด ๊ธฐ๋ฒ์ ์ฌ์ฉํ๋ฉด ๋ฃฉ์
ํ
์ด๋ธ์ ๊ต์ฒดํ๋ ๊ฒ์ผ๋ก ๋ง์ ํจ๊ณผ๋ฅผ ๊ตฌํํ ์ ์์ต๋๋ค. ์์ ๊ณ์ฐ ๊ธฐ๋ฐ์ ํจ๊ณผ๋ ๋๋ถ๋ถ ํ๋์ ์์๊ฐ๋ง์ ์ฌ์ฉํฉ๋๋ค. ์์, ๋๋น, ์ฑ๋, ์ปฌ๋ฌ ์บ์คํธ(color cast), ํดํธ(tint), ๋ฐ๊ธฐ, ๋
ธ์ถ๋, ๋ ๋ฒจ, ์ปค๋ธ, ํฌ์คํฐํ, ๊ทธ๋ฆผ์, ๊ฐ์กฐ, ๋ฑ ๊ฑฐ์ ๋ชจ๋ ํจ๊ณผ๋ฅผ ์์๊ฐ ๊ณ์ฐ์ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌํํ์ฃ . ๋ ์ด ๋ชจ๋ ํจ๊ณผ๋ฅผ ํ๋์ ๋ฃฉ์
ํ
์ด๋ธ๋ก ํฉ์น ์๋ ์์ต๋๋ค.
+
+๋ฃฉ์
ํ
์ด๋ธ์ ์ฌ์ฉํ๋ ค๋ฉด ๋จผ์ ์ ์ฉํ ์ฅ๋ฉด์ด ํ์ํ๋ ๊ฐ๋จํ ์ฅ๋ฉด์ ํ๋ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค. [glTF ๋ถ๋ฌ์ค๊ธฐ](threejs-load-gltf.html)์์ ๋ฐฐ์ ๋ฏ glTF ํ์ผ์ ๋ถ๋ฌ์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. ์์ ์ ์ฌ์ฉํ ๋ชจ๋ธ์ [The Ice Wolves](https://sketchfab.com/sarath.irn.kat005)์ [์ํ](https://sketchfab.com/models/a1d315908e9f45e5a3bc618bdfd2e7ee)์
๋๋ค.
+
+[๋ฐฐ๊ฒฝ๊ณผ ํ๋ ์์](threejs-backgrounds.html)์์ ๋ฐฐ์ ๋ ๋๋ก ๋ฐฐ๊ฒฝ๋ ์ถ๊ฐํ๊ฒ ์ต๋๋ค.
+
+{{{example url="../threejs-postprocessing-3dlut-prep.html" }}}
+
+์ด์ ์ฅ๋ฉด์ ๊ตฌํํ์ผ๋ 3DLUT๋ฅผ ๋ง๋ค์ด์ผ ํฉ๋๋ค. ๊ฐ์ฅ ๊ฐ๋จํ 3DLUT๋ 2x2x2 identity LUT๋ก, ์ฌ๊ธฐ์ *identity(๋์ผํ)*์ ์๋ฌด๋ฐ ๋ณํ๋ ์์์ ์๋ฏธํฉ๋๋ค. 1์ ๊ณฑํ๊ฑฐ๋ ์๋ฌด๊ฒ๋ ์ ํ๋ ๊ฒฝ์ฐ์ ๊ฐ์ฃ . LUT ์์ ์์๊ฐ์ ์ฌ์ฉํ๋ค๊ณ ํด๋ ์
๋ ฅ๋ ๊ฐ๊ณผ ์ ํํ ๊ฐ์ ๊ฐ์ ๋ฐํํ ํ
๋๊น์.
+
+<div class="threejs_center"><img src="resources/images/3dlut-standard-2x2.svg" class="noinvertdark" style="width: 200px"></div>
+
+WebGL1์ 3D ํ
์ค์ณ๋ฅผ ์ง์ํ์ง ์์ต๋๋ค. ๋ฐ๋ผ์ 3D ํ
์ค์ฒ๋ฅผ ์ฐ์ด ํผ์ณ ๋์ ํํ์ 4x2์ง๋ฆฌ 2D ํ
์ค์ฒ๋ฅผ ๋์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค.
+
+์๋๋ 4x2 2D ํ
์ค์ฒ๋ก identity LUT๋ฅผ ๊ตฌํํ ๊ฒ์
๋๋ค.
+
+```js
+const makeIdentityLutTexture = function() {
+ const identityLUT = new Uint8Array([
+ 0, 0, 0, 255, // black
+ 255, 0, 0, 255, // red
+ 0, 0, 255, 255, // blue
+ 255, 0, 255, 255, // magenta
+ 0, 255, 0, 255, // green
+ 255, 255, 0, 255, // yellow
+ 0, 255, 255, 255, // cyan
+ 255, 255, 255, 255, // white
+ ]);
+
+ return function(filter) {
+ const texture = new THREE.DataTexture(identityLUT, 4, 2, THREE.RGBAFormat);
+ texture.minFilter = filter;
+ texture.magFilter = filter;
+ texture.needsUpdate = true;
+ texture.flipY = false;
+ return texture;
+ };
+}();
+```
+
+ํํฐ๊ฐ ๋ค์ด๊ฐ ๊ฒ, ์ ๋ค์ด๊ฐ ๊ฒ ์ด 2๊ฐ๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+const lutTextures = [
+ { name: 'identity', size: 2, texture: makeIdentityLutTexture(THREE.LinearFilter) },
+ { name: 'identity not filtered', size: 2, texture: makeIdentityLutTexture(THREE.NearestFilter) },
+];
+```
+
+[ํ์ฒ๋ฆฌ์ ๊ดํ ๊ธ](threejs-post-processing.html)์์ ์์ฑํ๋ ์ฝ๋๋ฅผ ๊ฐ์ ธ์ ์ด ์์ด๋๋ค์ ๋์ ์ฐ๋๋ก ํฉ๋๋ค.
+
+```js
+const lutShader = {
+ uniforms: {
+ tDiffuse: { value: null },
+ lutMap: { value: null },
+ lutMapSize: { value: 1, },
+ },
+ vertexShader: `
+ varying vec2 vUv;
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ }
+ `,
+ fragmentShader: `
+ #include <common>
+
+ #define FILTER_LUT true
+
+ uniform sampler2D tDiffuse;
+ uniform sampler2D lutMap;
+ uniform float lutMapSize;
+
+ varying vec2 vUv;
+
+ vec4 sampleAs3DTexture(sampler2D tex, vec3 texCoord, float size) {
+ float sliceSize = 1.0 / size; // space of 1 slice
+ float slicePixelSize = sliceSize / size; // space of 1 pixel
+ float width = size - 1.0;
+ float sliceInnerSize = slicePixelSize * width; // space of size pixels
+ float zSlice0 = floor( texCoord.z * width);
+ float zSlice1 = min( zSlice0 + 1.0, width);
+ float xOffset = slicePixelSize * 0.5 + texCoord.x * sliceInnerSize;
+ float yRange = (texCoord.y * width + 0.5) / size;
+ float s0 = xOffset + (zSlice0 * sliceSize);
+
+ #ifdef FILTER_LUT
+
+ float s1 = xOffset + (zSlice1 * sliceSize);
+ vec4 slice0Color = texture2D(tex, vec2(s0, yRange));
+ vec4 slice1Color = texture2D(tex, vec2(s1, yRange));
+ float zOffset = mod(texCoord.z * width, 1.0);
+ return mix(slice0Color, slice1Color, zOffset);
+
+ #else
+
+ return texture2D(tex, vec2( s0, yRange));
+
+ #endif
+ }
+
+ void main() {
+ vec4 originalColor = texture2D(tDiffuse, vUv);
+ gl_FragColor = sampleAs3DTexture(lutMap, originalColor.xyz, lutMapSize);
+ }
+ `,
+};
+
+const lutNearestShader = {
+ uniforms: Object.assign( {}, lutShader.uniforms ),
+ vertexShader: lutShader.vertexShader,
+ fragmentShader: lutShader.fragmentShader.replace('#define FILTER_LUT', '//'),
+};
+```
+
+fragment ์์ด๋์ ๋ค์ ์ฝ๋๋
+
+```glsl
+#define FILTER_LUT true
+```
+
+์ฃผ์ ์ฒ๋ฆฌํ๋ ๋ ๋ฒ์งธ ์์ด๋๋ฅผ ์์ฑํ๊ธฐ ์ํ ๊ฒ์
๋๋ค.
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ ์์ด๋๋ก `Pass`๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
+const effectLUT = new THREE.ShaderPass(lutShader);
+effectLUT.renderToScreen = true;
+const effectLUTNearest = new THREE.ShaderPass(lutNearestShader);
+effectLUTNearest.renderToScreen = true;
+```
+
+๊ธฐ์กด์ ๋ฐฐ๊ฒฝ๊ณผ glTF๋ฅผ ๋ณ๋ ์ฅ๋ฉด์ผ๋ก ๋ถ๋ฆฌํ์ผ๋ฏ๋ก ๊ฐ ์ฅ๋ฉด์ `RenderPass`๋ฅผ ๋ฐ๋ก ์์ฑํฉ๋๋ค.
+
+```js
+const renderModel = new THREE.RenderPass(scene, camera);
+renderModel.clear = false; // ๋ฐฐ๊ฒฝ์ ์ง์ฐ์ง ์๋๋ก ํฉ๋๋ค
+const renderBG = new THREE.RenderPass(sceneBG, cameraBG);
+```
+
+๋ค์์ผ๋ก ์ฌ์ฉํ pass*๋ฅผ `EffectComposer`์ ์ถ๊ฐํฉ๋๋ค.
+
+โป ํธ์์ `Pass` ์ธ์คํด์ค๋ฅผ pass๋ก ๋ฒ์ญํฉ๋๋ค.
+
+```js
+const rtParameters = {
+ minFilter: THREE.LinearFilter,
+ magFilter: THREE.LinearFilter,
+ format: THREE.RGBFormat,
+};
+const composer = new THREE.EffectComposer(renderer, new THREE.WebGLRenderTarget(1, 1, rtParameters));
+
+composer.addPass(renderBG);
+composer.addPass(renderModel);
+composer.addPass(effectLUT);
+composer.addPass(effectLUTNearest);
+```
+
+GUI๋ฅผ ๋ง๋ค์ด LUT๋ฅผ ๋ฐ๊ฟ ์ ์๋๋ก ํฉ๋๋ค.
+
+```js
+const lutNameIndexMap = {};
+lutTextures.forEach((info, ndx) => {
+ lutNameIndexMap[info.name] = ndx;
+});
+
+const lutSettings = {
+ lut: lutNameIndexMap.identity,
+};
+const gui = new GUI({ width: 300 });
+gui.add(lutSettings, 'lut', lutNameIndexMap);
+```
+
+๋ง์ง๋ง์ผ๋ก ํํฐ๋ง ์ฌ๋ถ์ ๋ฐ๋ผ ํจ๊ณผ๊ฐ ๋ฐ๋๋๋ก ์ค์ ํฉ๋๋ค. LUT๊ฐ ์ ํํ ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ๋๋ก ํ๊ณ , `EffectComposer`๋ก ๋ ๋๋ง ํฉ๋๋ค.
+
+```js
+const lutInfo = lutTextures[lutSettings.lut];
+
+const effect = lutInfo.filter ? effectLUT : effectLUTNearest;
+effectLUT.enabled = lutInfo.filter;
+effectLUTNearest.enabled = !lutInfo.filter;
+
+const lutTexture = lutInfo.texture;
+effect.uniforms.lutMap.value = lutTexture;
+effect.uniforms.lutMapSize.value = lutInfo.size;
+
+composer.render(delta);
+```
+
+identity 3DLUT๋ฅผ ์ ํํ์ ๋๋ ์๋ฌด๋ฐ ๋ณํ๊ฐ ์์ต๋๋ค.
+
+{{{example url="../threejs-postprocessing-3dlut-identity.html" }}}
+
+ํ์ง๋ง ํํฐ๊ฐ identity not filtered LUT๋ฅผ ์ ํํ๋ฉด ์ฌ๋ฏธ์๋ ๊ฒฐ๊ณผ๊ฐ ๋์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/unfiltered-3dlut.jpg" style="width: 500px"></div>
+
+์ ์ด๋ฐ ๊ฒฐ๊ณผ๊ฐ ๋์จ ๊ฑธ๊น์? ํํฐ๋ง์ ์ฌ์ฉํ ๊ฒฝ์ฐ(linear), GPU๋ ์ ํ์ ์ผ๋ก ์์๊ฐ์ ์ฑ์๋ฃ์ต๋๋ค. ํํฐ๋ง์ ์ฌ์ฉํ์ง ์์ ๊ฒฝ์ฐ(nearest), ์์์ ์์๊ฐ์ ์ฑ์๋ฃ์ง ์๊ธฐ์ 3DLUT์์(๊ทผ์ฒ์) ์์๊ฐ์ด ์๋ ๊ณณ์ ์ฐพ์ ์ฌ์ฉํ๋ ๊ฒ์ด์ฃ .
+
+์ด๋์ ๋ ์ดํดํ๋ค๋ฉด ๋ ๋ค์ํ 3DLUT๋ฅผ ๋ง๋ค์ด๋ด
์๋ค.
+
+๋จผ์ ๋ฃฉ์
ํ
์ด๋ธ์ ํด์๋๋ฅผ ์ ํ๊ณ ๊ฐ๋จํ ์ฝ๋๋ฅผ ๋ง๋ค์ด ๋ฃฉ์
ํ
์ด๋ธ ์ ์ก๋ฉด์ฒด์ ๊ฐ ๋ฉด์ ๋ง๋ค๊ฒ ์ต๋๋ค.
+
+```js
+const ctx = document.querySelector('canvas').getContext('2d');
+
+function drawColorCubeImage(ctx, size) {
+ const canvas = ctx.canvas;
+ canvas.width = size * size;
+ canvas.height = size;
+
+ for (let zz = 0; zz < size; ++zz) {
+ for (let yy = 0; yy < size; ++yy) {
+ for (let xx = 0; xx < size; ++xx) {
+ const r = Math.floor(xx / (size - 1) * 255);
+ const g = Math.floor(yy / (size - 1) * 255);
+ const b = Math.floor(zz / (size - 1) * 255);
+ ctx.fillStyle = `rgb(${ r },${ g },${ b })`;
+ ctx.fillRect(zz * size + xx, yy, 1, 1);
+ }
+ }
+ }
+ document.querySelector('#width').textContent = canvas.width;
+ document.querySelector('#height').textContent = canvas.height;
+}
+
+drawColorCubeImage(ctx, 8);
+```
+
+์บ๋ฒ์ค ์์๋ ๋ง๋ญ๋๋ค.
+
+```html
+<canvas></canvas>
+```
+
+์ด์ ์ด๋ค identity 3D ๋ฃฉ์
ํ
์ด๋ธ์ด๋ ๋ง๋ค ์ ์์ต๋๋ค.
+
+{{{example url="../3dlut-base-cube-maker.html" }}}
+
+ํด์๋๊ฐ ๋์์๋ก ๋ ์ธ๋ฐํ ํจ๊ณผ๋ฅผ ์ค ์ ์์ง๋ง ์ ์ก๋ฉด์ฒดํ ๋ฐ์ดํฐ์ ํฌ๊ธฐ๋ ๊ธฐํ๊ธ์์ ์ผ๋ก ๋์ด๋ฉ๋๋ค. ํฌ๊ธฐ 8x8 ์ ์ก๋ฉด์ฒด๋ 2kb ์ ๋์ง๋ง 64x64 ์ ์ก๋ฉด์ฒด๋ ์ฝ 1mb๋ ๋์ฃ . ๊ทธ๋ฌ๋ ์ถฉ๋ถํ ํจ๊ณผ๋ฅผ ๊ตฌํํ ์ ์๋ ๋งํผ๋ง ์ฌ์ฉํ๋ ๊ฒ ์ข์ต๋๋ค.
+
+์ฌ์ด์ฆ๋ฅผ 16์ผ๋ก ์ค์ ํ๊ณ `Save...` ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์๋์ ๊ฐ์ ํ์ผ์ด ๋์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/identity-lut-s16.png"></div>
+
+๊ทธ๋ฆฌ๊ณ LUT๋ฅผ ์ ์ฉํ ํ๋ฉด์ ์บก์ณํด์ผ ํฉ๋๋ค. ์ด ๊ฒฝ์ฐ์๋ ์ด์ ์ ๋ง๋ ์ฅ๋ฉด์ ์๋ฌด๋ฐ ํจ๊ณผ๋ฅผ ์ฃผ์ง ์์ ํ๋ฉด์ด๊ฒ ์ฃ . ๋๊ฒ ์ ์์ ๋ฅผ ์ค๋ฅธ์ชฝ ํด๋ฆญํด "๋ค๋ฅธ ์ด๋ฆ์ผ๋ก ์ ์ฅ..."์ ํด๋ฆญํ๋ฉด ๋์ง๋ง, OS์ ๋ฐ๋ผ ๋ง์ฐ์ค ์ฐํด๋ฆญ์ด ๋์ํ์ง ์์ ์ ์์ต๋๋ค. ์ ๊ฒฝ์ฐ OS์ ๋ด์ฅ๋ ์คํฌ๋ฆฐ์ท ๊ธฐ๋ฅ์ ์ด์ฉํด ํ๋ฉด์ ์บก์ณํ์ต๋๋ค*.
+
+โป Windows 10 RS5(๋ ๋์คํค 5) ์ด์์ด๋ผ๋ฉด `Windows + Shift + S`๋ฅผ ๋๋ฌ ํ๋ฉด์ ์บก์ณํ ์ ์์ต๋๋ค. ์ญ์ฃผ.
+
+<div class="threejs_center"><img src="resources/images/3dlut-screen-capture.jpg" style="width: 600px"></div>
+
+์บก์ณ๋ณธ์ ์ด๋ฏธ์ง ์๋ํฐ์์ ๋ถ๋ฌ์ต๋๋ค. ์ ๋ ํฌํ ์ต์ ์ฌ์ฉํด ์ํ ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์ค๊ณ , ํ์ชฝ ๊ทํ์ด์ 3DLUT๋ฅผ ๋ถ์ฌ ๋ฃ์์ต๋๋ค.
+
+> ์ฐธ๊ณ : ์ ๊ฒฝ์ฐ ํฌํ ์ต์์ ์บก์ณ๋ณธ ์์ lut ํ์ผ์ ๋ถ๋ฌ์ค๋ ค๊ณ ํ์ ๋ ์ด๋ฏธ์ง๊ฐ ๋ ๋ฐฐ ๋ ์ปค์ก์ต๋๋ค. ์๋ง DPI๋ฅผ ๋ง์ถ๊ฑฐ๋ ํ๋ ์ด์ ๋๋ฌธ์ ๊ทธ๋ฐ ๊ฑฐ๊ฒ ์ฃ . lut ํ์ผ์ ๋ณ๋ ํญ์ ๋ถ๋ฌ์ ์บก์ณ๋ณธ ์์ ๋ณต์ฌ ๋ถ์ฌ ๋ฃ๊ธฐ ํ๋ ์ ์์ ์ผ๋ก ๋ถ๋ฌ์์ง๋๊ตฐ์.
+
+<div class="threejs_center"><img src="resources/images/3dlut-photoshop-before.jpg" style="width: 600px"></div>
+
+๊ทธ๋ฆฌ๊ณ ์ด๋ฏธ์ง์ ๋ถ์ฌํ๊ณ ์ถ์ ์์ ํจ๊ณผ๋ฅผ ๋ถ์ฌํฉ๋๋ค. ํฌํ ์ต์ ๊ฒฝ์ฐ ๋๋ถ๋ถ์ ํจ๊ณผ๋ ์ด๋ฏธ์ง(Image)->์กฐ์ (Adjustments) ๋ฉ๋ด์ ์์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/3dlut-photoshop-after.jpg" style="width: 600px"></div>
+
+์์์ ์กฐ์ ํ๋ฉด 3DLUT ์ด๋ฏธ์ง์๋ ๊ฐ์ ํจ๊ณผ๊ฐ ์ ์ฉ๋ ๊ฒ๋๋ค.
+
+์ ๊ทธ๋ผ ์ด์ ์ด๊ฑธ ์ด๋ป๊ฒ ์ธ ์ ์์๊น์?
+
+๋จผ์ ์ ๋ 3DLUT ์ด๋ฏธ์ง๋ฅผ `3dlut-red-only-s16.png`๋ผ๋ ์ด๋ฆ์ผ๋ก ์ ์ฅํ์ต๋๋ค. ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์๋ผ๋ ค๋ฉด ์ด๋ฏธ์ง๋ฅผ LUT ๋ถ๋ถ๋ง ์๋ผ 16x256๋ก ๋ง์ถ๋ ๊ฒ์ด ์ข์ง๋ง, ๊ทธ๋ฅ ์ฌ๋ฏธ์ผ์ ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์จ ์ดํ ์๋ฅด๊ฒ ์ต๋๋ค*. ์ด ๋ฐฉ๋ฒ์ ์ฅ์ ์ ๊ท์ฐฎ๊ฒ ์ด๋ฏธ์ง๋ฅผ ์๋ฅด๋ ๊ณผ์ ์์ด ํจ๊ณผ๋ฅผ ์ ์ฉํด๋ณด๊ณ ์ถ์ ๋๋ก ๋ฐ๋ก๋ฐ๋ก ์ ์ฉํ ์ ์๋ค๋ ๊ฒ์ด์ฃ . ๋ฌผ๋ก ๋์ญํญ์ ๋ญ๋นํ๋ค๋ ๊ฒ ๋จ์ ์
๋๋ค.
+
+โป ํฌํ ์ต CC ์ดํ ๋ฒ์ ผ์ ์ฌ์ฉํ๋ค๋ฉด ๋ ์ด์ด๋ฅผ ์ค๋ฅธ์ชฝ ํด๋ฆญํด `PNG๋ก ๋น ๋ฅด๊ฒ ๋ด๋ณด๋ด๊ธฐ` ๋ฉ๋ด๋ก ํด๋น ๊ทธ๋ฃน ๋๋ ๋ ์ด์ด๋ง .png ํ์ผ๋ก ๋ด๋ณด๋ผ ์ ์์ต๋๋ค. ์ด๋ฏธ์ง๋ฅผ ๊ท์ฐฎ๊ฒ ์๋ฅด๋ ๊ณผ์ ์์ด .png ํ์ผ์ ๋ฐ๋ก ์์ฑํ ์ ์์ฃ . ์ญ์ฃผ.
+
+์๋๋ ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์ค๋ ์ฝ๋์
๋๋ค. ์ค์ ์ฝ๋์์๋ ํ
์ค์ฒ๋ฅผ ๋ถ๋ฌ์์ ๋ ๋ฐ๋ก ์ฌ์ฉํ ์ ์๋๋ก identity lut๋ฅผ ๋จผ์ ๋ง๋ค์์ต๋๋ค. ๊ทธ ๋ค์ ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์ 3DLUT ๋ถ๋ถ๋ง ์บ๋ฒ์ค์ ๋ณต์ฌํ๊ณ , ์บ๋ฒ์ค์์ ๊ฐ์ ธ์จ ๋ฐ์ดํฐ๋ฅผ ํ
์ค์ฒ์ ์ง์ ํฉ๋๋ค. ๋ํ ํ
์ค์ฒ๊ฐ ๋ฐ๋์์ ๋ ๋ฐ๋ก ์ ์ฉํ๋๋ก `needsUpdate` ์์ฑ๋ true๋ก ์ค์ ํฉ๋๋ค.
+
+```js
+const makeLUTTexture = function() {
+ const imgLoader = new THREE.ImageLoader();
+ const ctx = document.createElement('canvas').getContext('2d');
+
+ return function(info) {
+ const texture = makeIdentityLutTexture(
+ info.filter ? THREE.LinearFilter : THREE.NearestFilter);
+
+ if (info.url) {
+ const lutSize = info.size;
+
+ /**
+ * ํฌ๊ธฐ๋ฅผ 2(identity LUT์ ํฌ๊ธฐ)๋ก ์ค์ ํฉ๋๋ค. ์ด ํฌ๊ธฐ๋ ๋์ค์ ์ด๋ฏธ์ง๋ฅผ
+ * ๋ถ๋ฌ์จ ๋ค ๋ณต์ํฉ๋๋ค. ์ด๋ฌ๋ฉด lut๋ฅผ ์ฌ์ฉํ๋ ์ฝ๋๋ ์ด๋ฏธ์ง์ ์ ์ฉ ์ฌ๋ถ๋ฅผ
+ * ์ ๊ฒฝ์ฐ์ง ์์๋ ๋ฉ๋๋ค.
+ **/
+ info.size = 2;
+
+ imgLoader.load(info.url, function(image) {
+ const width = lutSize * lutSize;
+ const height = lutSize;
+ info.size = lutSize;
+ ctx.canvas.width = width;
+ ctx.canvas.height = height;
+ ctx.drawImage(image, 0, 0);
+ const imageData = ctx.getImageData(0, 0, width, height);
+
+ texture.image.data = new Uint8Array(imageData.data.buffer);
+ texture.image.width = width;
+ texture.image.height = height;
+ texture.needsUpdate = true;
+ });
+ }
+
+ return texture;
+ };
+}();
+```
+
+๊ธฐ์กด ์ฝ๋๊ฐ LUT png ํ์ผ์ ์ฌ์ฉํ๋๋ก ์์ ํฉ๋๋ค.
+
+```js
+const lutTextures = [
+ { name: 'identity', size: 2, filter: true , },
+ { name: 'identity no filter', size: 2, filter: false, },
++ { name: 'custom', url: 'resources/images/lut/3dlut-red-only-s16.png' },
+];
+
++lutTextures.forEach((info) => {
++ // ์ฌ์ด์ฆ๊ฐ์ด ์๋ค๋ฉด ์ฌ์ด์ฆ ์ ๋ณด๋ฅผ ํ์ผ ์ด๋ฆ์์ ๊ฐ์ ธ์ต๋๋ค.
++ if (!info.size) {
++ /**
++ * ํ์ผ ์ด๋ฆ์ด '-s<์ซ์>[n]' ์ด๋ ๊ฒ ๋๋๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
++ * <์ซ์>๋ 3DLUT ์ ์ก๋ฉด์ฒด์ ํฌ๊ธฐ์
๋๋ค.
++ * [n]์ 'ํํฐ๋ง ์์' ๋๋ 'nearest'๋ฅผ ์๋ฏธํฉ๋๋ค.
++ *
++ * ์์:
++ * 'foo-s16.png' = ํฌ๊ธฐ:16, ํํฐ: true
++ * 'bar-s8n.png' = ํฌ๊ธฐ:8, ํํฐ: false
++ **/
++ const m = /-s(\d+)(n*)\.[^.]+$/.exec(info.url);
++ if (m) {
++ info.size = parseInt(m[1]);
++ info.filter = info.filter === undefined ? m[2] !== 'n' : info.filter;
++ }
++ }
++
++ info.texture = makeLUTTexture(info);
++});
+```
+
+์ ์ฝ๋๊ฐ LUT์ ์ฌ์ด์ฆ๋ฅผ ํ์ผ ์ด๋ฆ์ ์ธ์ฝ๋ฉํ ์์
๋๋ค. ์ด๋ฌ๋ฉด png๋ก LUT๋ฅผ ๋ฐ๊พธ๊ธฐ๊ฐ ํจ์ฌ ์ฝ์ฃ .
+
+๊ทธ๋ฅ์ ์ข ์ฌ์ฌํ๋ lut png ํ์ผ์ ๋ ๋ง์ด ๋ง๋ค์ด๋ด
์๋ค.
+
+```js
+const lutTextures = [
+ { name: 'identity', size: 2, filter: true , },
+ { name: 'identity no filter', size: 2, filter: false, },
+ { name: 'custom', url: 'resources/images/lut/3dlut-red-only-s16.png' },
++ { name: 'monochrome', url: 'resources/images/lut/monochrome-s8.png' },
++ { name: 'sepia', url: 'resources/images/lut/sepia-s8.png' },
++ { name: 'saturated', url: 'resources/images/lut/saturated-s8.png', },
++ { name: 'posterize', url: 'resources/images/lut/posterize-s8n.png', },
++ { name: 'posterize-3-rgb', url: 'resources/images/lut/posterize-3-rgb-s8n.png', },
++ { name: 'posterize-3-lab', url: 'resources/images/lut/posterize-3-lab-s8n.png', },
++ { name: 'posterize-4-lab', url: 'resources/images/lut/posterize-4-lab-s8n.png', },
++ { name: 'posterize-more', url: 'resources/images/lut/posterize-more-s8n.png', },
++ { name: 'inverse', url: 'resources/images/lut/inverse-s8.png', },
++ { name: 'color negative', url: 'resources/images/lut/color-negative-s8.png', },
++ { name: 'high contrast', url: 'resources/images/lut/high-contrast-bw-s8.png', },
++ { name: 'funky contrast', url: 'resources/images/lut/funky-contrast-s8.png', },
++ { name: 'nightvision', url: 'resources/images/lut/nightvision-s8.png', },
++ { name: 'thermal', url: 'resources/images/lut/thermal-s8.png', },
++ { name: 'b/w', url: 'resources/images/lut/black-white-s8n.png', },
++ { name: 'hue +60', url: 'resources/images/lut/hue-plus-60-s8.png', },
++ { name: 'hue +180', url: 'resources/images/lut/hue-plus-180-s8.png', },
++ { name: 'hue -60', url: 'resources/images/lut/hue-minus-60-s8.png', },
++ { name: 'red to cyan', url: 'resources/images/lut/red-to-cyan-s8.png' },
++ { name: 'blues', url: 'resources/images/lut/blues-s8.png' },
++ { name: 'infrared', url: 'resources/images/lut/infrared-s8.png' },
++ { name: 'radioactive', url: 'resources/images/lut/radioactive-s8.png' },
++ { name: 'goolgey', url: 'resources/images/lut/googley-s8.png' },
++ { name: 'bgy', url: 'resources/images/lut/bgy-s8.png' },
+];
+```
+
+์๋ ์์ ์์ ์ฌ๋ฌ lut๋ฅผ ์ํํด๋ณผ ์ ์์ต๋๋ค.
+
+{{{example url="../threejs-postprocessing-3dlut.html" }}}
+
+์ถ๊ฐ๋ก ํ ๊ฐ์ง ๋ง๋ถ์ด๊ฒ ์ต๋๋ค. ์ธํฐ๋ท์ ๋ค์ ธ๋ณด๋ Adobe์์ ๋ง๋ ํ์ค LUT ํ์์ด ์๋๊ตฐ์. [์ธํฐ๋ท์์ ๊ฒ์](https://www.google.com/search?q=lut+files)ํด๋ณด๋ฉด ์ด๋ฐ LUT ํ์์ ํ์ผ์ ์ฝ๊ฒ ์ฐพ์ ์ ์์ ๊ฒ๋๋ค.
+
+์ด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ฐ๋จํ๊ฒ ๋ก๋๋ฅผ ์์ฑํ์ต๋๋ค. ์ด 4๊ฐ์ง ํ์์ด ์๋ค๊ณ ๋ ํ๋, ์ ๊ฐ ์ฐพ์ ํ์์ ํ๋๋ฟ์ด๋ผ ๋ชจ๋ ํ์์์ ํ
์คํธํ์ง ๋ชปํ์ต๋๋ค.
+
+์ฌ๊ธฐ์ ๊ฐ๋จํ ๋๋๊ทธ-์ค-๋๋กญ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ๋ง๋ค์์ต๋๋ค. ์ด ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ด์ฉํด ์ฌ๋ฌ๋ถ์ด ์ง์ LUT ํ์ผ์ ์ ์ฉํ ์ ์๋๋ก ๋ง์ด์ฃ .
+
+๋จผ์ ์์ ๋ง๋ ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ถ๋ฌ์จ ๋ค
+
+```js
+import * as lutParser from './resources/lut-reader.js';
+import * as dragAndDrop from './resources/drag-and-drop.js';
+```
+
+์๋์ฒ๋ผ ์ฌ์ฉํฉ๋๋ค.
+
+```js
+dragAndDrop.setup({ msg: 'Drop LUT File here' });
+dragAndDrop.onDropFile(readLUTFile);
+
+function readLUTFile(file) {
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ const lut = lutParser.lutTo2D3Drgb8(lutParser.parse(e.target.result));
+ const {size, data, name} = lut;
+ const texture = new THREE.DataTexture(data, size * size, size, THREE.RGBFormat);
+ texture.minFilter = THREE.LinearFilter;
+ texture.needsUpdate = true;
+ texture.flipY = false;
+ const lutTexture = {
+ name: (name && name.toLowerCase().trim() !== 'untitled')
+ ? name
+ : file.name,
+ size: size,
+ filter: true,
+ texture,
+ };
+ lutTextures.push(lutTexture);
+ lutSettings.lut = lutTextures.length - 1;
+ updateGUI();
+ };
+
+ reader.readAsText(file);
+}
+```
+
+GUI๊ฐ ์๋ก ๋ถ๋ฌ์จ ํ์ผ์ ๋ฐ์ํ๋๋ก ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+const lutSettings = {
+ lut: lutNameIndexMap.thermal,
+};
+const gui = new GUI({ width: 300 });
+gui.addFolder('Choose LUT or Drag&Drop LUT File(s)');
+
+let lutGUI;
+function updateGUI() {
+ makeLutNameIndexMap();
+ if (lutGUI) {
+ gui.remove(lutGUI);
+ }
+ lutGUI = gui.add(lutSettings, 'lut', lutNameIndexMap);
+}
+updateGUI();
+```
+
+์ด์ [Adobe LUT ํ์ผ](https://www.google.com/search?q=lut+files)์ ๋ค์ดํด ์๋ ์์ ์ ๋๋๊ทธ-์ค-๋๋กญ์ผ๋ก ๋ถ๋ฌ์ฌ ์ ์์ ๊ฒ๋๋ค.
+
+{{{example url="../threejs-postprocessing-3dlut-w-loader.html" }}}
+
+๋ค๋ง Adobe LUT๋ ์จ๋ผ์ธ ํ๊ฒฝ์ ์ต์ ํ๋์ง ์์์ต๋๋ค. ํ์ผ ์ฉ๋์ด ๊ฝค ํฐ ํธ์ด์ฃ . ์๋ ์์ ๋ฅผ ์ฌ์ฉํ๋ฉด ์ฉ๋์ ์ข ๋ ์ค์ผ ์ ์์ต๋๋ค. ๋๋๊ทธ-์ค-๋๋กญ์ผ๋ก ํ์ผ์ ๋ถ๋ฌ์ค๊ณ ํฌ๊ธฐ๋ฅผ ์ ํํ ๋ค "Save..." ๋ฒํผ์ ํด๋ฆญํ๋ฉด ๋์ฃ .
+
+์๋ ์์ ๋ ๋จ์ํ ์์์ ์ผ๋ ์์ ๋ฅผ ์กฐ๊ธ ์์ ํ ๊ฒ์
๋๋ค. glFT ํ์ผ ์์ด ๋ฐฐ๊ฒฝ๋ง ๋ ๋๋งํ ๊ฒ์ด์ฃ . ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๋ ์๊น ๋ณธ ์คํฌ๋ฆฝํธ๋ก ๋ง๋ identity lut ์ด๋ฏธ์ง์
๋๋ค. ์ฌ๊ธฐ์ LUT ํ์ผ์ ๋ถ๋ฌ์ ํด๋น LUT ํ์ผ์ PNG๋ก ๋ง๋๋ ๋ฐ ์ฌ์ฉํ๋ ๊ฒ์ด์ฃ .
+
+{{{example url="../threejs-postprocessing-adobe-lut-to-png-converter.html" }}}
+
+์ด ๊ธ์์๋ ์์ด๋๊ฐ ์ด๋ป๊ฒ ์๋ํ๋์ง์ ๋ํด์๋ ์์ ์ค๋ช
ํ์ง ์์์ต๋๋ค. ๋์ค์ 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> | true |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-post-processing.md | @@ -0,0 +1,254 @@
+Title: Three.js ํ์ฒ๋ฆฌ
+Description: Three.js๋ก ํ์ฒ๋ฆฌํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ํ์ฒ๋ฆฌ
+
+*ํ์ฒ๋ฆฌ(post processing)*๋ ๋ณดํต 2D ์ด๋ฏธ์ง์ ์ด๋ค ํจ๊ณผ๋ ํํฐ๋ฅผ ๋ฃ๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. Three.js๋ ๋ค์ํ mesh๋ก ์ด๋ฃจ์ด์ง ์ฅ๋ฉด์ 2D ์ด๋ฏธ์ง๋ก ๋ ๋๋งํ์ฃ . ์ผ๋ฐ์ ์ผ๋ก ์ด ์ด๋ฏธ์ง๋ ๋ฐ๋ก ์บ๋ฒ์ค๋ฅผ ํตํด ๋ธ๋ผ์ฐ์ ํ๋ฉด์ ๋ ๋๋ง๋ฉ๋๋ค. ํ์ง๋ง ๋์ ์ด ์ด๋ฏธ์ง๋ฅผ [๋ ๋ ํ๊ฒ์ ๋ ๋๋งํ๊ณ ](threejs-rendertargets.html) ์บ๋ฒ์ค์ ๋ณด๋ด๊ธฐ ์ ์์์ *ํ์ฒ๋ฆฌ* ํจ๊ณผ๋ฅผ ์ค ์ ์์ต๋๋ค.
+
+์ธ์คํ๊ทธ๋จ ํํฐ, ํฌํ ์ต ํํฐ ๋ฑ์ด ํ์ฒ๋ฆฌ์ ์ข์ ์์ด์ฃ .
+
+Three.js์๋ ํ์ฒ๋ฆฌ๋ฅผ ์์ฐจ์ ์ผ๋ก ์ฒ๋ฆฌํด์ฃผ๋ ๋ชจ๋ฒ ํด๋์ค๊ฐ ์์ต๋๋ค. ์ผ๋จ `EffectComposer`์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค๊ณ ์ฌ๊ธฐ์ `Pass` ๊ฐ์ฒด(ํจ๊ณผ, ํํฐ)๋ค์ ์ถ๊ฐํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ `EffectComposer.render` ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด ํ์ฌ ์ฅ๋ฉด์ [๋ ๋ ํ๊ฒ](threejs-rendertargets.html)์ ๋ ๋๋งํ ๋ค ๊ฐ pass*๋ฅผ ์์๋๋ก ์ ์ฉํฉ๋๋ค.
+
+โป ํธ์์ `Pass` ์ธ์คํด์ค๋ฅผ pass๋ก ๋ฒ์ญํฉ๋๋ค.
+
+์ด pass๋ ๋น๋ท(vignette), ํ๋ฆผ(blur), ๋ธ๋ฃธ(bloom), ํ๋ฆ ๊ทธ๋ ์ธ(film grain) ํจ๊ณผ ๋๋ hue, ์ฑ๋(saturation), ๋๋น(contrast) ์กฐ์ ๋ฑ์ ํ์ฒ๋ฆฌ ํจ๊ณผ๋ก, ์ด ํจ๊ณผ๋ฅผ ๋ชจ๋ ์ ์ฉํ ๊ฒฐ๊ณผ๋ฌผ์ ์ต์ข
์ ์ผ๋ก ์บ๋ฒ์ค์ ๋ ๋๋งํฉ๋๋ค.
+
+์ฌ๊ธฐ์ ์ด๋ ์ ๋ `EffectComposer`์ ์๋ฆฌ๋ฅผ ์ดํดํ ํ์๊ฐ ์์ต๋๋ค. `EffectComposer`๋ ๋ ๊ฐ์ [๋ ๋ ํ๊ฒ](threejs-rendertargets.html)์ ์ฌ์ฉํฉ๋๋ค. ํธ์์ ์ด ๋์ **rtA**, **rtB**๋ผ๊ณ ๋ถ๋ฅด๋๋ก ํ์ฃ .
+
+`EffectComposer.addPass`๋ฅผ ๊ฐ pass๋ฅผ ์ ์ฉํ ์์๋๋ก ํธ์ถํ๊ณ `EffectComposer.render`๋ฅผ ํธ์ถํ๋ฉด pass*๋ ์๋ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ ์์๋ก ์ ์ฉ๋ฉ๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/threejs-postprocessing.svg" style="width: 600px"></div>
+
+๋จผ์ `RenderPass`์ ๋๊ธด ์ฅ๋ฉด์ **rtA**์ ๋ ๋๋งํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ **rtA**๋ฅผ ๋ค์ pass์ ๋๊ฒจ์ฃผ๋ฉด ํด๋น pass๋ **rtA**์ pass๋ฅผ ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ **rtB**์ ๋ ๋๋งํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ **rtB**๋ฅผ ๋ค์ pass๋ก ๋๊ฒจ ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ **rtA**์, **rtA**์ pass๋ฅผ ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ ๋ค์ **rtB**์, ์ด๋ฐ ์์ผ๋ก ๋ชจ๋ pass๊ฐ ๋๋ ๋๊น์ง ๊ณ์ ๋ฐ๋ณตํฉ๋๋ค.
+
+`Pass`์๋ ๊ณตํต์ ์ผ๋ก 4๊ฐ์ง ์ต์
์ด ์์ต๋๋ค.
+
+## `enabled`
+
+์ด pass๋ฅผ ์ฌ์ฉํ ์ง์ ์ฌ๋ถ์
๋๋ค.
+
+## `needsSwap`
+
+์ด pass๋ฅผ ์ ์ฉํ ํ `rtA`์ `rtB`๋ฅผ ๋ฐ๊ฟ์ง์ ์ฌ๋ถ์
๋๋ค.
+
+## `clear`
+
+์ด pass๋ฅผ ์ ์ฉํ๊ธฐ ์ ์ ํ๋ฉด์ ์ด๊ธฐํํ ์ง์ ์ฌ๋ถ์
๋๋ค.
+
+## `renderToScreen`
+
+์ง์ ํ ๋ ๋ ํ๊ฒ์ด ์๋ ์บ๋ฒ์ค์ ๋ ๋๋งํ ์ง์ ์ฌ๋ถ์
๋๋ค. ๋ณดํต `EffectComposer`์ ์ถ๊ฐํ๋ ๋ง์ง๋ง pass์ ์ด ์ต์
์ true๋ก ์ค์ ํฉ๋๋ค.
+
+๊ฐ๋จํ ์์ ๋ฅผ ๋ง๋ค์ด๋ด
์๋ค. [๋ฐ์ํ ๋์์ธ์ ๊ดํ ๊ธ](threejs-responsive.html)์์ ์ผ๋ ์์ ๋ฅผ ๊ฐ์ ธ์ค๊ฒ ์ต๋๋ค.
+
+์ถ๊ฐ๋ก ๋จผ์ `EffectComposer` ์ธ์คํด์ค๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
+const composer = new EffectComposer(renderer);
+```
+
+๋ค์์ผ๋ก `RenderPass`๋ฅผ ์ฒซ pass๋ก ์ถ๊ฐํฉ๋๋ค. ์ด pass๋ ๋๊ฒจ ๋ฐ์ ์ฅ๋ฉด์ ์ฒซ ๋ ๋ ํ๊ฒ์ ๋ ๋๋งํ ๊ฒ๋๋ค.
+
+```js
+composer.addPass(new RenderPass(scene, camera));
+```
+
+๋ค์์ผ๋ก `BloomPass`๋ฅผ ์ถ๊ฐํฉ๋๋ค. `BloomPass`๋ ์ฅ๋ฉด์ ์๋์ ์ฅ๋ฉด๋ณด๋ค ์๊ฒ ๋ ๋๋งํด ํ๋ฆผ(blur) ํจ๊ณผ๋ฅผ ์ค๋๋ค. ๊ทธ๋ฆฌ๊ณ ํจ๊ณผ๊ฐ ์ ์ฉ๋ ์ฅ๋ฉด์ ์๋ ์ฅ๋ฉด์ ๋ฎ์ด ์์ฐ๋ ์์ผ๋ก *๋ธ๋ฃธ* ํจ๊ณผ๋ฅผ ๊ตฌํํฉ๋๋ค.
+
+```js
+const bloomPass = new BloomPass(
+ 1, // ๊ฐ๋
+ 25, // ์ปค๋(kernel) ํฌ๊ธฐ
+ 4, // ์๊ทธ๋ง ?
+ 256, // ๋ ๋ ํ๊ฒ์ ํด์๋๋ฅผ ๋ฎ์ถค
+);
+composer.addPass(bloomPass);
+```
+
+๋ง์ง๋ง์ผ๋ก ์๋ณธ ์ฅ๋ฉด์ ๋
ธ์ด์ฆ์ ์ค์บ๋ผ์ธ(scanline)์ ์ถ๊ฐํ๋ `FilmPass`๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+const filmPass = new FilmPass(
+ 0.35, // ๋
ธ์ด์ฆ ๊ฐ๋
+ 0.025, // ์ค์บ๋ผ์ธ ๊ฐ๋
+ 648, // ์ค์บ๋ผ์ธ ๊ฐ์
+ false, // ํ๋ฐฑ
+);
+filmPass.renderToScreen = true;
+composer.addPass(filmPass);
+```
+
+`filmPass`๊ฐ ๋ง์ง๋ง pass์ด๊ธฐ์ ์บ๋ฒ์ค์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ๋ก ๋ ๋๋งํ๋๋ก `renderToScreen` ์ต์
์ true๋ก ์ค์ ํ์ต๋๋ค. ์ด ์ต์
์ ์ค์ ํ์ง ์์ผ๋ฉด ์บ๋ฒ์ค๊ฐ ์๋ ๋ค์ ๋ ๋ ํ๊ฒ์ ์ฅ๋ฉด์ ๋ ๋๋งํ ๊ฑฐ์์.
+
+๋ ์ด ํด๋์ค๋ค์ ์ฌ์ฉํ๊ธฐ ์ํด ์ฌ๋ฌ ์คํฌ๋ฆฝํธ๋ฅผ ๋ถ๋ฌ์์ผ ํฉ๋๋ค.
+
+```js
+import { EffectComposer } from './resources/threejs/r115/examples/jsm/postprocessing/EffectComposer.js';
+import { RenderPass } from './resources/threejs/r115/examples/jsm/postprocessing/RenderPass.js';
+import { BloomPass } from './resources/threejs/r115/examples/jsm/postprocessing/BloomPass.js';
+import { FilmPass } from './resources/threejs/r115/examples/jsm/postprocessing/FilmPass.js';
+```
+
+๋๋ถ๋ถ์ ํ์ฒ๋ฆฌ์๋ `EffectComposer.js`์ `RenderPass.js`๊ฐ ํ์์
๋๋ค.
+
+์ด์ `WebGLRenderer.render` ๋์ `EffectComposer.render`๋ฅผ ์ฌ์ฉ*ํ๊ณ * `EffectComposer`๊ฐ ๊ฒฐ๊ณผ๋ฌผ์ ์บ๋ฒ์ค์ ํฌ๊ธฐ์ ๋ง์ถ๋๋ก ํด์ผ ํฉ๋๋ค.
+
+```js
+-function render(now) {
+- time *= 0.001;
++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();
++ composer.setSize(canvas.width, canvas.height);
+ }
+
+ cubes.forEach((cube, ndx) => {
+ const speed = 1 + ndx * .1;
+- const rot = time * speed;
++ const rot = now * speed;
+ cube.rotation.x = rot;
+ cube.rotation.y = rot;
+ });
+
+- renderer.render(scene, camera);
++ composer.render(deltaTime);
+
+ requestAnimationFrame(render);
+}
+```
+
+`EffectComposer.render` ๋ฉ์๋๋ ์ธ์๋ก ๋ง์ง๋ง ํ๋ ์์ ๋ ๋๋งํ ์ดํ์ ์๊ฐ๊ฐ์ธ `deltaTime`์ ์ธ์๋ก ๋ฐ์ต๋๋ค. pass์ ์ ๋๋ฉ์ด์
์ด ํ์ํ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด ์ด ๊ฐ์ ๋๊ฒจ์ฃผ๊ธฐ ์ํด์์ด์ฃ . ์์ ์ ๊ฒฝ์ฐ์๋ `FilmPass`์ ์ ๋๋ฉ์ด์
์ด ์์ต๋๋ค.
+
+{{{example url="../threejs-postprocessing.html" }}}
+
+๋ฐํ์์ ํจ๊ณผ์ ์์ฑ์ ๋ณ๊ฒฝํ ๋๋ ๋ณดํต uniform์ value ๊ฐ์ ๋ฐ๊ฟ๋๋ค. GUI๋ฅผ ์ถ๊ฐํด ์ด ์์ฑ์ ์กฐ์ ํ ์ ์๊ฒ ๋ง๋ค์ด๋ณด์ฃ . ์ด๋ค ์์ฑ์ ์ด๋ป๊ฒ ์กฐ์ํ ์ ์๋์ง๋ ํด๋น ํจ๊ณผ์ ์์ค ์ฝ๋๋ฅผ ์ด์ด๋ด์ผ ์ ์ ์์ต๋๋ค.
+
+[`BloomPass.js`](https://github.com/mrdoob/three.js/blob/master/examples/js/postprocessing/BloomPass.js)์์
+์๋ ์ฝ๋๋ฅผ ์ฐพ์์ต๋๋ค.
+
+```js
+this.copyUniforms[ "opacity" ].value = strength;
+```
+
+์๋์ฒ๋ผ ํ๋ฉด ๊ฐ๋๋ฅผ ๋ฐํ์์ ๋ฐ๊ฟ ์ ์๊ฒ ๋ค์.
+
+```js
+bloomPass.copyUniforms.opacity.value = someValue;
+```
+
+๋ง์ฐฌ๊ฐ์ง๋ก [`FilmPass.js`](https://github.com/mrdoob/three.js/blob/master/examples/js/postprocessing/FilmPass.js)์์
+์๋ ์ฝ๋๋ฅผ ์ฐพ์์ต๋๋ค.
+
+```js
+if ( grayscale !== undefined ) this.uniforms.grayscale.value = grayscale;
+if ( noiseIntensity !== undefined ) this.uniforms.nIntensity.value = noiseIntensity;
+if ( scanlinesIntensity !== undefined ) this.uniforms.sIntensity.value = scanlinesIntensity;
+if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
+```
+
+์ด์ ์ด๋ป๊ฒ ๊ฐ์ ์ง์ ํด์ผ ํ๋์ง ์์์ผ๋ ์ด ๊ฐ์ ์กฐ์ํ๋ GUI๋ฅผ ๋ง๋ค์ด๋ด
์๋ค.
+
+```js
+import { GUI } from '../3rdparty/dat.gui.module.js';
+```
+
+์ผ๋จ ๋ชจ๋์ ๋ก๋ํฉ๋๋ค.
+
+```js
+const gui = new GUI();
+{
+ const folder = gui.addFolder('BloomPass');
+ folder.add(bloomPass.copyUniforms.opacity, 'value', 0, 2).name('strength');
+ folder.open();
+}
+{
+ const folder = gui.addFolder('FilmPass');
+ folder.add(filmPass.uniforms.grayscale, 'value').name('grayscale');
+ folder.add(filmPass.uniforms.nIntensity, 'value', 0, 1).name('noise intensity');
+ folder.add(filmPass.uniforms.sIntensity, 'value', 0, 1).name('scanline intensity');
+ folder.add(filmPass.uniforms.sCount, 'value', 0, 1000).name('scanline count');
+ folder.open();
+}
+```
+
+์ด์ ๊ฐ ์ค์ ์ ์กฐ์ํ ์ ์์ต๋๋ค.
+
+{{{example url="../threejs-postprocessing-gui.html" }}}
+
+์ฌ๊ธฐ๊น์ง ์ ๋ฐ๋ผ์๋ค๋ฉด ์ด์ ํจ๊ณผ๋ฅผ ์ง์ ๋ง๋ค์ด๋ณผ ์ ์์ต๋๋ค.
+
+ํ์ฒ๋ฆฌ ํจ๊ณผ๋ ์์ด๋๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์์ด๋๋ [GLSL (Graphics Library Shading Language)](https://www.khronos.org/files/opengles_shading_language.pdf)์ด๋ผ๋ ์ธ์ด๋ฅผ ์ฌ์ฉํ์ฃ . ์ธ์ด๊ฐ ๋ฐฉ๋ํด ์ด ๊ธ์์ ์ ๋ถ ๋ค๋ฃจ๊ธฐ๋ ์ด๋ ต์ต๋๋ค. ๊ธฐ์ด๋ถํฐ ์์๋ณด๊ณ ์ถ๋ค๋ฉด [์ด ๊ธ](https://webglfundamentals.org/webgl/lessons/ko/webgl-shaders-and-glsl.html)๊ณผ [์์ด๋๋ ๋ฌด์์ธ๊ฐ(The Book of Shaders)](https://thebookofshaders.com/)๋ฅผ ์ฝ์ด๋ณด๊ธฐ ๋ฐ๋๋๋ค.
+
+์ง์ ์์ ๋ฅผ ๋ง๋ค์ด๋ณด๋ ๊ฒ ๋์์ด ๋ ํ
๋ ๊ฐ๋จํ GLSL ํ์ฒ๋ฆฌ ์์ด๋๋ฅผ ๋ง๋ค์ด๋ด
์๋ค. ์ด๋ฏธ์ง์ ํน์ ์์ ํผํฉํ๋ ์์ด๋๋ฅผ ๋ง๋ค ๊ฒ๋๋ค.
+
+Three.js์๋ ํ์ฒ๋ฆฌ๋ฅผ ๋์์ฃผ๋ `ShaderPass` ํฌํผ ํด๋์ค๊ฐ ์์ต๋๋ค. ์ธ์๋ก vertex ์์ด๋, fragment ์์ด๋, ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ด๋ฃจ์ด์ง ๊ฐ์ฒด๋ฅผ ๋ฐ์ฃ . ์ด ํด๋์ค๋ ์ด์ pass์ ๊ฒฐ๊ณผ๋ฌผ์์ ์ด๋ค ํ
์ค์ฒ๋ฅผ ์ฝ์์ง, ๊ทธ๋ฆฌ๊ณ `EffectComposer`์ ๋ ๋ ํ๊ฒ๊ณผ ์บ๋ฒ์ค ์ค ์ด๋์ ๋ ๋๋งํ ์ง๋ฅผ ๊ฒฐ์ ํ ๊ฒ๋๋ค.
+
+์๋๋ ์ด์ pass์ ๊ฒฐ๊ณผ๋ฌผ์ ํน์ ์์ ํผํฉํ๋ ๊ฐ๋จํ ํ์ฒ๋ฆฌ ์์ด๋์
๋๋ค.
+
+```js
+const colorShader = {
+ uniforms: {
+ tDiffuse: { value: null },
+ color: { value: new THREE.Color(0x88CCFF) },
+ },
+ vertexShader: `
+ varying vec2 vUv;
+ void main() {
+ vUv = uv;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1);
+ }
+ `,
+ fragmentShader: `
+ varying vec2 vUv;
+ uniform sampler2D tDiffuse;
+ uniform vec3 color;
+ void main() {
+ vec4 previousPassColor = texture2D(tDiffuse, vUv);
+ gl_FragColor = vec4(
+ previousPassColor.rgb * color,
+ previousPassColor.a);
+ }
+ `,
+};
+```
+
+์ ์ฝ๋์์ `tDiffuse`๋ ์ด์ pass์ ๊ฒฐ๊ณผ๋ฌผ์ ๋ฐ์์ค๊ธฐ ์ํ ๊ฒ์ผ๋ก ๊ฑฐ์ ๋ชจ๋ ๊ฒฝ์ฐ์ ํ์์
๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ทธ ๋ฐ๋ก ๋ฐ์ `color` ์์ฑ์ Three.js์ `Color`๋ก ์ ์ธํ์ต๋๋ค.
+
+๋ค์์ผ๋ก vertex ์์ด๋๋ฅผ ์์ฑํด์ผ ํฉ๋๋ค. ์ ์ฝ๋์์ ์์ฑํ vertex ์์ด๋๋ ํ์ฒ๋ฆฌ์์ ๊ฑฐ์ ํ์ค์ฒ๋ผ ์ฌ์ฉํ๋ ์ฝ๋๋ก, ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ๋ฐ๊ฟ ํ์๊ฐ ์์ต๋๋ค. ๋ญ๊ฐ ๋ง์ด ์ค์ ํ ๊ฒฝ์ฐ(์๊น ์ธ๊ธํ ๋งํฌ ์ฐธ์กฐ)๊ฐ ์๋๋ผ๋ฉด `uv`, `projectionMatrix`, `modelViewMatrix`, `position` ๋ณ์๋ Three.js๊ฐ ์์์ ๋ฃ์ด์ค๋๋ค.
+
+๋ง์ง๋ง์ผ๋ก fragment ์์ด๋๋ฅผ ์์ฑํฉ๋๋ค. ์๋ ์ฝ๋๋ก ์ด์ pass์์ ๋๊ฒจ์ค ๊ฒฐ๊ณผ๋ฌผ์ ํฝ์
์์๊ฐ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.
+
+```glsl
+vec4 previousPassColor = texture2D(tDiffuse, vUv);
+```
+
+์ฌ๊ธฐ์ ์ง์ ํ ์์์ ๊ณฑํด `gl_FragColor`์ ๊ฒฐ๊ณผ๋ฅผ ์ ์ฅํฉ๋๋ค.
+
+```glsl
+gl_FragColor = vec4(
+ previousPassColor.rgb * color,
+ previousPassColor.a);
+```
+
+์ถ๊ฐ๋ก ๊ฐ๋จํ GUI๋ฅผ ๋ง๋ค์ด rgb์ ๊ฐ ์์๊ฐ์ ์กฐ์ ํ ์ ์๋๋ก ํฉ๋๋ค.
+
+```js
+const gui = new GUI();
+gui.add(colorPass.uniforms.color.value, 'r', 0, 4).name('red');
+gui.add(colorPass.uniforms.color.value, 'g', 0, 4).name('green');
+gui.add(colorPass.uniforms.color.value, 'b', 0, 4).name('blue');
+```
+
+์์ ํผํฉํ๋ ๊ฐ๋จํ ํ์ฒ๋ฆฌ ์์ด๋๋ฅผ ์์ฑํ์ต๋๋ค.
+
+{{{example url="../threejs-postprocessing-custom.html" }}}
+
+์ธ๊ธํ๋ฏ ์ด ๊ธ์์ GLSL์ ์์ฑ๋ฒ๊ณผ ์ฌ์ฉ์ ์ง์ ์์ด๋๋ฅผ ๋ง๋๋ ๋ฒ์ ๋ชจ๋ ๋ค๋ฃจ๊ธฐ๋ ๋ฌด๋ฆฌ์
๋๋ค. WebGL์ด ์ด๋ป๊ฒ ๋์ํ๋์ง ์๊ณ ์ถ๋ค๋ฉด [์ด ์๋ฆฌ์ฆ](https://webglfundamentals.org)๋ฅผ ์ฐธ๊ณ ํ์ธ์. [Three.js์ ํ์ฒ๋ฆฌ ์์ด๋ ์์ค ์ฝ๋](https://github.com/mrdoob/three.js/tree/master/examples/js/shaders)๋ฅผ ๋ถ์ํ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์
๋๋ค. ์๋์ ์ผ๋ก ๋ณต์กํ ์์ด๋๋ ์์ง๋ง ์์ ๊ฒ๋ถํฐ ์ฐจ๊ทผ์ฐจ๊ทผ ์ดํด๋ณธ๋ค๋ฉด ์ธ์ ๊ฐ ์ ์ฒด๋ฅผ ์ดํดํ ์ ์์ ๊ฑฐ์์.
+
+์์ฝ๊ฒ๋ Three.js์ ํ์ฒ๋ฆฌ ํจ๊ณผ ๋๋ถ๋ถ์ ๊ณต์ ๋ฌธ์๊ฐ ์์ด [์์ ๋ฅผ ์ฐธ๊ณ ํ๊ฑฐ๋](https://github.com/mrdoob/three.js/tree/master/examples) [ํ์ฒ๋ฆฌ ํจ๊ณผ์ ์์ค ์ฝ๋](https://github.com/mrdoob/three.js/tree/master/examples/js/postprocessing)๋ฅผ ์ง์ ๋ถ์ํด์ผ ํฉ๋๋ค. ๋ถ๋ ์ด ๊ธ๊ณผ ์ด ์๋ฆฌ์ฆ์ [๋ ๋ ํ๊ฒ์ ๊ดํ ๊ธ](threejs-rendertargets.html)์ด ์ข์ ์ถ๋ฐ์ ์ ๋ง๋ จํด์ฃผ์์ผ๋ฉด ์ข๊ฒ ๋ค์. | true |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-prerequisites.md | @@ -148,12 +148,50 @@ ES5์์ ๋ฐฐ์ด์ [`forEach`](https://developer.mozilla.org/ko/docs/Web/JavaSc
๊ธฐ์กด ๋ฐฉ๋ฒ
- const width = dims.width;
- const height = dims.height;
+```js
+const width = dims.width;
+const height = dims.height;
+```
+
+์๋ก์ด ๋ฐฉ๋ฒ
+
+```js
+const { width, height } = dims;
+```
+
+๊ตฌ์กฐ๋ถํดํ ๋น์ ๋ฐฐ์ด์๋ ์ ์ฉํ ์ ์์ต๋๋ค. `const position = [1, 2, 3, 4]`.
+์ด๋ฐ ๋ฐฐ์ด์ด ์๋ค๊ณ ํด๋ณด์ฃ .
+
+๊ธฐ์กด ๋ฐฉ๋ฒ
+
+```js
+const x = position[2];
+const y = position[1];
+```
์๋ก์ด ๋ฐฉ๋ฒ
- const { width, height } = dims;
+```js
+const [ , y, x ] = position;
+```
+
+๋ํ ๋งค๊ฐ๋ณ์์๋ ๊ตฌ์กฐ๋ถํดํ ๋น์ ์ ์ฉํ ์ ์์ต๋๋ค.
+
+```js
+const dims = { width: 300, height: 150 };
+const position = [1, 2, 3, 4];
+
+function distFromOrig([x, y]) {
+ return Math.sqrt(x * x + y * y);
+}
+
+const dist = distFromOrig(position); // dist = 2.236...
+
+function area({ width, height }) {
+ return width * height;
+}
+const a = area(dims); // a = 45000
+```
### ๊ฐ์ฒด ์ ์ธ ์ ์ถ์ฝ ๋ฌธ๋ฒ ์ฌ์ฉ
@@ -193,7 +231,7 @@ ES5์์ ๋ฐฐ์ด์ [`forEach`](https://developer.mozilla.org/ko/docs/Web/JavaSc
function log(className, ...args) {
const elem = document.createElement('div');
elem.className = className;
- elem.textContent = [...args].join(' ');
+ elem.textContent = args.join(' ');
document.body.appendChild(elem);
}
```
@@ -205,6 +243,22 @@ const position = [1, 2, 3];
somemesh.position.set(...position);
```
+๋ฐฐ์ด์ ์์ ๋ณต์ฌํ ๋ ์ฌ์ฉํ ์๋ ์๊ณ
+
+```js
+const copiedPositionArray = [...position];
+copiedPositionArray.push(4); // [1,2,3,4]
+console.log(position); // [1,2,3] ๊ธฐ์กด ๋ฐฐ์ด์ ์ํฅ์ ๋ฐ์ง ์์
+```
+
+๊ฐ์ฒด๋ฅผ ํฉ์น ๋๋ ์ฌ์ฉํ ์ ์์ฃ .
+
+```
+const a = { abc: 123 };
+const b = { def: 456 };
+const c = { ...a, ...b }; // c = { abc: 123, def: 456 }
+```
+
### `class` ์ฌ์ฉํ๊ธฐ
ES5 ์ดํ์ ๋ฌธ๋ฒ์ผ๋ก ํด๋์ค ์คํ์ผ์ ๊ฐ์ฒด๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋ค๋ฅธ ๊ฐ๋ฐ์๋ค์๊ฒ ๋ฏ์ ์์ | true |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-rendering-on-demand.md | @@ -0,0 +1,227 @@
+Title: ๋ถํ์ํ ๋ ๋๋ง ์์ ๊ธฐ
+Description: ๋ถํ์ํ ๋ ๋๋ง์ ์ ๊ฑฐํฉ๋๋ค
+TOC: ๋ถํ์ํ ๋ ๋๋ง ์์ ๊ธฐ
+
+๋๋ถ๋ถ์ ๊ฐ๋ฐ์์๊ฒ ์ด ์ฃผ์ ๋ ๋๋ฌด ๋ปํ ์ ์์ง๋ง, ํ์ํ ๋๊ตฐ๊ฐ๋ฅผ ์ํด
+๊ธ์ ์จ๋ณด๋ ค ํฉ๋๋ค. ๋๋ถ๋ถ์ Three.js ์์ ๋ ๋ ๋๋ง ๊ณผ์ ์ ๊ณ์ ๋ฐ๋ณตํฉ๋๋ค.
+๊ทธ๋ฌ๋๊น ์๋์ ๊ฐ์ด ์ฌ๊ท์ ์ผ๋ก `requestAnimationFrame` ํจ์๋ฅผ ์ฌ์ฉํ๋ค๋
+๊ฑฐ์ฃ .
+
+```js
+function render() {
+ ...
+ requestAnimationFrame(render);
+}
+requestAnimationFrame(render);
+```
+
+๊ณ์ ์ ๋๋ฉ์ด์
์ด ์๋ ๊ฒฝ์ฐ์์ผ ๋ณ ์๊ด์ด ์์ง๋ง, ์ ๋๋ฉ์ด์
์ด ์๋ ๊ฒฝ์ฐ๋ผ๋ฉด
+์ด๋จ๊น์? ์ด ๊ฒฝ์ฐ ๋ถํ์ํ ๋ ๋๋ง์ ๋ฐ๋ณตํ๋ ๊ฒ์ ์ฐ์ฐ ๋ญ๋น์ผ ๋ฟ๋๋ฌ ์ฌ์ฉ
+ํ๊ฒฝ์ด ๋ชจ๋ฐ์ผ์ด๋ผ๋ฉด ์ฌ์ฉ์์ ๋ฐฐํฐ๋ฆฌ๊น์ง ๋ญ๋นํ๋ ์
์
๋๋ค.
+
+์ฒ์ ํ ๋ฒ๋ง ๋ ๋๋งํ๊ณ , ๊ทธ ํ์ ๋ณํ๊ฐ ์์ ๋๋ง ๋ ๋๋งํ๋ ๊ฒ์ด ๊ฐ์ฅ ์ ํํ
+ํด๊ฒฐ์ฑ
์ผ ๊ฒ๋๋ค. ์ฌ๊ธฐ์ ๋ณํ๋ ํ
์ค์ฒ๋ ๋ชจ๋ธ์ ๋ก๋ฉ์ด ๋๋ฌ์ ๋, ์ธ๋ถ์์
+๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ ๋, ์ฌ์ฉ์๊ฐ ์นด๋ฉ๋ผ๋ฅผ ์กฐ์ ํ๊ฑฐ๋, ์ค์ ์ ๋ฐ๊พธ๊ฑฐ๋, ์ธํ ๊ฐ์ด
+๋ณ๊ฒฝ๋ ๊ฒฝ์ฐ ๋ฑ ๋ค์ํ๊ฒ ์ฃ .
+
+[๋ฐ์ํ ๋์์ธ์ ๊ดํ ๊ธ](threejs-responsive.html)์์ ์ผ๋ ์์ ๋ฅผ ์์ ํด
+ํ์์ ๋ฐ๋ฅธ ๋ ๋๋ง์ ๊ตฌํํด๋ด
์๋ค.
+
+๋จผ์ ๋ญ๊ฐ ๋ณํ๋ฅผ ์ผ์ผํฌ ์ ์๋ ์์๊ฐ ํ์ํ๋ `OrbitControls`๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+import * as THREE from './resources/three/r115/build/three.module.js';
++import { OrbitControls } from './resources/threejs/r115/examples/jsm/controls/OrbitControls.js';
+
+...
+
+const fov = 75;
+const aspect = 2; // canvas ๊ธฐ๋ณธ๊ฐ
+const near = 0.1;
+const far = 5;
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+camera.position.z = 2;
+
++const controls = new OrbitControls(camera, canvas);
++controls.target.set(0, 0, 0);
++controls.update();
+```
+
+์ ์ก๋ฉด์ฒด์ ์ ๋๋ฉ์ด์
์ ๋ฃ์ง ์์ ๊ฒ์ด๋ ์ด๋ค์ ์ฐธ์กฐํ ํ์๊ฐ ์์ต๋๋ค.
+
+```js
+-const cubes = [
+- makeInstance(geometry, 0x44aa88, 0),
+- makeInstance(geometry, 0x8844aa, -2),
+- makeInstance(geometry, 0xaa8844, 2),
+-];
++makeInstance(geometry, 0x44aa88, 0);
++makeInstance(geometry, 0x8844aa, -2);
++makeInstance(geometry, 0xaa8844, 2);
+```
+
+์ ๋๋ฉ์ด์
๊ณผ `requestAnimationFrame` ๊ด๋ จ ์ฝ๋๋ ์ ๊ฑฐํฉ๋๋ค.
+
+```js
+-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;
+- cube.rotation.x = rot;
+- cube.rotation.y = rot;
+- });
+
+ renderer.render(scene, camera);
+
+- requestAnimationFrame(render);
+}
+
+-requestAnimationFrame(render);
+```
+
+๊ทธ๋ฆฌ๊ณ `render` ํจ์๋ฅผ ์ง์ ํธ์ถํฉ๋๋ค.
+
+```js
+render();
+```
+
+์ด์ `OrbitControls`๊ฐ ์นด๋ฉ๋ผ ์ค์ ์ ๋ฐ๊ฟ ๋๋ง๋ค ์ง์ `render` ํจ์๋ฅผ ํธ์ถํด์ผ
+ํฉ๋๋ค. ๋ญ๊ฐ ๋ณต์กํ ๊ฒ ๊ฐ์ง๋ง ๋คํํ `OrbitControls`์๋ `change` ์ด๋ฒคํธ๊ฐ ์์ต๋๋ค.
+
+```js
+controls.addEventListener('change', render);
+```
+
+๋ํ ์ฐฝ ํฌ๊ธฐ๊ฐ ๋ฐ๋ ๋์ ๋์๋ ์ง์ ์ฒ๋ฆฌํด์ผ ํฉ๋๋ค. `render` ํจ์๋ฅผ ๊ณ์ ํธ์ถํ
+๋๋ ํด๋น ๋์์ ์๋์ผ๋ก ์ฒ๋ฆฌํ์ง๋ง, ์ง๊ธ์ `render` ํจ์๋ฅผ ์๋์ผ๋ก ํธ์ถํ๋ฏ๋ก
+์ฐฝ์ ํฌ๊ธฐ๊ฐ ๋ฐ๋ ๋ `render` ํจ์๋ฅผ ํธ์ถํ๋๋ก ํ๊ฒ ์ต๋๋ค.
+
+```js
+window.addEventListener('resize', render);
+```
+
+์ด์ ๋ถํ์ํ ๋ ๋๋ง์ ๋ฐ๋ณตํ์ง ์์ต๋๋ค.
+
+{{{example url="../threejs-render-on-demand.html" }}}
+
+`OrbitControls`์๋ ๊ด์ฑ(inertia) ์ต์
์ด ์์ต๋๋ค. `enableDamping` ์์ฑ์ ture๋ก
+์ค์ ํ๋ฉด ๋์์ด ์ข ๋ ๋ถ๋๋ฌ์์ง์ฃ .
+
+โป damping: ๊ฐ์ .
+
+```js
+controls.enableDamping = true;
+```
+
+๋ํ `OrbitControls`๊ฐ ๋ถ๋๋ฌ์ด ๋์์ ๊ตฌํํ ๋ ๋ณ๊ฒฝ๋ ์นด๋ฉ๋ผ ๊ฐ์ ๊ณ์ ๋๊ฒจ์ฃผ๋๋ก
+`render` ํจ์ ์์์ `controls.update` ๋ฉ์๋๋ฅผ ํธ์ถํด์ผ ํฉ๋๋ค. ํ์ง๋ง ์ด๋ ๊ฒ ํ๋ฉด
+`change` ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ `render` ํจ์๊ฐ ๋ฌดํ์ ํธ์ถ๋ ๊ฒ๋๋ค. controls๊ฐ `change`
+์ด๋ฒคํธ๋ฅผ ๋ณด๋ด๋ฉด `render` ํจ์๊ฐ ํธ์ถ๋๊ณ , `render` ํจ์๋ `controls.update` ๋ฉ์๋๋ฅผ
+ํธ์ถํด ๋ค์ `change` ์ด๋ฒคํธ๋ฅผ ๋ณด๋ด๊ฒ ๋ง๋ค ํ
๋๊น์.
+
+`requestAnimationFrame`์ด ์ง์ `render` ํจ์๋ฅผ ํธ์ถํ๊ฒ ํ๋ฉด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐ ํ ์
+์์ต๋๋ค. ๋๋ฌด ๋ง์ ํ๋ ์์ ๋ง๊ธฐ ์ํด ๋ณ์ ํ๋๋ฅผ ๋์ด ์์ฒญํ ํ๋ ์์ด ์์ ๊ฒฝ์ฐ์๋ง
+ํ๋ ์์ ์์ฒญํ๋๋ก ํ๋ฉด ๋๊ฒ ๋ค์.
+
+```js
++let renderRequested = false;
+
+function render() {
++ renderRequested = false;
+
+ if (resizeRendererToDisplaySize(renderer)) {
+ const canvas = renderer.domElement;
+ camera.aspect = canvas.clientWidth / canvas.clientHeight;
+ camera.updateProjectionMatrix();
+ }
+
++ controls.update();
+ renderer.render(scene, camera);
+}
+render();
+
++function requestRenderIfNotRequested() {
++ if (!renderRequested) {
++ renderRequested = true;
++ requestAnimationFrame(render);
++ }
++}
+
+-controls.addEventListener('change', render);
++controls.addEventListener('change', requestRenderIfNotRequested);
+```
+
+์ฐฝ ํฌ๊ธฐ ๋ณํ๊ฐ ์ผ์ด๋ฌ์ ๋๋ `requestRenderIfNotRequested`๋ฅผ ํธ์ถํ๋๋ก ํฉ๋๋ค.
+
+```js
+-window.addEventListener('resize', render);
++window.addEventListener('resize', requestRenderIfNotRequested);
+```
+
+์ฐจ์ด์ ์ ๋๋ผ๊ธฐ ์ด๋ ค์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ํ์ดํ ํค๋ฅผ ์ฐ๊ฑฐ๋ ์์ ๋ฅผ ๋๋๊ทธํด ๋ณด๊ณ
+๋ค์ ์ ์์ ๋ฅผ ์ด๋ฆฌ์ ๋ฆฌ ๋๋ ค๋ณด์ธ์. ์ฐจ์ด์ ์ด ๋๊ปด์ง ๊ฑฐ์์. ์ ์์ ๋ ํ์ดํ ํค๋ฅผ
+๋๋ ์ ๋ ์ผ์ ๊ฑฐ๋ฆฌ๋งํผ ์๊ฐ์ด๋ํ์ง๋ง ์๋์ ์์ ๋ ์ฝ๊ฐ ๋ฏธ๋๋ฌ์ง๋๋ค.
+
+{{{example url="../threejs-render-on-demand-w-damping.html" }}}
+
+๊ฐ๋จํ 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 { GUI } from '../3rdparty/dat.gui.module.js';
+```
+
+๋จผ์ ๊ฐ ์ ์ก๋ฉด์ฒด์ ์๊ณผ x์ถ ์ค์ผ์ผ์ ์กฐ์ ํ๋ GUI๋ฅผ ์ถ๊ฐํฉ๋๋ค. [์กฐ๋ช
์ ๊ดํ ๊ธ](threejs-lights.html)์์
+์ผ๋ `ColorGUIHelper`๋ฅผ ๊ฐ์ ธ์ ์ฐ๋๋ก ํ์ฃ .
+
+๋จผ์ GUI๋ฅผ ์์ฑํฉ๋๋ค.
+
+```js
+const gui = new GUI();
+```
+
+๊ทธ๋ฆฌ๊ณ ๊ฐ ์ ์ก๋ฉด์ฒด์ `material.color`, `cube.scale.x` ์ค์ ์ ํด๋๋ก ๋ฌถ์ด
+์ถ๊ฐํฉ๋๋ค.
+
+```js
+function makeInstance(geometry, color, x) {
+ const material = new THREE.MeshPhongMaterial({color});
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+
+ cube.position.x = x;
+
++ const folder = gui.addFolder(`Cube${ x }`);
++ folder.addColor(new ColorGUIHelper(material, 'color'), 'value')
++ .name('color')
++ .onChange(requestRenderIfNotRequested);
++ folder.add(cube.scale, 'x', .1, 1.5)
++ .name('scale x')
++ .onChange(requestRenderIfNotRequested);
++ folder.open();
+
+ return cube;
+}
+```
+
+dat.GUI ์ปจํธ๋กค(control)์ `onChange` ๋ฉ์๋์ ์ฝ๋ฐฑ ํจ์๋ฅผ ๋๊ฒจ์ฃผ๋ฉด GUI ๊ฐ์ด ๋ฐ๋
+๋๋ง๋ค ์ฝ๋ฐฑ ํจ์๋ฅผ ํธ์ถํฉ๋๋ค. ์์ ์ ๊ฒฝ์ฐ์๋ ๋จ์ํ `requestRenderIfNotRequested`
+ํจ์๋ฅผ ๋๊ฒจ์ฃผ๋ฉด ๋์ฃ . ๊ทธ๋ฆฌ๊ณ `folder.open` ๋ฉ์๋๋ฅผ ํธ์ถํด ํด๋๋ฅผ ์ด์ด ๋ก๋๋ค.
+
+{{{example url="../threejs-render-on-demand-w-gui.html" }}}
+
+์ด ๊ธ์ด ๋ถํ์ํ ๋ ๋๋ง ์ ๊ฑฐ์ ๋ํ ๊ฐ๋
์ ์กฐ๊ธ์ด๋ผ๋ ์ก์์ฃผ์๊ธธ ๋ฐ๋๋๋ค. ๋ณดํต
+Three.js๋ฅผ ์ฌ์ฉํ ๋๋ ์ด๋ ๊ฒ ๋ ๋๋ง ๋ฃจํ๋ฅผ ์ ์ดํ ์ผ์ด ์์ต๋๋ค. ๋๊ฒ ๊ฒ์ ๋๋
+์ ๋๋ฉ์ด์
์ด ๋ค์ด๊ฐ 3D ์ปจํ
์ธ ์ด๊ธฐ ๋๋ฌธ์ด์ฃ . ํ์ง๋ง ์ง๋๋, 3D ์๋ํฐ, 3D ๊ทธ๋ํ,
+์ํ ๋ชฉ๋ก ๋ฑ์์๋ ์ด๋ฐ ๊ธฐ๋ฒ์ด ํ์ํ ์๋ ์์ต๋๋ค. | true |
Other | mrdoob | three.js | 633dbb61bdfd242077b4c012fce7468c1e707c1a.json | add translation kr/threejs-rendering-on-demand.md
add translation kr/threejs-transparency.md
update translation kr/threejs-prerequisites.md
add translation kr/threejs-multiple-scenes.md
add translation kr/threejs-picking.md
fix typo & add translation kr/threejs-post-processing.md
add translation kr/threejs-post-processing-3dlut.md | threejs/lessons/kr/threejs-transparency.md | @@ -0,0 +1,396 @@
+Title: Three.js ํฌ๋ช
๋
+Description: Three.js์์ ํฌ๋ช
๋๋ฅผ ์ค์ ํ๋ ๋ฒ์ ์์๋ด
๋๋ค
+TOC: ๋ฌผ์ฒด์ ํฌ๋ช
๋ ์ค์ ํ๊ธฐ
+
+Three.js์์ ํฌ๋ช
๋๋ ๊ฐ๋จํ์ง๋ง ๋์์ ๊น๋ค๋ก์ด ์ฃผ์ ์
๋๋ค.
+
+๋จผ์ ์ฌ์ด ๊ฒ๋ถํฐ ์์๋ณด์ฃ . ์์ ๋ก ์ ์ก๋ฉด์ฒด 8๊ฐ๋ฅผ 2x2x2 ๊ทธ๋ฆฌ๋์ ๋ง์ถ ์ฅ๋ฉด์
+๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค.
+
+[๋ถํ์ํ ๋ ๋๋ง ์ ๊ฑฐํ๊ธฐ](threejs-rendering-on-demand.html)์์ ์ผ๋
+์์ ๋ฅผ ๊ฐ์ ธ์ ์ ์ก๋ฉด์ฒด 3๊ฐ๋ฅผ 8๊ฐ๋ก ์์ ํฉ๋๋ค. ๋จผ์ `makeInstance` ํจ์๊ฐ
+x, y, z ๊ฐ์ ๋ฐ๋๋ก ์์ ํ๊ฒ ์ต๋๋ค.
+
+```js
+-function makeInstance(geometry, color) {
++function makeInstance(geometry, color, x, y, z) {
+ const material = new THREE.MeshPhongMaterial({color});
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+
+- cube.position.x = x;
++ cube.position.set(x, y, z);
+
+ return cube;
+}
+```
+
+๊ทธ๋ฆฌ๊ณ ์ ์ก๋ฉด์ฒด 8๊ฐ๋ฅผ ๋ง๋ญ๋๋ค.
+
+```js
++function hsl(h, s, l) {
++ return (new THREE.Color()).setHSL(h, s, l);
++}
+
+-makeInstance(geometry, 0x44aa88, 0);
+-makeInstance(geometry, 0x8844aa, -2);
+-makeInstance(geometry, 0xaa8844, 2);
+
++{
++ const d = 0.8;
++ makeInstance(geometry, hsl(0 / 8, 1, .5), -d, -d, -d);
++ makeInstance(geometry, hsl(1 / 8, 1, .5), d, -d, -d);
++ makeInstance(geometry, hsl(2 / 8, 1, .5), -d, d, -d);
++ makeInstance(geometry, hsl(3 / 8, 1, .5), d, d, -d);
++ makeInstance(geometry, hsl(4 / 8, 1, .5), -d, -d, d);
++ makeInstance(geometry, hsl(5 / 8, 1, .5), d, -d, d);
++ makeInstance(geometry, hsl(6 / 8, 1, .5), -d, d, d);
++ makeInstance(geometry, hsl(7 / 8, 1, .5), d, d, d);
++}
+```
+
+์นด๋ฉ๋ผ๋ ์กฐ์ ํฉ๋๋ค.
+
+```js
+const fov = 75;
+const aspect = 2; // canvas ๊ธฐ๋ณธ๊ฐ
+const near = 0.1;
+-const far = 5;
++const far = 25;
+const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
+-camera.position.z = 4;
++camera.position.z = 2;
+```
+
+๋ฐฐ๊ฒฝ์์ ํ์์์ผ๋ก ๋ฐ๊ฟ์ฃผ๊ณ
+
+```js
+const scene = new THREE.Scene();
++scene.background = new THREE.Color('white');
+```
+
+์ ์ก๋ฉด์ฒด์ ์๋ฉด๋ ๋น์ ๋ฐ๋๋ก ์กฐ๋ช
์ ํ๋ ๋ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+-{
++function addLight(...pos) {
+ const color = 0xFFFFFF;
+ const intensity = 1;
+ const light = new THREE.DirectionalLight(color, intensity);
+- light.position.set(-1, 2, 4);
++ light.position.set(...pos);
+ scene.add(light);
+}
++addLight(-1, 2, 4);
++addLight( 1, -1, -2);
+```
+
+์ ์ก๋ฉด์ฒด๋ฅผ ํฌ๋ช
ํ๊ฒ ๋ง๋ค๋ ค๋ฉด [`transparent`](Material.transparent) ์์ฑ์
+์ผ๊ณ [`opacity`](Material.opacity) ์์ฑ์ ์ค์ ํด์ค์ผ ํฉ๋๋ค(CSS์ ๋ง์ฐฌ๊ฐ์ง๋ก
+0์ ์์ ํ ํฌ๋ช
ํจ, 1์ ์์ ํ ๋ถํฌ๋ช
ํจ์ ์๋ฏธ).
+
+```js
+function makeInstance(geometry, color, x, y, z) {
+- const material = new THREE.MeshPhongMaterial({color});
++ const material = new THREE.MeshPhongMaterial({
++ color,
++ opacity: 0.5,
++ transparent: true,
++ });
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+
+ cube.position.set(x, y, z);
+
+ return cube;
+}
+```
+
+์ด์ 8๊ฐ์ ๋ฐํฌ๋ช
ํ ์ ์ก๋ฉด์ฒด๊ฐ ์๊ฒผ์ต๋๋ค.
+
+{{{example url="../threejs-transparency.html"}}}
+
+์์ ๋ฅผ ๋๋๊ทธํ๋ฉด ํ๋ฉด์ ํ์ ์ํฌ ์ ์์ต๋๋ค.
+
+์๋ฒฝํ๋ฐ์, ๋ผ๊ณ ์๊ฐํ๋ค๋ฉด ์ข ๋ ์์ธํ ๋ณด์ธ์. ์ ์ก๋ฉด์ฒด์ ๋ท๋ฉด์ด ํ๋๋
+๋ณด์ด์ง ์์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/transparency-cubes-no-backs.png" style="width: 416px;"></div>
+<div class="threejs_center">๋ท๋ฉด์ด ๋ณด์ด์ง ์๋๋ค</div>
+
+์ด์ ์ [์ฌ์ง(material)์ ๊ดํด](threejs-materials.html) ๋ฐฐ์ธ ๋ [`side`](Material.side)
+์์ฑ์ ๋ํด ๋ฐฐ์ ์์ฃ . ์ด ์์ฑ์ `THREE.DoubleSide`๋ก ์ค์ ํด ์ ์ก๋ฉด์ฒด์
+์๋ฉด์ด ๋ชจ๋ ๋ณด์ด๋๋ก ํด๋ด
์๋ค.
+
+```js
+const material = new THREE.MeshPhongMaterial({
+ color,
+ map: loader.load(url),
+ opacity: 0.5,
+ transparent: true,
++ side: THREE.DoubleSide,
+});
+```
+
+{{{example url="../threejs-transparency-doubleside.html" }}}
+
+์์ ๋ฅผ ๋๋ ค๋ณด์ธ์. ๋ญ๊ฐ ํด๊ฒฐ๋ ๋ฏ ํ์ง๋ง ์์ธํ ๋ณด๋ฉด ๊ฐ๋ ๋ท๋ฉด ๋๋ ๋ท๋ฉด์
+์ผ๋ถ๊ฐ ๋ณด์ด์ง ์์ต๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/transparency-cubes-some-backs.png" style="width: 368px;"></div>
+<div class="threejs_center">์ ์ก๋ฉด์ฒด์ ์ผ์ชฝ ๋ท๋ฉด์ด ๋ณด์ด์ง ์๋๋ค</div>
+
+์ด๋ 3D ์์๋ฅผ ๋ ๋๋งํ๋ ๋ฐฉ์ ๋๋ฌธ์
๋๋ค. WebGL์ ๊ฐ geometry์ ์ผ๊ฐํ์
+ํ ๋ฒ์ ํ๋์ฉ ๋ ๋๋งํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ผ๊ฐํ์ ํฝ์
ํ๋๋ฅผ ๋ ๋๋งํ ๋๋ง๋ค
+2๊ฐ์ ์ ๋ณด๋ฅผ ๊ธฐ๋กํ๋๋ฐ, ํ๋๋ ํด๋น ํฝ์
์ ์์ด๊ณ ๋ค๋ฅธ ํ๋๋ ํฝ์
์
+๊น์ด(depth)์
๋๋ค. ๋ค์ ์ผ๊ฐํ์ ๊ทธ๋ฆด ๋ ํด๋น ํฝ์
์ด ์ด๋ฏธ ๊ทธ๋ ค์ง ํฝ์
๋ณด๋ค
+๊น์ด๊ฐ ๊น๋ค๋ฉด ํด๋น ํฝ์
์ ๋ ๋๋งํ์ง ์์ฃ .
+
+์ด๋ ๋ถํฌ๋ช
ํ ๋ฌผ์ฒด์์๋ ๋ฌธ์ ๊ฐ ๋์ง ์์์ง๋ง ํฌ๋ช
ํ ๋ฌผ์ฒด์์๋ ๋ฌธ์ ๊ฐ ๋ฉ๋๋ค.
+
+์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด ํฌ๋ช
ํ ๋ฌผ์ฒด๋ฅผ ๋ถ๋ฅํด ๋ค์ ์๋ ๋ฌผ์ฒด๋ฅผ ์์ ์๋ ๋ฌผ์ฒด๋ณด๋ค
+๋จผ์ ๋ ๋๋งํด์ผ ํฉ๋๋ค. `Mesh` ๊ฐ์ ๊ฒฝ์ฐ๋ Three.js๊ฐ ์๋์ผ๋ก ์ด๋ฅผ ์ฒ๋ฆฌํด์ฃผ์ฃ .
+๋ง์ฝ ๊ทธ๋ฌ์ง ์์๋ค๋ฉด ์ ์ผ ์ฒซ ๋ฒ์งธ ์์ ์์ ๋ค์ ์๋ ์ ์ก๋ฉด์ฒด๋ฅผ ์์ ๋ณผ ์
+์์์ ๊ฒ๋๋ค.
+
+์ ์ก๋ฉด์ฒด์๋ ํ ๋ฉด์ 2๊ฐ, ์ด 12๊ฐ์ ์ผ๊ฐํ์ด ์์ต๋๋ค. ๊ฐ ์ผ๊ฐํ์ ๋ ๋๋ง ์์๋
+[geometry์ ๊ดํ ๊ธ์์ ๋ดค๋ ๊ฒ](threejs-custom-buffergeometry.html)๊ณผ ๊ฐ์ฃ .
+์์ ์ ๋ฐ๋ผ ์นด๋ฉ๋ผ์์ ๊ฐ๊น์ด ์ผ๊ฐํ์ ๋จผ์ ๋ ๋๋งํ ๊ฒ๋๋ค. ์๋ฉด์ ๋ท๋ฉด๋ณด๋ค ๋จผ์
+๋ ๋๋งํ๋, ๋๋๋ก ๋ท๋ฉด์ด ๋ณด์ด์ง ์์ ์๋ฐ์ ์์ฃ .
+
+๊ตฌ์ฒด๋ ์ ์ก๋ฉด์ฒด ๋ฑ ๋ณผ๋ก ๋ฌผ์ฒด(convex object)์ ๊ฒฝ์ฐ, ๋ชจ๋ ๋ฌผ์ฒด๋ฅผ ํ ๋ฒ์ฉ ๋ ๋ ๋๋งํด
+๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. ํ๋๋ ์์ชฝ๋ฉด ์ผ๊ฐํ๋ง ๋ ๋๋งํ๊ณ , ๋ค๋ฅธ ํ๋๋ ๋ฐ๊นฅ์ชฝ
+์ผ๊ฐํ๋ง ๋ ๋๋งํ๋๋ก ๋ง๋๋ ๊ฒ์ด์ฃ .
+
+```js
+function makeInstance(geometry, color, x, y, z) {
++ [THREE.BackSide, THREE.FrontSide].forEach((side) => {
+ const material = new THREE.MeshPhongMaterial({
+ color,
+ opacity: 0.5,
+ transparent: true,
++ side,
+ });
+
+ const cube = new THREE.Mesh(geometry, material);
+ scene.add(cube);
+
+ cube.position.set(x, y, z);
++ });
+}
+```
+
+์ด์ฐ์ด์ฐ ํด๊ฒฐ๋ *๊ฒ์ฒ๋ผ* ๋ณด์
๋๋ค.
+
+{{{example url="../threejs-transparency-doubleside-hack.html" }}}
+
+Three.js์ ๋ถ๋ฅ ๊ธฐ์ค์ ๊ณ ์ ์ ์ธ ๋ฏํฉ๋๋ค. `side: THREE.BackSide` mesh๋ฅผ ๋จผ์
+๋ฃ๊ณ , ๊ทธ ๋ค์ ์ ํํ ๊ฐ์ ์์น์ `side: THREE.FrontSide` mesh๋ฅผ ๋ฃ์์ผ๋๊น์.
+
+์ด๋ฒ์๋ ํ๋ฉด 2๊ฐ๋ฅผ ๊ต์ฐจ๋ก ๋ฐฐ์นํด๋ด
์๋ค(์ ์ก๋ฉด์ฒด ๊ด๋ จ ์ฝ๋๋ฅผ ์ ๋ถ ์ง์ด ๋ค).
+๊ฐ ํ๋ฉด์๋ ๋ค๋ฅธ ํ
์ค์ฒ๋ฅผ ๋ฃ์ ๊ฒ๋๋ค.
+
+```js
+const planeWidth = 1;
+const planeHeight = 1;
+const geometry = new THREE.PlaneBufferGeometry(planeWidth, planeHeight);
+
+const loader = new THREE.TextureLoader();
+
+function makeInstance(geometry, color, rotY, url) {
+ const texture = loader.load(url, render);
+ const material = new THREE.MeshPhongMaterial({
+ color,
+ map: texture,
+ opacity: 0.5,
+ transparent: true,
+ side: THREE.DoubleSide,
+ });
+
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+
+ mesh.rotation.y = rotY;
+}
+
+makeInstance(geometry, 'pink', 0, 'resources/images/happyface.png');
+makeInstance(geometry, 'lightblue', Math.PI * 0.5, 'resources/images/hmmmface.png');
+```
+
+ํ๋ฉด์ ํ ๋ฒ์ ํ ๋ฉด๋ฐ์ ๋ณด์ง ๋ชปํ๋, `side: THREE.DoubleSide`๋ก ์ค์ ํ์ต๋๋ค. ๋ํ
+ํ
์ค์ฒ๋ฅผ ์ ๋ถ ๋ถ๋ฌ์์ ๋ ์ฅ๋ฉด์ ๋ค์ ๋ ๋๋งํ๋๋ก `render` ํจ์๋ฅผ `loader.load`
+๋ฉ์๋์ ๋๊ฒจ์คฌ์ต๋๋ค. ์ด๋ [ํ์์ ๋ฐ๋ฅธ ๋ ๋๋ง](threejs-rendering-on-demand.html)์
+๊ตฌํํ๊ธฐ ์ํ ๊ฒ์ด์ฃ .
+
+{{{example url="../threejs-transparency-intersecting-planes.html"}}}
+
+์๊น์ ๋น์ทํ ๋ฌธ์ ๊ฐ ๋ณด์
๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/transparency-planes.png" style="width: 408px;"></div>
+<div class="threejs_center">๋ฉด์ ๋ฐ์ชฝ์ด ์ฌ๋ผ์ก๋ค</div>
+
+ํ๋ฉด์ ๋๋ก ์ชผ๊ฐ ์ค์ ๋ก๋ ๊ต์ฐจํ์ง ์๊ฒ๋ ๋ง๋ค๋ฉด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค.
+
+```js
+function makeInstance(geometry, color, rotY, url) {
++ const base = new THREE.Object3D();
++ scene.add(base);
++ base.rotation.y = rotY;
+
++ [-1, 1].forEach((x) => {
+ const texture = loader.load(url, render);
++ texture.offset.x = x < 0 ? 0 : 0.5;
++ texture.repeat.x = .5;
+ const material = new THREE.MeshPhongMaterial({
+ color,
+ map: texture,
+ opacity: 0.5,
+ transparent: true,
+ side: THREE.DoubleSide,
+ });
+
+ const mesh = new THREE.Mesh(geometry, material);
+- scene.add(mesh);
++ base.add(mesh);
+
+- mesh.rotation.y = rotY;
++ mesh.position.x = x * .25;
+ });
+}
+```
+
+์ ๊ฑธ ์ด๋ป๊ฒ ๊ตฌํํ ์ง๋ ์ฌ๋ฌ๋ถ์ ์ ํ์
๋๋ค. [๋ธ๋ ๋(Blender)](https://blender.org)
+๊ฐ์ 3D ์๋ํฐ๋ฅผ ์ฌ์ฉํ๋ค๋ฉด ํ
์ค์ฒ ์ขํ๋ฅผ ์ง์ ์์ ํ๊ฒ ์ฃ . ์์ ์ ๊ฒฝ์ฐ์๋
+`PlaneBufferGeometry`๋ฅผ ์ผ์ต๋๋ค. [์ด์ ์ ๋ค๋ค๋ฏ](threejs-textures.html)
+์ด geometry๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํ
์ค์ฒ๋ฅผ ํฌ๊ธฐ์ ๋ง์ถฐ ๋๋ฆฝ๋๋ค. [`texture.repeat`](Texture.repeat)
+์์ฑ๊ณผ [`texture.offset`](Texture.offset) ์์ฑ์ ์กฐ์ ํด ๊ฐ ๋ฉด์ ์ ์ ํ
+ํ
์ค์ฒ๋ฅผ ์
ํ์ค ์ ์์ฃ .
+
+์ ์ฝ๋์์๋ `Object3D`๋ฅผ ๋ง๋ค์ด ๋ ํ๋ฉด์ ๋ถ๋ชจ๋ก ์ง์ ํ์ต๋๋ค. ์ด๋ ๊ฒ
+ํ๋ฉด ๋ณต์กํ ๊ณ์ฐ ์์ด ๊ฐ๋จํ๊ฒ `Object3D`๋ง ๋๋ ค์ ๋ ํ๋ฉด ๋ค ํ์ ์ํฌ
+์ ์์ฃ .
+
+{{{example url="../threejs-transparency-intersecting-planes-fixed.html"}}}
+
+์ด ๋ฐฉ๋ฒ์ ๊ต์ฐจ์ ์ด ๋ณํ์ง ์๋ ์ ๋ง ๊ฐ๋จํ ๊ฒฝ์ฐ์๋ง ๊ฐ๋ฅํฉ๋๋ค.
+
+ํ
์ค์ฒ๊ฐ ๋ค์ด๊ฐ ์์๋ ์ํ ํ
์คํธ(alpha test)๋ฅผ ํ์ฑํํด ์ด๋ฅผ ํด๊ฒฐํ ์
+์์ฃ .
+
+์ํ ํ
์คํธ๋ Three.js๊ฐ ํฝ์
์ ๋ ๋๋งํ์ง ์๋ ํน์ *์ํ* ๋จ๊ณ๋ฅผ ์๋ฏธํฉ๋๋ค.
+๋ง์ฝ ์๋ฌด๊ฒ๋ ๊ทธ๋ฆฌ์ง ์๊ฒ ์ค์ ํ๋ค๋ฉด ์์ ๊ฐ์ ๋ฌธ์ ๋ ์ฌ๋ผ์ง๊ฒ ์ฃ . ์๋์ ์ผ๋ก
+๊ฒฝ๊ณ๊ฐ ๋ถ๋ช
ํ ํ
์ค์ฒ, ๋๋ญ์, ์๋ ๋ฑ์ ๊ฒฝ์ฐ ์ด๋ ๊ฝค ์ ์๋ํฉ๋๋ค.
+
+์ด๋ฒ์๋ 2๊ฐ์ ๋ฉด์ ๋ง๋ค์ด ํ
์คํธํด๋ณด๋๋ก ํฉ์๋ค. ์๊น๋ ํ
์ค์ฒ๊ฐ ์ ๋ถ ๋ถํฌ๋ช
ํ์ฃ .
+์ด๋ฒ์๋ ๊ฐ ๋ฉด์๋ ๊ฐ๊ฐ ๋ค๋ฅธ, ๋ถ๋ถ์ ์ผ๋ก ํฌ๋ช
ํ ํ
์ค์ฒ๋ฅผ ์ฌ์ฉํ ๊ฒ๋๋ค.
+
+<div class="spread">
+ <div><img class="checkerboard" src="../resources/images/tree-01.png"></div>
+ <div><img class="checkerboard" src="../resources/images/tree-02.png"></div>
+</div>
+
+์๊น ํ๋ฉด 2๊ฐ๋ฅผ ๊ต์ฐจํด๋์๋(๋ฐ์ผ๋ก ๊ฐ๋ฅด๊ธฐ ์ ) ์์ ๋ฅผ ๊ฐ์ ธ์ ์ด ํ
์ค์ฒ์
+[`alphaTest`](Material.alphaTest) ์์ฑ์ ์ง์ ํ๊ฒ ์ต๋๋ค.
+
+```js
+function makeInstance(geometry, color, rotY, url) {
+ const texture = loader.load(url, render);
+ const material = new THREE.MeshPhongMaterial({
+ color,
+ map: texture,
+- opacity: 0.5,
+ transparent: true,
++ alphaTest: 0.5,
+ side: THREE.DoubleSide,
+ });
+
+ const mesh = new THREE.Mesh(geometry, material);
+ scene.add(mesh);
+
+ mesh.rotation.y = rotY;
+}
+
+-makeInstance(geometry, 'pink', 0, 'resources/images/happyface.png');
+-makeInstance(geometry, 'lightblue', Math.PI * 0.5, 'resources/images/hmmmface.png');
++makeInstance(geometry, 'white', 0, 'resources/images/tree-01.png');
++makeInstance(geometry, 'white', Math.PI * 0.5, 'resources/images/tree-02.png');
+```
+
+์ด๋๋ก ์คํํด๋ ๋์ง๋ง, ๊ฐ๋จํ UI๋ฅผ ๋ง๋ค์ด `alphaTest`์ `transparent` ์์ฑ์
+๊ฐ๊ณ ๋ ์ ์๊ฒ ํด๋ณด๊ฒ ์ต๋๋ค. [์ฌ ๊ทธ๋ํ์ ๊ดํ ๊ธ](threejs-scenegraph.html)์์
+์๊ฐํ๋ dat.GUI๋ฅผ ์จ์์.
+
+๋จผ์ dat.GUI์ ์ง์ ํ ํฌํผ ํด๋์ค๋ฅผ ๋ง๋ค๊ฒ ์ต๋๋ค. ์ด ํฌํผ ํด๋์ค๋ ์ฅ๋ฉด ์ ๋ชจ๋
+์ฌ์ง์ ํด๋น ๊ฐ์ผ๋ก ๋ณ๊ฒฝํ ๊ฒ๋๋ค.
+
+```js
+class AllMaterialPropertyGUIHelper {
+ constructor(prop, scene) {
+ this.prop = prop;
+ this.scene = scene;
+ }
+ get value() {
+ const { scene, prop } = this;
+ let v;
+ scene.traverse((obj) => {
+ if (obj.material && obj.material[prop] !== undefined) {
+ v = obj.material[prop];
+ }
+ });
+ return v;
+ }
+ set value(v) {
+ const { scene, prop } = this;
+ scene.traverse((obj) => {
+ if (obj.material && obj.material[prop] !== undefined) {
+ obj.material[prop] = v;
+ obj.material.needsUpdate = true;
+ }
+ });
+ }
+}
+```
+
+๋ค์์ผ๋ก GUI๋ฅผ ์ถ๊ฐํฉ๋๋ค.
+
+```js
+const gui = new GUI();
+gui.add(new AllMaterialPropertyGUIHelper('alphaTest', scene), 'value', 0, 1)
+ .name('alphaTest')
+ .onChange(requestRenderIfNotRequested);
+gui.add(new AllMaterialPropertyGUIHelper('transparent', scene), 'value')
+ .name('transparent')
+ .onChange(requestRenderIfNotRequested);
+```
+
+๋ฌผ๋ก 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 { GUI } from '../3rdparty/dat.gui.module.js';
+```
+
+{{{example url="../threejs-transparency-intersecting-planes-alphatest.html"}}}
+
+์์ ๋ฅผ ํ๋ํด๋ณด๋ฉด ํ๋ฉด์ ํ์ ํ
๋๋ฆฌ๊ฐ ๋ณด์ผ ๊ฒ๋๋ค.
+
+<div class="threejs_center"><img src="resources/images/transparency-alphatest-issues.png" style="width: 532px;"></div>
+
+์ด๋ ์์ ๋ดค๋ ์์ ์ ๊ฐ์ ๋ฌธ์ ์
๋๋ค. ํ์ ํ
๋๋ฆฌ๋ฅผ ๊ฐ์ง ์์๊ฐ ๋จผ์ ๊ทธ๋ ค์ ธ
+๋ค์ ์๋ ์์๊ฐ ์ผ๋ถ ๊ฐ๋ ค์ง ๊ฒ์ด์ฃ . ์๋ฒฝํ ํด๊ฒฐ์ฑ
์ ์์ต๋๋ค. ๊ทธ๋๊ทธ๋ ์ํฉ์
+๋ฐ๋ผ `alphaTest`๋ `transparent` ์ต์
์ ์กฐ์ ํด์ ์ํฉ์ ๋ง๋ ํด๊ฒฐ์ฑ
์ ์ฐพ์์ผ
+ํ์ฃ .
+
+๊ฒฐ๊ตญ ์ด ๊ธ์ ์ฃผ์ ๋ "์๋ฒฝํ ํฌ๋ช
๋๋ ๊ตฌํํ๊ธฐ ํ๋ค๋ค"๊ฐ ๋๊ฒ ๋ค์. ์ฌ๋งํ ๋ฐฉ๋ฒ์๋
+๋ชจ๋ ๋ฌธ์ ์, ํํ์ , ํธ๋ฒ ๋ฑ์ด ์กด์ฌํฉ๋๋ค.
+
+์๋์ฐจ์ ๊ฒฝ์ฐ๋ฅผ ์๋ก ๋ค์ด๋ณด์ฃ . ์๋์ฐจ๋ ๋ณดํต 4๋ฉด์ ์ ๋ฆฌ์ฐฝ์ด ์์ต๋๋ค. ๋ ๋๋ง ์์๋ฅผ
+์ ๋๋ก ์ ์ฉํ๋ ค๋ฉด ๊ฐ๊ฐ์ ์ฐฝ๋ฌธ์ ๋ณ๋์ ์์๋ก ๋ง๋ค์ด์ผ ํฉ๋๋ค. ๋ง์ฝ ํ๋์ ์์๋ผ๋ฉด
+Three.js๊ฐ ๋ ๋๋ง ์์๋ฅผ ์ ๋๋ก ๊ฒฐ์ ํ ์ ์๊ฒ ์ฃ .
+
+์๋ฌผ์ด๋ ์๋ ๋ฑ์ ๊ตฌํํ ๋๋ ์ผ๋ฐ์ ์ผ๋ก ์ํ ํ
์คํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
+
+์ด๋ค ๋ฐฉ๋ฒ์ ์ฌ์ฉํ ์ง๋ ์ ์ ์ผ๋ก ์ํฉ๊ณผ ์ฌ๋ฌ๋ถ์ ํ๋จ์ ๋ฌ๋ ค ์์ฃ . | true |
Other | mrdoob | three.js | a0656c6b5a207629127a856da0fc4a6ef5dc0a0f.json | Fix mismatch info
I should have sent pull request together, but I discovered this later.
same as previous, `light` should be child of `camera` not `scene`. | threejs/threejs-multiple-scenes-copy-canvas.html | @@ -80,7 +80,7 @@
const intensity = 1;
const light = new THREE.DirectionalLight(color, intensity);
light.position.set(-1, 2, 4);
- scene.add(light);
+ camera.add(light);
}
return {scene, camera, controls}; | false |
Other | mrdoob | three.js | c17cb2587d863518ca27074135dcffe4f94c2099.json | Fix mismatch info (#88)
light should be added to `camera` not `scene` | threejs/threejs-multiple-scenes-controls.html | @@ -82,7 +82,7 @@
const intensity = 1;
const light = new THREE.DirectionalLight(color, intensity);
light.position.set(-1, 2, 4);
- scene.add(light);
+ camera.add(light);
}
return {scene, camera, controls}; | false |
Other | mrdoob | three.js | ca306c07511a63a257d07f505e6a0a7ef4dbc5a6.json | Add version to glslang. | examples/jsm/libs/glslang.js | @@ -1,7 +1,7 @@
-
+// 0.0.15
var Module = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
-
+
return (
function(Module) {
Module = Module || {}; | false |
Other | mrdoob | three.js | 0f5de4f5da1014f81c00d309f93b1a1e709341e4.json | Fix ReDos in Color.js | src/math/Color.js | @@ -169,14 +169,14 @@ class Color {
let color;
const name = m[ 1 ];
- const components = m[ 2 ];
+ const components = m[ 2 ].replace(/^\s*/, '');
switch ( name ) {
case 'rgb':
case 'rgba':
- if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
+ if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
// rgb(255,0,0) rgba(255,0,0,0.5)
this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255; | false |
Other | mrdoob | three.js | 341b2e863a97932dd9705947b2327f4aee159156.json | Handle empty cases in Sphere.union (#24701) | src/math/Sphere.js | @@ -195,6 +195,18 @@ class Sphere {
union( sphere ) {
+ // handle empty sphere cases
+ if ( sphere.isEmpty() ) {
+
+ return;
+
+ } else if ( this.isEmpty() ) {
+
+ this.copy( sphere );
+ return;
+
+ }
+
// from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769
// To enclose another sphere into this sphere, we only need to enclose two points: | false |
Other | mrdoob | three.js | fa6899ae485cda3f5fceef325acf8bb2d9fc592f.json | Minimize glActiveTexture calls (#24492)
* Don't set activetexture for textures that won't be bound
* Fix texture state update of a previously bound texture
* Combine bindTexture and bindTextureToSlot into a single function | src/renderers/webgl/WebGLState.js | @@ -880,25 +880,40 @@ function WebGLState( gl, extensions, capabilities ) {
}
- function bindTexture( webglType, webglTexture ) {
+ function bindTexture( webglType, webglTexture, webglSlot ) {
- if ( currentTextureSlot === null ) {
+ if ( webglSlot === undefined ) {
- activeTexture();
+ if ( currentTextureSlot === null ) {
+
+ webglSlot = gl.TEXTURE0 + maxTextures - 1;
+
+ } else {
+
+ webglSlot = currentTextureSlot;
+
+ }
}
- let boundTexture = currentBoundTextures[ currentTextureSlot ];
+ let boundTexture = currentBoundTextures[ webglSlot ];
if ( boundTexture === undefined ) {
boundTexture = { type: undefined, texture: undefined };
- currentBoundTextures[ currentTextureSlot ] = boundTexture;
+ currentBoundTextures[ webglSlot ] = boundTexture;
}
if ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {
+ if ( currentTextureSlot !== webglSlot ) {
+
+ gl.activeTexture( webglSlot );
+ currentTextureSlot = webglSlot;
+
+ }
+
gl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );
boundTexture.type = webglType; | true |
Other | mrdoob | three.js | fa6899ae485cda3f5fceef325acf8bb2d9fc592f.json | Minimize glActiveTexture calls (#24492)
* Don't set activetexture for textures that won't be bound
* Fix texture state update of a previously bound texture
* Combine bindTexture and bindTextureToSlot into a single function | src/renderers/webgl/WebGLTextures.js | @@ -460,8 +460,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
- state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );
+ state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
}
@@ -476,8 +475,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
- state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture );
+ state.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
}
@@ -492,8 +490,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
- state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );
+ state.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
}
@@ -508,8 +505,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
- state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
+ state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
}
@@ -681,13 +677,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
const forceUpload = initTexture( textureProperties, texture );
const source = texture.source;
- state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( textureType, textureProperties.__webglTexture );
+ state.bindTexture( textureType, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
const sourceProperties = properties.get( source );
if ( source.version !== sourceProperties.__version || forceUpload === true ) {
+ state.activeTexture( _gl.TEXTURE0 + slot );
+
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
@@ -1042,13 +1039,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
const forceUpload = initTexture( textureProperties, texture );
const source = texture.source;
- state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
+ state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
const sourceProperties = properties.get( source );
if ( source.version !== sourceProperties.__version || forceUpload === true ) {
+ state.activeTexture( _gl.TEXTURE0 + slot );
+
_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );
_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment ); | true |
Other | mrdoob | three.js | 24f2d651f46ec3af5e63ea949fa93ac9eb81e5f2.json | Simplify calls to lookAt() (#24909)
* Simplify calls to lookAt()
* Clean up | examples/jsm/loaders/3DMLoader.js | @@ -15,7 +15,6 @@ import {
PointLight,
SpotLight,
RectAreaLight,
- Vector3,
Sprite,
SpriteMaterial,
CanvasTexture,
@@ -625,7 +624,7 @@ class Rhino3dmLoader extends Loader {
light.position.set( geometry.location[ 0 ] - ( height / 2 ), geometry.location[ 1 ], geometry.location[ 2 ] - ( width / 2 ) );
light.height = height;
light.width = width;
- light.lookAt( new Vector3( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] ) );
+ light.lookAt( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] );
break;
| true |
Other | mrdoob | three.js | 24f2d651f46ec3af5e63ea949fa93ac9eb81e5f2.json | Simplify calls to lookAt() (#24909)
* Simplify calls to lookAt()
* Clean up | examples/webgl_animation_skinning_morph.html | @@ -71,7 +71,7 @@
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.25, 100 );
camera.position.set( - 5, 3, 10 );
- camera.lookAt( new THREE.Vector3( 0, 2, 0 ) );
+ camera.lookAt( 0, 2, 0 );
scene = new THREE.Scene();
scene.background = new THREE.Color( 0xe0e0e0 ); | true |
Other | mrdoob | three.js | 24f2d651f46ec3af5e63ea949fa93ac9eb81e5f2.json | Simplify calls to lookAt() (#24909)
* Simplify calls to lookAt()
* Clean up | src/cameras/CubeCamera.js | @@ -1,6 +1,5 @@
import { NoToneMapping } from '../constants.js';
import { Object3D } from '../core/Object3D.js';
-import { Vector3 } from '../math/Vector3.js';
import { PerspectiveCamera } from './PerspectiveCamera.js';
const fov = 90, aspect = 1;
@@ -18,37 +17,37 @@ class CubeCamera extends Object3D {
const cameraPX = new PerspectiveCamera( fov, aspect, near, far );
cameraPX.layers = this.layers;
cameraPX.up.set( 0, - 1, 0 );
- cameraPX.lookAt( new Vector3( 1, 0, 0 ) );
+ cameraPX.lookAt( 1, 0, 0 );
this.add( cameraPX );
const cameraNX = new PerspectiveCamera( fov, aspect, near, far );
cameraNX.layers = this.layers;
cameraNX.up.set( 0, - 1, 0 );
- cameraNX.lookAt( new Vector3( - 1, 0, 0 ) );
+ cameraNX.lookAt( - 1, 0, 0 );
this.add( cameraNX );
const cameraPY = new PerspectiveCamera( fov, aspect, near, far );
cameraPY.layers = this.layers;
cameraPY.up.set( 0, 0, 1 );
- cameraPY.lookAt( new Vector3( 0, 1, 0 ) );
+ cameraPY.lookAt( 0, 1, 0 );
this.add( cameraPY );
const cameraNY = new PerspectiveCamera( fov, aspect, near, far );
cameraNY.layers = this.layers;
cameraNY.up.set( 0, 0, - 1 );
- cameraNY.lookAt( new Vector3( 0, - 1, 0 ) );
+ cameraNY.lookAt( 0, - 1, 0 );
this.add( cameraNY );
const cameraPZ = new PerspectiveCamera( fov, aspect, near, far );
cameraPZ.layers = this.layers;
cameraPZ.up.set( 0, - 1, 0 );
- cameraPZ.lookAt( new Vector3( 0, 0, 1 ) );
+ cameraPZ.lookAt( 0, 0, 1 );
this.add( cameraPZ );
const cameraNZ = new PerspectiveCamera( fov, aspect, near, far );
cameraNZ.layers = this.layers;
cameraNZ.up.set( 0, - 1, 0 );
- cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) );
+ cameraNZ.lookAt( 0, 0, - 1 );
this.add( cameraNZ );
} | true |
Other | mrdoob | three.js | a13c6a3e106b1a3b2add618599175bd58f71259f.json | Introduce scene.backgroundIntensity (#24876) | docs/api/en/scenes/Scene.html | @@ -40,6 +40,11 @@ <h3>[property:Float backgroundBlurriness]</h3>
Sets the blurriness of the background. Only influences environment maps assigned to [page:Scene.background]. Valid input is a float between *0* and *1*. Default is *0*.
</p>
+ <h3>[property:Float backgroundIntensity]</h3>
+ <p>
+ Attenuates the color of the background. Only applies to background textures. Default is *1*.
+ </p>
+
<h3>[property:Texture environment]</h3>
<p>
Sets the environment map for all physical materials in the scene. | true |
Other | mrdoob | three.js | a13c6a3e106b1a3b2add618599175bd58f71259f.json | Introduce scene.backgroundIntensity (#24876) | src/renderers/shaders/ShaderLib.js | @@ -218,6 +218,7 @@ const ShaderLib = {
uniforms: {
uvTransform: { value: /*@__PURE__*/ new Matrix3() },
t2D: { value: null },
+ backgroundIntensity: { value: 1 }
},
vertexShader: ShaderChunk.background_vert,
@@ -230,7 +231,8 @@ const ShaderLib = {
uniforms: {
envMap: { value: null },
flipEnvMap: { value: - 1 },
- backgroundBlurriness: { value: 0 }
+ backgroundBlurriness: { value: 0 },
+ backgroundIntensity: { value: 1 }
},
vertexShader: ShaderChunk.backgroundCube_vert, | true |
Other | mrdoob | three.js | a13c6a3e106b1a3b2add618599175bd58f71259f.json | Introduce scene.backgroundIntensity (#24876) | src/renderers/shaders/ShaderLib/background.glsl.js | @@ -13,21 +13,26 @@ void main() {
export const fragment = /* glsl */`
uniform sampler2D t2D;
+uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
- gl_FragColor = texture2D( t2D, vUv );
+ vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
// inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved)
- gl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );
+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
+ texColor.rgb *= backgroundIntensity;
+
+ gl_FragColor = texColor;
+
#include <tonemapping_fragment>
#include <encodings_fragment>
| true |
Other | mrdoob | three.js | a13c6a3e106b1a3b2add618599175bd58f71259f.json | Introduce scene.backgroundIntensity (#24876) | src/renderers/shaders/ShaderLib/backgroundCube.glsl.js | @@ -29,6 +29,7 @@ export const fragment = /* glsl */`
uniform float flipEnvMap;
uniform float backgroundBlurriness;
+uniform float backgroundIntensity;
varying vec3 vWorldDirection;
@@ -50,6 +51,8 @@ void main() {
#endif
+ texColor.rgb *= backgroundIntensity;
+
gl_FragColor = texColor;
#include <tonemapping_fragment> | true |
Other | mrdoob | three.js | a13c6a3e106b1a3b2add618599175bd58f71259f.json | Introduce scene.backgroundIntensity (#24876) | src/renderers/webgl/WebGLBackground.js | @@ -105,6 +105,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
boxMesh.material.uniforms.envMap.value = background;
boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
+ boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
if ( currentBackground !== background ||
currentBackgroundVersion !== background.version ||
@@ -159,6 +160,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
}
planeMesh.material.uniforms.t2D.value = background;
+ planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
if ( background.matrixAutoUpdate === true ) {
| true |
Other | mrdoob | three.js | a13c6a3e106b1a3b2add618599175bd58f71259f.json | Introduce scene.backgroundIntensity (#24876) | src/scenes/Scene.js | @@ -15,6 +15,7 @@ class Scene extends Object3D {
this.fog = null;
this.backgroundBlurriness = 0;
+ this.backgroundIntensity = 1;
this.overrideMaterial = null;
@@ -35,6 +36,7 @@ class Scene extends Object3D {
if ( source.fog !== null ) this.fog = source.fog.clone();
this.backgroundBlurriness = source.backgroundBlurriness;
+ this.backgroundIntensity = source.backgroundIntensity;
if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
@@ -50,6 +52,7 @@ class Scene extends Object3D {
if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
if ( this.backgroundBlurriness > 0 ) data.backgroundBlurriness = this.backgroundBlurriness;
+ if ( this.backgroundIntensity !== 1 ) data.backgroundIntensity = this.backgroundIntensity;
return data;
| true |
Other | mrdoob | three.js | 065f2c3f1763c6bbf2b4d7398aa38b078116fe41.json | Fix typos in fundamentals.html (#24901)
* Fix typo in en/fundamentals.html
Word `be` was repeated.
* Remove extra "a" | manual/en/fundamentals.html | @@ -176,7 +176,7 @@ <h1>Fundamentals</h1>
<p><img src="../resources/frustum-3d.svg" width="500" class="threejs_center"></p>
<p>The height of the near and far planes are determined by the field of view.
The width of both planes is determined by the field of view and the aspect.</p>
-<p>Anything inside the defined frustum will be be drawn. Anything outside
+<p>Anything inside the defined frustum will be drawn. Anything outside
will not.</p>
<p>The camera defaults to looking down the -Z axis with +Y up. We'll put our cube
at the origin so we need to move the camera back a little from the origin
@@ -209,7 +209,7 @@ <h1>Fundamentals</h1>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no">const material = new THREE.MeshBasicMaterial({color: 0x44aa88});
</pre>
<p>We then create a <a href="/docs/#api/en/objects/Mesh"><code class="notranslate" translate="no">Mesh</code></a>. A <a href="/docs/#api/en/objects/Mesh"><code class="notranslate" translate="no">Mesh</code></a> in three represents the combination
-of a three things</p>
+of three things</p>
<ol>
<li>A <code class="notranslate" translate="no">Geometry</code> (the shape of the object)</li>
<li>A <a href="/docs/#api/en/materials/Material"><code class="notranslate" translate="no">Material</code></a> (how to draw the object, shiny or flat, what color, what texture(s) to apply. Etc.)</li>
@@ -461,4 +461,4 @@ <h3>es6 modules, three.js, and folder structure</h3>
-</body></html>
\ No newline at end of file
+</body></html> | false |
Other | mrdoob | three.js | b361e9b2f4c3d9a574612972c9749477787f1685.json | Fix Chinese typos on page responsive.html (#24884)
Co-authored-by: xiaoke <xiaoke@micous.com> | manual/zh/responsive.html | @@ -1,49 +1,53 @@
-<!DOCTYPE html><html lang="zh"><head>
- <meta charset="utf-8">
- <title>ๅๅบๅผ่ฎพ่ฎก</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <meta name="twitter:card" content="summary_large_image">
- <meta name="twitter:site" content="@threejs">
- <meta name="twitter:title" content="Three.js โ ๅๅบๅผ่ฎพ่ฎก">
- <meta property="og:image" content="https://threejs.org/files/share.png">
- <link rel="shortcut icon" href="/files/favicon_white.ico" media="(prefers-color-scheme: dark)">
- <link rel="shortcut icon" href="/files/favicon.ico" media="(prefers-color-scheme: light)">
-
- <link rel="stylesheet" href="/manual/resources/lesson.css">
- <link rel="stylesheet" href="/manual/resources/lang.css">
-<!-- Import maps polyfill -->
-<!-- Remove this when import maps will be widely supported -->
-<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
-
-<script type="importmap">
+<!DOCTYPE html>
+<html lang="zh">
+
+<head>
+ <meta charset="utf-8">
+ <title>ๅๅบๅผ่ฎพ่ฎก</title>
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <meta name="twitter:card" content="summary_large_image">
+ <meta name="twitter:site" content="@threejs">
+ <meta name="twitter:title" content="Three.js โ ๅๅบๅผ่ฎพ่ฎก">
+ <meta property="og:image" content="https://threejs.org/files/share.png">
+ <link rel="shortcut icon" href="/files/favicon_white.ico" media="(prefers-color-scheme: dark)">
+ <link rel="shortcut icon" href="/files/favicon.ico" media="(prefers-color-scheme: light)">
+
+ <link rel="stylesheet" href="/manual/resources/lesson.css">
+ <link rel="stylesheet" href="/manual/resources/lang.css">
+ <!-- Import maps polyfill -->
+ <!-- Remove this when import maps will be widely supported -->
+ <script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
+
+ <script type="importmap">
{
"imports": {
"three": "../../build/three.module.js"
}
}
</script>
- <link rel="stylesheet" href="/manual/zh/lang.css">
- </head>
- <body>
- <div class="container">
- <div class="lesson-title">
- <h1>ๅๅบๅผ่ฎพ่ฎก</h1>
- </div>
- <div class="lesson">
- <div class="lesson-main">
- <p>่ฟๆฏthree.js็ณปๅๆ็ซ ็็ฌฌไบ็ฏใ
-็ฌฌไธ็ฏๆฏ<a href="fundamentals.html">ๅ
ณไบๅบ็ก</a>ใ
-ๅฆๆไฝ ่ฟๆฒกๆ้
่ฏป็ฌฌไธ็ฏ้ฃไฝ ๅบ่ฏฅไป็ฌฌไธ็ฏๅผๅงใ</p>
-<p>ๆฌ็ฏๆ็ซ ๆฏๅ
ณไบๅฆไฝ่ฎฉไฝ ็three.jsๅบ็จ่ช้ๅบๅ็งๆ
ๅตใ
-็ฝ้กต็ๅๅบๅผๆฏๆ่ฎฉๅ
ถๅจๆก้ขใๅนณๆฟๅๆๆบ็ญไธๅๅฐบๅฏธ็ๅฑๅนไธๆพ็คบ่ฏๅฅฝใ</p>
-<p>ๅฏนthree.jsๆฅ่ฏดๆๆดๅค็ๆ
ๅต่ฆ่่ใไพๅฆ๏ผๆไปฌๅฏ่ฝ้่ฆๅค็ๆงไปถๅจๅทฆไพงใๅณไพงใ้กถ้จๆๅบ้จ็ไธ็ปด็ผ่พๅจใๆฌๆ็ไธญ้ด้จๅๅฑ็คบไบๅฆไธไธชไพๅญใ</p>
-<p>ไธไธไธชไพๅญไธญๆไปฌไฝฟ็จไบไธไธชๆฒกๆ่ฎพ็ฝฎๆ ทๅผๅๅฐบๅฏธ็ใ</p>
-<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><canvas id="c"></canvas>
+ <link rel="stylesheet" href="/manual/zh/lang.css">
+</head>
+
+<body>
+ <div class="container">
+ <div class="lesson-title">
+ <h1>ๅๅบๅผ่ฎพ่ฎก</h1>
+ </div>
+ <div class="lesson">
+ <div class="lesson-main">
+ <p>่ฟๆฏthree.js็ณปๅๆ็ซ ็็ฌฌไบ็ฏใ
+ ็ฌฌไธ็ฏๆฏ<a href="fundamentals.html">ๅ
ณไบๅบ็ก</a>ใ
+ ๅฆๆไฝ ่ฟๆฒกๆ้
่ฏป็ฌฌไธ็ฏ้ฃไฝ ๅบ่ฏฅไป็ฌฌไธ็ฏๅผๅงใ</p>
+ <p>ๆฌ็ฏๆ็ซ ๆฏๅ
ณไบๅฆไฝ่ฎฉไฝ ็three.jsๅบ็จ่ช้ๅบๅ็งๆ
ๅตใ
+ ็ฝ้กต็ๅๅบๅผๆฏๆ่ฎฉๅ
ถๅจๆก้ขใๅนณๆฟๅๆๆบ็ญไธๅๅฐบๅฏธ็ๅฑๅนไธๆพ็คบ่ฏๅฅฝใ</p>
+ <p>ๅฏนthree.jsๆฅ่ฏดๆๆดๅค็ๆ
ๅต่ฆ่่ใไพๅฆ๏ผๆไปฌๅฏ่ฝ้่ฆๅค็ๆงไปถๅจๅทฆไพงใๅณไพงใ้กถ้จๆๅบ้จ็ไธ็ปด็ผ่พๅจใๆฌๆ็ไธญ้ด้จๅๅฑ็คบไบๅฆไธไธชไพๅญใ</p>
+ <p>ไธไธไธชไพๅญไธญๆไปฌไฝฟ็จไบไธไธชๆฒกๆ่ฎพ็ฝฎๆ ทๅผๅๅฐบๅฏธ็ใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-html" translate="no"><canvas id="c"></canvas>
</pre>
-<p>้ฃไธชcanvas้ป่ฎค300x150ๅ็ด ใ</p>
-<p>ๅจwebๅนณๅฐๆจ่ไฝฟ็จCSSๆฅ่ฎพ็ฝฎ็ฉไฝ็ๅฐบๅฏธใ</p>
-<p>ๆไปฌ้่ฟๆทปๅ CSSๆฅ่ฎฉcanvasๅกซๅ
ๆดไธช้กต้ขใ</p>
-<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><style>
+ <p>้ฃไธชcanvas้ป่ฎค300x150ๅ็ด ใ</p>
+ <p>ๅจwebๅนณๅฐๆจ่ไฝฟ็จCSSๆฅ่ฎพ็ฝฎ็ฉไฝ็ๅฐบๅฏธใ</p>
+ <p>ๆไปฌ้่ฟๆทปๅ CSSๆฅ่ฎฉcanvasๅกซๅ
ๆดไธช้กต้ขใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-html" translate="no"><style>
html, body {
margin: 0;
height: 100%;
@@ -55,30 +59,36 @@ <h1>ๅๅบๅผ่ฎพ่ฎก</h1>
}
</style>
</pre>
-<p>HTMLไธญ็body้ป่ฎคๆ5ไธชๅ็ด ็marginๅผๆไปฅ่ฎพ็ฝฎmarginไธบ0ๆฅ็งป้คmarginๅผใ
-่ฎพ็ฝฎhtmlๅbody็้ซๅบฆไธบ100%่ฎฉไปไปฌๅ
ๆปกๆดไธช็ชๅฃใไธ็ถ็่ฏไปไปฌ็ๅคงๅฐๅชไผ
-ๅๅกซๅ
ไปไปฌ็ๅ
ๅฎนไธๆ ทใ</p>
-<p>็ถๅๆไปฌ่ฎฉ<code class="notranslate" translate="no">id=c</code>็ๅ
็ด ็ๅฐบๅฏธๆฏๅฎนๅจ็100%่ฟ้ๆฏbodyๆ ็ญพใ </p>
-<p>ๆๅๆไปฌ่ฎพ็ฝฎๅฎ็<code class="notranslate" translate="no">display</code>ไธบ<code class="notranslate" translate="no">block</code>ใcanvas็display้ป่ฎคไธบ
-<code class="notranslate" translate="no">inline</code>ใ่กๅ
ๅ
็ด ็ๆซๅฐพไผๆ็ฉบๆ ผใ
-้่ฟ่ฎพ็ฝฎcanvasไธบๅ็บงๅ
็ด ๅฐฑ่ฝๆถ้ค่ฟไธช็ฉบๆ ผใ</p>
-<p>่ฟ้ๆฏ็ปๆใ</p>
-<p></p><div translate="no" class="threejs_example_container notranslate">
- <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-no-resize.html"></iframe></div>
- <a class="threejs_center" href="/manual/examples/responsive-no-resize.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
-</div>
-
-<p></p>
-<p>ไฝ ๅฏไปฅ็ๅฐcanvasๅ
ๆปกไบๆดไธช้กต้ข๏ผไฝๆฏๆไธคไธช้ฎ้ขใ
-็ฌฌไธๆฏๆไปฌ็็ซๆนไฝ่ขซๆไผธไบใไปไปฌไธๆฏ็ซๆนไฝไบๆดๅๆฏไธช็ๅญ๏ผๅคช้ซๆ่
ๅคชๅฎฝใ ๅจๆฐๆ ็ญพไธญๆๅผๅฎ็ถๅๆนๅๅฐบๅฏธไฝ ๅฐฑ่ฝ็ๅฐ็ซๆนไฝๆฏๆไนๅจๅฎฝ้ซไธ่ขซๆไผธ็ใ</p>
-<p><img src="../resources/images/resize-incorrect-aspect.png" width="407" class="threejs_center nobg"></p>
-<p>ๅฆไธไธช้ฎ้ขๆฏ็ซๆนไฝ็่ตทๆฅๅ่พจ็ๅคชไฝๆ่
่ฏดๅ็ถๅๆ่
ๆ็นๆจก็ณใ
-ๅฐ็ชๅฃๆไผธ็้ๅธธๅคงไฝ ๅฐฑ่ฝ็ๅฐ้ฎ้ขใ</p>
-<p><img src="../resources/images/resize-low-res.png" class="threejs_center nobg"></p>
-<p>ๆไปฌๅ
่งฃๅณๆไผธ็้ฎ้ขใไธบๆญคๆไปฌ่ฆๅฐ็ธๆบ็ๅฎฝ้ซๆฏ่ฎพ็ฝฎไธบcanvas็ๅฎฝ้ซๆฏใ
-ๆไปฌๅฏไปฅ้่ฟcanvas็<code class="notranslate" translate="no">clientWidth</code>ๅ<code class="notranslate" translate="no">clientHeight</code>ๅฑๆงๆฅๅฎ็ฐใ</p>
-<p>ๆไปฌ้่ฆๅฐๆธฒๆๅพช็ฏๅๆ่ฟๆ ทใ</p>
-<pre class="prettyprint showlinemods notranslate lang-js" translate="no">function render(time) {
+ <p>HTMLไธญ็body้ป่ฎคๆ5ไธชๅ็ด ็marginๅผๆไปฅ่ฎพ็ฝฎmarginไธบ0ๆฅ็งป้คmarginๅผใ
+ ่ฎพ็ฝฎhtmlๅbody็้ซๅบฆไธบ100%่ฎฉไปไปฌๅ
ๆปกๆดไธช็ชๅฃใไธ็ถ็่ฏไปไปฌ็ๅคงๅฐๅชไผ
+ ๅๅกซๅ
ไปไปฌ็ๅ
ๅฎนไธๆ ทใ</p>
+ <p>็ถๅๆไปฌ่ฎฉ<code class="notranslate" translate="no">id=c</code>็ๅ
็ด ็ๅฐบๅฏธๆฏๅฎนๅจ็100%่ฟ้ๆฏbodyๆ ็ญพใ </p>
+ <p>ๆๅๆไปฌ่ฎพ็ฝฎๅฎ็<code class="notranslate" translate="no">display</code>ไธบ<code class="notranslate"
+ translate="no">block</code>ใcanvas็display้ป่ฎคไธบ
+ <code class="notranslate" translate="no">inline</code>ใ่กๅ
ๅ
็ด ็ๆซๅฐพไผๆ็ฉบๆ ผใ
+ ้่ฟ่ฎพ็ฝฎcanvasไธบๅ็บงๅ
็ด ๅฐฑ่ฝๆถ้ค่ฟไธช็ฉบๆ ผใ
+ </p>
+ <p>่ฟ้ๆฏ็ปๆใ</p>
+ <p></p>
+ <div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" "
+ src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-no-resize.html"></iframe>
+ </div>
+ <a class="threejs_center" href="/manual/examples/responsive-no-resize.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+ </div>
+
+ <p></p>
+ <p>ไฝ ๅฏไปฅ็ๅฐcanvasๅ
ๆปกไบๆดไธช้กต้ข๏ผไฝๆฏๆไธคไธช้ฎ้ขใ
+ ็ฌฌไธๆฏๆไปฌ็็ซๆนไฝ่ขซๆไผธไบใไปไปฌไธๆฏ็ซๆนไฝไบๆดๅๆฏไธช็ๅญ๏ผๅคช้ซๆ่
ๅคชๅฎฝใ ๅจๆฐๆ ็ญพไธญๆๅผๅฎ็ถๅๆนๅๅฐบๅฏธไฝ ๅฐฑ่ฝ็ๅฐ็ซๆนไฝๆฏๆไนๅจๅฎฝ้ซไธ่ขซๆไผธ็ใ</p>
+ <p><img src="../resources/images/resize-incorrect-aspect.png" width="407" class="threejs_center nobg"></p>
+ <p>ๅฆไธไธช้ฎ้ขๆฏ็ซๆนไฝ็่ตทๆฅๅ่พจ็ๅคชไฝๆ่
่ฏดๅ็ถๅๆ่
ๆ็นๆจก็ณใ
+ ๅฐ็ชๅฃๆไผธ็้ๅธธๅคงไฝ ๅฐฑ่ฝ็ๅฐ้ฎ้ขใ</p>
+ <p><img src="../resources/images/resize-low-res.png" class="threejs_center nobg"></p>
+ <p>ๆไปฌๅ
่งฃๅณๆไผธ็้ฎ้ขใไธบๆญคๆไปฌ่ฆๅฐ็ธๆบ็ๅฎฝ้ซๆฏ่ฎพ็ฝฎไธบcanvas็ๅฎฝ้ซๆฏใ
+ ๆไปฌๅฏไปฅ้่ฟcanvas็<code class="notranslate" translate="no">clientWidth</code>ๅ<code class="notranslate"
+ translate="no">clientHeight</code>ๅฑๆงๆฅๅฎ็ฐใ</p>
+ <p>ๆไปฌ้่ฆๅฐๆธฒๆๅพช็ฏๅๆ่ฟๆ ทใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-js" translate="no">function render(time) {
time *= 0.001;
+ const canvas = renderer.domElement;
@@ -87,30 +97,35 @@ <h1>ๅๅบๅผ่ฎพ่ฎก</h1>
...
</pre>
-<p>็ฐๅจ็ซๆนไฝๅบ่ฏฅไธไผๅๅฝขไบใ</p>
-<p></p><div translate="no" class="threejs_example_container notranslate">
- <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-update-camera.html"></iframe></div>
- <a class="threejs_center" href="/manual/examples/responsive-update-camera.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
-</div>
-
-<p></p>
-<p>ๅจๆฐๆ ็ญพ้กตไธญๆๅผไพๅญไฝ ๅบ่ฏฅ่ฝ็ๅฐ็ซๆนไฝ็ๅฎฝ้ซไธไผๅ่ขซๆไผธไบใ
-ไปไปฌ้ฝไผไฟๆๆญฃ็กฎ็ๆฏไพไธ็ฎก็ชๅฃ็ๅฐบๅฏธๅฆไฝใ</p>
-<p><img src="../resources/images/resize-correct-aspect.png" width="407" class="threejs_center nobg"></p>
-<p>ๆไปฌ็ฐๅจๆฅ่งฃๅณๅ็ถๅ็้ฎ้ขใ</p>
-<p>canvasๅ
็ด ๆไธคไธชๅฐบๅฏธใไธไธชๆฏcanvasๅจ้กต้ขไธ็ๆพ็คบๅฐบๅฏธ๏ผ
-ๆฏๆไปฌ็จCSSๆฅ่ฎพ็ฝฎ็ใๅฆไธไธชๅฐบๅฏธๆฏcanvasๆฌ่บซๅ็ด ็ๆฐ้ใ่ฟๅๅพ็ไธๆ ทใ
-ๆฏๅฆๆไปฌๆไธไธช128x64ๅ็ด ็ๅพ็็ถๅๆไปฌๅฏไปฅ้่ฟCSS่ฎฉๅฎๆพ็คบไธบ
-400x200ๅ็ด ใ</p>
-<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><img src="some128x64image.jpg" style="width:400px; height:200px">
+ <p>็ฐๅจ็ซๆนไฝๅบ่ฏฅไธไผๅๅฝขไบใ</p>
+ <p></p>
+ <div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" "
+ src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-update-camera.html"></iframe>
+ </div>
+ <a class="threejs_center" href="/manual/examples/responsive-update-camera.html"
+ target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+ </div>
+
+ <p></p>
+ <p>ๅจๆฐๆ ็ญพ้กตไธญๆๅผไพๅญไฝ ๅบ่ฏฅ่ฝ็ๅฐ็ซๆนไฝ็ๅฎฝ้ซไธไผๅ่ขซๆไผธไบใ
+ ไปไปฌ้ฝไผไฟๆๆญฃ็กฎ็ๆฏไพไธ็ฎก็ชๅฃ็ๅฐบๅฏธๅฆไฝใ</p>
+ <p><img src="../resources/images/resize-correct-aspect.png" width="407" class="threejs_center nobg"></p>
+ <p>ๆไปฌ็ฐๅจๆฅ่งฃๅณๅ็ถๅ็้ฎ้ขใ</p>
+ <p>canvasๅ
็ด ๆไธคไธชๅฐบๅฏธใไธไธชๆฏcanvasๅจ้กต้ขไธ็ๆพ็คบๅฐบๅฏธ๏ผ
+ ๆฏๆไปฌ็จCSSๆฅ่ฎพ็ฝฎ็ใๅฆไธไธชๅฐบๅฏธๆฏcanvasๆฌ่บซๅ็ด ็ๆฐ้ใ่ฟๅๅพ็ไธๆ ทใ
+ ๆฏๅฆๆไปฌๆไธไธช128x64ๅ็ด ็ๅพ็็ถๅๆไปฌๅฏไปฅ้่ฟCSS่ฎฉๅฎๆพ็คบไธบ
+ 400x200ๅ็ด ใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-html" translate="no"><img src="some128x64image.jpg" style="width:400px; height:200px">
</pre>
-<p>ไธไธชcanvas็ๅ
้จๅฐบๅฏธ๏ผๅฎ็ๅ่พจ็๏ผ้ๅธธ่ขซๅซๅ็ปๅพ็ผๅฒๅบ(drawingbuffer)ๅฐบๅฏธใ
-ๅจthree.jsไธญๆไปฌๅฏไปฅ้่ฟ่ฐ็จ<code class="notranslate" translate="no">renderer.setSize</code>ๆฅ่ฎพ็ฝฎcanvas็็ปๅพ็ผๅฒๅบใ
-ๆไปฌๅบ่ฏฅ้ๆฉไปไนๅฐบๅฏธ? ๆๆพ่ๆ่ง็ๆฏ"ๅcanvas็ๆพ็คบๅฐบๅฏธไธๆ ท"ใ
-ๅณๅฏไปฅ็ดๆฅ็จcanvas็<code class="notranslate" translate="no">clientWidth</code>ๅ<code class="notranslate" translate="no">clientHeight</code>ๅฑๆงใ</p>
-<p>ๆไปฌๅไธไธชๅฝๆฐๆฅๆฃๆฅๆธฒๆๅจ็canvasๅฐบๅฏธๆฏไธๆฏๅcanvas็ๆพ็คบๅฐบๅฏธไธไธๆ ท
-ๅฆๆไธไธๆ ทๅฐฑ่ฎพ็ฝฎๅฎใ</p>
-<pre class="prettyprint showlinemods notranslate lang-js" translate="no">function resizeRendererToDisplaySize(renderer) {
+ <p>ไธไธชcanvas็ๅ
้จๅฐบๅฏธ๏ผๅฎ็ๅ่พจ็๏ผ้ๅธธ่ขซๅซๅ็ปๅพ็ผๅฒๅบ(drawingbuffer)ๅฐบๅฏธใ
+ ๅจthree.jsไธญๆไปฌๅฏไปฅ้่ฟ่ฐ็จ<code class="notranslate" translate="no">renderer.setSize</code>ๆฅ่ฎพ็ฝฎcanvas็็ปๅพ็ผๅฒๅบใ
+ ๆไปฌๅบ่ฏฅ้ๆฉไปไนๅฐบๅฏธ? ๆๆพ่ๆ่ง็ๆฏ"ๅcanvas็ๆพ็คบๅฐบๅฏธไธๆ ท"ใ
+ ๅณๅฏไปฅ็ดๆฅ็จcanvas็<code class="notranslate" translate="no">clientWidth</code>ๅ<code class="notranslate"
+ translate="no">clientHeight</code>ๅฑๆงใ</p>
+ <p>ๆไปฌๅไธไธชๅฝๆฐๆฅๆฃๆฅๆธฒๆๅจ็canvasๅฐบๅฏธๆฏไธๆฏๅcanvas็ๆพ็คบๅฐบๅฏธไธไธๆ ท
+ ๅฆๆไธไธๆ ทๅฐฑ่ฎพ็ฝฎๅฎใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-js" translate="no">function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const width = canvas.clientWidth;
const height = canvas.clientHeight;
@@ -121,17 +136,18 @@ <h1>ๅๅบๅผ่ฎพ่ฎก</h1>
return needResize;
}
</pre>
-<p>ๆณจๆๆไปฌๆฃๆฅไบcanvasๆฏๅฆ็็้่ฆ่ฐๆดๅคงๅฐใ
-่ฐๆด็ปๅธๅคงๅฐๆฏcanvas่ง่็ไธไธชๆ่ถฃ้จๅ๏ผๅฆๆๅฎๅทฒ็ปๆฏๆไปฌๆณ่ฆ็ๅคงๅฐ๏ผๆๅฅฝไธ่ฆ่ฎพ็ฝฎ็ธๅ็ๅคงๅฐ.</p>
-<p>ไธๆฆๆไปฌ็ฅ้ไบๆฏๅฆ้่ฆ่ฐๆดๅคงๅฐๆไปฌๅฐฑ่ฐ็จ<code class="notranslate" translate="no">renderer.setSize</code>็ถๅ
-ไผ ๅ
ฅๆฐ็ๅฎฝ้ซใๅจๆซๅฐพไผ ๅ
ฅ<code class="notranslate" translate="no">false</code>ๅพ้่ฆใ
-<code class="notranslate" translate="no">render.setSize</code>้ป่ฎคไผ่ฎพ็ฝฎcanvas็CSSๅฐบๅฏธไฝ่ฟๅนถไธๆฏๆไปฌๆณ่ฆ็ใ
-ๆไปฌๅธๆๆต่งๅจ่ฝ็ปง็ปญๅทฅไฝๅฐฑๅๅ
ถไปไฝฟ็จCSSๆฅๅฎไนๅฐบๅฏธ็ๅ
ถไปๅ
็ด ใๆไปฌไธๅธๆ
-three.jsไฝฟ็จcanvasๅๅ
ถไปๅ
็ด ไธไธๆ ทใ</p>
-<p>ๆณจๆๅฆๆๆไปฌ็canvasๅคงๅฐ่ขซ่ฐๆดไบ้ฃๅฝๆฐไผ่ฟๅtrueใๆไปฌๅฏไปฅๅฉ็จ
-่ฟไธชๆฅๆฃๆฅๆฏๅฆๆๅ
ถไป็ไธ่ฅฟๅบ่ฏฅๆดๆฐใๆไปฌไฟฎๆนๆธฒๆๅพช็ฏ
-ๆฅไฝฟ็จๆไปฌ็ๆฐๅฝๆฐใ</p>
-<pre class="prettyprint showlinemods notranslate lang-js" translate="no">function render(time) {
+ <p>ๆณจๆๆไปฌๆฃๆฅไบcanvasๆฏๅฆ็็้่ฆ่ฐๆดๅคงๅฐใ
+ ่ฐๆด็ปๅธๅคงๅฐๆฏcanvas่ง่็ไธไธชๆ่ถฃ้จๅ๏ผๅฆๆๅฎๅทฒ็ปๆฏๆไปฌๆณ่ฆ็ๅคงๅฐ๏ผๆๅฅฝไธ่ฆ่ฎพ็ฝฎ็ธๅ็ๅคงๅฐ.</p>
+ <p>ไธๆฆๆไปฌ็ฅ้ไบๆฏๅฆ้่ฆ่ฐๆดๅคงๅฐๆไปฌๅฐฑ่ฐ็จ<code class="notranslate" translate="no">renderer.setSize</code>็ถๅ
+ ไผ ๅ
ฅๆฐ็ๅฎฝ้ซใๅจๆซๅฐพไผ ๅ
ฅ<code class="notranslate" translate="no">false</code>ๅพ้่ฆใ
+ <code class="notranslate" translate="no">render.setSize</code>้ป่ฎคไผ่ฎพ็ฝฎcanvas็CSSๅฐบๅฏธไฝ่ฟๅนถไธๆฏๆไปฌๆณ่ฆ็ใ
+ ๆไปฌๅธๆๆต่งๅจ่ฝ็ปง็ปญๅทฅไฝๅฐฑๅๅ
ถไปไฝฟ็จCSSๆฅๅฎไนๅฐบๅฏธ็ๅ
ถไปๅ
็ด ใๆไปฌไธๅธๆ
+ three.jsไฝฟ็จcanvasๅๅ
ถไปๅ
็ด ไธไธๆ ทใ
+ </p>
+ <p>ๆณจๆๅฆๆๆไปฌ็canvasๅคงๅฐ่ขซ่ฐๆดไบ้ฃๅฝๆฐไผ่ฟๅtrueใๆไปฌๅฏไปฅๅฉ็จ
+ ่ฟไธชๆฅๆฃๆฅๆฏๅฆๆๅ
ถไป็ไธ่ฅฟๅบ่ฏฅๆดๆฐใๆไปฌไฟฎๆนๆธฒๆๅพช็ฏ
+ ๆฅไฝฟ็จๆไปฌ็ๆฐๅฝๆฐใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-js" translate="no">function render(time) {
time *= 0.001;
+ if (resizeRendererToDisplaySize(renderer)) {
@@ -142,53 +158,64 @@ <h1>ๅๅบๅผ่ฎพ่ฎก</h1>
...
</pre>
-<p>ๅ ไธบๅชๆcanvas็ๆพ็คบๅฐบๅฏธๅๅๆถๅฎฝ้ซๆฏๆๅๅๆไปฅๆไปฌ
-ๅชๅจ<code class="notranslate" translate="no">resizeRendererToDisplaySize</code>ๅฝๆฐ่ฟๅ<code class="notranslate" translate="no">true</code>ๆถๆ่ฎพ็ฝฎๆๅๆบ็ๅฎฝ้ซๆฏใ</p>
-<p></p><div translate="no" class="threejs_example_container notranslate">
- <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/responsive.html"></iframe></div>
- <a class="threejs_center" href="/manual/examples/responsive.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
-</div>
-
-<p></p>
-<p>็ฐๅจๆธฒๆ็ๅ่พจ็ๅบ่ฏฅๆฏๅcanvas็ๆพ็คบๅฐบๅฏธไธๆ ท็ใ</p>
-<p>ไธบไบ่ฏดๆธ
ๆฅ่ฎฉCSSๅค็่ฐๆดๅฐบๅฏธๆไปฌๅฐไปฃ็ ๆพ่ฟ<a href="../examples/threejs-responsive.js">ไธไธชๅ็ฌ็jsๆไปถ</a>ใ
-่ฟ้่ฟๆไธไบไพๅญๆไปฌ่ฎฉCSSๅณๅฎๅฐบๅฏธ็ๅคงๅฐๅนถไธๆณจๆๆไปฌๅนถๆฒกๆๆนๅไปปไฝ
-ไปฃ็ ๆฅ่ฎฉไปไปฌๅทฅไฝใ</p>
-<p>ๆไปฌๅฐ็ซๆนไฝๆพๅจๆๅญๆฎต่ฝ็ไธญ้ดใ</p>
-<p></p><div translate="no" class="threejs_example_container notranslate">
- <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-paragraph.html&startPane=html"></iframe></div>
- <a class="threejs_center" href="/manual/examples/responsive-paragraph.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
-</div>
-
-<p></p>
-<p>่ฟๆฏๆไปฌๅจ็ผ่พๅจๆ ทๅผๅธๅฑไธญไฝฟ็จ็็ธๅไปฃ็ ๏ผๅณไพง็ๆงๅถๅบๅๅฏไปฅ่ฐๆดๅคงๅฐใ</p>
-<p></p><div translate="no" class="threejs_example_container notranslate">
- <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-editor.html&startPane=html"></iframe></div>
- <a class="threejs_center" href="/manual/examples/responsive-editor.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
-</div>
-
-<p></p>
-<p>้็นๆณจๆๆไปฌ็ไปฃ็ ๅนถๆฒกๆๆนๅ๏ผๅชๆๆไปฌ็HTMLๅCSSๅไบใ</p>
-<h2 id="-hd-dpi-">ๅบๅฏนHD-DPIๆพ็คบๅจ</h2>
-<p>HD-DPIไปฃ่กจๆฏ่ฑๅฏธ้ซๅฏๅบฆ็นๆพ็คบๅจ(่ง็ฝ่ๆพ็คบๅจ)ใๅฎๆ็ๆฏๅฝไปๅคงๅคๆฐ็Macๅwindowsๆบๅจไปฅๅๅ ไนๆๆ็ๆบ่ฝๆๆบใ</p>
-<p>ๆต่งๅจไธญ็ๅทฅไฝๆนๅผๆฏไธ็ฎกๅฑๅน็ๅ่พจ็ๆๅค้ซไฝฟ็จCSSๅ็ด ่ฎพ็ฝฎๅฐบๅฏธไผ่ขซ่ฎคไธบๆฏไธๆ ท็ใ
-ๅๆ ท็็ฉ็ๅฐบๅฏธๆต่งๅจไผๆธฒๆๅบๅญไฝ็ๆดๅค็ป่ใ</p>
-<p>ไฝฟ็จthree.jsๆๅค็งๆนๆณๆฅๅบๅฏนHD-DPIใ</p>
-<p>็ฌฌไธ็งๅฐฑๆฏไธๅไปปไฝ็นๅซ็ไบๆ
ใ่ฟๅฏไปฅ่ฏดๆฏๆๅธธ่ง็ใ
-ๆธฒๆไธ็ปดๅพๅฝข้่ฆๅคง้็GPUๅค็่ฝๅใ็งปๅจ็ซฏ็GPU่ฝๅๆฏๆก้ข็ซฏ็่ฆๅผฑใ่ณๅฐๆชๆญขๅฐ2018ๅนด,
-ๆๆบ้ฝๆ้ๅธธ้ซ็ๅ่พจ็ๆพ็คบๅจใ
-็ฎๅๆๅฅฝ็ๆๆบ็HD-DPIๆฏไพไธบ3x๏ผๆๆๆฏ้้ซๅฏๅบฆ็นๆพ็คบๅจไธ็ไธไธชๅ็ด ๅจ้ซๅฏๅบฆๆพ็คบๅจไธๆฏ9ไธชๅ็ด ใ
-ๆๅณ็้่ฆ9ๅ็ๆธฒๆใ</p>
-<p>่ฎก็ฎ9ๅ็ๅ็ด ๆฏไธชๅคงๅทฅ็จๆไปฅๅฆๆไฟๆไปฃ็ ไธๅๆไปฌๅฐ่ฎก็ฎไธไธชๅ็ด ็ถๅๆต่งๅจๅฐไปฅไธๅๅคงๅฐ็ปๅถ(3x3=9ๅ็ด )ใ</p>
-<p>ๅฏนไบๅคงๅ็three.jsๅบ็จๆฅ่ฏดไธ้ขๅฐฑๆฏไฝ ๆณ่ฆ็ๅฆไพงไฝ ็ๅธง้็ไผๅพไฝใ</p>
-<p>ๅฐฝ็ฎกๅฆๆญคๅฆๆไฝ ็กฎๅฎๆณ็จ่ฎพๅค็ๅ่พจ็ๆฅๆธฒๆ๏ผthree.jsไธญๆไธค็งๆนๆณๆฅๅฎ็ฐใ</p>
-<p>ไธ็งๆฏไฝฟ็จrenderer.setPixelRatioๆฅๅ่ฏthree.jsๅ่พจ็็ๅๆฐใ
-่ฎฟ้ฎๆต่งๅจไปCSSๅ็ด ๅฐ่ฎพๅคๅ็ด ็ๅๆฐ็ถๅไผ ็ปthree.jsใ</p>
-<pre class="prettyprint showlinemods notranslate notranslate" translate="no"> renderer.setPixelRatio(window.devicePixelRatio);
-</pre><p>ไนๅไปปไฝๅฏน<code class="notranslate" translate="no">renderer.setSize</code>็่ฐ็จ้ฝไผ็ฅๅฅๅฐไฝฟ็จๆจ่ฏทๆฑ็ๅคงๅฐไนไปฅๆจไผ ๅ
ฅ็ๅ็ด ๆฏไพ.
-<strong>ๅผบ็ไธๅปบ่ฎฎ่ฟๆ ท</strong>ใ ็ไธ้ขใ</p>
-<p>ๅฆไธ็งๆนๆณๆฏๅจ่ฐๆดcanvas็ๅคงๅฐๆถ่ชๅทฑๅค็ใ</p>
-<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
+ <p>ๅ ไธบๅชๆcanvas็ๆพ็คบๅฐบๅฏธๅๅๆถๅฎฝ้ซๆฏๆๅๅๆไปฅๆไปฌ
+ ๅชๅจ<code class="notranslate" translate="no">resizeRendererToDisplaySize</code>ๅฝๆฐ่ฟๅ<code class="notranslate"
+ translate="no">true</code>ๆถๆ่ฎพ็ฝฎๆๅๆบ็ๅฎฝ้ซๆฏใ</p>
+ <p></p>
+ <div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" "
+ src="/manual/examples/resources/editor.html?url=/manual/examples/responsive.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/responsive.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+ </div>
+
+ <p></p>
+ <p>็ฐๅจๆธฒๆ็ๅ่พจ็ๅบ่ฏฅๆฏๅcanvas็ๆพ็คบๅฐบๅฏธไธๆ ท็ใ</p>
+ <p>ไธบไบ่ฏดๆธ
ๆฅ่ฎฉCSSๅค็่ฐๆดๅฐบๅฏธๆไปฌๅฐไปฃ็ ๆพ่ฟ<a href="../examples/threejs-responsive.js">ไธไธชๅ็ฌ็jsๆไปถ</a>ใ
+ ่ฟ้่ฟๆไธไบไพๅญๆไปฌ่ฎฉCSSๅณๅฎๅฐบๅฏธ็ๅคงๅฐๅนถไธๆณจๆๆไปฌๅนถๆฒกๆๆนๅไปปไฝ
+ ไปฃ็ ๆฅ่ฎฉไปไปฌๅทฅไฝใ</p>
+ <p>ๆไปฌๅฐ็ซๆนไฝๆพๅจๆๅญๆฎต่ฝ็ไธญ้ดใ</p>
+ <p></p>
+ <div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" "
+ src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-paragraph.html&startPane=html"></iframe>
+ </div>
+ <a class="threejs_center" href="/manual/examples/responsive-paragraph.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+ </div>
+
+ <p></p>
+ <p>่ฟๆฏๆไปฌๅจ็ผ่พๅจๆ ทๅผๅธๅฑไธญไฝฟ็จ็็ธๅไปฃ็ ๏ผๅณไพง็ๆงๅถๅบๅๅฏไปฅ่ฐๆดๅคงๅฐใ</p>
+ <p></p>
+ <div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" "
+ src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-editor.html&startPane=html"></iframe>
+ </div>
+ <a class="threejs_center" href="/manual/examples/responsive-editor.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+ </div>
+
+ <p></p>
+ <p>้็นๆณจๆๆไปฌ็ไปฃ็ ๅนถๆฒกๆๆนๅ๏ผๅชๆๆไปฌ็HTMLๅCSSๅไบใ</p>
+ <h2 id="-hd-dpi-">ๅบๅฏนHD-DPIๆพ็คบๅจ</h2>
+ <p>HD-DPIไปฃ่กจๆฏ่ฑๅฏธ้ซๅฏๅบฆ็นๆพ็คบๅจ(่ง็ฝ่ๆพ็คบๅจ)ใๅฎๆ็ๆฏๅฝไปๅคงๅคๆฐ็Macๅwindowsๆบๅจไปฅๅๅ ไนๆๆ็ๆบ่ฝๆๆบใ</p>
+ <p>ๆต่งๅจไธญ็ๅทฅไฝๆนๅผๆฏไธ็ฎกๅฑๅน็ๅ่พจ็ๆๅค้ซไฝฟ็จCSSๅ็ด ่ฎพ็ฝฎๅฐบๅฏธไผ่ขซ่ฎคไธบๆฏไธๆ ท็ใ
+ ๅๆ ท็็ฉ็ๅฐบๅฏธๆต่งๅจไผๆธฒๆๅบๅญไฝ็ๆดๅค็ป่ใ</p>
+ <p>ไฝฟ็จthree.jsๆๅค็งๆนๆณๆฅๅบๅฏนHD-DPIใ</p>
+ <p>็ฌฌไธ็งๅฐฑๆฏไธๅไปปไฝ็นๅซ็ไบๆ
ใ่ฟๅฏไปฅ่ฏดๆฏๆๅธธ่ง็ใ
+ ๆธฒๆไธ็ปดๅพๅฝข้่ฆๅคง้็GPUๅค็่ฝๅใ็งปๅจ็ซฏ็GPU่ฝๅๆฏๆก้ข็ซฏ็่ฆๅผฑใ่ณๅฐๆชๆญขๅฐ2018ๅนด,
+ ๆๆบ้ฝๆ้ๅธธ้ซ็ๅ่พจ็ๆพ็คบๅจใ
+ ็ฎๅๆๅฅฝ็ๆๆบ็HD-DPIๆฏไพไธบ3x๏ผๆๆๆฏ้้ซๅฏๅบฆ็นๆพ็คบๅจไธ็ไธไธชๅ็ด ๅจ้ซๅฏๅบฆๆพ็คบๅจไธๆฏ9ไธชๅ็ด ใ
+ ๆๅณ็้่ฆ9ๅ็ๆธฒๆใ</p>
+ <p>่ฎก็ฎ9ๅ็ๅ็ด ๆฏไธชๅคงๅทฅ็จๆไปฅๅฆๆไฟๆไปฃ็ ไธๅๆไปฌๅฐ่ฎก็ฎไธไธชๅ็ด ็ถๅๆต่งๅจๅฐไปฅไธๅๅคงๅฐ็ปๅถ(3x3=9ๅ็ด )ใ</p>
+ <p>ๅฏนไบๅคงๅ็three.jsๅบ็จๆฅ่ฏดไธ้ขๅฐฑๆฏไฝ ๆณ่ฆ็ๅฆไพงไฝ ็ๅธง้็ไผๅพไฝใ</p>
+ <p>ๅฐฝ็ฎกๅฆๆญคๅฆๆไฝ ็กฎๅฎๆณ็จ่ฎพๅค็ๅ่พจ็ๆฅๆธฒๆ๏ผthree.jsไธญๆไธค็งๆนๆณๆฅๅฎ็ฐใ</p>
+ <p>ไธ็งๆฏไฝฟ็จrenderer.setPixelRatioๆฅๅ่ฏthree.jsๅ่พจ็็ๅๆฐใ
+ ่ฎฟ้ฎๆต่งๅจไปCSSๅ็ด ๅฐ่ฎพๅคๅ็ด ็ๅๆฐ็ถๅไผ ็ปthree.jsใ</p>
+ <pre class="prettyprint showlinemods notranslate notranslate" translate="no"> renderer.setPixelRatio(window.devicePixelRatio);
+</pre>
+ <p>ไนๅไปปไฝๅฏน<code class="notranslate" translate="no">renderer.setSize</code>็่ฐ็จ้ฝไผ็ฅๅฅๅฐไฝฟ็จๆจ่ฏทๆฑ็ๅคงๅฐไนไปฅๆจไผ ๅ
ฅ็ๅ็ด ๆฏไพ.
+ <strong>ๅผบ็ไธๅปบ่ฎฎ่ฟๆ ท</strong>ใ ็ไธ้ขใ
+ </p>
+ <p>ๅฆไธ็งๆนๆณๆฏๅจ่ฐๆดcanvas็ๅคงๅฐๆถ่ชๅทฑๅค็ใ</p>
+ <pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
@@ -200,32 +227,37 @@ <h2 id="-hd-dpi-">ๅบๅฏนHD-DPIๆพ็คบๅจ</h2>
return needResize;
}
</pre>
-<p>็ฌฌไบ็ซ ๆนๆณไปๅฎข่งไธๆฅ่ฏดๆดๅฅฝใไธบไปไน๏ผๅ ไธบๆๆฟๅฐไบๆๆณ่ฆ็ใ
-ๅจไฝฟ็จthree.jsๆถๆๅพๅค็งๆ
ๅตไธๆไปฌ้่ฆ็ฅ้canvas็็ปๅพ็ผๅฒๅบ็็กฎๅๅฐบๅฏธใ
-ๆฏๅฆๅถไฝๅๆๅค็ๆปค้ๆ่
ๆไปฌๅจๆไฝ็่ฒๅจ้่ฆ่ฎฟ้ฎgl_FragCoordๅ้๏ผๅฆๆๆไปฌๆชๅฑๆ่
็ปGPU
-่ฏปๅๅ็ด ๏ผ็ปๅถๅฐไบ็ปด็canvas็ญ็ญใ
-้่ฟๆไปฌ่ชๅทฑๅค็ๆไปฌไผไธ็ด็ฅ้ไฝฟ็จ็ๅฐบๅฏธๆฏไธๆฏๆไปฌ้่ฆ็ใ
-ๅนๅๅนถๆฒกๆไปไน็นๆฎ็้ญๆณๅ็ใ</p>
-<p>่ฟๆฏไธไธชไฝฟ็จไธ้ขไปฃ็ ็ไพๅญใ</p>
-<p></p><div translate="no" class="threejs_example_container notranslate">
- <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-hd-dpi.html"></iframe></div>
- <a class="threejs_center" href="/manual/examples/responsive-hd-dpi.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
-</div>
-
-<p></p>
-<p>ๅฏ่ฝๅพ้พ็ๅบๅบๅซไฝๆฏๅฆๆไฝ ๆไธไธชHD-DPIๆพ็คบๅจ
-ๅไธ้ข็ไพๅญๅๅฏนๆฏไฝ ๅฐฑ่ฝๅ็ฐ่พน่งๆดๆธ
ๆฐใ</p>
-<p>่ฟ็ฏๆ็ซ ๆถต็ไบไธไธช้ๅธธๅบ็กไฝๆฏๅพๆๅฟ
่ฆ็ไธป้ขใๆฅไธๆฅๆไปฌๅฟซ้
-<a href="primitives.html">่ฟไธ้three.jsๆไพ็ๅบๆฌ็ไธ่ฅฟ </a>.</p>
-
+ <p>็ฌฌไบ็งๆนๆณไปๅฎข่งไธๆฅ่ฏดๆดๅฅฝใไธบไปไน๏ผๅ ไธบๆๆฟๅฐไบๆๆณ่ฆ็ใ
+ ๅจไฝฟ็จthree.jsๆถๆๅพๅค็งๆ
ๅตไธๆไปฌ้่ฆ็ฅ้canvas็็ปๅพ็ผๅฒๅบ็็กฎๅๅฐบๅฏธใ
+ ๆฏๅฆๅถไฝๅๆๅค็ๆปค้ๆ่
ๆไปฌๅจๆไฝ็่ฒๅจ้่ฆ่ฎฟ้ฎgl_FragCoordๅ้๏ผๅฆๆๆไปฌๆชๅฑๆ่
็ปGPU
+ ่ฏปๅๅ็ด ๏ผ็ปๅถๅฐไบ็ปด็canvas็ญ็ญใ
+ ้่ฟๆไปฌ่ชๅทฑๅค็ๆไปฌไผไธ็ด็ฅ้ไฝฟ็จ็ๅฐบๅฏธๆฏไธๆฏๆไปฌ้่ฆ็ใ
+ ๅนๅๅนถๆฒกๆไปไน็นๆฎ็้ญๆณๅ็ใ</p>
+ <p>่ฟๆฏไธไธชไฝฟ็จไธ้ขไปฃ็ ็ไพๅญใ</p>
+ <p></p>
+ <div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" "
+ src="/manual/examples/resources/editor.html?url=/manual/examples/responsive-hd-dpi.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/responsive-hd-dpi.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
</div>
+
+ <p></p>
+ <p>ๅฏ่ฝๅพ้พ็ๅบๅบๅซไฝๆฏๅฆๆไฝ ๆไธไธชHD-DPIๆพ็คบๅจ
+ ๅไธ้ข็ไพๅญๅๅฏนๆฏไฝ ๅฐฑ่ฝๅ็ฐ่พน่งๆดๆธ
ๆฐใ</p>
+ <p>่ฟ็ฏๆ็ซ ๆถต็ไบไธไธช้ๅธธๅบ็กไฝๆฏๅพๆๅฟ
่ฆ็ไธป้ขใๆฅไธๆฅๆไปฌๅฟซ้่ฟไธ้
+ <a href="primitives.html">three.jsๆไพ็ๅบๆฌ็ไธ่ฅฟ </a>.
+ </p>
+
</div>
</div>
-
+ </div>
+
<script src="/manual/resources/prettify.js"></script>
<script src="/manual/resources/lesson.js"></script>
-</body></html>
\ No newline at end of file
+</body>
+
+</html>
\ No newline at end of file | false |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGL1Renderer.html | @@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:WebGLRenderer] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Poichรฉ la versione r118 [page:WebGLRenderer] utilizza automaticamente un contesto di rendering WebGL 2, quando viene aggiornato un progetto estistente a
+ => r118, l'applicazione potrebbe rompersi per due ragioni:
+
+ <ul>
+ <li>Il codice dello shader personalizzato deve essere conforme a GLSL 3.0.</li>
+ <li>I controlli dell'estensione WebGL 1 devono essere cambiati.</li>
+ </ul>
+
+ Se non hai tempo di cambiare il tuo codice ma vuoi ancora utilizzare l'ultima versione, puoi usare [name].
+ Questa versione di renderer forzerร un contesto di rendering WebGL 1.
+ </p>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:Object parameters] )</h3>
+ <p>
+ Crea un nuovo [name].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:WebGLRenderer] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean isWebGL1Renderer]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:WebGLRenderer] per i metodi comuni.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGL3DRenderTarget.html | @@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:WebGLRenderTarget] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Rappresenta un render target tridimensionale.
+ </p>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:Number width], [param:Number height], [param:Number depth] )</h3>
+ <p>
+ [page:Number width] - la lunghezza del render target, in pixel. Il valore predefinito รจ `1`.<br />
+ [page:Number height] - l'altezza del render target, in pixel. Il valore predefinito รจ `1`.<br />
+ [page:Number depth] - la profonditร del render target. Il valore predefinito รจ `1`.<br /><br />
+
+ Crea un nuovo [name].
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>Vedi [page:WebGLRenderTarget] per le proprietร ereditate</h3>
+
+ <h3>[property:number depth]</h3>
+ <p>
+ La profonditร del render target.
+ </p>
+
+ <h3>[property:Data3DTexture texture]</h3>
+ <p>
+ La proprietร texture รจ sovrasctitta con un'istanza di [page:Data3DTexture].
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>Vedi [page:WebGLRenderTarget] per i metodi ereditati</h3>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGLArrayRenderTarget.html | @@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:WebGLRenderTarget] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Questo tipo di render target rappresenta un array di texture.
+ </p>
+
+ <h2>Esempi</h2>
+
+ <p>
+ [example:webgl2_rendertarget_texture2darray WebGL 2 / render target / array]<br />
+ </p>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:Number width], [param:Number height], [param:Number depth] )</h3>
+ <p>
+ [page:Number width] - la lunghezza del render target, in pixel. Il valore predefinito รจ `1`.<br />
+ [page:Number height] - l'altezza del render target, in pixel. Il valore predefinito รจ `1`.<br />
+ [page:Number depth] - la profonditร del render target. Il valore predefinito รจ `1`.<br /><br />
+
+ Crea un nuovo [name].
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>Vedi [page:WebGLRenderTarget] per le proprietร ereditate</h3>
+
+ <h3>[property:number depth]</h3>
+ <p>
+ La profonditร del render target.
+ </p>
+
+ <h3>[property:DataArrayTexture texture]</h3>
+ <p>
+ La proprietร texture รจ sovrasctitta con un'istanza di [page:DataArrayTexture].
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>Vedi [page:WebGLRenderTarget] per i metodi ereditati</h3>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGLCubeRenderTarget.html | @@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:WebGLRenderTarget] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Utilizzato da [page:CubeCamera] come suo [page:WebGLRenderTarget].
+ </p>
+
+ <h2>Esempi</h2>
+
+ <p>Vedi [page:CubeCamera] per gli esempi.</p>
+
+
+ <h2>Costruttore</h2>
+
+
+ <h3>[name]([param:Number size], [param:Object options])</h3>
+ <p>
+ [page:Float size] - la dimensione, in pixel. Il valore predefinito รจ `1`.<br />
+ options - (opzionale) oggetto che contiene i parametri della texture per un target texture auto generato
+ e i booleani depthBuffer/stencilBuffer.
+
+ Per una spiegazione dei parametri della texture vedi [page:Texture Texture]. Le seguenti
+ sono opzioni valide:<br /><br />
+
+ [page:Constant wrapS] - Il valore predefinito รจ [page:Textures ClampToEdgeWrapping]. <br />
+ [page:Constant wrapT] - Il valore predefinito รจ [page:Textures ClampToEdgeWrapping]. <br />
+ [page:Constant magFilter] - Il valore predefinito รจ [page:Textures .LinearFilter]. <br />
+ [page:Constant minFilter] - Il valore predefinito รจ [page:Textures LinearFilter]. <br />
+ [page:Boolean generateMipmaps] - Il valore predefinito รจ `false`.<br />
+ [page:Constant format] - Il valore predefinito รจ [page:Textures RGBAFormat]. <br />
+ [page:Constant type] - Il valore predefinito รจ [page:Textures UnsignedByteType]. <br />
+ [page:Number anisotropy] - Il valore predefinito รจ `1`. Vedi [page:Texture.anisotropy]<br />
+ [page:Constant encoding] - Il valore predefinito รจ [page:Textures LinearEncoding]. <br />
+ [page:Boolean depthBuffer] - Il valore predefinito รจ `true`.<br />
+ [page:Boolean stencilBuffer] - Il valore predefinito รจ `false`.<br /><br />
+
+ Crea un nuovo [name]
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>Vedi [page:WebGLRenderTarget] per le proprietร ereditate</h3>
+
+ <h2>Metodi</h2>
+
+ <h3>Vedi [page:WebGLRenderTarget] per i metodi ereditati</h3>
+
+ <h3>[method:this fromEquirectangularTexture]( [param:WebGLRenderer renderer], [param:Texture texture] )</h3>
+ <p>
+ [page:WebGLRenderer renderer] โ il renderer.<br/>
+ [page:Texture texture] โ la texture equirettangolare.
+ </p>
+ <p>
+ Utilizza questo metodo se vuoi convertire un panorama equirettangolare nel formato cubemap.
+ </p>
+
+ <h3>[method:undefined clear]( [param:WebGLRenderer renderer], [param:Boolean color], [param:Boolean depth], [param:Boolean stencil] )</h3>
+ <p>
+ Chiama questo metodo per cancellare il colore, la profonditร e/o i buffer stencil del render target.
+ Il buffer del colore รจ impostato al colore corrente del renderer. L'impostazione predefinita degli argomenti รจ `true`.
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGLMultipleRenderTargets.html | @@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:WebGLRenderTarget] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Un target di rendering speciale che consente a un fragment shader di scrivere su piรน texture.
+ Questo approccio รจ utile per le tecniche di rendering avanzate come la post-eleborazione o il rendering differito.
+
+ Attenzione: [name] puรฒ solo essere utilizzato in un contesto di rendering WebGL 2.
+ </p>
+
+ <h2>Esempi</h2>
+
+ <p>
+ [example:webgl2_multiple_rendertargets webgl2 / multiple / rendertargets ]
+ </p>
+
+ <h2>Costruttore</h2>
+
+
+ <h3>[name]([param:Number width], [param:Number height], [param:Number count], [param:Object options])</h3>
+
+ <p>
+ [page:Number width] - La larghezza del target di rendering. Il valore predefinito รจ `1`.<br />
+ [page:Number height] - L'altezza del target di rendering. Il valore predefinito รจ `1`.<br />
+ [page:Number count] - Il numero di target di rendering. Il valore predefinito รจ `1`.<br />
+
+ options - (oggetto opzionale che contiene i parametri della texture per una texture target auto generata
+ e i booleani depthBuffer/stencilBuffer. Per una spiegazione dei parametri della texture consultare [page:Texture Texture].
+ Per un elenco di opzioni valide, consultare [page:WebGLRenderTarget WebGLRenderTarget].)<br /><br />
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>[property:Boolean isWebGLMultipleRenderTargets]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:Array texture]</h3>
+ <p>
+ La proprietร texture viene sovrascritta in [name] e sostituita con un array. Questo array contiene i
+ riferimenti alla [page:WebGLRenderTarget.texture texture] dei rispettivi target di rendering.
+ </p>
+
+ <p>Le proprietร [page:WebGLRenderTarget WebGLRenderTarget] sono disponibili su questa classe.</p>
+
+ <h2>Metodi</h2>
+
+ <p>I metodi [page:WebGLRenderTarget WebGLRenderTarget] sono disponibili su questa classe.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGLRenderTarget.html | @@ -0,0 +1,137 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Un [link:https://webglfundamentals.org/webgl/lessons/webgl-render-to-texture.html render target] รจ un buffer
+ dove la scheda video disegna i pixel per una scena che viene renderizzata in background.
+ Viene utilizzata in diversi effetti, come applicare la post-elaborazione a un'immagine
+ renderizzata prima di visualizzarla sullo schermo.
+ </p>
+
+
+ <h2>Costruttore</h2>
+
+
+ <h3>[name]([param:Number width], [param:Number height], [param:Object options])</h3>
+
+ <p>
+ [page:Float width] - La lunghezza del renderTarget. Il valore predefinito รจ `1`.<br />
+ [page:Float height] - L'altezza del renderTarget. Il valore predefinito รจ `1`.<br />
+ options - oggetto opzionale che contiene i parametri della texture per una texture target auto generata
+ e i booleani depthBuffer/stencilBuffer.
+
+ Per una spiegazione dei parametri della texture vedi [page:Texture Texture]. Le seguenti
+ sono opzioni valide:<br /><br />
+
+ [page:Constant wrapS] - il valore predefinito รจ [page:Textures ClampToEdgeWrapping]. <br />
+ [page:Constant wrapT] - il valore predefinito รจ [page:Textures ClampToEdgeWrapping]. <br />
+ [page:Constant magFilter] - il valore predefinito รจ [page:Textures LinearFilter]. <br />
+ [page:Constant minFilter] - il valore predefinito รจ [page:Textures LinearFilter]. <br />
+ [page:Boolean generateMipmaps] - il valore predefinito รจ `false`.<br />
+ [page:Constant format] - il valore predefinito รจ [page:Textures RGBAFormat]. <br />
+ [page:Constant type] - il valore predefinito รจ [page:Textures UnsignedByteType]. <br />
+ [page:Number anisotropy] - il valore predefinito รจ `1`. Vedi [page:Texture.anisotropy]<br />
+ [page:Constant encoding] - il valore predefinito รจ [page:Textures LinearEncoding]. <br />
+ [page:Boolean depthBuffer] - il valore predefinito รจ `true`. <br />
+ [page:Boolean stencilBuffer] - il valore predefinito รจ `false`.<br />
+ [page:Number samples] - il valore predefinito รจ 0.<br /><br />
+
+ Crea un nuovo [name]
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>[property:Boolean isWebGLRenderTarget]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:number width]</h3>
+ <p>
+ La lunghezza del render target.
+ </p>
+
+ <h3>[property:number height]</h3>
+ <p>
+ L'altezza del render target.
+ </p>
+
+ <h3>[property:Vector4 scissor]</h3>
+ <p>
+ Un area rettangolare all'interno della viewport del render target. I frammenti che sono fuori dall'area verranno scartati.
+ </p>
+
+ <h3>[property:Boolean scissorTest]</h3>
+ <p>
+ Indica se il test scissor รจ attivo o no.
+ </p>
+
+ <h3>[property:Vector4 viewport]</h3>
+ <p>
+ Il viewport di questo render target.
+ </p>
+
+ <h3>[property:Texture texture]</h3>
+ <p>
+ Questa istanza della texture contiene i pixel renderizzati. Utilizzalo come input per ulteriori informazioni.
+ </p>
+
+ <h3>[property:Boolean depthBuffer]</h3>
+ <p>
+ Effettua il rendering al buffer di profonditร . L'impostazione predefinita รจ `true`.
+ </p>
+
+ <h3>[property:Boolean stencilBuffer]</h3>
+ <p>
+ Effettua il rendering al buffer stencil. Il valore predefinito รจ `false`.
+ </p>
+
+ <h3>[property:DepthTexture depthTexture]</h3>
+ <p>
+ Se impostato, la profonditร della scena verrร renderizzata su questa texture. Il valore predefinito รจ `null`.
+ </p>
+
+ <h3>[property:Number samples]</h3>
+ <p>
+ Definisce il conteggio di campioni MSAA. Puรฒ essere utilizzato solo con WebGL 2. Il valore predefinito รจ `0`.
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>[method:undefined setSize]( [param:Number width], [param:Number height] )</h3>
+ <p>
+ Imposta la dimensione del render target.
+ </p>
+
+ <h3>[method:WebGLRenderTarget clone]()</h3>
+ <p>
+ Crea una copia di questo render target.
+ </p>
+
+ <h3>[method:this copy]( [param:WebGLRenderTarget source] )</h3>
+ <p>
+ Adotta le impostazioni del render target dato.
+ </p>
+
+ <h3>[method:undefined dispose]()</h3>
+ <p>
+ Libera le risorse relative alla GPU allocate a questa istanza. Chiama questo metodo ogni volta che questa istanza non viene piรน utilizzata nella tua app.
+ </p>
+
+ <p>I metodi [page:EventDispatcher EventDispatcher] sono disponibili in questa classe.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/WebGLRenderer.html | @@ -0,0 +1,520 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Il WebGL rendering mostra le tue scene meravigliosamente realizzate utilizzando
+ [link:https://en.wikipedia.org/wiki/WebGL WebGL].
+ </p>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:Object parameters] )</h3>
+ <p>
+ [page:Object parameters] - (opzionale) oggetto con proprietร che definiscono il comportamento del renderer.
+ Il costruttore inoltre non accetta alcun parametro. In tutti i casi, assumerร impostazioni predefinite
+ quando i parametri mancheranno. I seguenti sono parametri validi:<br /><br />
+
+ [page:DOMElement canvas] - Un [link:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas canvas]
+ dove il renderer disegna il suo output.
+ Questo corrisponde alla proprietร [page:WebGLRenderer.domElement domElement] di seguito.
+ Se non viene passato, un nuovo elemento canvas sarร creato.<br />
+
+
+ [page:WebGLRenderingContext context] - Questo puรฒ essere utilizzato per collegare il renderer ad un
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext] esistente.
+ Il valore predefinito รจ `null`.<br />
+
+ [page:String precision] - Precisione dello shader. Puรฒ essere `"highp"`, `"mediump"` o `"lowp"`.
+ Il valore predefinito รจ `"highp"` se supportato dal dispositivo.<br />
+
+ [page:Boolean alpha] - controlla il valore predefinito di alfa. Quando impostato a `true`, il valore รจ `0`. Altrimenti รจ `1`. Il valore predefinito รจ `false`.<br />
+
+ [page:Boolean premultipliedAlpha] - Indica se il renderer presumerร che i colori abbiano
+ [link:https://en.wikipedia.org/wiki/Glossary_of_computer_graphics#Premultiplied_alpha premoltiplicato alfa].
+ Il valore predefinito รจ `true`.<br />
+
+ [page:Boolean antialias] - Indica se eseguire l'antialiasing. Il valore predefinito รจ `false`.<br />
+
+ [page:Boolean stencil] - Indica se il buffer di disegno ha un
+ [link:https://en.wikipedia.org/wiki/Stencil_buffer buffer stencil] di almeno 8 bit.
+ Il valore predefinito รจ `true`.<br />
+
+ [page:Boolean preserveDrawingBuffer] - Indica se conservare i buffer finchรฉ non verranno cancellati
+ o sovrascritti manualmente. Il valore predefinito รจ `false`.<br />
+
+ [page:String powerPreference] - Fornisce un suggerimento allo user agent indicando quale configurazione della
+ GPU รจ adatta per questo contesto WebGL. Puรฒ essere `"high-performance"`, `"low-power"` o `"default"`. Il valore predefinito รจ `"default"`.
+ Vedi [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2 WebGL spec] per i dettagli.<br />
+
+ [page:Boolean failIfMajorPerformanceCaveat] - Indica se la creazione del renderer avrร esito negativo in caso di rilevamento
+ di prestazioni ridotte. Il valore predefinito รจ `false`.
+ Vedi [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2 WebGL spec] per i dettagli.<br />
+
+ [page:Boolean depth] - Indica se il buffer di disegno ha un
+ [link:https://en.wikipedia.org/wiki/Z-buffering buffer di depth] di almeno 16 bit.
+ Il valore predefinito รจ `true`.<br />
+
+ [page:Boolean logarithmicDepthBuffer] - Indica se usare un buffer di depth logaritmico. Potrebbe essere necessario utilizzare
+ questa opzione se si ha a che fare con enormi differenze di scala in una singola scena. Si noti che questa impostazione
+ utilizza gl_FragDepth, se disponibile, che disabilita l'ottimizzione [link:https://www.khronos.org/opengl/wiki/Early_Fragment_Test Early Fragment Test]
+ e puรฒ causare una riduzione delle prestazioni.
+ Il valore predefinito รจ `false`. Vedi l'esempio [example:webgl_camera_logarithmicdepthbuffer camera / logarithmicdepthbuffer].
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>[property:Boolean autoClear]</h3>
+ <p>Definisce se il renderer deve cancellare automaticamente il suo output prima di eseguire il rendering di un frame.</p>
+
+
+ <h3>[property:Boolean autoClearColor]</h3>
+ <p>
+ Se [page:.autoClear autoClear] รจ `true`, definisce se il renderer deve cancellare il buffer del colore.
+ Il valore predefinito รจ `true`.
+ </p>
+
+
+ <h3>[property:Boolean autoClearDepth]</h3>
+ <p>
+ Se [page:.autoClear autoClear] รจ `true`, definisce se il renderer deve cancellare il buffer di depth.
+ Il valore predefinito รจ `true`.
+ </p>
+
+
+ <h3>[property:Boolean autoClearStencil]</h3>
+ <p>
+ Se [page:.autoClear autoClear] รจ `true`, definisce se il renderer deve cancellare il buffer dello stencil.
+ Il valore predefinito รจ `true`.
+ </p>
+
+ <h3>[property:Object debug]</h3>
+ <p>
+ - [page:Boolean checkShaderErrors]:
+ Se รจ `true`, definisce se i programmi material shader devono essere controllati per errori
+ durante la compilazione e il processo di collegamento.
+ Puรฒ essere utile disabilitare questo controllo in produzione per aumentare le prestazioni.
+ ร fortemente raccomandato mantenere questi controlli attivi durante lo sviluppo.
+ Se lo shader non si compila e non si collega - non funzionerร e il materiale associato non verrร visualizzato.
+ Il valore predefinito รจ `true`.
+ </p>
+
+ <h3>[property:Object capabilities]</h3>
+ <p>
+ Un oggetto che contiene i dettagli sulle capacitร del [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext] corrente.<br />
+
+ - [page:Boolean floatFragmentTextures]: indica se il contesto supporta l'estensione [link:https://developer.mozilla.org/en-US/docs/Web/API/OES_texture_float OES_texture_float].<br />
+ - [page:Boolean floatVertexTextures]: `true` se [page:Boolean floatFragmentTextures] e [page:Boolean vertexTextures] sono entrambi true.<br />
+ - [page:Method getMaxAnisotropy](): Restituisce l'anisotropia massima disponibile.<br />
+ - [page:Method getMaxPrecision](): Restituisce la precisione massima disponibile per gli shader vertex e fragment. <br />
+ - [page:Boolean isWebGL2]: `true` se il contesto in uso รจ un oggetto WebGL2RenderingContext.<br />
+ - [page:Boolean logarithmicDepthBuffer]: `true` se il [page:parameter logarithmicDepthBuffer] era impostato a true nel costruttore e
+ il contesto supporta l'estensione [link:https://developer.mozilla.org/en-US/docs/Web/API/EXT_frag_depth EXT_frag_depth].<br />
+ - [page:Integer maxAttributes]: Il valore di `gl.MAX_VERTEX_ATTRIBS`.<br />
+ - [page:Integer maxCubemapSize]: Il valore di `gl.MAX_CUBE_MAP_TEXTURE_SIZE`.
+ Altezza massima * larghezza delle texture della mappa del cubo che uno shader puรฒ utilizzare.<br />
+ - [page:Integer maxFragmentUniforms]: Il valore di `gl.MAX_FRAGMENT_UNIFORM_VECTORS`.
+ Il numero di uniforms che possono essere utilizzate da un fragment shader.<br />
+ - [page:Integer maxSamples]: Il valore di `gl.MAX_SAMPLES`.
+ Il numero massimo di campioni nel contesto dell'anti-aliasing multicampione (MSAA).<br />
+ - [page:Integer maxTextureSize]: Il valore di `gl.MAX_TEXTURE_SIZE`.
+ Altezza massima * larghezza di una texture che uno shader utilizza.<br />
+ - [page:Integer maxTextures]: Il valore di `gl.MAX_TEXTURE_IMAGE_UNITS`.
+ Il numero massimo di texture che possono essere utilizzate da uno shader.<br />
+ - [page:Integer maxVaryings]: Il valore di `gl.MAX_VARYING_VECTORS`.
+ Il numero di vettori varying che possono essere utilizzati dagli shader.<br />
+ - [page:Integer maxVertexTextures]: Il valore di `gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS`.
+ Il numero di texture che possono essere utilizzate in un vertex shader.<br />
+ - [page:Integer maxVertexUniforms]: Il valore di `gl.MAX_VERTEX_UNIFORM_VECTORS`.
+ Il numero massimo di uniforms che possono essere utilizzate in un vertex shader.<br />
+ - [page:String precision]: La precisione dello shader attualmente utilizzata dal renderer.<br />
+ - [page:Boolean vertexTextures]: `true` se [property:Integer maxVertexTextures] รจ maggiore di 0 (ad es. รจ possibile utilizzare vertex texture).<br />
+ </p>
+
+ <h3>[property:Array clippingPlanes]</h3>
+ <p>
+ L'utente definisce piani di taglio specificati come oggetti THREE.Plane nello spazio world.
+ Questi piani si applicano a livello globale. I punti nello spazio il cui prodotto scalare con il
+ piano รจ negativo vengono tagliati.
+ Il valore predefinito รจ [].
+ </p>
+
+ <h3>[property:DOMElement domElement]</h3>
+ <p>
+ Un [link:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas canvas] dove il renderer disegna il suo output.<br />
+ Questo viene automaticamente creato dal renderer nel costruttore (se non รจ giร stato fornito);
+ devi solo aggiungerlo alla tua pagina in questo modo:<br />
+ <code>
+ document.body.appendChild( renderer.domElement );
+ </code>
+ </p>
+
+ <h3>[property:Object extensions]</h3>
+ <p>
+ - [page:Object get]( [param:String extensionName] ):
+ Utilizzato per verificare se le varie estensioni sono supportate e restituisce un oggetto con i dettagli dell'estensione se disponibile.
+ Questo metodo puรฒ controllare per le seguenti estensioni:<br />
+
+ <ul>
+ <li>`WEBGL_depth_texture`</li>
+ <li>`EXT_texture_filter_anisotropic`</li>
+ <li>`WEBGL_compressed_texture_s3tc`</li>
+ <li>`WEBGL_compressed_texture_pvrtc`</li>
+ <li>`WEBGL_compressed_texture_etc1`</li>
+ </ul>
+ </p>
+
+ <h3>[property:number outputEncoding]</h3>
+ <p>Definisce la codifica di output del renderer. Il valore predefinito รจ [page:Textures THREE.LinearEncoding].</p>
+ <p>Se il target render รจ stato impostato utilizzando [page:WebGLRenderer.setRenderTarget .setRenderTarget],
+ verrร invece utilizzato renderTarget.texture.encoding.</p>
+ <p>Vedi la pagina [page:Textures texture constants] per i dettagli su altri formati.</p>
+
+ <h3>[property:Object info]</h3>
+ <p>
+ Un oggetto con una serie di informazioni statistiche sulla memoria della scheda grafica e sul processo di rendering.
+ Utile per il debug o solo per curiositร . L'oggetto contiene i seguenti campi:</p>
+ <p>
+ <ul>
+ <li>memory:
+ <ul>
+ <li>geometries</li>
+ <li>textures</li>
+ </ul>
+ </li>
+ <li>render:
+ <ul>
+ <li>calls</li>
+ <li>triangles</li>
+ <li>points</li>
+ <li>lines</li>
+ <li>frame</li>
+ </ul>
+ </li>
+ <li>programs
+ </li>
+ </ul>
+ </p>
+ <p>
+ Per impostazione predefinita questi dati vengono reimpostati ad ogni chiamata di rendering ma quando si
+ hanno piรน passaggi di rendering per frame (ad esempio quando si utilizza la post elaborazione) puรฒ essere
+ preferibile ripristinare con un modello personalizzato.
+ Inanzitutto, imposta `autoReset` a `false`.
+ <code>
+ renderer.info.autoReset = false;
+ </code>
+ Chiama `reset()` ogni volta che hai terminato di renderizzare ogni singolo frame.
+ <code>
+ renderer.info.reset();
+ </code>
+ </p>
+
+ <h3>[property:Boolean localClippingEnabled]</h3>
+ <p>Definisce se il render rispetta i piani di taglio a livello di oggetto. Il valore predefinito รจ `false`.</p>
+
+ <h3>[property:Boolean physicallyCorrectLights]</h3>
+ <p>
+ Indica se utilizzare la modalitร di illuminazione fisicamente corretta. Il valore predefinito รจ `false`.
+ Vedi l'esempio [example:webgl_lights_physical lights / physical].
+ </p>
+
+ <h3>[property:Object properties]</h3>
+ <p>
+ Utilizzato internamente dal renderer per mantenere traccia delle proprietร dei vari oggetti secondari.
+ </p>
+
+ <h3>[property:WebGLRenderLists renderLists]</h3>
+ <p>
+ Utilizzato internamente per gestire l'ordine del rendering degli oggetti della scena.
+ </p>
+
+ <h3>[property:WebGLShadowMap shadowMap]</h3>
+ <p>
+ Questo contiene il riferimento alla mappa delle ombre, se utilizzato.<br />
+ - [page:Boolean enabled]:
+ Se impostato, utilizza le mappe delle ombre nella scena. Il valore predefinito รจ `false`.<br />
+ - [page:Boolean autoUpdate]:
+ Abilita aggiornamenti automatici delle ombre nella scena. Il valore predefinito รจ `true`.<br />
+ Se non hai bisogno di luci/ombre, puoi impostarlo su `false` quando viene creata un'istanza del renderer.<br />
+ - [page:Boolean needsUpdate]:
+ Quando impostato a `true`, le mappe delle ombre nella scena verranno aggiornate nella prossima chiamata a `render`. Il valore predefinito รจ `false`.<br />
+ Se hai disabilitato gli aggiornamenti automatici alle mappe della ombre (`shadowMap.autoUpdate = false`),
+ avrai bisogno di impostare questo a `true` e poi fare una chiamata a `render` per aggiornare le ombre nella tua scena.<br />
+ - [page:Integer type]:
+ Definisce il tipo di mappa delle ombre (non filtrato, filtro di chiusura percentuale, filtro di chiusura percentuale con filtro
+ bilineare nello shader).
+ Le opzioni sono:
+ <ul>
+ <li>THREE.BasicShadowMap</li>
+ <li>THREE.PCFShadowMap (default)</li>
+ <li>THREE.PCFSoftShadowMap</li>
+ <li>THREE.VSMShadowMap</li>
+ </ul>
+ Vedi [page:Renderer Renderer constants] per i dettagli.<br />
+ </p>
+
+ <h3>[property:Boolean sortObjects]</h3>
+ <p>
+ Definisce se il renderer deve ordinare gli oggetti. Il valore predefinito รจ `true`.<br /><br />
+
+ Nota: L'ordinamento viene utilizzato per tentare di eseguire correttamente il rendering di oggetti
+ con un certo grado di trasparenza. Per definizione, l'ordinamento degli oggetti potrebbe non funzionare
+ in tutti i casi. A seconda delle esigenze dell'applicazione, potrebbe essere necessario disattivare
+ l'ordinamento e utilizzare altri metodi per gestire il rendering della trasparenza, ad es.
+ determinare manualmente l'ordine di rendering di ciascun oggetto.
+ </p>
+
+ <h3>[property:Object state]</h3>
+ <p>
+ Contiene funzioni per settare varie proprietร dello stato [page:WebGLRenderer.context].
+ </p>
+
+ <h3>[property:Constant toneMapping]</h3>
+ <p>
+ Il valore predefinito รจ [page:Renderer NoToneMapping]. Vedi [page:Renderer Renderer constants] per altre scelte.
+ </p>
+
+ <h3>[property:Number toneMappingExposure]</h3>
+ <p>
+ Livello della mappatura dei toni. Il valore predefinito รจ `1`.
+ </p>
+
+ <h3>[property:WebXRManager xr]</h3>
+ <p>
+ Fornisce accesso all'[page:WebXRManager interfaccia] relativa al WebXR del renderer.
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>[method:undefined clear]( [param:Boolean color], [param:Boolean depth], [param:Boolean stencil] )</h3>
+ <p>
+ Dice al renderer di cancellare il suo colore, il(i) buffer di disegno depth e stancil.
+ Questo metodo inizializza il buffer del colore al valore di color corrente.<br />
+ Il valore predefinito degli argomenti รจ `true`.
+ </p>
+
+ <h3>[method:undefined clearColor]( )</h3>
+ <p>Cancella il buffer di colore. Equivalente a chiamare [page:WebGLRenderer.clear .clear]( true, false, false ).</p>
+
+ <h3>[method:undefined clearDepth]( )</h3>
+ <p>Cancella il buffer di profonditร . Equivalente a chiamare [page:WebGLRenderer.clear .clear]( false, true, false ).</p>
+
+ <h3>[method:undefined clearStencil]( )</h3>
+ <p>Cancella il buffer di stencil. Equivalente a chiamare [page:WebGLRenderer.clear .clear]( false, false, true ).</p>
+
+ <h3>[method:undefined compile]( [param:Object3D scene], [param:Camera camera] )</h3>
+ <p>Compila tutti i materiali nella scena con la telecamera. Questo รจ utile per precompilare le ombre prima del primo rendering.</p>
+
+ <h3>[method:undefined copyFramebufferToTexture]( [param:Vector2 position], [param:FramebufferTexture texture], [param:Number level] )</h3>
+ <p>
+ Copia i pixel dal WebGLFramebuffer corrente in una texture 2D. Abilita l'accesso a
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/copyTexImage2D WebGLRenderingContext.copyTexImage2D].
+ </p>
+
+ <h3>[method:undefined copyTextureToTexture]( [param:Vector2 position], [param:Texture srcTexture], [param:Texture dstTexture], [param:Number level] )</h3>
+ <p>
+ Copia tutti i pixel della texture in una texture esistente partendo dalla posizione data. Abilita l'accesso a
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texSubImage2D WebGLRenderingContext.texSubImage2D].
+ </p>
+
+ <h3>[method:undefined copyTextureToTexture3D]( [param:Box3 sourceBox], [param:Vector3 position], [param:Texture srcTexture], [param:Texture dstTexture], [param:Number level] )</h3>
+ <p>
+ Copia i pixel della texture nei limiti '[page:Box3 sourceBox]' nella texture di destinazione partendo dalla posizione data. Abilita l'accesso a
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/texSubImage3D WebGL2RenderingContext.texSubImage3D].
+ </p>
+
+ <h3>[method:undefined dispose]( )</h3>
+ <p>
+ Libera le risorse relative alla GPU allocata a questa istanza. Chiama questo metodo ogni volta che questa istanza non viene piรน utilizzata nella
+ tua applicazione.
+ </p>
+
+ <h3>[method:undefined forceContextLoss]()</h3>
+ <p>
+ Simula la perdita del contesto WebGL. Questo richiede il supporto per le
+ estensioni [link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context WEBGL_lose_context].
+ </p>
+
+ <h3>[method:undefined forceContextRestore]( )</h3>
+ <p>
+ Simula il ripristino del contesto WebGL. Questo richiede il supporto per le
+ estensioni [link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context WEBGL_lose_context].
+ </p>
+
+ <h3>[method:Float getClearAlpha]()</h3>
+ <p>Restituisce un [page:Float float] con l'alfa corrente. Intervallo tra 0 e 1.</p>
+
+ <h3>[method:Color getClearColor]( [param:Color target] )</h3>
+ <p>Restituisce un'istanza [page:Color THREE.Color] con l'alfa corrente.</p>
+
+ <h3>[method:WebGL2RenderingContext getContext]()</h3>
+ <p>Restituisce il contesto WebGL corrente.</p>
+
+ <h3>[method:WebGLContextAttributes getContextAttributes]()</h3>
+ <p>Restituisce un oggetto che descrive gli attributi impostati sul contesto WebGL quando รจ stato creato.</p>
+
+ <h3>[method:Integer getActiveCubeFace]()</h3>
+ <p>Restituisce la faccia del cubo attiva corrente.</p>
+
+ <h3>[method:Integer getActiveMipmapLevel]()</h3>
+ <p>Restituisce il livello mipmap attivo corrente.</p>
+
+ <h3>[method:RenderTarget getRenderTarget]()</h3>
+ <p>Restituisce il [page:RenderTarget RenderTarget] correnti se ci sono; altrimenti restituisce `null`.</p>
+
+ <h3>[method:Vector4 getCurrentViewport]( [param:Vector4 target] )</h3>
+ <p>
+ [page:Vector4 target] โ il risultato verrร copiato in questo Vector4.<br /><br />
+
+ Restituisce il viewport corrente.
+ </p>
+
+ <h3>[method:Vector2 getDrawingBufferSize]( [param:Vector2 target] )</h3>
+ <p>
+ [page:Vector2 target] โ il risultato verrร copiato in questo Vector2.<br /><br />
+
+ Restituisce la lunghezza e l'altezza del buffer di disegno del renderer, in pixel.
+ </p>
+
+ <h3>[method:number getPixelRatio]()</h3>
+ <p>Restituisce il pixel ratio del dispotivo corrente utilizzato.</p>
+
+ <h3>[method:Vector4 getScissor]( [param:Vector4 target] )</h3>
+ <p>
+ [page:Vector4 target] โ il risultato verrร copiato in questo Vector4.<br /><br />
+
+ Restituisce la regione scissor.
+ </p>
+
+ <h3>[method:Boolean getScissorTest]()</h3>
+ <p>Restituisce `true` se scissor test รจ abilitato; altrimenti restituisce `false`.</p>
+
+ <h3>[method:Vector2 getSize]( [param:Vector2 target] )</h3>
+ <p>
+ [page:Vector2 target] โ il risultato verrร copiato in questo Vector2.<br /><br />
+
+ Restituisce la lunghezza e l'altezza del canvas di output del renderer, in pixel.
+ </p>
+
+ <h3>[method:Vector4 getViewport]( [param:Vector4 target] )</h3>
+ <p>
+ [page:Vector4 target] โ il risultato verrร copiato in questo Vector4.<br /><br />
+
+ Restituisce il viewport.
+ </p>
+
+ <h3>[method:undefined initTexture]( [param:Texture texture] )</h3>
+ <p>
+ Inizializza la texture data. Utilizzato per precaricare una texture piuttosto che aspettare fino al primo rendering
+ (il quale puรฒ causare notevoli ritardi dovuti alla decodifica e al sovraccarico di caricamento della GPU).
+ </p>
+
+ <h3>[method:undefined resetGLState]( )</h3>
+ <p>Reimposta lo stato GL al valore predefinito. Chiamato internamente se il contesto WebGL viene perso.</p>
+
+ <h3>[method:undefined readRenderTargetPixels]( [param:WebGLRenderTarget renderTarget], [param:Float x], [param:Float y], [param:Float width], [param:Float height], [param:TypedArray buffer], [param:Integer activeCubeFaceIndex] )</h3>
+ <p>buffer - Uint8Array รจ l'unico tipo di destinazione supportato in tutti i casi, altri tipi dipendono dal renderTarget e dalla piattaforma. Vedi [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12 WebGL spec] per i dettagli.</p>
+ <p>Legge le informazioni dei pixel dal renderTarget nel buffer che gli hai passato. Questo รจ un wrapper attorno a [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels WebGLRenderingContext.readPixels]().</p>
+ <p>Vedi l'esempio [example:webgl_interactive_cubes_gpu interactive / cubes / gpu].</p>
+ <p>Per leggere un [page:WebGLCubeRenderTarget WebGLCubeRenderTarget] utilizzare il parametro opzionale activeCubeFaceIndex per determinare quale faccia deve essere letta.</p>
+
+
+ <h3>[method:undefined render]( [param:Object3D scene], [param:Camera camera] )</h3>
+ <p>
+ Renderizza una [page:Scene scena] o un altro tipo di [page:Object3D oggetto] utilizzando una [page:Camera telecamera].<br />
+
+ Il rendering viene seguito su un set [page:WebGLRenderTarget renderTarget] specificato chiamando
+ [page:WebGLRenderer.setRenderTarget .setRenderTarget] o sul canvas come al solito.<br />
+
+ Per impostazione predefinita i buffer sono cancellati prima del rendering ma puoi prevenirlo imposstando la proprietร [page:WebGLRenderer.autoClear autoClear] a false.
+ Se vuoi prevenire solo certi buffer dall'essere cancellati puoi impostare le proprietร [page:WebGLRenderer.autoClearColor autoClearColor], [page:WebGLRenderer.autoClearStencil autoClearStencil] o
+ [page:WebGLRenderer.autoClearDepth autoClearDepth] a false. Per cancellare forzatamente uno o piรน buffer chiama [page:WebGLRenderer.clear .clear].
+ </p>
+
+ <h3>[method:undefined resetState]()</h3>
+ <p>Puรฒ essere utilizzato per reimpostare lo stato interno WebGL. Questo metodo รจ principalmente rilevante per applicazioni che condividono un singolo contesto WebGL tra multiple librerie WebGL.</p>
+
+ <h3>[method:undefined setAnimationLoop]( [param:Function callback] )</h3>
+ <p>[page:Function callback] โ La funzione cancellerร ogni frame disponibile. Se viene passato `null`, si interromperร qualsiasi animazione giร in corso.</p>
+ <p>Una funzione incorporata che puรฒ essere utilizzata al posto di [link:https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame].
+ Questa funzione deve essere utilizza per oggetti WebXR.</p>
+
+ <h3>[method:undefined setClearAlpha]( [param:Float alpha] )</h3>
+ <p>Imposta l'alfa. L'input valido รจ un float tra `0.0` e `1.0`.</p>
+
+ <h3>[method:undefined setClearColor]( [param:Color color], [param:Float alpha] )</h3>
+ <p>Imposta il colore e l'opacitร .</p>
+
+ <h3>[method:undefined setPixelRatio]( [param:number value] )</h3>
+ <p>Imposta la pixel ratio del dispositivo. Questo viene utilizzato per il dispositivo HiDPI per evitare la sfocatura del canvas di output.</p>
+
+ <h3>[method:undefined setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipmapLevel] )</h3>
+ <p>
+ renderTarget -- Il [page:WebGLRenderTarget renderTarget] cha ha bisogno di essere attivato. Quando viene fornito `null`, il canvas invece viene impostato come target di rendering attivo.<br />
+ activeCubeFace -- Specifica il lato attivo del cubo (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) di [page:WebGLCubeRenderTarget].
+ Quando si passa un [page:WebGLArrayRenderTarget] o [page:WebGL3DRenderTarget] questo indica il livello z in cui eseguire il rendering (opzionale).<br />
+ activeMipmapLevel -- Specifica il livello mipmap attivo (opzionale).<br /><br />
+ Questo metodo imposta il renderTarget attivo.
+ </p>
+
+ <h3>[method:undefined setScissor]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
+ [method:undefined setScissor]( [param:Vector4 vector] )</h3>
+
+ <p>
+ I parametri x, y, lunghezza, e altezza della regione di scissor.<br />
+ Opzionale, un vettore component-4 che specifica i parametri della regione.<br /><br />
+
+ Imposta la regione di scissor da (x, y) a (x + width, y + height).<br />
+ (x, y) indica l'angolo in basso a sinistra della regione di scissor.
+ </p>
+
+ <h3>[method:undefined setScissorTest]( [param:Boolean boolean] )</h3>
+ <p>
+ Abilita o disabilita lo scissor test. Quando questo รจ abilitato, solo i pixel con l'area di
+ scissor definita saranno influenzati da ulteriori azioni del render.
+ </p>
+
+ <h3>[method:undefined setOpaqueSort]( [param:Function method] )</h3>
+ <p>
+ Imposta la funzione di ordinamento opaco per la WebGLRenderLists.
+ Passa null per utilizzare la funzione predefinita painterSortStable.
+ </p>
+
+ <h3>[method:undefined setTransparentSort]( [param:Function method] )</h3>
+ <p>
+ Imposta la funzione di ordinamento trasparente per la WebGLRenderLists.
+ Passa null per utilizzare la funzione predefinita reversePainterSortStable.
+ </p>
+
+ <h3>[method:undefined setSize]( [param:Integer width], [param:Integer height], [param:Boolean updateStyle] )</h3>
+ <p>
+ Ridimensiona il canvas di output a (width, height) con la pixel ratio del device presa nell'account,
+ e inoltre imposta il viewport per adattarsi a quella dimensione, partendo da (0, 0).
+ Impostando [page:Boolean updateStyle] a false impedisce qualsiasi modifica di stile al canvas di output.
+ </p>
+
+ <h3>[method:undefined setViewport]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
+ [method:undefined setViewport]( [param:Vector4 vector] )</h3>
+
+ <p>
+ I parametri x, y, lunghezza, e altezza del viewport.<br />
+ Opzionale, un vettore component-4 che specifica i parametri del viewport.<br /><br />
+
+ Imposta il viewport per il rendering da (x, y) a (x + width, y + height).<br />
+ (x, y) indica l'angolo in basso a sinistra della regione.
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/shaders/ShaderChunk.html | @@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">Blocchi shader per la libreria Shader WebGL.</p>
+
+
+
+ <h2>Proprietร </h2>
+
+
+
+ <h2>Metodi</h2>
+
+
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/shaders/ShaderLib.html | @@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">Libreria Shader WebGL per three.js.</p>
+
+
+ <h2>Proprietร </h2>
+
+
+
+ <h2>Metodi</h2>
+
+
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/shaders/UniformsLib.html | @@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">Libreria di uniformi per shared webgl condivisi.</p>
+
+
+
+ <h2>Proprietร </h2>
+
+
+
+ <h2>Metodi</h2>
+
+
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/shaders/UniformsUtils.html | @@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Fornisce funzioni di utilitร per gestire le uniformi.
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>[method:Object clone]( [param:Object src] )</h3>
+ <p>
+ src -- Un oggetto che rappresenta le definizioni delle uniformi.<br /><br />
+
+ Clona le definizioni delle uniformi date eseguendo una copia profonda. Questo significa che se
+ il [page:Uniform.value valore] di una uniforme si riferisce ad un oggetto come un [page:Vector3]
+ o una [page:Texture], la uniforme clonata farร riferimento a un nuovo oggetto di riferimento.
+ </p>
+
+ <h3>[method:Object merge]( [param:Array uniforms] )</h3>
+ <p>
+ uniforms -- Un array di oggetti contente le definizioni della uniforme.<br /><br />
+
+ Unisce le definizioni della uniforme date nel singolo oggetto. Poichรฉ il metodo
+ utilizza internamente [page:.clone](), esegue una copia profonda durante
+ la produzione delle definizioni della uniforme unita.
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/webgl/WebGLProgram.html | @@ -0,0 +1,169 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">Costruttore per il programma GLSL inviato agli shader vertex e fragment, comprese le uniformi e gli attributi.</p>
+
+ <h2>Uniformi e attributi incorporati</h2>
+
+ <h3>Vertex shader (incondizionato):</h3>
+ <div>
+ <code>
+ // = object.matrixWorld
+ uniform mat4 modelMatrix;
+
+ // = camera.matrixWorldInverse * object.matrixWorld
+ uniform mat4 modelViewMatrix;
+
+ // = camera.projectionMatrix
+ uniform mat4 projectionMatrix;
+
+ // = camera.matrixWorldInverse
+ uniform mat4 viewMatrix;
+
+ // = trasposizione inversa di modelViewMatrix
+ uniform mat3 normalMatrix;
+
+ // = posizione della telecamera nello spazio world
+ uniform vec3 cameraPosition;
+ </code>
+ <code>
+ // attributi di vertice predefiniti forniti da Geometry e BufferGeometry
+ attribute vec3 position;
+ attribute vec3 normal;
+ attribute vec2 uv;
+ </code>
+ <p>
+ Si noti che รจ possibile quindi calcolare la posizione di un vertice nel vertex shader con:
+ <code>
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+ </code>
+ o in alternativa
+ <code>
+ gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4( position, 1.0 );
+ </code>
+ </p>
+ </div>
+
+ <h3>Vertex shader (condizionale):</h3>
+ <div>
+ <code>
+ #if defined( USE_COLOR_ALPHA )
+ // attributo del colore del vertice con alfa
+ attribute vec4 color;
+ #elif defined( USE_COLOR )
+ // attributo del colore del vertice
+ attribute vec3 color;
+ #endif
+ </code>
+ <code>
+ #ifdef USE_MORPHTARGETS
+
+ attribute vec3 morphTarget0;
+ attribute vec3 morphTarget1;
+ attribute vec3 morphTarget2;
+ attribute vec3 morphTarget3;
+
+ #ifdef USE_MORPHNORMALS
+
+ attribute vec3 morphNormal0;
+ attribute vec3 morphNormal1;
+ attribute vec3 morphNormal2;
+ attribute vec3 morphNormal3;
+
+ #else
+
+ attribute vec3 morphTarget4;
+ attribute vec3 morphTarget5;
+ attribute vec3 morphTarget6;
+ attribute vec3 morphTarget7;
+
+ #endif
+ #endif
+ </code>
+ <code>
+ #ifdef USE_SKINNING
+ attribute vec4 skinIndex;
+ attribute vec4 skinWeight;
+ #endif
+ </code>
+ <code>
+ #ifdef USE_INSTANCING
+ // Si noti che modelViewMatrix non รจ impostato durante il rendering di un modello istanziato,
+ // ma puรฒ essere calcolato da viewMatrix * modelMatrix.
+ //
+ // Utilizzo di base:
+ // gl_Position = projectionMatrix * viewMatrix * modelMatrix * instanceMatrix * vec4(position, 1.0);
+ attribute mat4 instanceMatrix;
+ #endif
+ </code>
+ </div>
+
+ <h3>Fragment shader:</h3>
+ <div>
+ <code>
+ uniform mat4 viewMatrix;
+ uniform vec3 cameraPosition;
+ </code>
+ </div>
+
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:WebGLRenderer renderer], [param:String cacheKey], [param:Object parameters] )</h3>
+ <p>Per i parametri vedere [page:WebGLRenderer WebGLRenderer].</p>
+
+ <h2>Proprietร </h2>
+
+ <h3>[property:String name]</h3>
+ <p>Il nome del rispettivo programma di shader.</p>
+
+ <h3>[property:String id]</h3>
+ <p>L'identificativo di questa istanza.</p>
+
+ <h3>[property:String cacheKey]</h3>
+ <p>Questa chiave consente la riutilizzabilitร di un unico [name] per diversi materiali.</p>
+
+ <h3>[property:Integer usedTimes]</h3>
+ <p>Quante volte questa istanza viene utilizzata per il rendering di elementi di rendering.</p>
+
+ <h3>[property:Object program]</h3>
+ <p>L'attuale programma di shader.</p>
+
+ <h3>[property:WebGLShader vertexShader]</h3>
+ <p>Il vertex shader.</p>
+
+ <h3>[property:WebGLShader fragmentShader]</h3>
+ <p>Il fragment shader.</p>
+
+ <h2>Metodi</h2>
+
+ <h3>[method:Object getUniforms]()</h3>
+ <p>
+ Restituisce una mappa nome-valore di tutte le posizioni uniformi attive.
+ </p>
+
+ <h3>[method:Object getAttributes]()</h3>
+ <p>
+ Restituisce una mappa nome-valore di tutte le posizioni degli attributi dei vertici attivi.
+ </p>
+
+ <h3>[method:undefined destroy]()</h3>
+ <p>
+ Distrugge un'istanza di [name].
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/api/it/renderers/webxr/WebXRManager.html | @@ -0,0 +1,151 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Questa classe rappresenta un'astrazione dell'API WebXR Device ed รจ utilizzata internamente da [page:WebGLRenderer].
+ [name] inoltre fornisce un'interfaccia pubblica che permette agli utenti di abilitare e disabilitare XR ed
+ eseguire attivitร relative a XR come ad esempio il recupero dei controller.
+ </p>
+
+ <h2>Proprietร </h2>
+
+ <h3>[property:Boolean cameraAutoUpdate]</h3>
+ <p>
+ Indica se la telecamera XR del manager deve essere aggiornata automaticamente o no. Il valore predefinito รจ `true`.
+ </p>
+
+ <h3>[property:Boolean enabled]</h3>
+ <p>
+ Questo flag notifica al renderer di essere pronto per il rendering XR. L'impostazione predefinita รจ `false`.
+ Impostalo a `true` se stai utilizzando XR nella tua applicazione.
+ </p>
+
+ <h3>[property:Boolean isPresenting]</h3>
+ <p>
+ Indica se la presentazione XR รจ attiva o meno. Il valore predefinito รจ `false`. Questo flag รจ di sola
+ lettura e impostato automaticamente da [name].
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>[method:ArrayCamera getCamera]()</h3>
+ <p>
+ Restituisce un'istanza di [page:ArrayCamera] che rappresenta la telecamera XR sessione XR attiva.
+ Per ogni vista contiene un oggetto telecamera separato nella sua proprietร [page:ArrayCamera.cameras telecamere].
+ </p>
+ <p>
+ Il `fov` della telecamera non viene utilizzato attualmente e non riflette il fov della telecamera XR. Se hai bisogno del fov a
+ livello di app, devi calcolare manualmente dalle matrici di proiezione della telecamera XR.
+ </p>
+
+ <h3>[method:Group getController]( [param:Integer index] )</h3>
+ <p>
+ [page:Integer index] โ L'indice del controller. <br /><br />
+
+ Restituisce un [page:Group gruppo] che rappresenta il cosidetto spazio *target ray* del controller XR.
+ Utilizza questo spazio per visualizzare gli oggetti 3D che supportano l'utente nel puntare attivitร come
+ l'intersezione dell'interfaccia utente.
+ </p>
+
+ <h3>[method:Group getControllerGrip]( [param:Integer index] )</h3>
+ <p>
+ [page:Integer index] โ L'indice del controller. <br /><br />
+
+ Restituisce un [page:Group gruppo] che rappresenta il cosidetto spazio `grip` del controller XR.
+ Utilizza questo spazio se l'utente terrร altri oggetti 3D come una spada laser.
+ </p>
+
+ <p>
+ Nota: Se vuoi mostrare qualcosa nella mano dell'utente e offrire un raggio di puntamento allo stesso tempo, ti consigliamo di allegare
+ l'oggetto tenuto in mano al gruppo restituito da [page:.getControllerGrip]() e il raggio al gruppo restituito da [page:.getController]().
+ L'idea รจ quella di avere due gruppi diversi in due coordinate delle spazio diverse per lo stesso controller WebXR.
+ </p>
+
+ <h3>[method:Float getFoveation]()</h3>
+ <p>
+ Restituisce la quantitร di foveazione utilizzata dal compositore XR per il livello di proiezione.
+ </p>
+
+ <h3>[method:Group getHand]( [param:Integer index] )</h3>
+ <p>
+ [page:Integer index] โ L'indice del controller. <br /><br />
+
+ Restituisce un [page:Group gruppo] che rappresenta il cosidetto spazio `hand` o `joint` per il controller XR.
+ Utilizza questo spazio per visualizzare le mani dell'utente quando vengono utilizzati i controller non fisici.
+ </p>
+
+ <h3>[method:String getReferenceSpace]()</h3>
+ <p>
+ Restituisce lo spazio di riferimento.
+ </p>
+
+ <h3>[method:XRSession getSession]()</h3>
+ <p>
+ Restituisce l'oggetto `XRSession` il quale permette una maggiore gestione delle sessioni WebXR attive a livello di applicazione.
+ </p>
+
+ <h3>[method:undefined setFoveation]( [param:Float foveation] )</h3>
+ <p>
+ [page:Float foveation] โ Il foveazione da impostare.<br /><br />
+
+ Specifica la quantitร di foveazione utilizzata dal compositore XR per il livello. Deve essere un valore tra `0` e `1`.
+ </p>
+
+ <h3>[method:undefined setFramebufferScaleFactor]( [param:Float framebufferScaleFactor] )</h3>
+ <p>
+ [page:Float framebufferScaleFactor] โ Il fattore di scala del framebuffer da impostare.<br /><br />
+
+ Specifica il fattore di ridimensionamento da utilizzare per determinare la dimensione del framebuffer durante il rendering
+ su un dispositivo XR. Il valore รจ relativo alla risoluzione del dispositivo XR predefinito. Il valore predefinito รจ `1`.
+ Un valore di `0.5` specificherebbe un framebuffer con il 50% della risoluzione nativa del display.
+ </p>
+
+ <p>
+ Nota: Non รจ possibile modificare il fattore di scala del framebuffer durante la presentazione del contenuto.
+ </p>
+
+ <h3>[method:undefined setReferenceSpace]( [param:XRReferenceSpace referenceSpace] )</h3>
+ <p>
+ [page:XRReferenceSpace referenceSpace] โ Uno spazio personalizzato di riferimento.<br /><br />
+
+ Puรฒ essere utilizzato per configurare uno spazio personalizzato di riferimento il quale sovrascrive
+ lo spazio di riferimento predefinito.
+ </p>
+
+ <h3>[method:undefined setReferenceSpaceType]( [param:String referenceSpaceType] )</h3>
+ <p>
+ [page:String referenceSpaceType] โ Il tipo dello spazio di riferimento da impostare.<br /><br />
+
+ Puรฒ essere utilizzare per configurare una relazione spaziale con l'ambiente fisico dell'utente. A seconda di come l'utente
+ si muove nello spazio 3D, l'impostazione di uno spazio di riferimento appropriato puรฒ migliorare il tracciamento.
+ Il valore predefinito รจ `local-floor`.
+ Consultare l'[link:https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType MDN] per i possibli valori e i relativi casi d'uso.
+ </p>
+
+ <h3>[method:undefined updateCamera]( [param:PerspectiveCamera camera] )</h3>
+ <p>
+ Aggiorna lo stato della telecamera XR. Utilizza questo metodo a livello di app, se imposti [page:.cameraAutoUpdate] a `false`.
+ Questo metodo richiede la telecamera non XR della scena come parametro. La trasformazione della telecamera passata viene automaticamente
+ regolata sulla posizione della telecamera XR quando si chiama questo metodo.
+ </p>
+
+ <p>
+ Nota: Non รจ possibile modificare il tipo dello spazio di riferimento durante la presentazione del contenuto XR.
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 61807e80c5126cd664aa85bfcaf52f5f45933302.json | Add renderers italian version (#24882) | docs/list.json | @@ -1396,6 +1396,27 @@
"Skeleton": "api/it/objects/Skeleton",
"SkinnedMesh": "api/it/objects/SkinnedMesh",
"Sprite": "api/it/objects/Sprite"
+ },
+
+ "Renderers": {
+ "WebGLMultipleRenderTargets": "api/it/renderers/WebGLMultipleRenderTargets",
+ "WebGLRenderer": "api/it/renderers/WebGLRenderer",
+ "WebGL1Renderer": "api/it/renderers/WebGL1Renderer",
+ "WebGLRenderTarget": "api/it/renderers/WebGLRenderTarget",
+ "WebGL3DRenderTarget": "api/it/renderers/WebGL3DRenderTarget",
+ "WebGLArrayRenderTarget": "api/it/renderers/WebGLArrayRenderTarget",
+ "WebGLCubeRenderTarget": "api/it/renderers/WebGLCubeRenderTarget"
+ },
+
+ "Renderers / Shaders": {
+ "ShaderChunk": "api/it/renderers/shaders/ShaderChunk",
+ "ShaderLib": "api/it/renderers/shaders/ShaderLib",
+ "UniformsLib": "api/it/renderers/shaders/UniformsLib",
+ "UniformsUtils": "api/it/renderers/shaders/UniformsUtils"
+ },
+
+ "Renderers / WebXR": {
+ "WebXRManager": "api/it/renderers/webxr/WebXRManager"
}
}
}, | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Bone.html | @@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Un osso che รจ parte di uno [page:Skeleton Scheletro]. Lo scheletro a sua volta viene
+ utilizzato da [page:SkinnedMesh]. Le ossa sono quasi identiche ad un [page:Object3D] vuoto.
+ </p>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const root = new THREE.Bone();
+ const child = new THREE.Bone();
+
+ root.add( child );
+ child.position.y = 5;
+ </code>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( )</h3>
+ <p>
+ Crea un nuovo [name].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean isBone]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+
+ <h3>[property:String type]</h3>
+ <p>Impostato su 'Bone', puรฒ essere utilizzato per trovare tutte le ossa in una scena.</p>
+
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Group.html | @@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Questo รจ quasi identico ad un [page:Object3D Object3D].
+ Il suo scopo รจ rendere sintatticamente piรน chiaro il lavoro con gruppi di oggetti.
+ </p>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const geometry = new THREE.BoxGeometry( 1, 1, 1 );
+ const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
+
+ const cubeA = new THREE.Mesh( geometry, material );
+ cubeA.position.set( 100, 100, 0 );
+
+ const cubeB = new THREE.Mesh( geometry, material );
+ cubeB.position.set( -100, -100, 0 );
+
+ // Crea un gruppo e aggiunge due cubi
+ // Questi cubi possono essere ruotati / ridimensionati etc come gruppo
+ const group = new THREE.Group();
+ group.add( cubeA );
+ group.add( cubeB );
+
+ scene.add( group );
+ </code>
+
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( )</h3>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean isGroup]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:String type]</h3>
+ <p>Una stringa 'Group'. Non deve essere modificata.</p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/InstancedMesh.html | @@ -0,0 +1,133 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Mesh] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una versione speciale di [page:Mesh] con il supporto per il rendering istanziato. Utilizza [name]
+ se devi renderizzare un grande numero di oggetti con la stessa geometria e materiale ma con
+ diverse trasformazioni world. L'utilizzo di [name] ti aiuterร a ridurre il numero di
+ chiamate di disegno e quindi migliorare le prestazioni complessive del rendering nell'applicazione.
+ </p>
+
+ <h2>Esempi</h2>
+
+ <p>
+ [example:webgl_instancing_dynamic WebGL / instancing / dynamic]<br />
+ [example:webgl_instancing_performance WebGL / instancing / performance]<br />
+ [example:webgl_instancing_scatter WebGL / instancing / scatter]<br />
+ [example:webgl_instancing_raycast WebGL / instancing / raycast]
+ </p>
+
+ <h2>Costruttore</h2>
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material], [param:Integer count] )</h3>
+ <p>
+ [page:BufferGeometry geometry] - un'istanza di [page:BufferGeometry].<br />
+ [page:Material material] - un'istanza di [page:Material]. Il valore di default รจ un nuovo [page:MeshBasicMaterial].<br />
+ [page:Integer count] - il numero di istanze.<br />
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Mesh] per le proprietร comuni.</p>
+
+ <h3>[property:Integer count]</h3>
+ <p>
+ Il numero di istanze. Il valore `count` passato nel costruttore rappresenta il numero
+ massimo di istanze di questa mesh. Puoi modificare il numero di istanze in fase di esecuzione ad un valore intero
+ nell'intervallo [0, count].
+ </p>
+ <p>
+ Se hai bisogno di piรน istanze del valore count originale, devi creare una nuova [name].
+ </p>
+
+ <h3>[property:InstancedBufferAttribute instanceColor]</h3>
+ <p>
+ Rappresenta i colori di tutte le istanze. Il valore predefinito รจ `null`.
+ ร necessario impostare il suo flag [page:BufferAttribute.needsUpdate needsUpdate]
+ a true se si modificano i dati di istanza tramite [page:.setColorAt]().
+ </p>
+
+ <h3>[property:InstancedBufferAttribute instanceMatrix]</h3>
+ <p>
+ Rappresenta la trasformazione locale di tutte le istanze.
+ ร necessario impostare il suo flag [page:BufferAttribute.needsUpdate needsUpdate]
+ a true se si modificano i dati di istanza tramite [page:.setMatrixAt]().
+ </p>
+
+ <h3>[property:Boolean isInstancedMesh]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Mesh] per i metodi comuni.</p>
+
+ <h3>[method:undefined dispose]()</h3>
+ <p>
+ Libera le risorse relative alla GPU allocate da questa istanza.
+ Chiama questo metodo ogni volta che questa istanza non รจ piรน utilizzata nella tua applicazione.
+ </p>
+
+ <h3>[method:undefined getColorAt]( [param:Integer index], [param:Color color] )</h3>
+ <p>
+ [page:Integer index]: L'indice di un'istanza. I valori devono essere nell'intervallo [0, count].
+ </p>
+ <p>
+ [page:Color color]: Il colore dell'oggetto sarร impostato al colore dell'istanza definita.
+ </p>
+ <p>
+ Ottieni il colore dell'istanza definita.
+ </p>
+
+ <h3>[method:undefined getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
+ <p>
+ [page:Integer index]: L'indice di un'istanza. I valori devono essere nell'intervallo [0, count].
+ </p>
+ <p>
+ [page:Matrix4 matrix]: Questa matrice 4x4 sarร impostata alla matrice trasformazione locale dell'istanza definita.
+ </p>
+ <p>
+ Ottieni la matrice trasformazione locale dell'istanza definita.
+ </p>
+
+ <h3>[method:undefined setColorAt]( [param:Integer index], [param:Color color] )</h3>
+ <p>
+ [page:Integer index]: L'indice di un'istanza. I valori devono essere nell'intervallo [0, count].
+ </p>
+ <p>
+ [page:Color color]: Il colore di una singola istanza.
+ </p>
+ <p>
+ Imposta il colore dato all'istanza definita.
+ Assicurati di impostare [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate]
+ a true dopo l'aggiornamento di tutti i colori.
+ </p>
+
+ <h3>[method:undefined setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
+ <p>
+ [page:Integer index]: L'indice di un'istanza. I valori devono essere nell'intervallo [0, count].
+ </p>
+ <p>
+ [page:Matrix4 matrix]: Una matrice 4x4 che rappresenta la trasformazione locale di una singola istanza.
+ </p>
+ <p>
+ Imposta la matrice trasformazione locale data all'istanza definita.
+ Assicurati di impostare [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate]
+ a true dopo l'aggiornamento di tutte le matrici.
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/LOD.html | @@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Livello di Dettaglio - mostra mesh con piรน o meno geometria in base alla distanza dalla telecamera.<br /><br />
+
+ Ogni livello รจ associato ad un oggetto, e il rendering puรฒ essere commutato tra di loro alle distanze specificate.
+ In genere creeresti, per esempio, tre mesh, una per il lontano (dettaglio basse), una per la gamma media (medio dettaglio)
+ e una per i primi piani (alto dettaglio).
+ </p>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const lod = new THREE.LOD();
+
+ // Crea sfere con 3 livelli di dettaglio e crea nuovi livelli LOD per loro
+ for( let i = 0; i < 3; i++ ) {
+
+ const geometry = new THREE.IcosahedronGeometry( 10, 3 - i )
+
+ const mesh = new THREE.Mesh( geometry, material );
+
+ lod.addLevel( mesh, i * 75 );
+
+ }
+
+ scene.add( lod );
+ </code>
+
+ <h2>Esempi</h2>
+
+ <p>
+ [example:webgl_lod webgl / lod ]
+ </p>
+
+ <h2>Costruttore</h2>
+ <h3>[name]( )</h3>
+ <p>
+ Crea un nuovo [name].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean autoUpdate]</h3>
+ <p>
+ Indica se l'oggetto LOD viene aggiornato automaticamente dal renderer per frame o no.
+ Se impostato a false, devi chiamare da solo [page:LOD.update]() nel ciclo di rendering.
+ Il valore predefinito รจ true.
+ </p>
+
+ <h3>[property:Boolean isLOD]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:Array levels]</h3>
+ <p>
+ Un array di oggetti [page:Object level].<br /><br />
+
+ Ogni livello รจ un oggetto con due proprietร :<br />
+ [page:Object3D object] - L'[page:Object3D] da visualizzare a questo livello.<br />
+ [page:Float distance] - La distanza alla quale visualizzare questo livello di dettaglio.
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h3>[method:this addLevel]( [param:Object3D object], [param:Float distance] )</h3>
+ <p>
+ [page:Object3D object] - L'[page:Object3D] da visualizzare a questo livello.<br />
+ [page:Float distance] - La distanza alla quale visualizzare questo livello di dettaglio.<br /><br />
+
+ Aggiunge una mesh che sarร visualizzata ad una certa distanza e maggiore. In genere, maggiore รจ
+ la distanza, minore รจ il dettaglio sulla mesh.
+ </p>
+
+ <h3>[method:LOD clone]()</h3>
+ <p>
+ Restituisce un clone di questo oggetto LOD e degli oggetti specifici della distanza ad esso associati.
+ </p>
+
+
+ <h3>[method:Integer getCurrentLevel]()</h3>
+ <p>
+ Ottiene il livello LOD attivo attualmente. Come indice dell'array dei livelli.
+ </p>
+
+ <h3>[method:Object3D getObjectForDistance]( [param:Float distance] )</h3>
+ <p>
+ Ottiene un riferimento al primo [page:Object3D] (mesh) che รจ maggiore della [page:Float distance].
+ </p>
+
+ <h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
+ <p>
+ Ottiene le intersezioni tra un [page:Ray] lanciato a questo LOD.
+ [page:Raycaster.intersectObject] chiamerร questo metodo.
+ </p>
+
+ <h3>[method:Object toJSON]( meta )</h3>
+ <p>
+ Crea una struttura JSON con i dettagli di questo oggetto LOD.
+ </p>
+
+ <h3>[method:undefined update]( [param:Camera camera] )</h3>
+ <p>
+ Imposta la visibilitร di ogni [page:Object3D oggetto] del [page:levels livello] in base
+ alla distanza dalla [page:Camera telecamera].
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Line.html | @@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una linea continua.<br /><br />
+
+ Questo รจ quasi lo stesso di [page:LineSegments]; l'unica differenza รจ che questo viene renderizzato utilizzando
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINE_STRIP]
+ invece di [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINES]
+
+ </p>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const material = new THREE.LineBasicMaterial({
+ color: 0x0000ff
+ });
+
+ const points = [];
+ points.push( new THREE.Vector3( - 10, 0, 0 ) );
+ points.push( new THREE.Vector3( 0, 10, 0 ) );
+ points.push( new THREE.Vector3( 10, 0, 0 ) );
+
+ const geometry = new THREE.BufferGeometry().setFromPoints( points );
+
+ const line = new THREE.Line( geometry, material );
+ scene.add( line );
+ </code>
+
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material] )</h3>
+
+ <p>
+ [page:BufferGeometry geometry] โ vertici che rappresentano il segmento(i) di linea. Il valore predefinito รจ una nuova [page:BufferGeometry].<br />
+ [page:Material material] โ materiale per la linea. Il valore predefinito รจ una nuova [page:LineBasicMaterial].<br />
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:BufferGeometry geometry]</h3>
+ <p>Vertici che rappresentano il segmento(i) di linea.</p>
+
+ <h3>[property:Boolean isLine]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:Material material]</h3>
+ <p>Materiale per la linea.</p>
+
+ <h3>[property:Array morphTargetInfluences]</h3>
+ <p>
+ Un array di pesi solitamente da 0 a 1 che specifica la quantitร di morph applicata.
+ Non definito per impostazione predefinita, ma reimpostato su un array vuoto da [page:.updateMorphTargets]().
+ </p>
+
+ <h3>[property:Object morphTargetDictionary]</h3>
+ <p>
+ Un dizionario di morphTargets basato sulla proprietร morphTarget.name.
+ Non definito per impostazione predefinita, ma ricompilato [page:.updateMorphTargets]().
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h3>[method:this computeLineDistances]()</h3>
+ <p>
+ Calcola un array di valori di distanza necessari per [page:LineDashedMaterial].
+ Per ogni vertice nella geometria, il metodo calcola la lunghezza cumulativa dal punto
+ corrente fino all'inizio della linea.
+ </p>
+
+ <h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
+ <p>
+ Ottiene le intersezioni tra un [page:Ray] lanciato e questa linea.
+ [page:Raycaster.intersectObject] chiamerร questo metodo.
+ </p>
+
+ <h3>[method:Line clone]()</h3>
+ <p>
+ Restituisce un clone di questo oggetto Line e i suoi discendenti.
+ </p>
+
+ <h3>[method:undefined updateMorphTargets]()</h3>
+ <p>
+ Aggiorna i morphTargets in modo che non abbiano alcuna influenza sull'oggetto.
+ Reimposta le proprietร [page:.morphTargetInfluences] e [page:.morphTargetDictionary].
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/LineLoop.html | @@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] → [page:Line] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una linea continua che si ricollega alla partenza.<br /><br />
+
+ Questo รจ quasi lo stesso di [page:Line]; l'unica differenza รจ che viene
+ renderizzato utilizzando
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINE_LOOP]
+ invece di [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINE_STRIP],
+ il quale disegna una linea retta al vertice successivo, e ricollega l'ultimo vertice al primo.
+ </p>
+
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material] )</h3>
+
+ <p>
+ [page:BufferGeometry geometry] โ Elenco di vertici che rappresentano i punti del ciclo della linea.<br />
+ [page:Material material] โ Materiale per la linea. Il valore predefinito รจ [page:LineBasicMaterial LineBasicMaterial].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Line] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean isLineLoop]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Line] per i metodi comuni.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/LineSegments.html | @@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] → [page:Line] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una serie di linee tracciate tra coppie di vertici.<br /><br />
+
+ Questo รจ quasi lo stesso di [page:Line]; l'unica differenza รจ che viene
+ renderizzato utilizzando
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINES]
+ invece di [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINE_STRIP].
+ </p>
+
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material] )</h3>
+
+ <p>
+ [page:BufferGeometry geometry] โ Coppia(e) di vertici che rappresentano ogni segmento(i) di linea.<br />
+ [page:Material material] โ Materiale per la linea. Il valore predefinito รจ [page:LineBasicMaterial LineBasicMaterial].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Line] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean isLineSegments]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Line] per i metodi comuni.</p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Mesh.html | @@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una classe che rappresenta oggetti basati su [link:https://en.wikipedia.org/wiki/Polygon_mesh mesh poligonali] triangolari.
+ Serve anche come base per altre classi come [page:SkinnedMesh].
+ </p>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const geometry = new THREE.BoxGeometry( 1, 1, 1 );
+ const material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
+ const mesh = new THREE.Mesh( geometry, material );
+ scene.add( mesh );
+ </code>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material] )</h3>
+ <p>
+ [page:BufferGeometry geometry] โ (opzionale) un'istanza di [page:BufferGeometry]. Il valore predefinito รจ una nuova [page:BufferGeometry].<br />
+ [page:Material material] โ (opzionale) un singolo o un array di [page:Material Material]. Il valore predefinito รจ una nuova [page:MeshBasicMaterial].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:BufferGeometry geometry]</h3>
+ <p>
+ Un'istanza di [page:BufferGeometry] (o classi derivate), che definisce la struttura dell'oggetto.
+ </p>
+
+ <h3>[property:Boolean isMesh]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:Material material]</h3>
+ <p>
+ Un'istanza di materiale derivata dalla classe base [page:Material] o un array di materiali, che definisce
+ l'aspetto dell'oggetto. Il valore predefinito รจ [page:MeshBasicMaterial].
+ </p>
+
+ <h3>[property:Array morphTargetInfluences]</h3>
+ <p>
+ Un array di pesi solitamente da 0 a 1 che specifica la quantitร di morph applicata.
+ Non definito per impostazione predefinita, ma reimpostato su un array vuoto da [page:Mesh.updateMorphTargets updateMorphTargets].
+ </p>
+
+ <h3>[property:Object morphTargetDictionary]</h3>
+ <p>
+ Un dizionario di morphTargets basato sulla proprietร morphTarget.name.
+ Non definito per impostazione predefinita, ma ricompilato [page:Mesh.updateMorphTargets updateMorphTargets].
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h3>[method:Mesh clone]()</h3>
+ <p>Restituisce un clone di questo oggetto [name] e i suoi discendenti.</p>
+
+ <h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
+ <p>
+ Ottiene le intersezioni tra un raggio lanciato e questa mesh.
+ [page:Raycaster.intersectObject] chiamerร questo metodo, ma i risultati non saranno ordinati.
+ </p>
+
+ <h3>[method:undefined updateMorphTargets]()</h3>
+ <p>
+ Aggiorna i morphTargets in modo che non abbiano influenza sull'oggetto. Reimposta le proprietร
+ [page:Mesh.morphTargetInfluences morphTargetInfluences] e
+ [page:Mesh.morphTargetDictionary morphTargetDictionary].
+ </p>
+
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Points.html | @@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una classe per visualizzare punti.
+ I punti sono renderizzati dal [page:WebGLRenderer] utilizzando
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.POINTS].
+ </p>
+
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material] )</h3>
+ <p>
+ [page:BufferGeometry geometry] โ (opzionale) un'istanza di [page:BufferGeometry]. Il valore predefinito รจ una nuova [page:BufferGeometry].<br />
+ [page:Material material] โ (opzionale) un [page:Material Materiale]. Il valore predefinito รจ una nuova [page:PointsMaterial].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:BufferGeometry geometry]</h3>
+ <p>
+ Un'istanza di [page:BufferGeometry] (o classi derivate), che definisce la struttura dell'oggetto.
+ </p>
+
+ <h3>[property:Boolean isPoints]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:Material material]</h3>
+ <p>
+ Un'istanza di [page:Material], che definisce
+ l'aspetto dell'oggetto. Il valore predefinito รจ [page:PointsMaterial].
+ </p>
+
+ <h3>[property:Array morphTargetInfluences]</h3>
+ <p>
+ Un array di pesi solitamente da 0 a 1 che specifica la quantitร di morph applicata.
+ Non definito per impostazione predefinita, ma reimpostato su un array vuoto da [page:Points.updateMorphTargets updateMorphTargets].
+ </p>
+
+ <h3>[property:Object morphTargetDictionary]</h3>
+ <p>
+ Un dizionario di morphTargets basato sulla proprietร morphTarget.name.
+ Non definito per impostazione predefinita, ma ricompilato [page:Points.updateMorphTargets updateMorphTargets].
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
+ <p>
+ Ottiene le intersezioni tra un raggio lanciato e questo Points.
+ [page:Raycaster.intersectObject] chiamerร questo metodo, ma i risultati non saranno ordinati.
+ </p>
+
+ <h3>[method:Points clone]()</h3>
+ <p>
+ Restituisce un clone di questo oggetto [name] e i suoi discendenti.</p>
+ </p>
+
+ <h3>[method:undefined updateMorphTargets]()</h3>
+ <p>
+ Aggiorna i morphTargets in modo che non abbiano influenza sull'oggetto. Reimposta le proprietร
+ [page:Points.morphTargetInfluences morphTargetInfluences] e
+ [page:Points.morphTargetDictionary morphTargetDictionary].
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Skeleton.html | @@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Utilizza un array di [page:Bone ossa] per creare uno scheletro che puรฒ essere utilizzato da una
+ [page:SkinnedMesh].
+ </p>
+
+ <h2>Codice di Esempio</h2>
+ <code>
+ // Crea un semplice "braccio"
+
+ const bones = [];
+
+ const shoulder = new THREE.Bone();
+ const elbow = new THREE.Bone();
+ const hand = new THREE.Bone();
+
+ shoulder.add( elbow );
+ elbow.add( hand );
+
+ bones.push( shoulder );
+ bones.push( elbow );
+ bones.push( hand );
+
+ shoulder.position.y = -5;
+ elbow.position.y = 0;
+ hand.position.y = 5;
+
+ const armSkeleton = new THREE.Skeleton( bones );
+ </code>
+
+ <p>
+ Vedi la pagina [page:SkinnedMesh] per un esempio dell'utilizzo con [page:BufferGeometry].
+ </p>
+
+ <h2>Costruttore</h2>
+
+
+ <h3>[name]( [param:Array bones], [param:Array boneInverses] )</h3>
+ <p>
+ [page:Array bones] - L'array di [page:Bone ossa]. Il valore predefinito รจ un array vuoto.<br/>
+ [page:Array boneInverses] - (opzionale) Un array di [page:Matrix4 Matrix4].<br /><br />
+
+ Crea un nuovo [name].
+ </p>
+
+
+ <h2>Proprietร </h2>
+
+ <h3>[property:Array bones]</h3>
+ <p>
+ L'array di [page:Bone ossa]. Si noti che questa รจ una copia dell'array originale, non un riferimento,
+ quindi puoi modificare l'array originale senza che ci siano effetti su questo.
+ </p>
+
+ <h3>[property:Array boneInverses]</h3>
+ <p>
+ Un array di [page:Matrix4 Matrix4] che rappresenta l'inverso della [page:Matrix4 matrixWorld]
+ delle singole ossa.
+ </p>
+
+ <h3>[property:Float32Array boneMatrices]</h3>
+ <p>
+ Il buffer dell'array che contiene i dati dell'osso quando si utilizza una texture di vertice.
+ </p>
+
+ <h3>[property:DataTexture boneTexture]</h3>
+ <p>
+ Il [page:DataTexture] che contiene i dati dell'osso quando si utilizza una texture di vertice.
+ </p>
+
+ <h3>[property:Integer boneTextureSize]</h3>
+ <p>
+ La dimensione del [page:.boneTexture].
+ </p>
+
+ <h2>Metodi</h2>
+
+ <h3>[method:Skeleton clone]()</h3>
+ <p>
+ Restituisce un clone di questo oggetto Skeleton.
+ </p>
+
+ <h3>[method:undefined calculateInverses]()</h3>
+ <p>Genera l'array [page:.boneInverses boneInverses] se non viene fornito nel costruttore.</p>
+
+ <h3>[method:this computeBoneTexture]()</h3>
+ <p>Calcola un'istanza di [page:DataTexture] in moda da passare i dati dell'osso in modo piรน efficiente allo shader.
+ La texture viene assegnata a [page:.boneTexture boneTexture].</p>
+
+ <h3>[method:undefined pose]()</h3>
+ <p>Restituisce lo scheletro nella posa di base.</p>
+
+ <h3>[method:undefined update]()</h3>
+ <p>
+ Aggiorna [page:Float32Array boneMatrices] e [page:DataTexture boneTexture] dopo che le ossa sono state modificate.
+ Questo viene chiamato automaticamente dal [page:WebGLRenderer] se lo scheletro viene utilizzato con una [page:SkinnedMesh].
+ </p>
+
+ <h3>[method:Bone getBoneByName]( [param:String name] )</h3>
+ <p>
+ name -- Stringa da abbinare alla proprietร .name di Bone. <br /><br />
+
+ Cerca nell'array osseo dello scheletro e restituisce il primo con un nome corrispondente.<br />
+ </p>
+
+ <h3>[method:undefined dispose]()</h3>
+ <p>
+ Libera le risorse relative alla GPU allocate da questa istanza. Chiama questo metodo ogni
+ volta che questa istanza non viene piรน utilizzata nella tua app.
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/SkinnedMesh.html | @@ -0,0 +1,174 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] → [page:Mesh] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una mesh che ha uno [page:Skeleton scheletro] con [page:Bone ossa] che puรฒ essere
+ utilizzata per animare i vertici della geometria.<br /><br />
+
+ [name] puรฒ essere utilizzata solo con WebGL 2. Con WebGL 1 รจ necessario il supporto delle texture del vertice
+ e `OES_texture_float`.
+ </p>
+
+ <iframe id="scene" src="scenes/bones-browser.html"></iframe>
+
+ <script>
+
+ // iOS iframe auto-resize workaround
+
+ if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
+
+ const scene = document.getElementById( 'scene' );
+
+ scene.style.width = getComputedStyle( scene ).width;
+ scene.style.height = getComputedStyle( scene ).height;
+ scene.setAttribute( 'scrolling', 'no' );
+
+ }
+
+ </script>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
+
+ // crea manualmente gli indici della pelle e i pesi della pelle
+ // (tipicamente un loader leggerebbe questi dati da un modello 3D per te)
+
+ const position = geometry.attributes.position;
+
+ const vertex = new THREE.Vector3();
+
+ const skinIndices = [];
+ const skinWeights = [];
+
+ for ( let i = 0; i < position.count; i ++ ) {
+
+ vertex.fromBufferAttribute( position, i );
+
+ // calcola skinIndex e skinWeight in base ad alcuni dati di configurazione
+
+ const y = ( vertex.y + sizing.halfHeight );
+
+ const skinIndex = Math.floor( y / sizing.segmentHeight );
+ const skinWeight = ( y % sizing.segmentHeight ) / sizing.segmentHeight;
+
+ skinIndices.push( skinIndex, skinIndex + 1, 0, 0 );
+ skinWeights.push( 1 - skinWeight, skinWeight, 0, 0 );
+
+ }
+
+ geometry.setAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( skinIndices, 4 ) );
+ geometry.setAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeights, 4 ) );
+
+ // crea skinned mesh e skeleton
+
+ const mesh = new THREE.SkinnedMesh( geometry, material );
+ const skeleton = new THREE.Skeleton( bones );
+
+ // vedi esempio da THREE.Skeleton
+
+ const rootBone = skeleton.bones[ 0 ];
+ mesh.add( rootBone );
+
+ // lega lo scheletro alla mesh
+
+ mesh.bind( skeleton );
+
+ // muove le ossa e manipola il modello
+
+ skeleton.bones[ 0 ].rotation.x = -0.1;
+ skeleton.bones[ 1 ].rotation.x = 0.2;
+ </code>
+
+ <h2>Costruttore</h2>
+ <h3>[name]( [param:BufferGeometry geometry], [param:Material material] )</h3>
+ <p>
+ [page:BufferGeometry geometry] - un'istanza di [page:BufferGeometry].<br />
+ [page:Material material] - (opzionale) un'istanza di [page:Material]. Il valore predefinito รจ un nuovo [page:MeshBasicMaterial].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Mesh] per le proprietร comuni.</p>
+
+ <h3>[property:String bindMode]</h3>
+ <p>
+ O "attached" o "detached". "attached" utilizza la proprietร [page:SkinnedMesh.matrixWorld]
+ per la matrice di trasformazione delle ossa. "detached" utilizza [page:SkinnedMesh.bindMatrix]. Il valore predefinito รจ "attached".
+ </p>
+
+ <h3>[property:Matrix4 bindMatrix]</h3>
+ <p>
+ La matrice di base che viene utilizzata per le trasformazioni ossee vincolate.
+ </p>
+
+ <h3>[property:Matrix4 bindMatrixInverse]</h3>
+ <p>
+ La matrice di base che viene utilizzata per reimpostare le trasformazioni ossee vincolate.
+ </p>
+
+ <h3>[property:Boolean isSkinnedMesh]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+ <h3>[property:Skeleton skeleton]</h3>
+ <p>
+ [page:Skeleton] che rappresenta la gerarchia ossea della skinned mesh.
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Mesh] per i metodi comuni.</p>
+
+ <h3>[method:undefined bind]( [param:Skeleton skeleton], [param:Matrix4 bindMatrix] )</h3>
+ <p>
+ [page:Skeleton skeleton] - [page:Skeleton] creato da un albero di [page:Bone Bones].<br/>
+ [page:Matrix4 bindMatrix] - [page:Matrix4] che rappresenta la trasformazione base dello scheletro.<br /><br />
+
+ Lega uno scheletro alla skinned mesh. Il bindMatrix viene salvato nella proprietร .bindMatrix
+ e il .bindMatrixInverse viene calcolato.
+ </p>
+
+ <h3>[method:SkinnedMesh clone]()</h3>
+ <p>
+ Questo metodo attualmente non clona correttamente un'istanza di [name]. Si prega di utilizzare [page:SkeletonUtils.clone]() nel frattempo.
+ </p>
+
+ <h3>[method:undefined normalizeSkinWeights]()</h3>
+ <p>
+ Normalizza i pesi della skin.
+ </p>
+
+ <h3>[method:undefined pose]()</h3>
+ <p>
+ Questo metodo imposta la skinned mesh nella posa di riposo (reimposta la posa).
+ </p>
+
+ <h3>[method:Vector3 boneTransform]( [param:Integer index], [param:Vector3 target] )</h3>
+ <p>
+ Calcola la posizione del vertice in corrispondenza dell'indice specificato rispetto alle attuali trasformazioni ossee.
+ Il vettore target deve essere inizializzato con le coordinate del vertice prima della trasformazione:
+ <code>
+const target = new THREE.Vector3();
+target.fromBufferAttribute( mesh.geometry.attributes.position, index );
+mesh.boneTransform( index, target );
+ </code>
+ </p>
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/api/it/objects/Sprite.html | @@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html lang="it">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../../" />
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Object3D] →
+
+ <h1>[name]</h1>
+
+ <p class="desc">
+ Una sprite รจ un piano che รจ sempre rivolto verso la telecamera, generalmente con
+ una texture parzialmente trasparente applicata.<br /><br />
+
+ Le sprite non proiettano ombre, impostare <code>castShadow = true</code> non avrร alcun effetto.
+ </p>
+
+ <h2>Codice di Esempio</h2>
+
+ <code>
+ const map = new THREE.TextureLoader().load( 'sprite.png' );
+ const material = new THREE.SpriteMaterial( { map: map } );
+
+ const sprite = new THREE.Sprite( material );
+ scene.add( sprite );
+ </code>
+
+ <h2>Costruttore</h2>
+
+ <h3>[name]( [param:Material material] )</h3>
+ <p>
+ [page:Material material] - (opzionale) un'istanza di [page:SpriteMaterial]. Il valore predefinito รจ una [page:SpriteMaterial] bianca.<br /><br />
+
+ Crea una nuova [name].
+ </p>
+
+ <h2>Proprietร </h2>
+ <p>Vedi la classe base [page:Object3D] per le proprietร comuni.</p>
+
+ <h3>[property:Boolean isSprite]</h3>
+ <p>
+ Flag di sola lettura per verificare se l'oggetto dato รจ di tipo [name].
+ </p>
+
+
+ <h3>[property:SpriteMaterial material]</h3>
+ <p>
+ Un'istanza di [page:SpriteMaterial], che definisce l'aspetto dell'oggetto.
+ Il valore predefinito รจ una [page:SpriteMaterial] bianca.
+ </p>
+
+
+ <h3>[property:Vector2 center]</h3>
+ <p>
+ Il punto di ancoraggio della sprite, e il punto attorno al quale ruota la sprite. Un valore di (0.5, 0.5)
+ corrisponde al punto medio della sprite. Un valore di (0, 0) corrisponde all'angolo inferiore sinistro della sprite.
+ Il valore predefinito รจ (0.5, 0.5).
+ </p>
+
+ <h2>Metodi</h2>
+ <p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
+
+ <h3>[method:Sprite clone]()</h3>
+ <p>
+ Restituisce un clone di questo oggetto Sprite e i suoi discendenti.
+ </p>
+
+ <h3>[method:this copy]( [param:Sprite sprite] )</h3>
+ <p>
+ Copia le proprietร della sprite passata in questa.
+ </p>
+
+ <h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
+ <p>
+ Ottiene le intersezioni tra un raggio lanciato e questa sprite. [page:Raycaster.intersectObject]() chiamerร questo metodo.
+ Il raycaster deve essere inizializzato chiamando [page:Raycaster.setFromCamera]() prima di eseguire il raycast contro le sprite.
+ </p>
+
+
+ <h2>Source</h2>
+
+ <p>
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </p>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 2f2c19b280a596eada0adf67ff9e6d5bfcca03ac.json | Add Objects italian version (#24850) | docs/list.json | @@ -1381,6 +1381,21 @@
"DiscreteInterpolant": "api/it/math/interpolants/DiscreteInterpolant",
"LinearInterpolant": "api/it/math/interpolants/LinearInterpolant",
"QuaternionLinearInterpolant": "api/it/math/interpolants/QuaternionLinearInterpolant"
+ },
+
+ "Oggetti": {
+ "Bone": "api/it/objects/Bone",
+ "Group": "api/it/objects/Group",
+ "InstancedMesh": "api/it/objects/InstancedMesh",
+ "Line": "api/it/objects/Line",
+ "LineLoop": "api/it/objects/LineLoop",
+ "LineSegments": "api/it/objects/LineSegments",
+ "LOD": "api/it/objects/LOD",
+ "Mesh": "api/it/objects/Mesh",
+ "Points": "api/it/objects/Points",
+ "Skeleton": "api/it/objects/Skeleton",
+ "SkinnedMesh": "api/it/objects/SkinnedMesh",
+ "Sprite": "api/it/objects/Sprite"
}
}
}, | true |
Other | mrdoob | three.js | d95e790fb089cf7ba34e1a83a2d3695c75748e58.json | improve mouse drag interaction (#24844) | examples/webgpu_equirectangular.html | @@ -72,8 +72,8 @@
controls = new OrbitControls( camera, renderer.domElement );
controls.autoRotate = true;
- controls.minDistance = 2;
- controls.maxDistance = 10;
+ controls.rotateSpeed = - 0.125; // negative, to track mouse pointer
+ controls.autoRotateSpeed = 1.0;
window.addEventListener( 'resize', onWindowResize );
| false |
Other | mrdoob | three.js | 305c488ad56bb21e49cbd0a8651f05b766979206.json | kill double `.normalize` (#22503) | src/extras/core/Curve.js | @@ -277,7 +277,6 @@ class Curve {
const u = i / segments;
tangents[ i ] = this.getTangentAt( u, new Vector3() );
- tangents[ i ].normalize();
}
| false |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/js/interactive/InteractiveGroup.js | @@ -24,7 +24,7 @@
_pointer.x = event.clientX / element.clientWidth * 2 - 1;
_pointer.y = - ( event.clientY / element.clientHeight ) * 2 + 1;
raycaster.setFromCamera( _pointer, camera );
- const intersects = raycaster.intersectObjects( scope.children );
+ const intersects = raycaster.intersectObjects( scope.children, false );
if ( intersects.length > 0 ) {
@@ -63,7 +63,7 @@
tempMatrix.identity().extractRotation( controller.matrixWorld );
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
- const intersections = raycaster.intersectObjects( scope.children );
+ const intersections = raycaster.intersectObjects( scope.children, false );
if ( intersections.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/jsm/interactive/InteractiveGroup.js | @@ -32,7 +32,7 @@ class InteractiveGroup extends Group {
raycaster.setFromCamera( _pointer, camera );
- const intersects = raycaster.intersectObjects( scope.children );
+ const intersects = raycaster.intersectObjects( scope.children, false );
if ( intersects.length > 0 ) {
@@ -77,7 +77,7 @@ class InteractiveGroup extends Group {
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
- const intersections = raycaster.intersectObjects( scope.children );
+ const intersections = raycaster.intersectObjects( scope.children, false );
if ( intersections.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/jsm/webxr/OculusHandPointerModel.js | @@ -343,7 +343,7 @@ class OculusHandPointerModel extends THREE.Object3D {
if ( this.raycaster ) {
- return this.raycaster.intersectObjects( objects );
+ return this.raycaster.intersectObjects( objects, false );
}
@@ -353,7 +353,7 @@ class OculusHandPointerModel extends THREE.Object3D {
if ( this.raycaster && ! this.attached ) {
- const intersections = this.raycaster.intersectObjects( objects );
+ const intersections = this.raycaster.intersectObjects( objects, false );
const direction = new THREE.Vector3( 0, 0, - 1 );
if ( intersections.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/misc_controls_pointerlock.html | @@ -279,7 +279,7 @@
raycaster.ray.origin.copy( controls.getObject().position );
raycaster.ray.origin.y -= 10;
- const intersections = raycaster.intersectObjects( objects );
+ const intersections = raycaster.intersectObjects( objects, false );
const onObject = intersections.length > 0;
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_camera_cinematic.html | @@ -188,7 +188,7 @@
raycaster.setFromCamera( mouse, camera );
- const intersects = raycaster.intersectObjects( scene.children );
+ const intersects = raycaster.intersectObjects( scene.children, false );
if ( intersects.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_geometry_spline_editor.html | @@ -371,7 +371,7 @@
raycaster.setFromCamera( pointer, camera );
- const intersects = raycaster.intersectObjects( splineHelperObjects );
+ const intersects = raycaster.intersectObjects( splineHelperObjects, false );
if ( intersects.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_interactive_cubes.html | @@ -135,7 +135,7 @@
raycaster.setFromCamera( pointer, camera );
- const intersects = raycaster.intersectObjects( scene.children );
+ const intersects = raycaster.intersectObjects( scene.children, false );
if ( intersects.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_interactive_cubes_ortho.html | @@ -143,7 +143,7 @@
raycaster.setFromCamera( pointer, camera );
- const intersects = raycaster.intersectObjects( scene.children );
+ const intersects = raycaster.intersectObjects( scene.children, false );
if ( intersects.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_interactive_raycasting_points.html | @@ -245,7 +245,7 @@
raycaster.setFromCamera( pointer, camera );
- const intersections = raycaster.intersectObjects( pointclouds );
+ const intersections = raycaster.intersectObjects( pointclouds, false );
intersection = ( intersections.length ) > 0 ? intersections[ 0 ] : null;
if ( toggle > 0.02 && intersection !== null ) { | true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_interactive_voxelpainter.html | @@ -117,7 +117,7 @@
raycaster.setFromCamera( pointer, camera );
- const intersects = raycaster.intersectObjects( objects );
+ const intersects = raycaster.intersectObjects( objects, false );
if ( intersects.length > 0 ) {
@@ -138,7 +138,7 @@
raycaster.setFromCamera( pointer, camera );
- const intersects = raycaster.intersectObjects( objects );
+ const intersects = raycaster.intersectObjects( objects, false );
if ( intersects.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_loader_ifc.html | @@ -82,7 +82,7 @@
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera( mouse, camera );
- const intersected = raycaster.intersectObjects( scene.children );
+ const intersected = raycaster.intersectObjects( scene.children, false );
if ( intersected.length ) {
const found = intersected[ 0 ]; | true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_modifier_curve.html | @@ -179,7 +179,7 @@
rayCaster.setFromCamera( mouse, camera );
action = ACTION_NONE;
- const intersects = rayCaster.intersectObjects( curveHandles );
+ const intersects = rayCaster.intersectObjects( curveHandles, false );
if ( intersects.length ) {
const target = intersects[ 0 ].object; | true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_modifier_curve_instanced.html | @@ -209,7 +209,7 @@
rayCaster.setFromCamera( mouse, camera );
action = ACTION_NONE;
- const intersects = rayCaster.intersectObjects( curveHandles );
+ const intersects = rayCaster.intersectObjects( curveHandles, false );
if ( intersects.length ) {
const target = intersects[ 0 ].object; | true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_postprocessing_ssrr.html | @@ -243,7 +243,7 @@
raycaster.setFromCamera( mouse, camera );
- const intersect = raycaster.intersectObjects( objects )[ 0 ];
+ const intersect = raycaster.intersectObjects( objects, false )[ 0 ];
if ( intersect ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_postprocessing_unreal_bloom_selective.html | @@ -184,7 +184,7 @@
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
- const intersects = raycaster.intersectObjects( scene.children );
+ const intersects = raycaster.intersectObjects( scene.children, false );
if ( intersects.length > 0 ) {
const object = intersects[ 0 ].object; | true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webgl_raycast_texture.html | @@ -328,7 +328,7 @@
raycaster.setFromCamera( mouse, camera );
- return raycaster.intersectObjects( objects );
+ return raycaster.intersectObjects( objects, false );
}
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webxr_vr_cubes.html | @@ -205,7 +205,7 @@
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
- const intersects = raycaster.intersectObjects( room.children );
+ const intersects = raycaster.intersectObjects( room.children, false );
if ( intersects.length > 0 ) {
| true |
Other | mrdoob | three.js | e30436d09281e940b7bcef9a957e2ee645438dc0.json | Specify the recursive flag (#22500) | examples/webxr_vr_dragging.html | @@ -217,7 +217,7 @@
raycaster.ray.origin.setFromMatrixPosition( controller.matrixWorld );
raycaster.ray.direction.set( 0, 0, - 1 ).applyMatrix4( tempMatrix );
- return raycaster.intersectObjects( group.children );
+ return raycaster.intersectObjects( group.children, false );
}
| true |
Other | mrdoob | three.js | c191406da786ee02f601b4e04228a62feec513d3.json | remove unnecessary import | examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js | @@ -1,5 +1,4 @@
import WebGPUUniformBuffer from './WebGPUUniformBuffer.js';
-import { GPUBindingType } from './constants.js';
class WebGPUUniformsGroup extends WebGPUUniformBuffer {
| false |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/jsm/renderers/webgpu/WebGPUBackground.js | @@ -1,5 +1,5 @@
import { GPULoadOp } from './constants.js';
-import { Color } from '../../../../build/three.module.js';
+import { Color } from 'three';
let _clearAlpha;
const _clearColor = new Color(); | true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/jsm/renderers/webgpu/WebGPURenderPipelines.js | @@ -7,7 +7,7 @@ import {
NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending,
AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation,
ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor
-} from '../../../../build/three.module.js';
+} from 'three';
class WebGPURenderPipelines {
| true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/jsm/renderers/webgpu/WebGPURenderer.js | @@ -14,7 +14,7 @@ import WebGPUNodes from './nodes/WebGPUNodes.js';
import glslang from '../../libs/glslang.js';
-import { Frustum, Matrix4, Vector3, Color } from '../../../../build/three.module.js';
+import { Frustum, Matrix4, Vector3, Color } from 'three';
console.info( 'THREE.WebGPURenderer: Modified Matrix4.makePerspective() and Matrix4.makeOrtographic() to work with WebGPU, see https://github.com/mrdoob/three.js/issues/20276.' );
| true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js | @@ -1,4 +1,4 @@
-import { WebGLRenderTarget } from '../../../../build/three.module.js';
+import { WebGLRenderTarget } from 'three';
class WebGPUTextureRenderer {
| true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/jsm/renderers/webgpu/WebGPUTextures.js | @@ -1,7 +1,7 @@
import { GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension } from './constants.js';
import { CubeTexture, Texture, NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter, RepeatWrapping, MirroredRepeatWrapping,
RGBFormat, RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, sRGBEncoding
-} from '../../../../build/three.module.js';
+} from 'three';
import WebGPUTextureUtils from './WebGPUTextureUtils.js';
class WebGPUTextures { | true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/jsm/renderers/webgpu/WebGPUUniform.js | @@ -1,4 +1,4 @@
-import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from '../../../../build/three.module.js';
+import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from 'three';
class WebGPUUniform {
| true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/webgpu_compute.html | @@ -10,9 +10,16 @@
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> WebGPU - Compute<br/>(Chrome Canary with flag: --enable-unsafe-webgpu)
</div>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "../build/three.module.js"
+ }
+ }
+ </script>
<script type="module">
- import * as THREE from '../build/three.module.js';
+ import * as THREE from 'three';
import WebGPURenderer from './jsm/renderers/webgpu/WebGPURenderer.js';
import WebGPU from './jsm/renderers/webgpu/WebGPU.js'; | true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/webgpu_instance_uniform.html | @@ -11,9 +11,16 @@
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - webgpu materials
</div>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "../build/three.module.js"
+ }
+ }
+ </script>
<script type="module">
- import * as THREE from '../build/three.module.js';
+ import * as THREE from 'three';
import WebGPURenderer from './jsm/renderers/webgpu/WebGPURenderer.js';
import WebGPU from './jsm/renderers/webgpu/WebGPU.js'; | true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/webgpu_materials.html | @@ -11,9 +11,16 @@
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - webgpu materials
</div>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "../build/three.module.js"
+ }
+ }
+ </script>
<script type="module">
- import * as THREE from '../build/three.module.js';
+ import * as THREE from 'three';
import WebGPURenderer from './jsm/renderers/webgpu/WebGPURenderer.js';
import WebGPU from './jsm/renderers/webgpu/WebGPU.js'; | true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/webgpu_rtt.html | @@ -10,9 +10,16 @@
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> WebGPU - RTT<br/>(Chrome Canary with flag: --enable-unsafe-webgpu)
</div>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "../build/three.module.js"
+ }
+ }
+ </script>
<script type="module">
- import * as THREE from '../build/three.module.js';
+ import * as THREE from 'three';
import WebGPURenderer from './jsm/renderers/webgpu/WebGPURenderer.js';
import WebGPUTextureRenderer from './jsm/renderers/webgpu/WebGPUTextureRenderer.js'; | true |
Other | mrdoob | three.js | 494b3421d4284bd83bdea1b1a56dd76753bb3178.json | Adopt importmaps in WebGPU examples | examples/webgpu_sandbox.html | @@ -10,9 +10,16 @@
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> WebGPU - sandbox<br/>(Chrome Canary with flag: --enable-unsafe-webgpu)
</div>
+ <script type="importmap">
+ {
+ "imports": {
+ "three": "../build/three.module.js"
+ }
+ }
+ </script>
<script type="module">
- import * as THREE from '../build/three.module.js';
+ import * as THREE from 'three';
import { DDSLoader } from './jsm/loaders/DDSLoader.js';
| true |
Other | mrdoob | three.js | c3f83169d60fbc4f3ca25fb83d04bffc84bdf9e5.json | use default value | examples/webgpu_instance_uniform.html | @@ -35,7 +35,7 @@
this.updateType = NodeUpdateType.Object;
- this.inputNode = new ColorNode( new THREE.Color() );
+ this.inputNode = new ColorNode();
}
| false |
Other | mrdoob | three.js | 015a27c4b4d9759cc0f94e4f933d57c3f1df7454.json | add missing default value | examples/jsm/renderers/nodes/inputs/ColorNode.js | @@ -1,8 +1,9 @@
import InputNode from '../core/InputNode.js';
+import { Color } from '../../../../../build/three.module.js';
class ColorNode extends InputNode {
- constructor( value ) {
+ constructor( value = new Color() ) {
super( 'color' );
| true |
Other | mrdoob | three.js | 015a27c4b4d9759cc0f94e4f933d57c3f1df7454.json | add missing default value | examples/jsm/renderers/nodes/inputs/Vector2Node.js | @@ -1,8 +1,9 @@
import InputNode from '../core/InputNode.js';
+import { Vector2 } from '../../../../../build/three.module.js';
class Vector2Node extends InputNode {
- constructor( value ) {
+ constructor( value = new Vector2() ) {
super( 'vec2' );
| true |
Other | mrdoob | three.js | 59e8e47d2df52b9572b14e1bd7f616b1cb0809a7.json | compile node material per object | examples/jsm/renderers/webgpu/WebGPUBindings.js | @@ -24,12 +24,11 @@ class WebGPUBindings {
if ( data === undefined ) {
const pipeline = this.pipelines.get( object );
- const material = object.material;
-
- const nodeBuilder = this.nodes.get( material );
// each material defines an array of bindings (ubos, textures, samplers etc.)
+ const nodeBuilder = this.nodes.get( object );
+
const bindings = nodeBuilder.getBindings();
// setup (static) binding layout and (dynamic) binding group | true |
Other | mrdoob | three.js | 59e8e47d2df52b9572b14e1bd7f616b1cb0809a7.json | compile node material per object | examples/jsm/renderers/webgpu/WebGPURenderPipelines.js | @@ -57,7 +57,7 @@ class WebGPURenderPipelines {
// get shader
- const nodeBuilder = this.nodes.get( material );
+ const nodeBuilder = this.nodes.get( object );
// shader modules
@@ -788,22 +788,15 @@ class WebGPURenderPipelines {
function onMaterialDispose( event ) {
const properties = this.properties;
- const nodes = this.nodes;
- const shaderModules = this.shaderModules;
const material = event.target;
const materialProperties = properties.get( material );
- const nodeBuilder = nodes.get( material );
material.removeEventListener( 'dispose', materialProperties.disposeCallback );
properties.remove( material );
- nodes.remove( material );
- shaderModules.vertex.delete( nodeBuilder.vertexShader );
- shaderModules.fragment.delete( nodeBuilder.fragmentShader );
-
- // @TODO: still needed remove bindings and pipeline
+ // @TODO: still needed remove nodes, bindings and pipeline
}
| true |
Other | mrdoob | three.js | 59e8e47d2df52b9572b14e1bd7f616b1cb0809a7.json | compile node material per object | examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js | @@ -13,25 +13,25 @@ class WebGPUNodes {
}
- get( material ) {
+ get( object ) {
- let nodeBuilder = this.builders.get( material );
+ let nodeBuilder = this.builders.get( object );
if ( nodeBuilder === undefined ) {
- nodeBuilder = new WebGPUNodeBuilder( material, this.renderer ).build();
+ nodeBuilder = new WebGPUNodeBuilder( object.material, this.renderer ).build();
- this.builders.set( material, nodeBuilder );
+ this.builders.set( object, nodeBuilder );
}
return nodeBuilder;
}
- remove( material ) {
+ remove( object ) {
- this.builders.delete( material );
+ this.builders.delete( object );
}
@@ -45,7 +45,7 @@ class WebGPUNodes {
const material = object.material;
- const nodeBuilder = this.get( material );
+ const nodeBuilder = this.get( object );
const nodeFrame = this.nodeFrame;
nodeFrame.material = material; | true |
Other | mrdoob | three.js | 9d9b9fac2571c690ae81742c53769b0bc72cf06a.json | Add Chinese translation for tips article. (#23501) | manual/list.json | @@ -321,11 +321,11 @@
"ๆ้ๆธฒๆ": "zh/rendering-on-demand",
"่ฐ่ฏJavaScript": "zh/debugging-javascript",
"่ฐ่ฏ็่ฒๅจ": "zh/debugging-glsl",
- "Taking a screenshot": "zh/tips#screenshot",
- "Prevent the Canvas Being Cleared": "zh/tips#preservedrawingbuffer",
- "Get Keyboard Input From a Canvas": "zh/tips#tabindex",
- "Make the Canvas Transparent": "zh/tips#transparent-canvas",
- "Use three.js as Background in HTML": "zh/tips#html-background"
+ "canvasๆชๅพ": "zh/tips#screenshot",
+ "้ฒๆญขcanvas่ขซๆธ
็ฉบ": "zh/tips#preservedrawingbuffer",
+ "ไปcanvas่ทๅ้ฎ็่พๅ
ฅ": "zh/tips#tabindex",
+ "้ๆๅcanvas": "zh/tips#transparent-canvas",
+ "ๅจHTMLไธญไฝฟ็จthree.jsๅจ็ป่ๆฏ": "zh/tips#html-background"
},
"ไผๅ": {
"ๅคง้ๅฏน่ฑก็ไผๅ": "zh/optimize-lots-of-objects", | true |
Other | mrdoob | three.js | 9d9b9fac2571c690ae81742c53769b0bc72cf06a.json | Add Chinese translation for tips article. (#23501) | manual/zh/tips.html | @@ -1,6 +1,6 @@
-<!DOCTYPE html><html lang="zh"><head>
+<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
- <title>Tips</title>
+ <title>ๅฐๆๅทง</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@threejs">
@@ -22,7 +22,6 @@
}
}
</script>
- <link rel="stylesheet" href="/manual/zh/lang.css">
</head>
<body>
<div class="container">
@@ -31,8 +30,305 @@ <h1>Tips</h1>
</div>
<div class="lesson">
<div class="lesson-main">
- <p>ๆฑๆญ๏ผ่ฟๆฒกๆไธญๆ็ฟป่ฏๅฆใ <a href="https://github.com/mrdoob/three.js">ๆฌข่ฟๅ ๅ
ฅ็ฟป่ฏ</a>! ๐</p>
-<p><a href="/manual/en/tips.html">่ฑๆๅๆ้พๆฅ</a>.</p>
+ <p>ๆฌๆไธญๆไปฌๆป็ปไบไธไบๅจไฝฟ็จthree.js่ฟ็จไธญๅฏ่ฝไผ้ๅฐ็ไฝๅ็่ตทๆฅไธ้่ฆๅ่ชๅๅบไธ็ซ ็ๅฐ้ฎ้ขใ</p>
+<hr>
+<p><a id="screenshot" data-toc="Taking a screenshot"></a></p>
+<h1 id="taking-a-screenshot-of-the-canvas">canvasๆชๅพ</h1>
+<p>ๅจๆต่งๅจไธญๅญๅจไธค็งๆๆ็ๆนๅผ่ฟ่กๆชๅพใ
+ๆง็
+<a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL"><code class="notranslate" translate="no">canvas.toDataURL</code></a>
+ไธๆฐ็ๆดๅฅฝ็
+<a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob"><code class="notranslate" translate="no">canvas.toBlob</code></a></p>
+<p>ๆไปฅไฝ ๅฏ่ฝ่ฎคไธบไป
้่ฟๆทปๅ ไธๅไปฃ็ ๅณๅฏ่ฝปๆพๅฎ็ฐๆชๅพๅ่ฝ</p>
+<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><canvas id="c"></canvas>
++<button id="screenshot" type="button">Save...</button>
+</pre>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">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();
+ };
+}());
+</pre>
+<p>ไธ้ขๆฏๆฅ่ชไป็ป <a href="responsive.html">ๅๅบๅผ่ฎพ่ฎก</a>
+ๅนถๆทปๅ ไบไธ่ฟฐไปฃ็ ไธไธไบๆพ็ฝฎๆ้ฎ็CSS็ไพๅญใ</p>
+<p></p><div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/tips-screenshot-bad.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/tips-screenshot-bad.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+</div>
+
+<p></p>
+<p>ๅฝๆๅฐ่ฏๆชๅพๅพๅฐไบๅฆไธๅพ็</p>
+<div class="threejs_center"><img src="../resources/images/screencapture-413x313.png"></div>
+
+<p>ๆฏ็๏ผๅฐฑๆฏไธๅผ ็บฏ้ป็ๅพ็่ๅทฒใ</p>
+<p>ๅๅณไบไฝ ็ๆต่งๅจไธ็ณป็ป็ไธๅ่ฟไธชไพๅญไนๆๅฏ่ฝไผๆญฃๅธธ็ๆ๏ผไฝๆฏไธ่ฌๆ
ๅตไธ่ฟไธชไพๅญๆฏๆ ๆณๆญฃๅธธ็ๆ็ใ</p>
+<p>่ฟไธช้ฎ้ข็ๅบ็ฐๆฏๅ ไธบๅบไบๆง่ฝๅๅ
ผๅฎนๆง็่้๏ผ้ป่ฎคๆ
ๅตไธๆต่งๅจไผๅจ็ปๅถๅฎๆๅๆธ
้คWebGL canvas็็ผๅญใ</p>
+<p>่งฃๅณๆนๆกๆฏๅจไฝ ๆ่ทๆชๅพๅ่ฐ็จไธๆฌกๆธฒๆไปฃ็ ใ</p>
+<p>ๅจๆไปฌ็ไปฃ็ ้ๆไปฌๅช่ฆ่ฟ่กๅฐๅน
ๅบฆ่ฐๆดๅณๅฏใ้ฆๅ
๏ผๅ็ฆปๅบๆไปฌ็ๆธฒๆไปฃ็ </p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">+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);
+</pre>
+<p>็ฐๅจ <code class="notranslate" translate="no">render</code> ๆนๆณๅชไธๅฎ้
็ๆธฒๆ่ฟ็จ็ธๅ
ณ่ไบใๆไปฌๅฏไปฅๅจๅๅฅฝ่ฆๆ่ทcanvasๆชๅพๅ่ฐ็จๅฎใ</p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">const elem = document.querySelector('#screenshot');
+elem.addEventListener('click', () => {
++ render();
+ canvas.toBlob((blob) => {
+ saveBlob(blob, `screencapture-${canvas.width}x${canvas.height}.png`);
+ });
+});
+</pre>
+<p>็ฐๅจๅบ่ฏฅ่ฝๆญฃๅธธ็ๆไบใ</p>
+<p></p><div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/tips-screenshot-good.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/tips-screenshot-good.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+</div>
+
+<p></p><p>ๆๅ
ณๅ
ถไป่งฃๅณๆนๆก๏ผ่ฏทๅ้
ไธไธ้กนใ</p>
+<hr>
+
+<p><a id="preservedrawingbuffer" data-toc="Prevent the Canvas Being Cleared"></a></p>
+<h1 id="preventing-the-canvas-being-cleared">้ฒๆญขcanvas่ขซๆธ
็ฉบ</h1>
+<p>ๅฆๆไฝ ๆณ่ฆ่ฎฉ็จๆทไฝฟ็จๅจ็ปๅฏน่ฑก่ฟ่ก็ปๅพใไฝ ้่ฆๅจๅๅปบ <a href="/docs/#api/zh/renderers/WebGLRenderer"><code class="notranslate" translate="no">WebGLRenderer</code></a> ็ๆถๅไผ ๅ
ฅ <code class="notranslate" translate="no">preserveDrawingBuffer: true</code>ใ่ฟๅฐ้ปๆญขๆต่งๅจๆธ
็canvasใ็ฑปไผผ็๏ผไฝ ไน้่ฆๅ่ฏthree.jsไธ่ฆ่ชๅจๆธ
็canvasใ</p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">const canvas = document.querySelector('#c');
+-const renderer = new THREE.WebGLRenderer({canvas});
++const renderer = new THREE.WebGLRenderer({
++ canvas,
++ preserveDrawingBuffer: true,
++ alpha: true,
++});
++renderer.autoClearColor = false;
+</pre>
+<p></p><div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/tips-preservedrawingbuffer.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/tips-preservedrawingbuffer.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+</div>
+
+<p></p>
+<p>้่ฆๆณจๆ็ๆฏๅฆๆไฝ ็กฎๅฎ้่ฆๅถไฝไธไธช็ปๅพ็จๅบ็่ฏ่ฟๅนถไธ่ฝ่งฃๅณไฝ ็้ฎ้ข๏ผๅ ไธบๆต่งๅจไป็ถไผๆนๅๅ่พจ็็ๆถๅ้ๆถๆๅฏ่ฝๆธ
็ฉบcanvasใๆไปฌ็ฎๅ็ๆนๆกๆฏ่ฎฉcanvas็ๅ่พจ็่ท้ๆพ็คบๅคงๅฐ็ๆนๅใ่canvas็ๆพ็คบๅคงๅฐไนๅจ้็็ชๅฃๅคงๅฐๅๅใ่ฟๅ
ๆฌไบๅณไพฟ็จๆทๅจๅฆไธไธชๆ ็ญพ้กตไธญไธ่ฝฝไบไธไธชๆไปถ๏ผๆต่งๅจๆทปๅ ไบไธไธช็ถๆๆ ็ๆ
ๅตใไนๅ
ๆฌไบ็จๆท่ฝฌๅจๆๆบๆถๆต่งๅจไป็บตๅๅๆข่ณๆจชๅๅธๅฑ็ๆ
ๅต</p>
+<p>ๅฆๆไฝ ๅๅฎ้่ฆๅถไฝไธไธช็ปๅพ็็จๅบ๏ผไฝ ๅฏไปฅ
+<a href="rendertargets.html">ไฝฟ็จๆธฒๆ็ฎๆ ็ๆนๅผๆธฒๆๅฐ็บน็ไธ</a>ใ</p>
+<hr>
+<p><a id="tabindex" data-toc="Get Keyboard Input From a Canvas"></a></p>
+<h1 id="getting-keyboard-input">่ทๅ้ฎ็่พๅ
ฅ</h1>
+<p>ๅจ่ฟไบๆ็จไธญ๏ผๆไปฌ้ๅธธไผๅฐไบไปถ็ๅฌๅจ็ปๅฎๅฐcanvasไธ <code class="notranslate" translate="no">canvas</code>ใ
+่ฝ็ถ่ฎธๅคไบไปถ้ฝ่ฝ็ๆ๏ผไฝๆฏ้ป่ฎคๆ
ๅตไธ้ฎ็ไบไปถไธไผๆญฃๅธธๅๅบใ</p>
+<p>ไธบไบ่ทๅ้ฎ็ไบไปถ๏ผๆไปฌๅฐcanvas็ <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/tabIndex"><code class="notranslate" translate="no">tabindex</code></a>
+ๅฑๆง่ฎพ็ฝฎไธบ0ๆๆด้ซใๅฆไธใ</p>
+<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><canvas tabindex="0"></canvas>
+</pre>
+<p>่ฟๅฐๅฏผ่ดไธไธชๆฐ็้ฎ้ข๏ผไปปไฝ่ฎพ็ฝฎไบ <code class="notranslate" translate="no">tabindex</code> ็ๅ
็ด ไผๅจ่็ฆ็ๆถๅ็ชๅบๆพ็คบใไธบไบ่งฃๅณ่ฟไธช้ฎ้ข๏ผๆไปฌๅจCSSไธญๅฐๅฎfocus็ถๆไธ็outlineๅฑๆง่ฎพ็ฝฎไธบnone</p>
+<pre class="prettyprint showlinemods notranslate lang-css" translate="no">canvas:focus {
+ outline:none;
+}
+</pre>
+<p>่ฟ้ไธบไบๆผ็คบไฝฟ็จไบ3ไธชcanvas</p>
+<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><canvas id="c1"></canvas>
+<canvas id="c2" tabindex="0"></canvas>
+<canvas id="c3" tabindex="1"></canvas>
+</pre>
+<p>ๅนถไธๅชไธบๆๅไธไธชcanvas่ฎพ็ฝฎcss </p>
+<pre class="prettyprint showlinemods notranslate lang-css" translate="no">#c3:focus {
+ outline: none;
+}
+</pre>
+<p>่ฎฉๆไปฌ็จๅๆ ท็ไบไปถ็ๅฌๅจๅๅซไธๅฎไปฌ็ธๅ
ณ่</p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">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}`);
+ });
+});
+</pre>
+<p>่ฏทๆณจๆ๏ผไฝ ๆ ๆณ่ฎฉ็ฌฌไธไธชcanvasๆฅๆถๅฐ้ฎ็่พๅ
ฅใ็ฌฌไบไธชcanvas่ฝ็ถ่ฝๆฅๆถๅฐ่พๅ
ฅไฝๆฏ่ขซ็ชๅบๆพ็คบไบใ็ฌฌไธไธชcanvasๅๆถ่งฃๅณไบ่ฟ่ฟไธคไธช้ฎ้ขใ</p>
+<p></p><div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/tips-tabindex.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/tips-tabindex.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+</div>
+
+<p></p>
+<hr>
+<p><a id="transparent-canvas" data-toc="Make the Canvas Transparent"></a></p>
+<h1 id="making-the-canvas-transparent">้ๆๅcanvas</h1>
+<p>้ป่ฎคๆ
ๅตไธTHREE.js่ฎฉcanvasๆพ็คบไธบไธ้ๆใๅฆๆไฝ ้่ฆ่ฎฉcanvasๅๅพ้ๆๅฏไปฅๅจๅๅปบ <a href="/docs/#api/zh/renderers/WebGLRenderer"><code class="notranslate" translate="no">WebGLRenderer</code></a> ็ๆถๅไผ ๅ
ฅ <a href="/docs/#api/zh/renderers/WebGLRenderer#alpha"><code class="notranslate" translate="no">alpha:true</code></a></p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">const canvas = document.querySelector('#c');
+-const renderer = new THREE.WebGLRenderer({canvas});
++const renderer = new THREE.WebGLRenderer({
++ canvas,
++ alpha: true,
++});
+</pre>
+<p>ไฝ ๅฏ่ฝ่ฟๆณๅ่ฏๅฎไฝ ็็ปๆ <strong>ไธ</strong> ไฝฟ็จ premultiplied alpha</p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">const canvas = document.querySelector('#c');
+const renderer = new THREE.WebGLRenderer({
+ canvas,
+ alpha: true,
++ premultipliedAlpha: false,
+});
+</pre>
+<p>Three.js ไฝฟ็จ
+<a href="/docs/#api/zh/renderers/WebGLRenderer#premultipliedAlpha"><code class="notranslate" translate="no">premultipliedAlpha: true</code></a> ไฝไธบcanvas็็ผบ็ๅผ๏ผไฝไฝฟ็จ <a href="/docs/#api/zh/materials/Material#premultipliedAlpha"><code class="notranslate" translate="no">premultipliedAlpha: false</code></a> ไฝไธบๆ่ดจ็็ผบ็ๅผใ</p>
+<p>ๅฆๆไฝ ๆณ่ฆๆดๅฅฝ็็่งฃpremultiplied alpha็ไฝฟ็จไธๅฆ๏ผ่ฟ้ๆ<a href="https://developer.nvidia.com/content/alpha-blending-pre-or-not-pre">ไธ็ฏๅ
ณไบ่ฟไธช้ฎ้ข็ๅฅฝๆ็ซ </a>ใ</p>
+<p>ไธ็ฎกๆๆ ท๏ผ่ฎฉๆไปฌ็จ้ๆcanvasๆฅ่ฎพ็ฝฎไธไธช็ฎๅ็ไพๅญใ</p>
+<p>ๆไปฌๅฐไธ่ฟฐ้
็ฝฎๅบ็จๅฐๆฅ่ช<a href="responsive.html">ๅ
ณไบๅๅบๅผ่ฎพ่ฎก็ๆ็ซ </a>้็ไพๅญใ่ฎฉๆไปฌไนๅฐๆ่ดจๅๅพๆด้ๆใ</p>
+<pre class="prettyprint showlinemods notranslate lang-js" translate="no">function makeInstance(geometry, color, x) {
+- const material = new THREE.MeshPhongMaterial({color});
++ const material = new THREE.MeshPhongMaterial({
++ color,
++ opacity: 0.5,
++ });
+
+...
+</pre>
+<p>ๅนถไธๆทปๅ ไธไบHTMLๅ
ๅฎน</p>
+<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><body>
+ <canvas id="c"></canvas>
++ <div id="content">
++ <div>
++ <h1>Cubes-R-Us!</h1>
++ <p>We make the best cubes!</p>
++ </div>
++ </div>
+</body>
+</pre>
+<p>่ฟๆไธไบๅฐ็ปๅธๆพ็ฝฎๅฐๅ้ข็CSS</p>
+<pre class="prettyprint showlinemods notranslate lang-css" translate="no">body {
+ margin: 0;
+}
+#c {
+ width: 100%;
+ height: 100%;
+ 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: 100%;
++ height: 100%;
++ display: flex;
++ justify-content: center;
++ align-items: center;
++}
+</pre>
+<p>ๆณจๆ <code class="notranslate" translate="no">pointer-events: none</code> ไฝฟๅพcanvasไธๅๅบ้ผ ๆ ไธ่งฆๆธไบไปถ๏ผไปฅ่ณไบไฝ ่ฝๅค้ไธญไธ้ข็ๆๅญใ</p>
+<p></p><div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/tips-transparent-canvas.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/tips-transparent-canvas.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+</div>
+
+<p></p>
+<hr>
+<p><a id="html-background" data-toc="Use three.js as Background in HTML"></a></p>
+<h1 id="making-your-background-a-three-js-animation">ไฝฟ็จthree.jsๅจ็ปไฝไธบ่ๆฏ</h1>
+<p>ไธไธชๅธธ่ง็้ฎ้ขๆฏๅฆไฝไฝฟ็จthree.jsๅจ็ปไฝไธบ็ฝ็ซ็่ๆฏใ</p>
+<p>่ฟๆไธค็งๆพ่ๆ่ง็ๆนๆณใ</p>
+<ul>
+<li>ๅฐcanvas็CSS <code class="notranslate" translate="no">position</code> ๅฑๆงๅฆไธ่ฎพ็ฝฎไธบ <code class="notranslate" translate="no">fixed</code></li>
+</ul>
+<pre class="prettyprint showlinemods notranslate lang-css" translate="no">#c {
+ position: fixed;
+ left: 0;
+ top: 0;
+ ...
+}
+</pre>
+<p>ไฝ ๅฏ็ฎๅ็ๅจไธไธไธช็ไพๅญ้ไฝฟ็จ่ฟไธช่งฃๅณๆนๆกใๅช้่ฆๅฐ <code class="notranslate" translate="no">z-index</code> ่ฎพไธบ -1
+ๅฐฑๅฏไปฅ็ๅฐ็ซๆนไฝไปฌๆพ็คบๅฐๆๅญๅ้ขใ</p>
+<p>่ฟไธช่งฃๅณๆนๆกๅญๅจไธไธชๅฐ็ผบ็น๏ผ้ฃๅฐฑๆฏไฝ ็Javascriptๅฟ
้กป้ๆๅจ้กต้ขไธญใ่ไธๅฆๆไฝ ็้กต้ขๅฎ็ฐๅพๅคๆ็่ฏ๏ผไฝ ้่ฆไฟ่ฏ้กต้ข้็three.jsๅฏ่งๅไปฃ็ ไธไธๅฎ็ฐๅ
ถไปๅ่ฝ็ไปฃ็ ็ธๅฒ็ชใ</p>
+<ul>
+<li>ไฝฟ็จ <code class="notranslate" translate="no">iframe</code></li>
+</ul>
+<p>่ฟ็ง่งฃๅณๆนๆก่ขซๅบ็จๅจไบ <a href="/">ๆฌ็ซ้ฆ้กต</a>.</p>
+<p>ๅจไฝ ็็ฝ้กต็งๅช้่ฆๆๅ
ฅไธไธชiframe๏ผๅ่ฟๆ ท</p>
+<pre class="prettyprint showlinemods notranslate lang-html" translate="no"><iframe id="background" src="responsive.html">
+<div>
+ Your content goes here.
+</div>
+</pre>
+<p>็ถๅไฟฎๆนๆ ทๅผไฝฟๅ
ถๅกซๆปก็ชๅฃ๏ผๅนถไธๅคไบ่ๆฏไธญใ่ฟๅ ไนๅๆไปฌไนๅ็จๅฐ็canvasๆ ทๅผไปฃ็ ไธๆ ทใๅชไธ่ฟๅ ไธบiframeๅญๅจ้ป่ฎค่พนๆก๏ผๆไปฌ้่ฆ้ขๅคๅฐ <code class="notranslate" translate="no">border</code> ่ฎพไธบ <code class="notranslate" translate="no">none</code> ใ</p>
+<pre class="prettyprint showlinemods notranslate notranslate" translate="no">#background {
+ position: fixed;
+ width: 100%;
+ height: 100%;
+ left: 0;
+ top: 0;
+ z-index: -1;
+ border: none;
+ pointer-events: none;
+}
+</pre><p></p><div translate="no" class="threejs_example_container notranslate">
+ <div><iframe class="threejs_example notranslate" translate="no" style=" " src="/manual/examples/resources/editor.html?url=/manual/examples/tips-html-background.html"></iframe></div>
+ <a class="threejs_center" href="/manual/examples/tips-html-background.html" target="_blank">็นๅปๆญคๅคๅจๆฐๆ ็ญพ้กตไธญๆๅผ</a>
+</div>
+
+<p></p>
</div>
</div> | true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | docs/api/en/renderers/WebGLMultisampleRenderTarget.html | @@ -1,57 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:WebGLRenderTarget] →
-
- <h1>[name]</h1>
-
- <p class="desc">
- A special render target that can be used to utilize multi-sampled renderbuffers.
- Heads up: [name] can only be used with a WebGL 2 rendering context.
- </p>
-
- <h2>Examples</h2>
-
- <p>
- [example:webgl2_multisampled_renderbuffers webgl2 / multisampled / renderbuffers ]
- </p>
-
- <h2>Constructor</h2>
-
-
- <h3>[name]([param:Number width], [param:Number height], [param:Object options])</h3>
-
- <p>
- [page:Float width] - The width of the render target. <br />
- [page:Float height] - The height of the render target.<br />
- [page:Object options] - (optional) object that holds texture parameters for an auto-generated target
- texture and depthBuffer/stencilBuffer booleans.
- </p>
-
- <h2>Properties</h2>
-
- <h3>[property:number samples]</h3>
- <p>
- Specifies the number of samples to be used for the renderbuffer storage. However, the maximum supported
- size for multisampling is platform dependent and defined via *gl.MAX_SAMPLES*.
- </p>
-
- <p>[page:WebGLRenderTarget WebGLRenderTarget] properties are available on this class.</p>
-
- <h2>Methods</h2>
-
- <p>[page:WebGLRenderTarget WebGLRenderTarget] methods are available on this class.</p>
-
- <h2>Source</h2>
-
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </p>
- </body>
-</html> | true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | docs/api/en/renderers/WebGLRenderTarget.html | @@ -93,6 +93,10 @@ <h3>[property:DepthTexture depthTexture]</h3>
If set, the scene depth will be rendered to this texture. Default is null.
</p>
+ <h3>[property:Number samples]</h3>
+ <p>
+ Defines the count of MSAA samples. Can only be used with WebGL 2. Default is *0*.
+ </p>
<h2>Methods</h2>
| true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | docs/api/zh/renderers/WebGLMultisampleRenderTarget.html | @@ -1,57 +0,0 @@
-<!DOCTYPE html>
-<html lang="zh">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:WebGLRenderTarget] →
-
- <h1>[name]</h1>
-
- <p class="desc">
- A special render target that can be used to utilize multi-sampled renderbuffers.
- Heads up: [name] can only be used with a WebGL 2 rendering context.
- </p>
-
- <h2>Examples</h2>
-
- <p>
- [example:webgl2_multisampled_renderbuffers webgl2 / multisampled / renderbuffers ]
- </p>
-
- <h2>Constructor</h2>
-
-
- <h3>[name]([param:Number width], [param:Number height], [param:Object options])</h3>
-
- <p>
- [page:Float width] - The width of the render target. <br />
- [page:Float height] - The height of the render target.<br />
- [page:Object options] - (optional) object that holds texture parameters for an auto-generated target
- texture and depthBuffer/stencilBuffer booleans.
- </p>
-
- <h2>Properties</h2>
-
- <h3>[property:number samples]</h3>
- <p>
- Specifies the number of samples to be used for the renderbuffer storage. However, the maximum supported
- size for multisampling is platform dependent and defined via *gl.MAX_SAMPLES*.
- </p>
-
- <p>[page:WebGLRenderTarget WebGLRenderTarget] properties are available on this class.</p>
-
- <h2>Methods</h2>
-
- <p>[page:WebGLRenderTarget WebGLRenderTarget] methods are available on this class.</p>
-
- <h2>Source</h2>
-
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </p>
- </body>
-</html> | true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | docs/api/zh/renderers/WebGLRenderTarget.html | @@ -89,6 +89,10 @@ <h3>[property:DepthTexture depthTexture]</h3>
ๅฆๆ่ฎพ็ฝฎ๏ผ้ฃไนๅบๆฏ็ๆทฑๅบฆๅฐไผ่ขซๆธฒๆๅฐๆญค็บน็ไธใ้ป่ฎคไธบnull
</p>
+ <h3>[property:Number samples]</h3>
+ <p>
+ Defines the count of MSAA samples. Can only be used with WebGL 2. Default is *0*.
+ </p>
<h2>ๆนๆณ</h2>
| true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | docs/list.json | @@ -283,7 +283,6 @@
"Renderers": {
"WebGLMultipleRenderTargets": "api/en/renderers/WebGLMultipleRenderTargets",
- "WebGLMultisampleRenderTarget": "api/en/renderers/WebGLMultisampleRenderTarget",
"WebGLRenderer": "api/en/renderers/WebGLRenderer",
"WebGL1Renderer": "api/en/renderers/WebGL1Renderer",
"WebGLRenderTarget": "api/en/renderers/WebGLRenderTarget",
@@ -783,7 +782,6 @@
"ๆธฒๆๅจ": {
"WebGLMultipleRenderTargets": "api/zh/renderers/WebGLMultipleRenderTargets",
- "WebGLMultisampleRenderTarget": "api/zh/renderers/WebGLMultisampleRenderTarget",
"WebGLRenderer": "api/zh/renderers/WebGLRenderer",
"WebGL1Renderer": "api/zh/renderers/WebGL1Renderer",
"WebGLRenderTarget": "api/zh/renderers/WebGLRenderTarget", | true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | examples/jsm/objects/Reflector.js | @@ -8,8 +8,7 @@ import {
UniformsUtils,
Vector3,
Vector4,
- WebGLRenderTarget,
- WebGLMultisampleRenderTarget
+ WebGLRenderTarget
} from 'three';
class Reflector extends Mesh {
@@ -27,7 +26,7 @@ class Reflector extends Mesh {
const textureHeight = options.textureHeight || 512;
const clipBias = options.clipBias || 0;
const shader = options.shader || Reflector.ReflectorShader;
- const multisample = options.multisample || 4;
+ const multisample = ( options.multisample !== undefined ) ? options.multisample : 4;
//
@@ -46,18 +45,7 @@ class Reflector extends Mesh {
const textureMatrix = new Matrix4();
const virtualCamera = new PerspectiveCamera();
- let renderTarget;
-
- if ( multisample > 0 ) {
-
- renderTarget = new WebGLMultisampleRenderTarget( textureWidth, textureHeight );
- renderTarget.samples = multisample;
-
- } else {
-
- renderTarget = new WebGLRenderTarget( textureWidth, textureHeight );
-
- }
+ const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );
const material = new ShaderMaterial( {
uniforms: UniformsUtils.clone( shader.uniforms ), | true |
Other | mrdoob | three.js | 48b05d3500acc084df50be9b4c90781ad9b8cb17.json | Remove WebGLMultisampleRenderTarget. (#23455)
* Remove WebGLMultisampleRenderTarget.
* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.
* Exampels: Clean up.
* WebGLRenderer: Use multisampling when possible without reporting errors.
* Update WebGLRenderer.js
Co-authored-by: mrdoob <info@mrdoob.com> | examples/jsm/objects/Refractor.js | @@ -9,8 +9,7 @@ import {
UniformsUtils,
Vector3,
Vector4,
- WebGLRenderTarget,
- WebGLMultisampleRenderTarget
+ WebGLRenderTarget
} from 'three';
class Refractor extends Mesh {
@@ -28,7 +27,7 @@ class Refractor extends Mesh {
const textureHeight = options.textureHeight || 512;
const clipBias = options.clipBias || 0;
const shader = options.shader || Refractor.RefractorShader;
- const multisample = options.multisample || 4;
+ const multisample = ( options.multisample !== undefined ) ? options.multisample : 4;
//
@@ -43,18 +42,7 @@ class Refractor extends Mesh {
// render target
- let renderTarget;
-
- if ( multisample > 0 ) {
-
- renderTarget = new WebGLMultisampleRenderTarget( textureWidth, textureHeight );
- renderTarget.samples = multisample;
-
- } else {
-
- renderTarget = new WebGLRenderTarget( textureWidth, textureHeight );
-
- }
+ const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );
// material
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.