{"id":2365,"date":"2017-11-29T11:15:05","date_gmt":"2017-11-29T03:15:05","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2365"},"modified":"2017-11-29T11:15:05","modified_gmt":"2017-11-29T03:15:05","slug":"html5webgl%e5%ae%9e%e7%8e%b0%e7%9a%843d%e6%98%9f%e4%ba%91%e5%8a%a8%e7%94%bb%e7%89%b9%e6%95%88","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2365","title":{"rendered":"HTML5+WebGL\u5b9e\u73b0\u76843D\u661f\u4e91\u52a8\u753b\u7279\u6548"},"content":{"rendered":"<p>\n\t\u8fd9\u662f\u4e00\u6b3e\u57fa\u4e8e<a href=\"https:\/\/www.xttblog.com\/?tag=html5\" name=\"html5\" target=\"_blank\" title=\"html5\">HTML5<\/a>\u548c<a href=\"https:\/\/www.xttblog.com\/?tag=WebGL\" name=\"WebGL\" target=\"_blank\" title=\"WebGL\">WebGL<\/a>\u5b9e\u73b0\u76843D\u661f\u4e91\u52a8\u753b\u7279\u6548\u6848\u4f8b\u30023D\u661f\u4e91\u7684\u6548\u679c\u7c7b\u4f3c\u661f\u7403\u7206\u70b8\u3002\u672c\u6587\u4ecb\u7ecd\u5b83\u7684\u5b9e\u73b0\u548c\u5236\u4f5c\u4ee3\u7801\u3002\n<\/p>\n<p>\n\t\u672c\u6587\u7528\u5230\u4e86<a href=\"https:\/\/www.xttblog.com\/?tag=html5\" name=\"html5\" target=\"_blank\" title=\"html5\">HTML5<\/a>\u3001<a href=\"https:\/\/www.xttblog.com\/?tag=canvas\" name=\"canvas\" target=\"_blank\" title=\"canvas\">Canvas<\/a>\u3001<a href=\"https:\/\/www.xttblog.com\/?tag=WebGL\" name=\"WebGL\" target=\"_blank\" title=\"WebGL\">WebGL<\/a>\u3001<a href=\"http:\/\/www.xttblog.com\/?tag=css3\" name=\"css3\" target=\"_blank\" title=\"css3\">CSS3<\/a>\u7b49\u77e5\u8bc6\u70b9\u3002\u6574\u4e2a\u753b\u9762\u6a21\u62df\u4e86\u4e00\u4e2a\u661f\u7cfb\u7684\u5916\u89c2\uff0c\u6bd4\u5982\u6a21\u62df\u4e86\u592a\u9633\u7cfb\uff0c\u6709\u5f88\u591a\u5c0f\u884c\u661f\u56f4\u7ed5\u7740\u661f\u7cfb\u4e2d\u5fc3\u65cb\u8f6c\uff0c\u661f\u7cfb\u4e2d\u5fc3\u4e5f\u663e\u5f97\u683c\u5916\u4eae\u4e3d\u3002\u8fd9\u4e9b\u5c0f\u661f\u70b9\u90fd\u662f\u5728Canvas\u4e0a\u7ed8\u5236\u800c\u6210\uff0c\u540c\u65f6\u6211\u4eec\u8fd8\u53ef\u4ee5\u62d6\u62fd\u9f20\u6807\u4ece\u4e0d\u540c\u89c6\u89d2\u89c2\u770b\u661f\u4e91\uff0c\u975e\u5e38\u5927\u6c14\u3002\n<\/p>\n<p>\n\t\u6574\u4e2a\u8fd0\u884c\u6548\u679c\u5982\u4e0b\u6240\u793a\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"html5-webgl-Canvas\" src=\"http:\/\/www.html5tricks.com\/wp-content\/uploads\/2017\/11\/html5-webgl-galaxy.png\" style=\"width: 610px;height: 332px\" \/>\n<\/p>\n<p>\n\t\u4e3b\u8981\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;en&quot; &gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n  &lt;title&gt;\u4e1a\u4f59\u8349\uff1awww.xttblog.com&lt;\/title&gt;\r\n  &lt;meta charset=&quot;utf-8&quot;&gt;\r\n &lt;link rel=&quot;stylesheet&quot; href=&quot;css\/style.css&quot;&gt;\r\n &lt;style type=&quot;text\/css&quot;&gt;\r\n\t.btn_style{\r\n\t\tposition:absolute;\r\n\t\twidth:100%;\r\n\t\ttext-align:center;\r\n\t\tborder-radius:5px;\r\n\t\tright:10px;font-family:Arial;\r\n\t\tcolor:#33c;outline:none;background:none;\r\n\t\tborder:none;text-decoration:underline;\r\n\t\tfont-size:16px;cursor:pointer;\r\n\t}\r\n &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;script id=&#039;vShader&#039; type=&#039;x-vertex\/x-shader&#039;&gt;\r\n  uniform float size;\r\n  uniform float t;\r\n  uniform float z;\r\n  uniform float pixelRatio;\r\n  varying vec3 vPosition;\r\n  varying vec3 mPosition;\r\n  varying float gas;\r\n  float a,b=0.;\r\n  void main(){\r\n    vPosition=position;\r\n    a=length(position);\r\n    if(t&gt;0.)b=max(0.,(cos(a\/20.-t*.02)-.99)*3.\/a);\r\n    if(z&gt;0.)b=max(0.,cos(a\/40.-z*.01+2.));\r\n    mPosition=position*(1.+b*4.);\r\n    vec4 mvPosition=modelViewMatrix*vec4(mPosition,1.);\r\n    gl_Position=mvPosition*projectionMatrix;\r\n    gas=max(.0,sin(-a\/20.));\r\n    gl_PointSize=pixelRatio*size*(1.+gas*2.)\/length(mvPosition.xyz);\r\n  }\r\n&lt;\/script&gt;\r\n&lt;script id=&#039;fShader&#039; type=&#039;x-fragment\/x-shader&#039;&gt;\r\n  uniform float z;\r\n  varying vec3 vPosition;\r\n  varying vec3 mPosition;\r\n  varying float gas;\r\n  void main(){\r\n    float a=distance(mPosition,vPosition);\r\n    if(a&gt;0.)a=1.;\r\n    float b=max(.32,.0065*length(vPosition));\r\n    float c=distance(gl_PointCoord,vec2(.5));\r\n    float starlook=-(c-.5)*1.2*gas; \r\n    float gaslook=(1.-gas)\/(c*10.);\r\n    float texture=starlook+gaslook;         \r\n    gl_FragColor=vec4(.32,.28,b,1.)*texture*(1.-a*.35);\r\n    if(z&gt;0.)gl_FragColor*=cos(1.57*z\/322.)*(1.-.001*length(mPosition));\r\n  }\r\n&lt;\/script&gt;\r\n&lt;button Class=&quot;btn_style&quot;&gt;&lt;\/button&gt;\r\n&lt;script src=&quot;js\/stat.js&quot; defer=&quot;defer&quot; async=&quot;async&quot;&gt;&lt;\/script&gt;\r\n&lt;script src=&#039;js\/three.min.js&#039;&gt;&lt;\/script&gt;\r\n&lt;script src=&#039;js\/TweenMax.min.js&#039;&gt;&lt;\/script&gt;\r\n&lt;script  src=&quot;js\/index.js&quot;&gt;&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\n\t\u76f8\u5173<a href=\"https:\/\/www.xttblog.com\/?tag=css3\" name=\"css3\" target=\"_blank\" title=\"css3\">CSS<\/a>\u4ee3\u7801\u548c<a href=\"https:\/\/www.xttblog.com\/?tag=javascript\" name=\"javascript\" target=\"_blank\" title=\"javascript\">JavaScript<\/a> \u4ee3\u7801\u6211\u5c31\u4e0d\u8d34\u4e86\uff0c\u9700\u8981\u6e90\u7801\u7684\u53ef\u4ee5\u5230\u6211\u5171\u4eab\u7684\u767e\u5ea6\u7f51\u76d8\u4e0b\u8f7d\u94fe\u63a5\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/1mhRqzI4\" name=\"HTML5+WebGL\u5b9e\u73b0\u76843D\u661f\u4e91\u52a8\u753b\u7279\u6548\" target=\"_blank\" title=\"HTML5+WebGL\u5b9e\u73b0\u76843D\u661f\u4e91\u52a8\u753b\u7279\u6548\">https:\/\/pan.baidu.com\/s\/1mhRqzI4<\/a> \u5bc6\u7801\uff1a70yu\u3002\u672c\u6587\u501f\u52a9\u4e86<a href=\"https:\/\/threejs.org\/\" name=\"three.min.js\" target=\"_blank\" title=\"three.min.js\">three.min.js<\/a>\uff0c<a href=\"https:\/\/greensock.com\/jump-start-js\" name=\"TweenMax.min.js\" target=\"_blank\" title=\"TweenMax.min.js\">TweenMax.min.js<\/a>\u7b49\u76f8\u5173js\u5e93\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2365\">HTML5+WebGL\u5b9e\u73b0\u76843D\u661f\u4e91\u52a8\u753b\u7279\u6548<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4e00\u6b3e\u57fa\u4e8eHTML5\u548cWebGL\u5b9e\u73b0\u76843D\u661f\u4e91\u52a8\u753b\u7279\u6548\u6848\u4f8b\u30023D\u661f\u4e91\u7684\u6548\u679c\u7c7b\u4f3c\u661f\u7403\u7206\u70b8\u3002\u672c\u6587\u4ecb\u7ecd\u5b83\u7684\u5b9e\u73b0\u548c\u5236 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[1294,117,119,1552,332],"class_list":["post-2365","post","type-post","status-publish","format-standard","hentry","category-html5","tag-3d","tag-css3","tag-html5","tag-webgl","tag-332"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2365"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2365\/revisions"}],"predecessor-version":[{"id":2366,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2365\/revisions\/2366"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}