æ¡ä»¶ä»ãããŒãã¹ãã©ããã®ãã¬ãŒã ã¯ãŒã¯ãè¶
ãããµã€ããéçºããå Žåãã¢ãã¡ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã«é¢ããŠé
ããæ©ããçåãçããŸãã ãããã¯ãAwwwardsãFWAãCSS Design Awardsãªã©ã®ã«ã¿ãã°ã«å«ãŸãããã¶ã€ã³ãµã€ããªã©ã§ç¹ã«éèŠã§ãã ãã ããå€ãã®å Žåãã¢ãã¡ãŒã·ã§ã³ã®äœæãšãã®åŸã®æé©åã®ã¿ã¹ã¯ã¯ãå¿
èŠã«å¿ããŠãã©ãããå§ããŠãããããªãçµéšã®æµ
ãéçºè
ã«ä»»ãããŠããŸãã éåžžãããã¯ãã¹ãŠã䜿çšãäžå¯èœãªæå¶ãµã€ããããã³ãã®ãããªãããžã§ã¯ãã®ã¯ã©ã¹å
šäœã«å¯Ÿãããã®åŸã®åŠå®çãªæ
床ã«ã€ãªãããŸãã ãã®èšäºã§ã¯ã蚱容å¯èœãªã¢ãã¡ãŒã·ã§ã³ããã©ãŒãã³ã¹ã®å¢çãã©ãã«ããã®ããäžè¬çãªããã«ããã¯ã¯äœãªã®ããããããéçºè
ããŒã«ã®ã©ãã調ã¹ãã¹ããªã®ããç解ããããšããŸãã
ã¡ãã£ãšããçºèšïŒãã®èšäºã¯åå¿è
éçºè
åãã§ãããã¢ãã¡ãŒã·ã§ã³ã®æé©åãžã®äžè¬çãªã¢ãããŒãã瀺ãããšãç®çãšããŠãããããå€ãã®ããšã¯åçŽãªåŠè¡ç圢åŒã§ã¯ãªãç°¡ç¥åãããŠããŸãã
ãã©ãŠã¶ãããŒãžã衚瀺ããæ¹æ³
ãŸãããã©ãŠã¶ã«ããŒãžã®çŸåšã®ç¶æ
ã衚瀺ããããšãã«äœãèµ·ããããç解ããŠãããšåœ¹ç«ã¡ãŸãã 4ã€ã®äž»ãªæé ããããŸãã
- ã¹ã¿ã€ã«ã®èšç®ïŒãã©ãŠã¶ãŒã¯CSSã»ã¬ã¯ã¿ãŒã解æããé©çšããã¹ã¿ã€ã«ã決å®ããŸãïŒ
- ã¬ã€ã¢ãŠãã®äœæïŒããŒãžã¬ã€ã¢ãŠãã¯å®éã«åœ¢æãããŸãïŒ
- ãã€ã³ãïŒåŸç¶ã®ã¬ã³ããªã³ã°çšã®èŠçŽ ã®ãã¯ã»ã«è¡šçŸãäœæããŸãïŒ
- ã¬ã€ã€ãŒæ§æïŒãã©ãŠã¶ãŒã¯ãã¹ãŠããŸãšããŠåéããç»é¢ã«è¡šç€ºããŸãïŒ
ããã«ããã©ãŠã¶ã¯åžžã«ãã®é åºã§åäœããæåŸãŸã§é²ã¿ãŸãã ããŒãåŸã«ããŒãžãæåã«è¡šç€ºããããšã4ã€ã®ã¹ããããã¹ãŠãå®è¡ãããŸãã å°æ¥ãã¢ã¯ã·ã§ã³ã®1ã€ãå®è¡ãããå¯èœæ§ããããŸãããåæã«ãã¹ãŠã®ã¢ã¯ã·ã§ã³ãå®è¡ãããŸãã ããããåã®ãã®ã§ã¯ãããŸããã
ãããã®åã¹ãããã®ããã«ããã¯ã«ã€ããŠããã«æ€èšããäžèŠãããšããæããªè³ªåã1ã€è³ªåããŸãã
ãããé
ããªããã©ãããããã¯åé¡ã§ã...
éåžžã«é »ç¹ã«ãæããã«é
ãWebãµã€ãã§äœãããŠããªã人ã«äŒã£ãŠããç§ã®ããŒãžã®é床ã¯100ãã€ã³ãã«ãªããŸãããã¹ãŠã¯åé¡ãããŸããããšèšãããšãã§ããŸãã ãŸãã¯ãã®éã«ãããŸãæ©èœããŠãããµã€ãã§ã¯ãããçš®ã®ã¢ã«ãŽãªãºã ãããã€ãã®äžå¯è§£ãªã¡ããªãã¯ã«åºã¥ããŠéå¹ççã«æ©èœããããã人ã
ã¯é·ãéãããçš®ã®æé©åã«åãçµãã§ããŸããã ãããããããã®äž¡æ¥µç«¯ã®éã¯åžžèã®çãäžã«ããã¯ãã§ãã
ã« çŠ
ãç¥ã ã¢ãã¡ãŒã·ã§ã³ãæé©åããå¿
èŠããããã©ãããç解ããã«ã¯ãæ·±ãå²åŠçæèãå®çŸããå¿
èŠããããŸãã
ãµã€ããé
ãããšãããããšãé
ãããšãæå³ããŸãã ãµã€ãã®é床ãäœäžããŠããªããã°ãé床ã¯äœäžããŠããŸããã
äœããã®çç±ã§ãå€ãã®äººããã®å£°æãéåžžã«æãã ãšæã£ãŠããŸãããããã§ããïŒ ãšã³ããŠãŒã¶ãŒã«ãšã£ãŠãããã©ãŒãã³ã¹ãšã¯ãããçš®ã®ã¡ããªãã¯ã§ã¯ãªããå³å¯ãªæ°åŠçæ£åœåã䌎ãçæ³çãªã¢ã«ãŽãªãºã ã§ããããŸããã 圌ã«ãšã£ãŠãããã©ãŒãã³ã¹ã¯2ã€ã®ããšã®1ã€ã§ããããã©ãŒãã³ã¹ãäœäžããããäœäžããªããã§ãã
圌ã¯ã©ã®ããã«ããã決å®ããŸããïŒ ã¢ãã¿ãŒã®åŸãã§å€ãã®æéãéãã人ã®ç®ã¯ãfpsã®äœäžã«éãåå¿ãå§ããŸãã ããã¯å¥åŠãªäžå¿«æãåŒãèµ·ãããŸãã ãããã£ãŠãéçºè
ãšããŠã®ç§ãã¡ã®ä»äºã¯ãå°ç€æ²äžãé²ãããšã§ãã ãŠãŒã¶ãŒã¯ãã©ãŠã¶ã60 fpsã§åäœããã®ãèŠãããšã«æ
£ããŠããŸããïŒ ããã§ã¯ããã¹ãŠãåãã«ãªãããã«ãã¹ãŠãè¡ã£ãŠããŸãã äžçšåºŠã®éã®ã©ããããããæã£ãŠèŠãŠã 60fpsããã¯ããã«å°ãªã-æé©åãããŠããŸãã ç§ãã¡ã¯çŽ60ãèŠã-äœã觊ããªãã§ãã ããã ãŠãŒã¶ãŒã¯ãšã«ããéãã«æ°ä»ããªãã§ãããããããŠæé©åã®ããã«æé©åã«å€ãã®æéãè²»ãããŸãã
æé©åã®ããã«æé©åãè¡ããªãã§ãã ããã
16.5ms
fpsã®èŠ³ç¹ããèªåãè¡šçŸããã®ã¯äŸ¿å©ã§ã¯ãªãã®ã§ãããªç§ã«ç§»ããŸãããã 1000ms / 60fpsã®åçŽãªåå²ã«ããããã¬ãŒã ããšã«çŽ16.5msã®æéãåŸãããŸãã
ããã¯ã©ãããæå³ã§ããïŒ 16.5msã®éããã©ãŠã¶ã¯äžèšã®æé ã«åŸã£ãŠãããŒãžã®çŸåšã®ç¶æ
ãã¢ãã¡ãŒã·ã§ã³ã§è¡šç€ºããåæã«ãä»ã®ã¹ã¯ãªããã®äœæ¥ããµãŒããŒãšã®éä¿¡ãªã©ã®ããã«ãªãœãŒã¹ãä¿æããå¿
èŠããããŸãã ããŒãžã®çŸåšã®ç¶æ
ã衚瀺ããã®ã«ããå€ãã®æéãè²»ããããå Žåãç®ãéããŠã©ã°ã確èªããŸãã çŽ16msã®å Žåãæ²äžã¯ãããŸããããéã®è² è·ãéåžžã«é«ããªããã¯ãŒã©ãŒã鳎ããé»è©±ãæãŸãå¯èœæ§ããããŸãã ãããã£ãŠã1ã€ã®ãã¬ãŒã ã®ã¬ã³ããªã³ã°ãæéå
ã«ãã®å€ã«è¿ã¥ããªãããã«ããå¿
èŠããããŸããããã©ãŒãã³ã¹ã«äœè£ãããããã«ãããã«è¯ãã®ã¯10ms以äžã§ãã ãã¹ãã¯åžžã«äžå€®ã®ããŒããŠã§ã¢ã§å®è¡ãããããšãå¿ããªãã§ãã ãããããšãã°ã次ã®äŸã§ã¯ãã¹ã¯ãªãŒã³ã·ã§ããã¯ã°ã©ãã£ãã¯ãçµ±åãããPentium Silverã§æ®åœ±ãããŸãã
ãŠãŒã¶ãŒãæã€å¯èœæ§ãé«ãããŒããŠã§ã¢ã§ãã¹ããå®è¡ããŸãã è·å Žã®ããŒãã«ã®äžã«ããããšã³ãããã»ããµãšãã€ãã³ã°ãã¡ãŒã ãããå Žåããã¹ãŠãæ£åžžã«æ©èœããŸãããäºç®ã®ã©ãããããã䜿çšãããŠãŒã¶ãŒã¯éåžžã«æ²ãããªããŸãã
ããªãã®è¯ãç®ãšçŽæã ãã«é Œããªãããã«ãå°ãªããšãåºæ¬çãªã¬ãã«ã§éçºè
ããŒã«ãç¿åŸããããšã¯æçšã§ãã ãããã¯æ£ç¢ºãªããã©ãŒãã³ã¹ããŒã¿ãæäŸããã ãã§ãªãããã¹ãŠãããŸãæ©èœããªãå Žåã«åé¡ãæ¢ãå ŽæãæããŠãããŸãã
Google Chromeã®éçºè
ããŒã«
å€ãã®ã³ãŒããŒã¯ãLinuxã³ã³ãœãŒã«ããããã©ãŠã¶ãŒã®éçºè
ããŒã«ã«ãã°ãã°æãããŸãã ãããå®éã«ã¯ãæããããšã¯äœããããŸããã ã¯ããå€ãã®ãã¿ã³ããããŸããããããã¯åé¡ã解決ããããã«åé·ã§ãã ã¢ãã¡ãŒã·ã§ã³ãã©ããããããããŠäœããããå¿
èŠããããã©ãããç解ããããã«ããŸãæåã«æ³šæãæã䟡å€ãããå ŽæãèŠãŠãããŸãããã
ããã©ãŒãã³ã¹ã«é¢ããŠã¯ãã»ãšãã©ã®æéãããã©ãŒãã³ã¹ã¿ãã§éãããåããã¿ã³ãæŒããŸãã
Ctrl-Eã·ã§ãŒãã«ãããŸãã¯å·ŠåŽã®äžžããã¿ã³ã¯ãäœãèµ·ãã£ãŠããã®ããèšé²ãå§ããåæ¢ããŸãã çµæã¯ããã«è¡šç€ºãããŸãã ãã©ãŠã¶ã¯ããããã®ããšãæžããŸãããäœåºŠãèªããããäžåºŠèŠãã»ããããã®ã§ãäœããã®ã¢ãã¡ãŒã·ã§ã³ã䜿ã£ãŠèŠãŠã¿ãŸãããã ãŸãã¯ã·ã³ãã«ãªCSSã¢ãã¡ãŒã·ã§ã³ã«ããŸãã å
šç»é¢ã§éããšãç®ç«ã£ãçŽè©°ãŸãã§åäœããããšãããããŸãã
å
šç»é¢ã¢ãŒãã§æ°ç§éèšé²ããããã§äœãèµ·ãããã確èªããŸãã
ãã©ãŠã¶ã¯ãå®è¡ãããã¹ãŠãèšé²ããŸãã ãŠã£ã³ããŠã®äžéšã«fpsãã£ãŒãã衚瀺ãããŸãã ããŒãžã§ã®äœæ¥äžã«ç°åžžã«é床ãäœäžãå§ããå Žåã«ãç°åžžã®æ€åºã«ç°¡åã«äœ¿çšã§ããŸãã ããŠã¹ã§ãã£ãŒããã¯ãªãã¯ããŠæšªã«åŒããããã€ãŒã«ãåããšããã®æéç¯å²ãéžæã§ãããã®è©³çŽ°æ
å ±ãäžã«è¡šç€ºãããŸãã ãã®åçŽãªäŸã§ã¯ãç°åžžã¯ãããŸãããããã¹ãŠãéåžžã«åçã«æ©èœããããã§ã¯ãªãããšã¯æããã§ãã
ããã«Framesè¡ã«æ³šæããŠãã ãããåè¡ã«è²»ããããæéã«é¢ããæ
å ±ãå«ãŸããŠããŸãã ãã®æéã¯çµ¶ãããžã£ã³ããã16msã倧å¹
ã«è¶
ããŠããããšãããããŸãïŒå®éã®äŸã§ã¯ããã®ã¢ãã¡ãŒã·ã§ã³ãå°ãæ¹åããŸãïŒã
次ã«ãè² è·ãããŸããŸãªè²ã§è¡šç€ºãããè€æ°ã®è¡ã衚瀺ãããŸãããã©ãŠã¶ãããŸããŸãªçš®é¡ã®ã¢ã¯ãã£ããã£ã«è²»ãããæéã確èªã§ããŸãã ã¢ãã¡ãŒã·ã§ã³ã¯åäžã§ãåãæäœãåãã¬ãŒã ã«å¯ŸããŠå®è¡ããã玫ãšç·ã§ç€ºãããŠããŸãã ããŠã¹ãè²ä»ãã®ãããã¯ã®äžã«çœ®ããšãæåã«èšåãããã€ã³ããåŠçããŠããããšãæããã«ãªããŸãã ã¹ã¿ã€ã«ã®åèšç®ãšã¬ã€ã€ãŒããªãŒã®æŽæ°ã¯çŽ«è²ã§ã ãã€ã³ã ã¬ã€ã€ãŒãšåæã¬ã€ã€ãŒã¯ç·è²ã§ãã
å¥ã®ã¢ãã¡ãŒã·ã§ã³ãæ€èšããŠãã ããã ä»åã¯ã¹ã¯ãªããã䜿çšããŸã-åçŽãªãã€ãºãžã§ãã¬ãŒã¿ãŒã ããã¯ããªãäŸç€ºçãªäŸã§ãããèšèšã®èŠ³ç¹ããã¯èå³ããããŸããã
ã¹ã¯ãªããã®å®è¡ã衚瀺ããé»è²ã®ãããã¯ãè¿œå ãããŠããããšã«æ°ä»ããããããŸããã å€ãã®é¢æ°åŒã³åºããããå ŽåãåŒã³åºãããšã«ããã«1ãããã¯ãè¿œå ãããŸãããµã€ãºã«ãã£ãŠãæãéããé¢æ°ãç°¡åã«èŠã€ããããšãã§ããŸãããããããæé©åãéå§ãã䟡å€ããããŸãã
ãã®äŸã§ã¯ã1ã€ã®ãã¬ãŒã ã«è²»ããããæéã¯çŽ80ããªç§å€åããŸãã ããããããã«ãããã®ã¯ãèçŒã§ããã¹ãŠãã¯ã©ãã·ã¥ããæ§åãã¯ã£ãããšèŠãããšãã§ããŸãã 以äžã®èŠçŽã»ã¯ã·ã§ã³ãèŠããšãã¹ã¯ãªãããæãæéããããããšãããããŸãã ããããšæ¯èŒããŠã ã¬ã³ããªã³ã°ãšãã€ã³ãã¯ç¡èŠã§ãããšã©ãŒã®ããã«èŠããŸãã ãã¡ãããå¿
ãããããã§ã¯ãããŸããããé »ç¹ã«èµ·ãããŸãã
é¢æ°åŒã³åºããšããŠããŒã¯ãããŠãããããã¯ãã¯ãªãã¯ãããšãã¹ã¯ãªããã³ãŒãå
ã®é¢æ°ãžã®ãªã³ã¯ã衚瀺ãããŸãã 確èªãããšããã®äŸã§ã¯ãç»é¢äžã®ãã¹ãŠã®ãã¯ã»ã«ã埪ç°ããŠããããšãããããŸãã ã·ã§ãŒããŒã§ãã®ãããªã¿ã¹ã¯ãå®è¡ããæ¹ãè«ççã§ããå Žåãããã©ãŒãã³ã¹ã¯äœåãåäžããŸãã ããããå®éã®äŸã§èŠãŠãããŸãã
ã©ãããã°...
ãã©ãŠã¶ãŒã§ããŒãžã®çŸåšã®ç¶æ
ã衚瀺ããéã®æé ãšãæãæéãããã£ãŠããããŒãžã確èªããæé ãåŠã³ãŸããã ç¹å®ã®ã¹ããããå€ãã®ãªãœãŒã¹ãå¿
èŠãšããããã«ãªãæãäžè¬çãªçç±ãç¥ããç¹å®ã®ã±ãŒã¹ã§äœããã¹ããã«ã€ããŠã®ãã³ããããã€ã瀺ããŸãã
ã¹ã¿ã€ã«èšç®
ãã®ã¹ãããã§ãã§ã«åé¡ãçºçããŠããããšãããã£ãå Žåãã»ãšãã©ã®å Žåããã€ã³ãã¯ã¢ãã¡ãŒã·ã§ã³å
ã«ãããŸããããããŒãžäžã®èŠçŽ ãå€ããããšããäºå®ã§ãã èšèšãµã€ãã§ã¯ãããã¯éåžžã«ãŸãã§ããéåžžããã®ãããªåé¡ã¯ãæ°åã®èŠçŽ ãæã€å€§ããªããŒãã«ã®ãµãã©ã€ãã§ãã
ããŒãžäžã®èŠçŽ ã®æ°ãæžãããã¬ã€ã¢ãŠããç°¡çŽ åããŸãã ã©ãããŒã䜿çšããŠã³ãŒãã®äžéšãç¹°ãè¿ãããšã«ç¹ã«æ³šæããŠãã ãããã³ãŒãã¯åé€ã§ããå¯èœæ§ããããŸãã
æåã«é¢é£ãã2çªç®ã®çç±ã¯ãè€éãªCSSã»ã¬ã¯ã¿ãŒã§ãã å°ããããŒãžã§ãæ·±ããã¹ããé£æ¥ããèŠçŽ ãšã®ããªãããŒãªãããã³ã°ãªã©ã䜿çšããããšãéåžžã«å¯èœã§ããå Žåãæ¬åœã«å€§ããããŒãžã§ã¯ãããã¯ãã¹ãŠããã©ãŒãã³ã¹ã®äœäžã«ã€ãªããå¯èœæ§ããããŸãã
CSSã»ã¬ã¯ã¿ãŒãç°¡çŽ åããBEMã䜿çšããŸãã
ã¬ã€ã¢ãŠãäœæ
ãã®ã¢ã€ãã ã¯ãã§ã«ãã¶ã€ã³ãšã¢ãã¡ãŒã·ã§ã³ã«è¿ãã®ã§ãããããé¢çœãããšãå§ãŸããŸãã ç解ããããšãæåã«éèŠãªããšã¯ãã¬ã€ã¢ãŠãå
šäœã圢æãããããšã§ãã äœããå€ãããšãæ°ãã«åœ¢æãããŸãã ãã®ããã倧ããªããŒãžã§ã®å°ããªå€æŽã§ãããã®ã¹ãããã§é¡èãªé
延ãåŒãèµ·ããå¯èœæ§ããããŸãã
ã¢ãã¡ãŒã·ã§ã³ãäœæããéã«ç§ãã¡ãå°ãäž»ãªã«ãŒã«ã¯ããããªãå Žåã§ãã¬ã€ã¢ãŠãã®åæ§ç¯ãèš±å¯ããªãããšã§ãã ãããã£ãŠãéåžžã¯æé©åãè©Šã¿ãŸããïŒç¹ã«æ©äŒã¯ãããŸããïŒãã€ãŸããåé¿ããããšããŸãã
ã¬ã€ã¢ãŠãã®åæ§ç¯ãåŒãèµ·ããå¯èœæ§ã®ããå€ãã®ããããã£ããããŸããããšãã°ã csstriggers.comã¯æªããªããã€ã³ã¿ãŒãããäžã®ãªã¹ããèŠã€ããããšãã§ããŸãã ä»ã®ã¢ãã¡ãŒã·ã§ã³ãããé »ç¹ã«ããããã£ãèŠã€ããããšãã§ããŸãïŒ
display position / top / left / right / bottom width / height padding / margin border font-size / font-weight / line-height ...
ãããã®ããããã£ã¯ãã¹ãŠãèŠçŽ ã®å¹ŸäœåŠçç¹æ§ãè¡šã1ã€ã®ãã®ã«çµ±äžãããŠããããšã«æ°ä»ããããããŸããã衚瀺ãã©ã¡ãŒã¿ããµã€ãºãç©ççäœçœ®ã§ãã ãããã£ãŠãããããã¹ãŠãèšæ¶ããã®ã§ã¯ãªããããããäœãæããŠããã®ããèŠããŠãããŠãã ããã
èŠçŽ ã®å¹ŸäœåŠçããããã£ãå€æŽããªãã§ãã ãã;å€æãšäžéæ床ããããã䜿çšããŠãã ããã
ãããšã¯å¥ã«ãèŠçŽ ã®èæ¯ãå€æŽãããšãã®ã¹ãããã«æ»ãããšã«ã泚æãã䟡å€ããããŸãã 圌ãã¯åžžã«ãããå¿ããŠããã®ã§ãå¥ã®æšå¥šäºé
ã§åŒ·èª¿ããŸãïŒ
èæ¯èŠçŽ ãå€æŽããªãã§ãã ããã
äžéšã®ãã©ãŠã¶ïŒ Firefoxã§æãçªãããšã¯ãããŸãã ïŒç¹ã«åäœæéãããè€æ°ã®ã¢ãã¡ãŒã·ã§ã³ãå®è¡ãããå Žåãå€æã䌎ãCSSã¢ãã¡ãŒã·ã§ã³ã®å
žåçãªé
ããçŸããããšããããŸãã å€èŠçã«ã¯ãããã¯åœŒå¥³ã®äœåã®äžæåæ¢ãšããŠã ãã§ãªããã¢ãã¡ãŒã·ã§ã³ã®æåã®éšåã®ãå
èš³ããšããŠãèŠãããããããŸããã ãã©ãŠã¶ã¯åžžã«äœããåèšç®ããŠããããã§ãã ãã®åäœã¯ãã»ãšãã©ã®å Žåã backface-visibilityããããã£ã䜿çšããŠä¿®æ£ãããŸãã
å¯èœã§ããã°ãã¢ãã¡ãŒã·ã§ã³åãããèŠçŽ ã«backface-visibilityïŒhiddenãè¿œå ããŸãã
ãŸããã¬ã€ã¢ãŠãã®åæ§ç¯ã¯ãã¹ã¯ãªããããã®èŠçŽ ã®åŒã³åºãã«ãã£ãŠåŒãèµ·ããããŸãã ããã«ãããã¯CSSãçŽæ¥ââå€æŽããå¿
èŠã¯ãªããèŠçŽ ã®äžéšã®ããããã£ãšã¡ãœããã«ã¢ããŒã«ããããšãã§ããŸãã æãäžè¬çãªãã®ã¯æ¬¡ã®ãšããã§ãã
offset*** client*** inner*** scroll***
ã¢ãã¡ãŒã·ã§ã³ã§ã¯ããããã«æ³šæããå¿
èŠããããŸãã å€æ°ã®èŠçŽ ã«ã€ããŠãããã®ããããã£ãšã¡ãœãããåç
§ãå§ãããšããã®ãã³ã«ã¬ã€ã¢ãŠããåæ§ç¯ãããŸãã
ã«ãŒãå
ã®åã
ã®èŠçŽ ã«ã€ããŠãåè¿°ã®ããããã£ãšã¡ãœãããåç
§ããããšã¯é¿ããŠãã ããã
ãã€ã³ããšã¬ã€ã€ãŒæ§æ
ããã2ã€ã®ã¹ããããäžç·ã«æ€èšããŸãã ãããã¯ããçšåºŠé¢é£ããŠãããéåžžãäžæ¹ã«åé¡ãããå Žåãããäžæ¹ã«ãåé¡ããããŸãã ãããã®æé ãã¹ãããããŠåé¿ããããšã¯æ©èœããªããããäœããã®æ¹æ³ã§æé©åãè©Šã¿ãŠããŸãã
ãã©ãŠã¶ã¯ããŒãžã®ãã¯ã»ã«ç»åãå
šäœã§ã¯ãªãéšåçã«-ã¬ã€ã€ãŒã§æºåããŸãã ãããããããããããŸããã åã¬ã€ã€ãŒã¯ãããèªäœãååšãããã®ããã«ååšããæ®ãã«åœ±é¿ãäžããŸãããããã«ãããäžéšã®CSSããã¯ã®åºç€ãäœæãããŸãã ããããç§ãã¡ã¯ãããã«ã€ããŠããäžåºŠè©±ããŸãã 次ã«ããããã®ã¬ã€ã€ãŒããæçµç»åãåéãããŸãã ã¢ãã¡ãŒã·ã§ã³ã®ã³ã³ããã¹ãã§ã¯ãã¢ãã¡ãŒã·ã§ã³èŠçŽ ãå¥ã®ã¬ã€ã€ãŒã«é
眮ããŠããããã®å€æŽãåšå²ã®ãã¹ãŠã«åœ±é¿ããªãããã«ããããšãéåžžã«äŸ¿å©ã§ãã èŠçŽ ã®å
容ã¯å°ããããšãæãŸããã ãããè¡ãã«ã¯ã will-changeããããã£ã䜿çšãããã以åã®ããã«transformïŒtranslateZïŒ0ïŒã䜿çšããŸãã èŠããŠããã¹ãå¯äžã®ããšã¯ãã¬ã€ã€ãŒã®æ°ãç¡å¶éã«å¢ããããšã¯ã§ããªããšããããšã§ãã ããæç¹ã§ãããã¯ããªãã¯ãæãããå察ã®ããã©ãŒãã³ã¹ãäœäžããŸãã ãããã£ãŠã2ã€ã®ãã³ãããããŸãã
will-changeãŸãã¯transformïŒtranslateZïŒ0ïŒã䜿çšããŠãã¢ãã¡ãŒã·ã§ã³åãããèŠçŽ ãå¥ã®ã¬ã€ã€ãŒã«ç§»åããŸãã
ãããåæã«
ãã®ããžãã¹ã§ç¡çãããªãã§ãã ããã æªåããŠããªãããšãéçºè
ããŒã«ã§ç¢ºèªããŠãã ããã
éåžžã«å€ãã®å Žåãæ·±å»ãªåé¡ã¯ãäœããã®æ¹æ³ã§èŠçŽ ã®ç»åãå€æãããã£ã«ã¿ãŒã«ãã£ãŠåŒãèµ·ããããŸãã ãŒããã䜿çšããåçŽãªCSSãã£ã«ã¿ãŒãSVGãšã®æ··ä¹±ãããªãã·ã§ã³ã䜿çšã§ããŸãããå¹æã¯åãã«ãªããããã©ãŒãã³ã¹ãèããäœäžããŸãã
è€éãªãã£ã«ã¿ãŒã䜿çšããªãã§ãã ããã ããã§ãæå³ããå¹æãå¿
èŠãªå Žåã¯ãWebGLã«å®è£
ããããšãæ€èšããŠãã ããã
ãããã®ãã³ãã¯ã©ã®ããã«æ©èœããŸããïŒ
ãããã¯æ©èœããŸãããå¥è·¡ãæåŸ
ããå¿
èŠã¯ãããŸããã ãããäžã§ã¯ãåå¿è
ããæå¿ã®å€æŽãå ããŸããããäœãå€ãã£ãŠããŸããããšèšãããšããããŸãã éåžžãããã¯ãäž»ãªåé¡ãå¥ã®å Žæã«ãã£ãããšãæå³ãããã®ææ³ã¯ãæ°ä»ãããªãã»ã©çç£æ§ã®ããããªå¢å ããããããŸããã ãã®ãããéçºè
ã®ããŒã«ã䜿çšããŠããã«ããã¯ãã©ãã«ããããæ£ç¢ºã«ææ¡ããæ£åžžã«æ©èœããŠãããã®ãæé©åããããã®æéãšåŽåãç¡é§ã«ããªãããšãéèŠã§ãã
ããããã¹ãŠãããããŒãžã®ã¬ã³ããªã³ã°ã«åœ±é¿ãäžããæ¹æ³ã¯å€ããªãããããã®å¹æã¯å¿
ãããéèŠã§ã¯ãªããšçµè«ä»ããããšãã§ããŸãã ãããã®ããªãã¯ã¯ç¹å¹è¬ã§ã¯ãªããã¢ãã¡ãŒã·ã§ã³ã磚ãããã«å¿
èŠã§ãã ããã©ãŒãã³ã¹ãéåžžã«äœããµã€ããèŠããšãã»ãšãã©ã®å Žåãç§ãã¡èªèº«ã®ã¹ã¯ãªãããåå ã§ããããã©ãŠã¶ãŒã®è
žã®ã©ããã§ã®CSS解æã®äžå¯è§£ãªåé¡ã§ã¯ãªãããšã«æ°ä»ãã§ãããã
ã¹ã¯ãªãã...
æå¶ã¢ãã¡ãŒã·ã§ã³ã®åé¡ãæãé »ç¹ã«çºçããå Žæãç¥ã£ãŠããŸããïŒç§ã®èŠ³å¯ã«ãããšïŒã ãã®éçºã¢ãããŒãããïŒ
銬鹿ããŠããããã«èãããŸãããããã§ãã äœãèµ·ãã£ãŠããã®ããç解ããããšãªããæããã«ã©ããããå®å
šã«ã³ããŒããããœãªã¥ãŒã·ã§ã³ãåžžã«ãããŸãã ã³ãŒãã®ååãåé€ããŠãããã¹ãŠãæ©èœãç¶ããå ŽåããããŸãã å€ãã®å ŽåãSOãŸãã¯Toasterã«å¯Ÿããåçã®ã³ãŒãã¯ãæ¬çªçšã§ã¯ãããŸããã ããã¯æãããªã¯ãã§ãã 圌ã¯ã¢ã€ãã¢ã瀺ãã質åã«çããŸãããç¹å®ã®ã¿ã¹ã¯ã«æé©ãªæçµãªãã·ã§ã³ã§ã¯ãããŸããã
ãã§ã«ã³ããŒããŠããå Žåã¯ãå°ãªããšãäžå¿
èŠãªã¢ã¯ã·ã§ã³ã®ã³ãŒããèŠãŠãã ããã
RequestAnimationFrame
圌ãã¯ãããã®æ¹æ³ã«ã€ããŠè©±ããã¢ãã¡ãŒã·ã§ã³ã§setTimeout / setIntervalã®ä»£ããã«äœ¿çšããããšãæšå¥šããŸã ã ããã¯çã«ããªã£ãŠããŸãããããã®ã¡ãœããã¯ããã©ãŠã¶ãåæç»ãããã¬ãŒã ãšåæãåããªãåŸåããããå°ããªé
延ãçºçããããã§ãã ãããã2ã€ã®ãã€ã³ãããããŸãã
ãŸããããŒãžã§è€æ°ã®èŠçŽ ãã¢ãã¡ãŒã·ã§ã³åãããrequestAnimationFrameãäœåºŠãåŒã³åºããšãfpsãæ¥æ¿ã«æ²äžããŸãã çè«çã«ã¯ãããã¯ãã¹ãã§ã¯ãããŸããããå®éã«ã¯ããã¹ãŠããã®ããã«èµ·ãããŸãã ããã§ãã¹ãã«æ
£ããããšãã§ããŸã ã
ãã¹ãŠã®ã¢ãã¡ãŒã·ã§ã³ã³ãŒã«ããã¯ã1ã€ã®requestAnimationFrameã«çµåããŸãã
2çªç®ã®ãã€ã³ãã¯ããããããã£ã³ãã¹ã䜿çšããŠéãã¢ãã¡ãŒã·ã§ã³ããã§ã«æã£ãŠããç¶æ³ã«é¢é£ããŠããå¯èœæ§ãé«ãããããããã£ã³ãã¹ã䜿çšãããããŸãã¯ããçŽãæéããªãããã次ã®ããšãèµ·ãããŸãïŒ ããããçŸåšã®ç¶æ
ãèšç®ããã«ã¯å€ãã®ãªãœãŒã¹ãå¿
èŠã§ãããã®å³ãèŠããšãã¢ãã¡ãŒã·ã§ã³ã¯ã¹ã ãŒãºã«ãçŸããã2Nç§ãããã«ã¯3Nç§ã§åäœããŸãã ãã®çµæããã¹ãŠããã£ããç¥èŠãããŸãã ãã®åäœãäœããã®æ¹æ³ã§ä¿®æ£ããããã«ããã¹ãŠã®æšå¥šäºé
ã«åããããšãã§ããŸããããã«ããã setInterval / setTimeoutã䜿çšããã¢ãã¡ãŒã·ã§ã³åãããèŠçŽ ã®ç¶æ
ãæœè±¡ãã¬ãŒã ã§ã¯ãªãç©çæéã«ãã€ã³ãããŸãã ãã®çµæãfpsã¯æ£åŒã«æžå°ããŸãããçç£æ§ãåäžãããšããå¿ççãªåœ±é¿ããããŸãã
極端ã«é
ãã¢ãã¡ãŒã·ã§ã³ã®å ŽåãsetInterval / setTimeoutãåªå
ããŠrequestAnimationFrameãæåŠããããšã¯çã«ããªã£ãŠããŸãã
ãã£ã³ãã¹ãšã·ã§ãŒããŒ
éæšæºãµã€ãã®ã¢ãã¡ãŒã·ã§ã³ã®å€§éšåã¯ããã£ã³ãã¹ã«é¢é£ããŠããŸãã ããã¯ç解ã§ããããšã§ãããCSSã¯éããããã®ã§ãããããã§ã¯ãã¶ã€ããŒã®ç©ºæ³ãå®çŸã§ããŸãã ãã ããéåžžã®2Dãã£ã³ãã¹ã¯æãçç£çãªæè¡ãšã¯ã»ã©é ãããšã«çæããå¿
èŠããããŸãã ãã®äžã«å€ãã®èŠçŽ ãæç»ãããããã¯ã»ã«ãçŽæ¥æäœããããããšãfpsãæ²ãã§ãããšããäºå®ã«ããã«æ°ä»ããããŸãã¯çªç¶ãã€ã³ããšã¬ã€ã€ãŒã®åæã«ããªãã®æéããããããã«ãªããŸãã ãã®åé¡ã¯ãäŸã§æ確ã«ç¢ºèªã§ããŸãã
ãã©ãŠã¶ã®æ©èœãèŠãŠã¿ãŸãããïŒLinuxã§ã®ææ°ã®Google ChromeïŒïŒ
ã¬ã€ã€ãŒæ§æã¹ããããã©ãã ãæ¡å€§ãããã«æ³šç®ããŠãã ããã èŠçŽ ã1ã€ãããªãã®ã§ãå°ãéè«ççã«èŠããŸãããããã«äœãé·ãçµã¿ç«ãŠãããã®ã§ããããã ãããã2Dãã£ã³ãã¹ã䜿çšããå Žåããã®åäœã¯çãããªãããããšé¢ä¿ãããããšã¯éåžžã«åé¡ããããŸãã ãããWebGLã䜿çšããåŸåãããçç±ã®1ã€ã§ããããã®ãããªè³ªåã¯ãããŸããã
2Dãã£ã³ãã¹ãšWebGLãéžæã§ããå Žåã¯ã2çªç®ãéžæããŸãã ããã«ãããåãã¿ã¹ã¯ã§åæããã©ãŒãã³ã¹ããŒãã¹ãåŸãããŸãã
éåžžãWebGLã«ã¯äœãé¢é£ä»ããããŠããŸããïŒ ã·ã§ãŒããŒä»ãã ãããŠãã·ã§ãŒããŒã®ãããã°ã¯ãã·ã§ãŒããŒã§äœæ¥ãã人ã«ãšã£ãŠã¯é çã®çš®ã§ãã ãããŠãããã®éçºè
ããŒã«ã¯å®è³ªçã«ç¡åã§ãã éåžžãã·ã§ãŒããŒã®èšç®ãå€ãããå Žåãã»ãšãã©ã®æéã¯ãåçŽãã§ããããšãäžã®èŠçŽã§ããããŸããããã¯å®éããã©ãŠã¶ãŒã«é¢ä¿ãªãã·ã§ãŒããŒãå®è¡ãããããæçšãªè©³çŽ°ãååŸããããšã¯ã§ããŸããã
ã·ã§ãŒããŒã§ã¯ä»ã®æ©èœãããã©ã®æ©èœãåªå
ãããã«ã€ããŠãããŸããŸãªæšå¥šäºé
ããããŸãããããã®æ©èœã¯ããããããæé©åãããŠããããã§ãã ãŸãã¯ããã®ããããã³ã°æäœãé¿ããå¿
èŠããããŸãã ããã¯ãã¹ãŠçå®ã§ãããç§ã®èŠ³å¯ã«ãããšãã»ãšãã©ã®å Žåããµã€ããé
ãããããã·ã§ãŒããŒã¯éåžžã«å€§ããªã·ã§ãŒããŒã§ãã 1ã€ã®å Žæã§100ã®GLSLè¡ãèšè¿°ããå Žåãããã¯ã»ãšãã©åäœããªãããšãä¿èšŒãããŠããŸãã ãŸããããŸããŸãªãã¹ããããæ§é ãã«ãŒãããããŠãã¹ãŠãããå Žåãæžã蟌ã¿ã¯ãªããªããŸãã 以äžãé€ããããã§æšå¥šäºé
ãäœæããããšã¯å°é£ã§ãã
äœæ¥äžã«ãã¹ãŠãåœåã®ããã«è€éã§ãããå€ãã®ã³ãŒããååšããé床ãäœäžããããšã«æ°ä»ããå Žåã¯ãã§ããã ãæ©ããã¶ã€ããŒãšé¡§å®¢ãšè©±ãåããäœãå€æŽã§ããããèããæ¹ãããã§ãããã
äºåã«æºåããããããªã¯ãããçš®ã®æ··ä¹±ãããã®ããªã¢ã«ã¿ã€ã ã§ã¬ã³ããªã³ã°ããããšãããããã¯ããã«ããŸãæ©èœãããšããçµè«ã«è³ãããšããããããŸãã ãããèŠããŠã ã¯ãã誰ããèªåãèŠããããšæã£ãŠããŸãããããããç§ã¯ãã®ããã«ã§ããŸãããšèªæ
¢ãããã®ã§ããããšã³ããŠãŒã¶ãŒãå¿ããªãã§ãã ããã
ãã®èãã«é¢é£ããŠãåãªãªã³ãã¢ãŒããç¹ã«åœ±é¿ãåãããããç
æ°ããæãåºããŸãã äœããã®çç±ã§ãcanvasã§äœæ¥ãããšãã«åŒ·ãçŸããŸãã ãã®ããããã®ãããªäººã
ã®ã³ãŒãã¯åžžã«æ
éã«ã³ããŒããå¿
èŠããããŸãã 圌ãã¯ãæ£ãããæ°åŠã¢ã«ãŽãªãºã ãè€éãªç©çåŒã䜿çšããŠãå®å
šã«åœ¹ã«ç«ããªãå Žåã§ããèŠçŽ ã®ãã¹ãŠã®åããéåžžã«æ£ç¢ºã«èšç®ããããšããŸãã ããã«ãããããã»ããµã®è² è·ãå¢å ããæ¡ä»¶ä»ã10ããªç§ã§ã¯äœãã«ãŠã³ãããæéããããŸããã å®éã«ã¯ãããããã®åŒãšç©çåŠã®åŠæ ¡ã®ç¥èãç¿åŸã§ããŸãã ç©äºãè€éã«ããå¿
èŠã¯ãããŸããã匟éããµã€ã«çšã®ãœãããŠã§ã¢ã§ã¯ãªãããŠã§ããµã€ããäœæããŸãã
åçŽãªã¢ã«ãŽãªãºã ã䜿çšããŸãã
RayMarchingãšåŒã°ããå¥ã®ããªãã¯ããããŸãã äžéšã®äººã
ã¯ãããã«ããããŸããŸãªå¹æã®äœæãææŠãå¿ã®ãŠã©ãŒã ã¢ããã®ãããªãã®ãšèããæã«ã¯çµæã¯éåžžã«å°è±¡çã§ãã ããšãã°ãããã§ã¯æ°Žäžã®äžçå
šäœãçæãããŸãïŒããããªã¢ã«ã¿ã€ã ã§èšç®ãããšãé»è©±/ã©ãããããããã³ã°ã¢ããããå¯èœæ§ãããããããããªãæ¿å
¥ããŸããïŒã
ã·ã§ãŒããŒèªäœã¯ããã«ãããŸã ã
å®éã«ã¯ãããããã¹ãŠãæ©èœãããã«ã¯ä¿¡ããããªãã»ã©ã®ãªãœãŒã¹ãå¿
èŠã§ãã ãã«ã¹ã¯ãªãŒã³ã¢ãŒãã§ã¯ããã¬ãŒã ããšã«400ã800ããªç§ããããŸãïŒäžè¬ã«ããã®äŸã§ã¯æ倧1500ããªç§ã«ãªããŸãïŒã
ãã®ãããæŠéãµã€ãã§ãã®ãããªããšãããããšèããŠããå Žåã¯ãé ã«ããŒããŒããä»ãããè¶ã飲ã¿ãå¹æãå®è£
ããããã®ä»£æ¿ãªãã·ã§ã³ã«ã€ããŠèããŠãã ããã
RayMarchingã䜿çšããªãã§ãã ãããããã¯ããã©ãŒãã³ã¹ãäœäžããã確å®ãªæ¹æ³ã§ãã
å®çšäŸ
ããã©ãŒãã³ã¹ã®èšäºã«ã¯ååãªäŸããªãããšããããããŸãããäžèšã§èšãã®ã¯é£ããå ŽåããããŸãã ããã€ãèããŠã¿ãŠãã ããã æåã®CSSå転ãã³ãã«ã®äŸãèŠããŠããŸããïŒ ãã©ãŠã¶ã¯å€ãã®ããšãè¡ããŸããïŒ
å°ãã¹ããŒãã¢ãããããã§ãã ã©ãããå§ããŸããïŒ çŽ«è²ã®ãããã¯ã衚瀺ãããŸããã€ãŸãããã©ãŠã¶ãŒã¯åžžã«ã¬ã€ã¢ãŠããåæ§ç¯ããŠããŸãã ã¹ã¯ãªããã¯ãããŸããããäœããå€åããCSSã¢ãã¡ãŒã·ã§ã³ããããŸãã ã³ãŒããèŠãŠã¿ãŸãããã
@keyframes rotate { from { transform: rotate(0); } to { transform: rotate(360deg); } } @keyframes move-block { from { transform: translateX(0); background: @color1; } to { transform: translateX(-@block-size * 6); background: @color2; } }
å€æã¯ç§ãã¡ãæããããŸããããèŠçŽ ã®èæ¯ã«å€åãèŠãããŸãã ãããã¬ã€ã¢ãŠãã®åæ§ç¯ãåŒãèµ·ããå¯èœæ§ãããããšãæãåºãããã®ç¶æ³ã§äœãã§ããããèããŸã...
èæ¯ã®å€æŽã¯ãã¹ãŠã®ã³ã¹ãã§åé€ããå¿
èŠããããããã¢ãã¡ãŒã·ã§ã³ã®äžè¬çãªèãæ¹ã«åºã¥ããŠãæŸå°ç¶ã®ã°ã©ããŒã·ã§ã³ãäžéšã«é
眮ãããšãã»ãŒåãããªã¥ãŒã å¹æãåŸããããšå€æããŸãã åŸé
ã¯ããã©ãŒãã³ã¹ã«æªã圱é¿ãäžãããšèšã人ãããŸãããå€æŽããã€ããã¯ãããŸããã ç§ãã¡ã絶ããæªåœ±é¿ãäžããèŠçŽ ã®å±±å
šäœãåŸããããããããæªåœ±é¿ãäžããããããæ¹åããŸãããã çµæã¯æ¬¡ã®ãšããã§ãã
ãã©ãŠã¶ã®æ©èœãèŠãŠã¿ãŸãããã
ãã...ããããã®ã¢ã¯ã·ã§ã³ã®ä»£ããã«ãGPUãžã®ãŸããªåŒã³åºãããããŸãããã¢ãã¡ãŒã·ã§ã³èªäœã¯èããã¹ã ãŒãºã«åäœãå§ããŸããã
å¥ã®äŸ
ãã€ãºãžã§ãã¬ãŒã¿ãŒã®ãã©ãŠã¶ãŒã®æ§åãæãåºããŠãã ããã
åé¡ã¯ééããªãã¹ã¯ãªããã«ãããŸãã ãã¬ã³ããªã³ã°ããããã¯ãæ倧ã§ããããšãããããŸãã ããã¯ãç»åãã¬ã³ããªã³ã°ããããã®äž»ãªæ©èœã§ãã 圌女ãèŠãŠã¿ãŸãããïŒ
function render() { let imageData = CTX.createImageData(CTX.canvas.width, CTX.canvas.height); for (let i = 0; i < imageData.data.length; i += 4) { const color = getRandom(); imageData.data[i] = color; imageData.data[i + 1] = color; imageData.data[i + 2] = color; imageData.data[i + 3] = 255; } CTX.putImageData(imageData, 0, 0); requestAnimationFrame(render); }
åã
ã®ãã¯ã»ã«ã§é²è¡äžã®äœæ¥ã¯ééããªããããŸãã ããã¯ããŸãå¥åº·çã§ã¯ãããŸããã å¯èœã§ããã°ã2Dãã£ã³ãã¹ã§ã¯ãªãWebGLã䜿çšããæ¹ãè¯ããšèšããŸããããã®ã¿ã¹ã¯ã¯ãã·ã§ãŒããŒã䜿çšããŠäžŠååãããã ãã§ãã ãã£ãŠã¿ãŸãããïŒ
çµæã¯ã©ããªããŸããïŒ èªåã§èŠãŠãã ããïŒ
1ãã¬ãŒã ã®æéã¯ã»ãŒ16msã«æžå°ããŸããã ãã¡ãããããã¯çæ³çã§ã¯ãããŸããããããã§ã80msãããåªããŠããŸãã è€éã§çŸããã¢ãã¡ãŒã·ã§ã³ã§ã¯ããã®ãããªããã©ãŒãã³ã¹ã®åäžã¯éåžžã«é¡èã§ãã ãã®æ©äŒãå©çšããŠãåå¿è
ãããã°ã©ãã³ã°ã§ã®ã·ã§ãŒããŒã®å°å
¥ ãšäŸã®ç¶ãã«æ
£ããããšããå§ãããŸãã
ãããã«
ãã®èšäºã§ã¯ãã¢ãã¡ãŒã·ã§ã³ããã©ãŒãã³ã¹ã®æé©åããã®ã³ã³ããã¹ãã§ã®Chromeã®éçºè
ããŒã«ã®äœ¿çšæ¹æ³ãæåã«æ¢ãã¹ãããšãææ¡ããŸããã ãã®æ
å ±ãããã®ãããªã¿ã¹ã¯ã«åããŠçŽé¢ããã©ãããå§ããã°ãããããããªãéçºè
ã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸãã