ã¯ããã«
ãããã³ã¬ã§åãã Javaå ¥éè¬åº§ããä½ãéã«ãã箱人形ãã³ã¬ï¼Box Comicï¼ãã¨ããWebã¢ããªãéçºãã¾ããããã®ã¢ããªã¯ãHTML5ãï¼ãJavaScriptãï¼ãWebGLãã§ä½ããã¦ãã¾ãããã®ã¢ããªã§å©ç¨ãã¦ããã©ã¤ãã©ãªãthree.jsããããµã³ãã«ã³ã¼ãã¨ã¨ãã«è§£èª¬ãã¦ããçæé£è¼ã§ããä»åã¯æçµåã
ãååã¯ã3Dãªãã¸ã§ã¯ãããã¦ã¹ã§æä½ããæ¹æ³ãç´¹ä»ãã¾ãããæçµåã®ä»åã¯å¿ç¨ç·¨ã¨ãã¦ãéä¸ç·ããããã·ã箱人形ã®ä½æãããã¦ããããã¾ã¨ãã¦ããªãã¸ã§ã¯ããé¨åããã¦ã¹ã§æä½ãããµã³ãã«ãä½æãã¦è§£èª¬ãã¾ãã
対象èªè
ã以ä¸ã®èªè ã対象ã«ãã¦ãã¾ãã
- JavaScriptã§ããã°ã©ãã³ã°ãæ¸ãã人ã
- jQueryã使ã£ãããã°ã©ã ãæ¸ãããã¨ããã人ã
- HTML5ã®Canvasã使ã£ãããã°ã©ã ãæ¸ãããã¨ããã人ã
å¿ è¦ãªç°å¢
ããGoogle ChromeãããMozilla Firefoxãã¨ãã£ããWebGLã«å¯¾å¿ãããã©ã¦ã¶ãå¿ è¦ã§ãããInternet Explorerãã¯ãWebGLãå©ç¨ã§ãã¾ããã®ã§ãå®è¡ç°å¢ã¨ãã¦é©ãã¦ãã¾ããã
è¨äºã®æ§æ
ãæ¬é£è¼ã§ã¯ã以ä¸ã®å 容ããã³ã¼ãã示ããªãã解説ãã¦ãããæå¾ã«ãã³ã¬ã®ã³ãã¨ãã¦ããã¹ã¦ã®ããã°ã©ã ãçµ±åãããµã³ãã«ãä½æãã¾ãã
ãã¾ãããµã³ãã«ã¯ãã¯ã¹ãã£ãèªã¿è¾¼ãé¢ä¿ä¸ããã¼ã«ã«ã§ã¯åä½ãã¾ãããããã§ããµã¼ãã¼ä¸ã«ããµã³ãã«ãã¢ãããã¼ããã¦ããã¾ãããã©ããã£ãå 容ãã以ä¸ããã確èªãã ããã
å 容 | ãã¼ã¸ |
ã·ã¼ã³ã¨ã«ã¡ã©ã¨ã¬ã³ãã©ã¼ã®æºå | 3ãã¼ã¸ |
ç«æ¹ä½ã®è¡¨ç¤º | 4ãã¼ã¸ |
è²ä»ãæ¿ããªã´ã³ã®è¡¨ç¤º | 5ãã¼ã¸ |
ç»åããã¯ã¹ãã£ã¨ãã¦èªã¿è¾¼ã¿1 | 5ãã¼ã¸ |
ç»åããã¯ã¹ãã£ã¨ãã¦èªã¿è¾¼ã¿2 | 6ãã¼ã¸ |
Canvasããã¯ã¹ãã£ã¨ãã¦èªã¿è¾¼ã¿ | 6ãã¼ã¸ |
å 容 | ãã¼ã¸ |
ãã¦ã¹ã«ãã移åãå転ãæ¡ç¸®æä½ | 2ãã¼ã¸ |
ã¬ã¤ãã£ã¹ã¿ã¼ãå©ç¨ããé¸æã¨ç§»å1 | 3ãã¼ã¸ |
ã¬ã¤ãã£ã¹ã¿ã¼ãå©ç¨ããé¸æã¨ç§»å2 | 4ãã¼ã¸ |
ã¯ã©ã¼ã¿ããªã³ã«ããå転 | 5ãã¼ã¸ |
å 容 | ãã¼ã¸ |
éä¸ç·ã®è¡¨ç¤º | 1ãã¼ã¸ |
ãããã·ã®è¡¨ç¤º | 2ãã¼ã¸ |
箱人形ã®è¡¨ç¤º | 3ãã¼ã¸ |
WebGLããPNGãåºå | 4ãã¼ã¸ |
ã¾ã¨ã | 4ï½5ãã¼ã¸ |
ãããã§ã¯ãã³ã¼ãã示ãã¦è§£èª¬ãã¦ããã¾ãã
éä¸ç·ã®è¡¨ç¤º
ãéä¸ç·ã¯çãå©ç¨ãã¦ä½æãã¾ããã©ãå©ç¨ãããã¨ããã¨ãçãç´°é·ããããã®ã1æ¬ã®ç·ã¨è¦ç«ã¦ã¦ããã®ç·ãæ¾å°ç¶ã«é ç½®ãã¦éä¸ç·ã¨ãã¾ããããã§çã使ãã®ã¯ããã³ã®å ¥ãã¨æããåç¾ããããã§ãã
ããthree.jsãã«ã¯ãçãä½ãã¸ãªã¡ããªãSphereGeometryããåå¨ãã¾ãããã®ã¸ãªã¡ããªã§ä½ã£ãçã®ãscale.xããscale.zããå°ãããã¦ããscale.yãã大ãããããã¨ã§ãç·ç¶ã«å¤å½¢ããã¾ããæç»ä½ç½®ã¯ãMath.cosããMath.sinãã使ã£ã¦æ±ãã¾ããå¾ã¯ãæ¾å°ç¶ã«ãªãããã«å転ãããã°å®æã§ãã
ããã¤ã³ãã¯ãéä¸ç·ã¯ãªãã¸ã§ã¯ããå¤ãã®ã§ãã°ã«ã¼ãã«ç»é²ãã¦ã¾ã¨ãã¦æ±ããããã«ãããã¨ã§ããããã¨ãå¾ã§éä¸ç·ã®ä½ç½®ã移åããããè§åº¦ãå¤ãããããéã«ãã°ã«ã¼ãã®å±æ§ãå¤æ´ããã ãã§ãããªãã¾ããä¸ã®ç·ã1æ¬ãã¤å¤æ´ããã®ã¯å¤§å¤ã§ããã°ã«ã¼ãåããã¾ã使ããé層æ§é ãæã£ããªãã¸ã§ã¯ããä½ãã®ãã³ãã§ãã
ã以ä¸ãéä¸ç·ãä½æãã¦è¡¨ç¤ºãããcrocro.bc.viewFlash.jsããæ²è¼ãã¾ãã
//= ãµã³ãã«ï¼éä¸ç·ã®è¡¨ç¤º //== éä¸ç·ã®è¡¨ç¤º crocro.bc.viewFlash = function() { // å¤æ°ã®åæå var d3 = crocro.bc.d3; // 3Dæ ¼ç´ç¨ var flsh; // è¦ç´ ã®ä½æã¨æ ¼ç´ flsh = crocro.bc.mkFlash(0x000000); d3.scene.add(flsh); crocro.bc.render(); }; //== éä¸ç·ã®ä½æ crocro.bc.mkFlash = function(col) { // ãããªã¢ã«ã®ä½æ var material = new THREE.MeshBasicMaterial({color: col}); // ã°ã«ã¼ãã®ä½æ var group = new THREE.Object3D(); // éä¸ç·è¨å®ã®åæå var rMax = Math.PI * 2; var rStp = Math.PI / 32; var mvY = 300; // éä¸ç·ã®ä½æ for (var r = 0; r < rMax; r += rStp) { // ã¡ãã·ã¥ã®ä½æ var mesh = new THREE.Mesh( new THREE.SphereGeometry(1, 32, 32), material ); // ãµã¤ãºã縦é·ã« mesh.scale.x = 2; mesh.scale.y = 200; mesh.scale.z = 2; // æç»ä½ç½®ã®ç§»å mesh.position.x = mvY * Math.cos(r); mesh.position.y = - mvY * Math.sin(r); // å転 mesh.rotation.z = Math.PI / 2 - r; // ã°ã«ã¼ãã«ã¡ãã·ã¥ã追å group.add(mesh); } // ã°ã«ã¼ããæ»ãã¦çµäº return group; };