ã¡ãªã¿ã«ããããžã§ã¯ãèªäœã¯èå³æ·±ããã®ã§ãã çŸä»£ã®å€§ããªãªãŒãã³ã¹ããŒã¹ã§ã¯ã空éå ã移åããé©åãªäººãäŒè°å®€ãèŠã€ããããšã¯éåžžã«å°é£ã§ãã ãã¡ãããExcelã§å³ãäœæããããšãã§ããŸãããããã¯å¿ ãããåªãããœãªã¥ãŒã·ã§ã³ã§ã¯ãããŸããã ã¢ã¬ã¯ãµã³ããŒã»ã¢ã¢ãœãã¯ããã䟿å©ã«ãããè¡ããšããèããæã£ãŠããŸããã圌ã¯Frontend Confã§ãããå ±æããŸããã以äžã¯åœŒã®å ±åã®è»¢åã§ãã
ç©èª
ãããžã§ã¯ãã«é¢ããããã€ãã®èšèã åœç€Ÿã¯ç©æ¥µçã«éçºãé²ããŠãããæ°ããåŸæ¥å¡ãçŸãããªãã£ã¹ã§ã®ããã²ãŒã·ã§ã³ã®å¹³å¡ãªåé¡ãçºçããŸãã
æè¿ãŸã§ãããšãã°ãããã¢ã®1ã€ã®ãã®ãããã®ãããªã¹ã±ãããããããããããã«äœãé 眮ãããŠãããã瀺ãããŠããŸããã ããããããã¯ä¿®æ£ãããŠãããæéãçµã€ã«ã€ããŠäœããå€åãã人ã ãå¥ã®éšéã«ç§»åããã«ãŒãã¯ç¡é¢ä¿ã«ãªããŸãã
ããã«å€§ããªåé¡ã¯ãé©åãªåŸæ¥å¡ãèŠã€ããããšã§ããã æåã«ãConfluenceã«åŒ·åãªããŒãã«ããããŸãããã»ã«ã¯ãååãå ¥åãããåŸæ¥å¡ã®å Žæã§ãã æ³ååãããŸãè¯ããªããã°ãããŸã䟿å©ã§ã¯ãããŸããã 衚瀺ãããç»åã§ã¯ãããŒãã«ïŒå·ŠïŒãšãããïŒå³ïŒã¯ãªãã£ã¹ã®åãå Žæã«å¯Ÿå¿ããŠããŸãã ãã¡ããããã®ã¹ããŒã ã¯ããŒãã«ã䜿çšããŠäœæã§ããŸããéåžžã«å®äŸ¡ã§è¿ éãªãœãªã¥ãŒã·ã§ã³ã§ãããéåžžã«æãããŠããŸãã
æ°ããåŸæ¥å¡ãå¿ èŠãªãã®ãç°¡åã«èŠã€ããããããã«ããã£ãšäŸ¿å©ã«ãããšããã¢ã€ãã¢ããããŸããã
ããã¯ããã¹ãŠã®ããã¢ããã3次å ã®ãããã§ãã人ã«æ€çŽ¢ããŠèªåã®çŸåšå°ãèŠã€ããé£çµ¡å ãååŸããé©åãªäŒè°å®€ãèŠã€ããŠãããããšãã§ããŸãã
2D vs 3D
ãããžã§ã¯ãããŸã å§ãŸã£ãã°ããã®é ãåœç¶ãªããè°è«ããããŸããã 圌ãã¯ç§ã«èšã£ãïŒããªã3DïŒ ããã¯ãã¹ãŠç解äžèœã§ãã 誰ããäºæ¬¡å ã«ãŒãã«æ £ããŠããŸãïŒ è¿ éãã€ç°¡åã«äœæã§ããŸãã äºæ¬¡å ã«ããŸãããïŒã
3次å å®è£ ãéžæãããã®ã¯ãªãã§ããïŒ
å ã®2次å svgã¹ããŒã ã¯ãããŒãžäžã§ã¯ããŸããããã«èŠããŸããã 3Dã圱ãé è¿æ³ã®ãããã§å€§ããªãªãœãŒã¹ããªããŠãããããã¯ãããšã¬ã¬ã³ãã«èŠããŸãã
⢠æ確ã§ã
ç§ãã¡ã«ã¯ãŸã 3次å 空éã«ååšããŠããã®ã§ããã®ãããªãããã¯ããèŠèŠçã§ãã 奜ããªããã«åããå€ããŠããã²ãŒãã§ããŸã-éåžžã«äŸ¿å©ã§ãã
⢠ã§ãããã
ãããäž»ãªçç±ã§ã-ç§ã¯ãããè¡ãããšãã§ããŸãããç§ããããªã2次å ã®å®è£ ãšã¯ç°ãªããããã¯ç§ã«ãšã£ãŠèå³æ·±ãã§ãã
ã©ãããå§ãŸããŸããïŒ
ã¢ãã«äœæ
ãªãã·ã§ã³ããããŸãïŒ
â¢ã¢ãã©ãŒã®æ€çŽ¢ïŒãªãã·ã§ã³ïŒ
ãããããããæãçæ³çãªãªãã·ã§ã³ã§ãã3DMAXããã³åæ§ã®ããã°ã©ã ãç解ããŠãã人ãèŠã€ããŠã圌ããã¹ãŠãè¡ãããã«ãããã®ã¢ãã«ãæ¡çšããã ãã§ãã
â¢æ¢è£œã¢ãã«ã®æ€çŽ¢ïŒãªãã·ã§ã³ïŒ
ãã®ãããªäººãããªãå Žåãæ¢è£œã®ã¢ãã«ã¯ã€ã³ã¿ãŒãããã§èŠã€ããããšãã§ããŸãã
â¢3Dãšãã£ã¿ãŒãèªåã§ãã¹ã¿ãŒãã
ãã®ãªãã·ã§ã³ã¯å®éã«å¿ èŠã§ã ïŒæ¬åŒ§å ã«ããªãã·ã§ã³ããšããåèªã¯ãããŸããïŒ-ãšã«ããå¿ èŠãªã®ã§ã ãã€ãã¬ãã«ã®åé¡ã ã¢ãã©ãŒãããå Žåã§ããããããèªåã§äœããç·šéããããå°ãªããšããšãã£ã¿ãŒã§éããŠãã¢ãã«ãé©åã«äœæãããŠããããšã確èªããå¿ èŠããããŸãã ãããã£ãŠããã®é ç®ã¯å¿ é ã§ãã
3D Blenderãšãã£ã¿ãŒã䜿çšããŸããã
ãããã誰ãã3D MAX-3Dç·šéçšããã°ã©ã ã«ã€ããŠèããããšãããã§ãããã ããã¯å¯Ÿå¿ãããã®ã§ããããªãŒãã³ãœãŒã¹ã®äžçããã®ã¿ã§ãã ãã®ãšãã£ã¿ãŒã¯ç¡æã§ããã¹ãŠã®äž»èŠãªãã©ãããã©ãŒã ããããåžžã«é²åããŠããŸãã ããã«ã¯çŽ æŽãããæ©èœããããŸã-Blenderã䜿ã£ãŠã§ããããšã¯ãã¹ãŠãéåžžã®Pythonã¹ã¯ãªããã䜿ã£ãŠã§ããŸãã
ããã€ãã®ã€ã³ã¿ãŒãã§ã€ã¹èŠçŽ ã«ã«ãŒãœã«ãåããããšããããã¢ãããŠã£ã³ããŠã«ãããŒã¿ãåä¿¡ããããããŸãã¯ç¹å®ã®ã¢ã¯ã·ã§ã³ãæ©èœããããã«å®è¡ããå¿ èŠãããã¡ãœããã衚瀺ãããŸãã
ãã1ã€ã®ã¯ãŒã«ãªæ©èœã¯ãããã©ã«ãã§SVGããã®ã€ã³ããŒãããµããŒãããŠããããšã§ãã
ãœãŒã¹ãããªã¢ã«SVGãå ¥æããã°ãããªã®ã§ãéåžžã«é©ããŠããŸãã å³ãã€ã³ããŒãããŠãäžè§åœ¢ã«å€æããå£ã®é«ããèšå®ããã ãã§ãã å¯äžã®ããšã¯ãåŸæ¥å¡ãé 眮ãããŠããæ€ åããªããBlenderã«æåã§é 眮ããå¿ èŠããã£ãããšã§ãã
ååãšããŠããããã®å Žæã¯ãã¹ãŠåãã§ãããããå°ãããããŠã¯ããŒã³ãäœæããå¿ èŠããããŸããã äžããèŠããšå ŽæãæŽçããã®ãæã䟿å©ã§ãããäžããèŠããšãã¹ãŠãæ£åžžã«èŠããããã«èŠããŸãããå®éã«ã¯ç°ãªãã¬ãã«ã«ããããšãããããŸããã
ããã«ãå Žæãè€è£œãããšãã«ããããããžãªã¡ããªã誀ã£ãŠè€è£œããå¯èœæ§ããããŸãã ãžãªã¡ããªã¯ãã¯ã€ã€ãã¬ãŒã ãæ§æãããã€ã³ãã§ã ã ã¢ãã«ãããå€ãã®ãã£ã¹ã¯å®¹éãå æãå§ãããããè€è£œã¯ããŸãè¯ããããŸããã
ããã§ããããã®1ã€ãã€ãŸãPythonã¹ã¯ãªããã䜿çšã§ãããšããäºå®ã圹ç«ã¡ãŸãã
import bpy geometry = bpy.data.meshes['place'] for obj in bpy.context.selected_objects: obj.rotation_euler.x = 0 obj.rotation_euler.y = 0 obj.data = geometry obj.location.z = 0
å Žæã®ãžãªã¡ããªãååŸããéžæãããªããžã§ã¯ãã調ã¹ãå転ããªã»ãããããã¹ãŠãåããžãªã¡ããªãšé«ããåç §ããŠããããšã瀺ãïŒZ軞ãäžãåããŠããïŒã0ã«ãªã»ããããŸãã
圱
Blenderã«æ»ããšã圱ãçŒãä»ããããŸããã åœç¶ã ã·ã§ãŒãã£ã³ã°ãªããžã§ã¯ãã§ã¯ããããªã¥ãŒã ããããŸãã ãªã¢ã«ã¿ã€ã ã·ã§ãŒãã£ã³ã°æè¡ã®ã¢ã³ããšã³ããªã¯ã«ãŒãžã§ã³ ïŒãªããžã§ã¯ãã®çžäºã·ã§ãŒãã£ã³ã°ïŒã䜿çšããå Žåãã¬ã³ããªã³ã°ã®é床ãäœäžãããããäºåã«ã·ã£ããŠããã€ã¯ããããšããå§ãããŸãã
å³ã¯ã以åã«çŒãä»ãããã圱ã瀺ããŠããŸããå³åŽããã¯ã¹ãã£ãå·ŠåŽããã®åº§æšããªããžã§ã¯ãã«éãããããã¯ã¹ãã£åº§æšã§ãã
ãã¯ã¹ãã£åº§æšã®å€èŠ³ã®å¥ã®äŸã
ããã€ãã®ç°¡åãªã¢ã¯ã·ã§ã³ã®åŸããBakeããã¿ã³ãã¯ãªãã¯ããçžäºã·ã§ãŒãã£ã³ã°ãšãã€ã¯ãéžæããå¿ èŠããããŸãã ç§ã¯3Dãšãã£ã¿ãŒãããŸãåŸæã§ã¯ãªãã®ã§ããããã¯æ¬åœã®åœ±ã§ã¯ãããŸããããŸãããã¹ãŠããã¯ã¹ãã£ãªã³ã°ããŠã¯ãŒã«ã«ããããã«å æºãçŸããé 眮ããããšã¯å°é£ã§ããã ãããã£ãŠãçžäºã·ã§ãŒãã£ã³ã°ã¯éåžžã«é©åãªãªãã·ã§ã³ã§ãã
ãã©ããå®è£ ã®å€èŠ³ãšåœ±ä»ãã®åçãæ¯èŒã§ããŸãã
ã¢ãã«ãææ¡ããã¢ãã«ããããšä¿¡ããŠããŸãããããŠã誰ãã䜿çšã§ããããã«ããã©ãŠã¶ã«ãããæ§ç¯ããå¿ èŠããããŸãã
Webgl
WebGLä»æ§ãå©ãã«ãªããŸãã
ãããäœã§ãããã«ã€ããŠã®å°ãã®æŽå²ã WebGLã¯OpenGL for Embedded SystemsããŒãžã§ã³2.0ä»æ§ã«åºã¥ããŠãããåºæ¬çã«è¥å¹²ã®å€æŽãå ããŠç¹°ãè¿ããŠããŸãã äžæ¹ãOpenGL for Embedded Systemsã¯ãã¢ãã€ã«ããã€ã¹å°çšã«èšèšãããOpenGLä»æ§ã®ãµãã»ããã§ãã ã€ãŸããéå°ãªã«ããã¢ãŠãããããŸãã
WebGLããŒãžã§ã³2.0ããã©ãŠã¶ã§ãµããŒããããŠããŸããããŸã ããã»ã©æ®åããŠããŸããã WebGL Nextãè°è«ãããŠããŸãããäœã«çŠç¹ãåãããã®ãããããšããŸã£ããçŠç¹ãåãããã®ãã¯æ確ã§ã¯ãããŸããã ãããããã«ã«ã³ã«-ããã¯ãŸã æ確ã§ã¯ãããŸããã
WebGL 1.0ã¯ã©ãã§ããµããŒããããŠããŸã ïŒiOSãAndroidãªã©ã ããã«åé¡ã¯ãããŸããã
æ¯èŒã®ããã«ãWebGL 2.0ã¯çŸæç¹ã§ã¯ããŸããµããŒããããŠããªãããããåŸ ã¡ãã ããã
2D vs 3D [2]
WebGLãæãäžããããã«ã2次å ãš3次å ã®å®è£ ãæ¯èŒããŸãã ç°¡åãªãã¹ããè¡ããŸããããéåžžã®èµ€ãæ£æ¹åœ¢ã®2次å ããã³3次å ã®å®çŸãã©ã®ããã«èŠãããã§ãã
Canvasã®2次å å®è£ ã¯éåžžã«ç°¡åã§ãã
<canvas id="canvas" width="100" height="100"></canvas> <script> (function() { const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); context.fillStyle = 'rgba(255, 0, 0, 1)'; context.fillRect(25, 25, 50, 50); }()); </script>
ãã£ã³ãã¹èŠçŽ ãããããã®2次å ã®ã³ã³ããã¹ãã䜿çšããŠãå¡ãã€ã¶ãã¹ã¿ã€ã«ãå®çŸ©ããæ£æ¹åœ¢ãæç»ããŸãã
3次å å®è£ ã¯ãæåã¯äŒŒãŠããããã§ããcanvasèŠçŽ ããããã³ã³ããã¹ãã¯canvas.getContextïŒ 'webgl'ïŒã䜿çšããŠååŸãããŸãã ããããããã«éãããããŸãã ä»ãç§ã¯èª¬æããããšããŸãã å®è£ ã«æ·±ãå ¥ã蟌ãããšã¯ã§ããããããŸããªçšèªãæããããšããããŸãããããããã¹ãŠåçŽåããæ¹æ³ãããã«èª¬æããŸãã
<canvas id="canvas" width="100" height="100"></canvas> <script> (function() { const canvas = document.getElementById('canvas'); const gl = canvas.getContext('webgl'); // // // // // }()); </script>
次ã«ããå¿ èŠãããããšïŒ
1. é ç¹ã·ã§ãŒã㌠-ã³ã³ãã€ã«ããŠæž¡ããŸãã
const vertexShaderSource = ` attribute vec4 position; void main() { gl_Position = position; } `; const vertexShader = gl.createShader(gl.VERTEX_SHADER); gl.shaderSource(vertexShader, vertexShaderSource); gl.compileShader(vertexShader);
2. ãã©ã°ã¡ã³ãã·ã§ãŒã㌠ãåºåã§åã«èµ€è²ãäžãã-å床ã³ã³ãã€ã«ããŠæž¡ã
const fragmentShaderSource = ` void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } `; const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); gl.shaderSource(fragmentShader, vertexShaderSource); gl.compileShader(fragmentShader);
3. ããã°ã©ã -äž¡æ¹ã®ã·ã§ãŒããŒãããã°ã©ã ã«æ¥ç¶ããŠäœ¿çšããŸãã
const program = gl.createProgram(); gl.attachShader(program, vertexShader); gl.attachShader(program, fragmentShader); gl.linkProgram(program); gl.useProgram(program);
4.åè§åœ¢ã®é ç¹ã®åº§æšãèšå®ãããé ç¹ãããã¡ãŒ ãäœæåŸããã€ã³ãããé ç¹ã®åº§æšã転éããé ç¹ã·ã§ãŒããŒããã®äœçœ®å±æ§ãé ç¹ãããã¡ãŒã«é¢é£ä»ããŠäœ¿çšããå¿ èŠããããŸãã
const vertices = new Float32Array([ -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5 ]); const vertexSize = 2; const vertexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); const attrPosition = gl.getAttribLocation(program, 'position'); gl.vertexAttribPointer(attrPosition, vertexSize, gl.FLOAT, false, 0, 0); gl.enableVertexAttribArray(attrPosition);
5.次ã«ãããããã¹ãŠãæç»ããå¿ èŠããããŸãã
const vertices = new Float32Array([ -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5 ]); const vertexSize = 2; // ⊠gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertices.length / vertexSize);
ã ããããç°¡åã«ãèµ€ãæ£æ¹åœ¢ã§ããããšãå€æããŸããïŒ
ãããããWebGLã¯ããã»ã©åçŽã§ã¯ãªãããšã«æ°ä»ããã§ãããã ããã¯ããªãäœã¬ãã«ã§ãããå€ãã®ã¡ãœãããããããããã«ã¯100äžã®åŒæ°ããããŸãã ãããŠãããã¯ãŸã åçŽåãããã³ãŒãã§ã-å®éã®ã³ãŒãã§å¿ èŠãªãšã©ãŒã®ãã§ãã¯ã¯ãããŸããã
ãã€ãã£ãWebGLã詳ãã調ã¹ããå Žåã¯ãæŸç°èäžãRoger LeeããWebGLïŒProgramming Three-Dimensional Graphicsãã«ãããã·ã¢èªã®åªããæ¬ããããŸãã
ç§ã¯ãããèªãããšããå§ãããŸãããã¹ãŠãæåãã容æã«èªãããŸãã ããšãã°ãåçŽãªäžè§åœ¢ã®æç»ããå§ãŸãã圱ä»ãã®å®å šãª3次å ãªããžã§ã¯ãã®äœæã§çµãããŸãã
ãããç解ããæéããªããããããããã«ãªãå Žå-ç§ããã£ããããžã§ã¯ãã§ãããæ°æ¥ã§ããã«ãœã³ã®äžéšãšããŠå®è£ ãããŸããïŒ2é建ãŠã®æåã®ãããã¿ã€ãïŒã ãããã£ãŠãææã®ïŒãŸãã¯ææã§ã¯ãªãïŒãã¬ãŒã ã¯ãŒã¯ãå©ãã«ãªããŸãã
æã人æ°ã®ããWebGLãã¬ãŒã ã¯ãŒã¯ãšããŠThree.jsã䜿çšããŸããã ãã®ãã¬ãŒã ã¯ãŒã¯ã®äž»ãªå©ç¹ã¯ãäœã¬ãã«APIãæãäžããããšãªãããã¹ãŠãããéããããå°ãªãã³ãŒãã§å®è¡ã§ãã䟿å©ãªæœè±¡åãäœæããããšã§ãã ãããžã§ã¯ãå šäœã«å¯ŸããŠåäžã®ã·ã§ãŒããŒãèšè¿°ããããšã¯ã§ããŸããã
ãã®äŸã¯Readme Three.jsããåãããŠããŸãïŒ
var scene, camera, renderer, geometry, material, mesh; init(); animate(); function init() { scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000); camera.position.z = 1000; geometry = new THREE.BoxGeometry( 200, 200, 200 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); } function animate() { requestAnimationFrame( animate ); mesh.rotation.y += 0.02; renderer.render( scene, camera ); }
ãã®ã³ãŒãããã©ãŠã¶ã«ã³ããŒãããšãå®éããã§ã«å®å šãª3次å èŠèŠåãè¡ãããŠããŸãã ãããŠãããã¯åãªãæ®éã®æ£æ¹åœ¢ã§ã¯ãªããå転ãã3次å ã®ç«æ¹äœã§ãã
ãã®äŸãèããŠãã ãã
- ç¹å®ã®ã·ãŒã³ïŒ
scene
ïŒããããŸã-ããã¯ä»®æ³ç©ºéã§ãã ãããã®ã·ãŒã³ã¯è€æ°ããå ŽåããããŸãããéåžžã¯1ã€ã§ãã è€æ°ã®ã·ãŒã³ãååšããå Žåããããã¯ãã©ã¬ã«ã¯ãŒã«ããšããŠååšããŸãã
- ã«ã¡ã©ïŒ
camera
ïŒããããŸã-ããã¯ãã¹ã¯ãªãŒã³äžã®åçãæ®åœ±ããŠååŸãããã€ã³ãã§ãã
- 次ã¯ããªããžã§ã¯ããäœæããã³ãŒãã§ãã ããã«ããããã¥ãŒãã®
geometry
ïŒgeometry
ïŒãšãã®ãããªã¢ã«ïŒmaterial
ïŒãäœæãããŸãããã®å Žåã¯ãåãªããã©ãããªèµ€è²ã§ãã ãã¥ãŒããã¬ãŒã ãçµã¿åãããŠãã®äžã«ãããªã¢ã«ãé 眮ãããšãèµ€ããã¥ãŒãïŒmesh
ïŒãåŸããããããã¹ããŒãžïŒä»®æ³ç©ºéïŒã«é 眮ããŸãã
- 次ã®ã¹ãããã¯ãã¬ã³ãã©ãŒãªããžã§ã¯ããäœæãããã®äžã«ãã£ã³ãã¹ãªããžã§ã¯ããäœæããWebGLãšå¯Ÿè©±ããããšã§ãã ãã®å Žåãã¬ã³ããªã³ã°ãå
šç»é¢ã§è¡ãããããã«ãµã€ãºãèšå®ããããŒãžã®æ¬æã«ãã£ã³ãã¹ãè¿œå ããŸãã
- ãã®åŸã
animate()
é¢æ°ãåŒã³åºãã ãã§ãrequestAnimationFrame
ã«ãã£ãŠèªåèªèº«ãåŒã³åºãã ãã§ãªãããã¥ãŒããå転ããŸãã
ãã®ãããå®å šã«èŠèŠåãããŠããŸãã
ãã¥ãŒããäœæããã³ãŒãã»ã¯ã·ã§ã³ã䜿çšãããšãããŒããŒãããã³ãŒãã«ç°¡åã«çœ®ãæããããšãã§ããŸãã
var loader = new THREE.ObjectLoader(); loader.load('model.json', function(mesh) { scene.add(mesh); });
ã¢ãã«ãããŒãããããã«loadã¡ãœãããåŒã³åºãããã§ã«ã¹ã¿ã³ãã«æœè±¡ãã¥ãŒãã§ã¯ãªãã¢ãã«ãè¿œå ããŠããã©ãŠã¶ãŒã§è¡šç€ºããŸãã ããã¯äžè¬çã«ã¯ãŒã«ã§ãïŒ
ã¢ãã«ãååŸããã«ã¯ãç¹å®ã®åœ¢åŒã®ã¢ãã«ãå¿ èŠã§ãã Three.jsã«ã¯ãæ¥ç¶ããå¿ èŠãããæ¢è£œã®ãšã¯ã¹ããŒã¿ãŒãããïŒããã©ã«ãã§ã¯Blenderã«ã¯ãããŸããïŒãããã䜿çšããŠãã·ãŒã³ã«æ¢ã«ã€ã³ããŒãã§ãã圢åŒã«ã¢ãã«ããšã¯ã¹ããŒãããŸãã
ããããåçã¯éçã§ããããã¢ãã«ãããã£ãŠãããŸããŸãªè§åºŠããèŠãããšæããŸãã
Three.jsã«ã¯ããã®ããã®OrbitControlsãæ¢ã«ãããŸãã ã¡ã€ã³ã®Three.jsãã©ã«ããŒã§ã¯ãªãã äŸ ïŒ<script src = "three / examples / js / controls / OrbitControls.js"> </ script>ïŒã«ãããŸãã ã³ã¢ã³ãŒãã«ã¯å«ãŸããŠããªãããããã«æ¥ç¶ã§ãããã®ã¯ãã¹ãŠãããŸãã
OrbitControlsãæ¥ç¶ããã«ã¡ã©ãªããžã§ã¯ããæž¡ãã€ã³ã¹ã¿ã³ã¹ãäœæããŸãã
scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000); camera.position.z = 1000; new THREE.OrbitControls(camera);
ã«ã¡ã©ã¯OrbitControlsã«ãã£ãŠå¶åŸ¡ãããŸãã ãã®åŸãããŠã¹ã§ã¢ãã«ãå転ã§ããŸãã ããŠã¹ã®å·Šãã¿ã³ãæŒãããŸãŸåããå§ãããªããžã§ã¯ãããºãŒã ã€ã³ãŸãã¯ãºãŒã ã¢ãŠãããããšãã§ããŸãã
ããã¯Three.jsã®äŸã§ãã ã¢ãã«ãšã³ã³ãããŒã«ãããŒããããã ãã§ãååãšããŠãããã¯ãã§ã«å®å šãªèŠèŠåã§ãã ããšãã°æèšã販売ããŠããå Žåãã¢ãã«ãäœæããããã€ã³ã¿ãŒãããäžã§èŠã€ãããããã©ãŠã¶ã«æ¿å ¥ãããããããšãã§ãããŠãŒã¶ãŒã¯ãºãŒã ã€ã³ããŠããŸããŸãªè§åºŠããèŠãããšãã§ããŸãã
Three.jsãã¬ãŒã ã¯ãŒã¯ã䜿çšããŠ3次å ã°ã©ãã£ãã¯ã¹ã®äžçãããæ·±ãç解ããããã«ãUdacityã®åªããã³ãŒã¹ããããŸãã 圌ã¯è±èªã§ããããšãŠãé¢çœãã§ãã
ã¢ããªã±ãŒã·ã§ã³ã®ä»çµã¿
åºæ¬ãç¿åŸãããšããæ¬æ Œçãªã¢ããªã±ãŒã·ã§ã³ã®åäœãå®çŸããããã«ãããå€ãã®æ©èœãå¿ èŠã«ãªããŸã-ãã€ã¹ã枊巻ãã ãã§ãªããè¿œå ã®æ©èœãæ¥ç¶ããŸãã
ã¢ããªã±ãŒã·ã§ã³ã2ã€ã®éšåã«åå²ããŸããã
èŠèŽè
ããã¯ãCanvasãšWebGLã®æäœãæ åœããéšåã§ãã 次ã®ãã®ãå«ãŸããŸãã
- ãã€ã¯ãã·ã£ããŠã䜿çšããã¢ãã«ã
- ãªããžã§ã¯ãã®åãã£ã¹ãããããŸã-ãã£ã³ãã¹ãã¯ãªãã¯ããããšã§ãããããã3次å
空éã®èŠçŽ ã決å®ããã¡ã«ããºã ã§ãã ããã¯ãããšãã°ãèšç»äžã®å Žæãå²ãåœãŠãããã¢ã€ã³ã³ã«é¢ããæ
å ±ãååŸãããããããã«å¿
èŠã§ãã
- ã¢ã€ã³ã³ã®ã¹ãã©ã€ãã¯ã3次å
空éã®2次å
ç»åã®äžçš®ã§ãã æåã®3次å
ã·ã¥ãŒãã£ã³ã°ã²ãŒã ããã¬ã€ããå Žåãããšãã°ãDoom 1ããã³2ã§ã¯ããã¹ãŠã®æµãã¹ãã©ã€ããã€ãŸã2次å
ã§ãããåžžã«ããªããèŠãŠããããšãæãåºããŠãã ããã
UI
ã€ã³ã¿ãŒãã§ã€ã¹ã¯éåžžã«æšæºçã§ããã£ã³ãã¹ã®äžéšã«éããããæ€çŽ¢ãæ¿èªãããã³ããã¢å ã®ç§»åãå¯èœã§ãã ãããã£ãŠã3次å 空éã§çŽæ¥ã¯ãªãã¯ããã ãã§ãªããåŸæ¥ã®2次å ã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããŠãããã¢ãå²ãåœãŠãããšãã§ããŸãã
ç§ã¯2ã€ã®ç¬ç«ãããããã¯ãéžæããŸãããããã¯ç§ã«ãšã£ãŠäŸ¿å©ã ãšæãããããã§ã-çªç¶èª°ããWebGLããµããŒãããªããªã£ãå Žåããã¥ãŒã¢ãå¥ã®ãããã¯ã«ãã°ãã眮ãæããããšãã§ããŸãã UIã¯åããŸãŸã«ããããšãã§ããŸã-ãã®2次å ç»åã®å Žæããã€ã©ã€ããããšããŸãããã
ãã¹ãŠã¯Reduxã¹ãã¢ã§ç®¡çãããŸãã ã¢ã¯ã·ã§ã³ãçºçãããšãã¢ã¯ã·ã§ã³ãäœæãããŸãã ãã®å Žåãããã¢ãã¯ãªãã¯ããŠã3次å å³ã§ã2次å ã€ã³ã¿ãŒãã§ã€ã¹ã§ãããã¢ãéžæã§ããŸãã ãããã£ãŠãã¢ã¯ã·ã§ã³ãçºçããã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãæŽæ°ããããã¥ãŒã¢ãŒãšUIã®äž¡æ¹ã®éšåã«åºãããŸãã
ã¢ãã«ãããã察話æ§ããããã€ã³ã¿ãŒãã§ãŒã¹ããããŸãã ããããçŸæç¹ã§ã¯ãååãªå€§ããã®ã¢ããªã±ãŒã·ã§ã³ãããå ŽåããŠãŒã¶ãŒãããã¹ãŠãé ãïŒããšèšãåé¡ã«ééããå¯èœæ§ãé«ãã§ãã
ãã¹ãŠãé ããªããŸã
ã©ã®ãããªåé¡ã«ééãããã®è§£æ±ºã«äœã圹ç«ã£ããã説æããŸãã
æåã®åé¡ã¯ãmacOSäžã®Safariã®ãã¬ãŒãã§ããã ããã«ããããã¡ã€ã«ããããšãããšã
requestAnimatioFrame
ã¯æ£çŽãª60 FPSãçæãããã¹ãŠãããŸãããããã«èŠããŸããã ãããªã¯ãã¹ãŠããããããããŠããããšã瀺ããŠããŸãã ãããŠãããã¯Safariã§ã®ã¿ã§ããChromeã§ã¯ãã¹ãŠåé¡ãªããFireFoxã§ã¯åé¡ãããŸããã
é·ãéãç§ã¯äœãåé¡ãªã®ããçªãæ¢ããŸããã å¯èœãªãã¹ãŠããªãã«ããŸãã-ããã§ãé床ãäœäžããŸãã 次ã«ãäžã§ç€ºãããã¥ãŒãã䜿çšããŠThree.jsã®äŸãåãäžããèµ·åããŸããããé床ãäœäžããŸããïŒ
äºã¯ããã§ããããšãå€æããã WebGLã¯ã ããŒããŠã§ã¢ã¢ã³ããšã€ãªã¢ã¹ããµããŒãããŠããŸãã åçŽã«ã¢ã³ããšã€ãªã¢ã¹ãæå®ã§ããŸãïŒtrue-çŽç²ãªWebGLãThree.jsããåãããç»åã¯è¯ããªããŸãã ããã«ããã®ã¢ã³ããšã€ãªã¢ã·ã³ã°ã¯ããŒããŠã§ã¢ã§ãããããååã«è¿ éã«åäœããŸãããã®åé¡ãçºçãããŸã§ããããŸã§åé¡ã«æ°ã¥ããããšã¯ãããŸããã
ããããããã¯å·šå€§ãªè§£å床ã®Macããã¯ã®Retinaã¹ã¯ãªãŒã³äžã®Safariã«ããããã€ãã®ããã«ã匱ããããªã«ãŒãã§ããã®åé¡ãçºèŠãããŸããã ãã®ãã©ãŠã¶ã§ãã®ãããªããã€ã¹ã®ããŒããŠã§ã¢ã¢ã³ããšã€ãªã¢ã¹ãç¡å¹ã«ããã®ã«åœ¹ç«ã¡ãŸããã
ãŸã äžæºãæ±ããŠããå¥ã®åé¡ã¯ãã¢ããªã±ãŒã·ã§ã³ãèµ·åããããšãã«ã ã³ã³ãã¥ãŒã¿ãŒã¯ãŒã©ãŒãççã«å転ã ãé³ãç«ãŠå§ããããšã§ããã
ãã¹ãŠãã·ã³ãã«ã§ããããšãå€æããŸããã ç§ã瀺ããäŸã«ã¯ã
requestAnimationFrame
ã«ãã£ãŠèªåèªèº«ãåŒã³åºã
animate()
é¢æ°ããããŸãã åé¡ã¯ãåºæ¬çã«ããã¯å¿ èŠãªããšããããšã§ãã ã¢ãã«ãå転ããããšä»®å®ããŸããç»åã¯éçã§ãäœãèµ·ãããŸãããããããªã«ãŒãã¯èŠããããã
requestAnimationFrame
1ç§ããã60åããªã¬ãŒãã
requestAnimationFrame
ïŒçæ³çãªå ŽåïŒã äœãèµ·ãããŸããããã·ãŒã³ãäœåºŠãäœåºŠãåæç»ããããšãäœåãªãããããããªã«ãŒããæ·åããŸãã
解決çã¯æããã§ã ã äžèŠãªãšãã¯ã¬ã³ããªã³ã°ããªãã§ãã ãã ã ã«ã¡ã©ãå転ããå§ãããã¹ãŠãåããã¬ã³ããªã³ã°ãéå§ããŸãã ããŠã¹ãã¿ã³ãæŸããã«ã¡ã©ã®å転ãåæ¢ãããšãã¬ã³ããªã³ã°ãåæ¢ã§ããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãå€æŽãããå Žåãããšãã°ã2次å ã€ã³ã¿ãŒãã§ãŒã¹ã§å Žæãéžæãã匷調衚瀺ããå¿ èŠãããå Žåãéåžžã¯1ã€ã®ãã¬ãŒã ã®ã¿ãã¬ã³ããªã³ã°ã§ããããããã¹ãŠåŒ·èª¿è¡šç€ºãããŸãã
ãã§ã«ã¬ã€ãã£ã¹ãã£ã³ã°ã«ã€ããŠèšåããŸããã ãã£ã³ãã¹ãã¯ãªãã¯ãããšã3次å 空éã«ãã¯ãã«ãäœæããããªããžã§ã¯ããæ§æããã©ã®äžè§åœ¢ããã®ãã¯ãã«ãšäº€å·®ããããèšç®ãããŸãã ãããã£ãŠãæåã«äº€å·®ãããªããžã§ã¯ããéžæãããªããžã§ã¯ãã Three.jsã§ã¯ã次ã®ããã«ãªããŸãã
- ã¬ã€ãã£ã¹ã¿ãŒãããã
- 座æšãšã«ã¡ã©ãããã³äº€å·®ç¹ã確èªãããªããžã§ã¯ããéä¿¡ããŸãã
- ãã®çµæã亀差ç¹ãåŸãããŸãã
ããããå€æ°ã®äžè§åœ¢ã§æ§æãããéåžžã«å€§ããªã¢ãã«ãããå Žåãããã«ã¯å€ãã®æéãããããŸãã å®éããã¹ãŠã®ãªããžã§ã¯ããæ§æãããã¹ãŠã®äžè§åœ¢ããœãŒãããå¿ èŠããããŸãã ãããã£ãŠãå¥ã®æ¹æ³ã䜿çšãããŸãã äºåã«ãBlenderã§ãªããžã§ã¯ãã«è¿ããªããžã§ã¯ããäœæã§ããŸãããéåžžã«å°æ°ã®äžè§åœ¢ã§æ§æãããŠããŸãïŒäžã®å³ã§èµ€ã§ç€ºãããŠããŸãïŒã
é衚瀺ã«ããããšããå¥ã®ã¹ããŒãžã«é 眮ããããšãã§ããŸãããã¬ã€ãã£ã¹ãã£ã³ã°ã¯åœŒãšäžç·ã«è¡ãããã¯ããã«é«éã«ãªããŸãã
ããã«ãåºã®å Žåãæåã§äœæããå¿ èŠããã£ãå Žå-è€éãªãžãªã¡ããªããããããå Žæã§ã¯JSã³ãŒãã§èªåçã«çæã§ããŸãã å Žæãåããx軞ãšy軞äžã®æ倧äœçœ®ãèšç®ãïŒzã§ã¯å¿ èŠãããŸããïŒãå®äºã§ãã 2ã€ã®äžè§åœ¢ã§æ§æãããæ£æ¹åœ¢ããããŸã-ããã ãã§ãã
ã€ã³ã¹ã¿ã³ã¹åãã¯ãããžã䜿çšãããšãããã©ãŒãã³ã¹ãæ倧ã«åäžããŸãã ïŒçµæã¯å·ŠåŽã«ãããŸãïŒã Instancingã䜿çšããåã¯ã365ã®ãããŒã³ãŒã«ïŒãããªã«ãŒãã§ã®ãããŒïŒãããããã®åŸã¯51ã§ããããããããªãã®æ°ã§ãããããããã¢ã€ã³ã³ãåå ã§ãã
ãã€ã³ãã¯äœã§ããïŒ åããžãªã¡ããªãåç §ããå ŽæãããããšããäŒãããŸãã-ç°ãªãã€ã³ã¹ã¿ã³ã¹ãç°ãªãå Žæã«ç°ãªãè²ã§ååšããŠããããšãæãåºããŠãã ããã åãçš®é¡ã®ãªããžã§ã¯ããååšããå Žåããã®ææ³ãé©çšããŠããããªã«ãŒãã§ã®ã¬ã³ããªã³ã°ã®åæ°ãæžããããšãã§ããŸãã ããããã¹ãŠã®å Žæã1ã€ã®ãªããžã§ã¯ãã«çµåãããäžåºŠã«ã¬ã³ããªã³ã°ãããŸã-1ã€ã®ãã¹ã§ã
ã€ã³ã¹ã¿ã³ã¹ã¯WebGL 2ä»æ§ã®äžéšã§ãããæåã®WebGLã§ã¯ãæ¡åŒµæ©èœãä»ããŠäœ¿çšã§ããŸããæ¡åŒµæ©èœã¯ãææ°ã®ãã¹ãŠã®ãã©ãŠã¶ãŒã§ãµããŒãããã䜿çšå¯èœã§ãã
ãããã©ã®ããã«æ©èœãããã説æããããšããŸãã ããã©ã«ãã§ã¯ã4ã€ã®ç°ãªãäœçœ®ã«4ã€ã®ç°ãªãè²ã§4ã€ã®å ŽæããããšããŸãã éåžžããã®ããŒã¿ã¯ãŠããã©ãŒã ãä»ããŠæž¡ãããŸã-ããã¯ã·ã§ãŒããŒããã°ã©ã å šäœã«é©çšããããå€æ°ãã§ãã ãããã®å Žæã1ã€ã®ãããã«çµåããããšãå Žæã¯åãè²ã«ãªãã1ã€ã®å Žæã§æ··éããŸãã
ãããã£ãŠããããã®ããŒã¿ãæ£ç¢ºã«éä¿¡ããã«ã¯ïŒè²ãå Žæã®äœçœ®ã å±æ§ãå¿ èŠã§ãã ããã¯ãåé ç¹ã«åå¥ã«æž¡ããããã©ã¡ãŒã¿ãŒã§ãã
ã€ã³ã¹ã¿ã³ã¹åã«ã€ããŠç¥ã£ãŠããã¹ãããšïŒ
- ããã©ãŒãã³ã¹ã倧å¹
ã«åäžããŸã ã åãã¿ã€ãã®ã¢ã€ãã ãããããããããã¹ãŠãé
ããªãå Žåãã»ãšãã©ã®å Žåã倧å¹
ã«å¢å ããŸãã
- ããããããã¯é£ããã§ãã Three.jsããã®äŸã¯ããã«ãããŸã ã
次ã«çºçããåé¡ã¯ã次ã®ç»åã§ãïŒChromeå ïŒã ããã¯éåžžã ååãªãããªã¡ã¢ãªããªããšãã«çºçããŸã ã
äœã圹ç«ã¡ãŸããïŒ
ã¢ãã«ã®ç°¡çŽ å
svgç»åã3次å ãªããžã§ã¯ãã«å€æãããšããBlenderã¯å€ãã®äœåãªãã€ã³ããäœæããŸãã ãã¡ãããååŸãããªããžã§ã¯ãã¯æ»ããã§ãããã»ãšãã©ã®å Žåããã¯ç¹ã«èŠããŸããã ãããŠãäœåãªç¹ã¯ãã¹ãŠããããªã¡ã¢ãªã®æ¶è²»ãšããã©ãŒãã³ã¹ã®äœäžã§ãã
ãã¯ã¹ãã£ã®æé©å
éåžžã3次å ã²ãŒã ã§ã¯ãäžè§åœ¢ã®æ°ãæãå°ãªãäœããªãŽã³ã¢ãã«ã䜿çšãããŸãã ãããäžåããããã«ãå€æ°ã®ãã¯ã¹ãã£ã䜿çšããŠçŸããåçãäœæããŸãã æ®å¿µãªãããããã¯ãã©ãŠã¶ã§åé¡ã«ãªããŸããããã¯ãã¿ãã«å²ãåœãŠãããã¡ã¢ãªãããŸãå€ããªããããã¿ããçããšã¿ããã¯ã©ãã·ã¥ããããã§ãã ãããã£ãŠããã¯ã¹ãã£ã®æ°ãšãã®æé©åãæžããããã®ãã¯ããã¯ããããŸãã
ãã®ãã¯ããã¯ã®1ã€ã¯ãè€æ°ã®ãã¯ã¹ãã£ã1ã€ã«çµåããããšã§ãã 3ã€ã®é»ãšçœã®ãã¯ã¹ãã£ãããå Žåããããããã£ãã«ã«åå²ããŠ1ã€ã«çµåã§ããŸããæåã®ãã¯ã¹ãã£ã¯èµ€ã®ãã£ãã«ã«ã2çªç®ã¯ç·ã«ã3çªç®ã¯éã«è»¢éãããŸãã çµå±ã®ãšãããããã¯ãã¹ãŠ3åã®1ã®ãããªã¡ã¢ãªãå æããããšãããããŸãã
å§çž®ãã¯ã¹ãã£
ããŸããŸãªåœ¢åŒããããŸãïŒDXTãPVRTCãETCããããªã«ãŒãã®ãã¯ã¹ãã£ãµã€ãº1024 * 1024ããã¯ã¹ãã£ã¡ã¢ãª512 * 512ãšããŠãã€ãŸã4åå°ããããããšãã§ããŸãã
ã¯ãŒã«ãªå©çã«æããŸããã倧ããªå¶éããããŸãã
- ããŸããŸãªåœ¢åŒ ïŒDXT-ãã¹ã¯ãããã§ã®ã¿ãµããŒããPVRTC-iOSãETC-AndroidïŒã äžè¬çãªå Žåãã»ãšãã©ã®å Žåã4ã€ã®ç°ãªããã¯ã¹ãã£ïŒå圢åŒãããã³4çªç®ã®éå§çž®ïŒãä¿æããã·ã¹ãã ããµããŒããã圢åŒã確èªããå¿
èŠããããŸãã ãµããŒããããŠãã圢åŒããªãå Žåã¯ãå
ã®éå§çž®ãã¯ã¹ãã£ã䜿çšããŸãã
- ç»åã®å£å ã æªã¿ã®çšåºŠã¯å
ã®ç»åã«ãã£ãŠç°ãªããŸãã
- éæé åã®å¢çã«ã¢ãŒãã£ãã¡ã¯ãã衚瀺ãããå Žåã®éææ§ã®åé¡ ã
- 倧ããªãã¡ã€ã« ïŒãã ããgzipã䜿çšã§ããŸãïŒã ãµã€ãºã1024 * 1024ã®å®å
šã«é»ãPNGç»åãå³åº§ã«ããŠã³ããŒããããŸããããããªã¡ã¢ãªã§ã¯åãã€ã³ããã¡ã¢ãªãæ¶å»ããŸãã â , .
â .
â . (, ) .
â ! , - - . â , , , , .
, . 3D, . . , . , , , .
䟿å©ãªãªã³ã¯ïŒ
â Udacity
â « »
â threejs
â WebGL ( )
â WebGL ( )
:
https://twitter.com/gc_s9k
s9k0@ya.ru
, ++ , 28 29 . , FrontEnd Conf :
, , , .