{"id":266000,"date":"2015-09-20T13:34:02","date_gmt":"2015-09-20T09:34:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266000"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266000","title":{"rendered":"BabylonJS. \u0423\u0440\u043e\u043a 3 \u2014 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b"},"content":{"rendered":"<p>       \u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u0442\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0448\u0438. \u041d\u043e \u043e\u043d\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043a\u0430\u043a-\u0442\u043e \u043c\u0440\u0430\u0447\u043d\u043e\u0432\u0430\u0442\u043e. \u0414\u0430\u0432\u0430\u0439 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430\u0434 \u0438\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0438\u0434\u043e\u043c. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/808\/619\/9cf\/8086199cfc184b67b8db679c2d98665a.png\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043c\u0435\u0448\u0430<\/b>  <\/p>\n<pre><code class=\"javascript\">var sphere1 = BABYLON.Mesh.CreateSphere(&quot;sphere1&quot;, 10.0, 9.0, scene); var materialSphere1 = new BABYLON.StandardMaterial(&quot;texture1&quot;, scene); materialSphere1.wireframe = true; sphere1.material = materialSphere1; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9f5\/28e\/974\/9f528e974a3a43d48e010f8d067c1543.png\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0444\u0435\u0440\u0435. \u0414\u0430\u0432\u0430\u0439 \u043e\u043a\u0440\u0430\u0441\u0438\u043c \u0435\u0451 \u0432 <b>\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u0438 \u043f\u0440\u0438\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438<\/b>:  <\/p>\n<pre><code class=\"javascript\">var sphere2 = BABYLON.Mesh.CreateSphere(&quot;sphere2&quot;, 10.0, 12.0, scene); var materialSphere2 = new BABYLON.StandardMaterial(&quot;texture2&quot;, scene); materialSphere2.diffuseColor = new BABYLON.Color3(1, 0, 0); materialSphere2.alpha = 0.3; sphere2.material = materialSphere2; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d21\/c52\/4a9\/d21c524a98024b54b531d21dc1bec743.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c\u0443 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0443 \u2014 <b>\u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435<\/b>. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0444\u0435\u0440\u043e\u0439:  <\/p>\n<pre><code class=\"javascript\">var sphere3 = BABYLON.Mesh.CreateSphere(&quot;sphere3&quot;, 10.0, 11.0, scene); var materialSphere3 = new BABYLON.StandardMaterial(&quot;texture3&quot;, scene); materialSphere3.diffuseTexture = new BABYLON.Texture(&quot;t1.jpg&quot;, scene); sphere3.material = materialSphere3; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fa8\/8e6\/ef8\/fa88e6ef80fe485aa0fccedb064f6346.png\"\/><\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435, \u0442\u044b \u043c\u043e\u0436\u0435\u0448\u044c <b>\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e<\/b>. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0439 \u0441\u0444\u0435\u0440\u043e\u0439:  <\/p>\n<pre><code class=\"javascript\">var sphere4 = BABYLON.Mesh.CreateSphere(&quot;sphere4&quot;, 10.0, 5.0, scene); var materialSphere4 = new BABYLON.StandardMaterial(&quot;texture4&quot;, scene); materialSphere4.diffuseTexture = new BABYLON.Texture(&quot;t1.jpg&quot;, scene); materialSphere4.diffuseTexture.vOffset = 0.6; \/\/ 60% materialSphere4.diffuseTexture.uOffset = 0.4; \/\/ 40% sphere4.material = materialSphere4; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/2bd\/cbd\/ba0\/2bdcbdba040a4fb2b79cecfd0f7bd60f.png\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0444\u0435\u0440\u0435. \u0415\u0441\u043b\u0438 \u0442\u0432\u043e\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0438\u043c\u0435\u0435\u0442 <b>\u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b<\/b>, \u0438 \u0442\u044b \u0445\u043e\u0447\u0435\u0448\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u043e\u0439 \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b\u0430 \u0431\u044b\u043b \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 hasAlpha \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 true. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0442\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b false, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0440\u043d\u044b\u0439 \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u0441\u043b\u043e\u0439:  <\/p>\n<pre><code class=\"javascript\">var sphere5 = BABYLON.Mesh.CreateSphere(&quot;sphere5&quot;, 10.0, 12.0, scene); var materialSphere5 = new BABYLON.StandardMaterial(&quot;texture5&quot;, scene); materialSphere5.diffuseTexture = new BABYLON.Texture(&quot;t2.png&quot;, scene); materialSphere5.diffuseTexture.hasAlpha = true; sphere5.material = materialSphere5; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fa3\/d80\/d9f\/fa3d80d9fb4c4f5985c52eee3b188256.png\"\/><\/p>\n<p>  <a href=\"http:\/\/digitalhilsone.pw\/babylonjs\/l3.html\">\u041f\u0440\u0438\u043c\u0435\u0440 |<\/a><a href=\"http:\/\/digitalhilsone.pw\/babylonjs\/source\/l3.zip\"> \u0421\u043e\u0440\u0446\u044b<\/a><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0438\u0436\u043e\u043a \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0441 \u043a\u0430\u043a\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c &lt;canvas&gt; \u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \t\t\tvar canvas = document.querySelector(&quot;#renderCanvas&quot;); \t\t\tvar engine = new BABYLON.Engine(canvas, true); \t\t\t\/\/ ------------------------------------------------------------- \t\t\t\/\/ \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0446\u0435\u043d\u044b. \u0418 \u043e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0435\u0451 \u0432 \u0431\u0435\u043b\u044b\u0439 \u0446\u0432\u0435\u0442 \t\t\tvar createScene = function (){ \t\t\t\tvar scene = new BABYLON.Scene(engine); \t\t\t\tscene.clearColor = new BABYLON.Color3(1, 1, 1); \t\t\t\/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u0430\u043c\u0435\u0440\u0443 \t\t\tvar camera = new BABYLON.FreeCamera(&quot;camera1&quot;, new BABYLON.Vector3(0, 5, -10), scene); \t\t\t\tcamera.setTarget(BABYLON.Vector3.Zero()); \t\t\t\tcamera.attachControl(canvas, false); \t\t\t\/\/ \u041e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \t\t\tvar light = new BABYLON.HemisphericLight(&quot;light1&quot;, new BABYLON.Vector3(0, 1, 0), scene); \t\t\t\tlight.intensity = 0.5; \t\t\t\/\/ \t\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043c\u0435\u0448\u0430 \t\t\tvar sphere1 = BABYLON.Mesh.CreateSphere(&quot;sphere1&quot;, 10.0, 9.0, scene); \t\t\tvar materialSphere1 = new BABYLON.StandardMaterial(&quot;texture1&quot;, scene); \t\t\tmaterialSphere1.wireframe = true; \t\t\tsphere1.material = materialSphere1; \t\t\t\/\/ \u041d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \t\t\tvar sphere2 = BABYLON.Mesh.CreateSphere(&quot;sphere2&quot;, 10.0, 12.0, scene); \t\t\tvar materialSphere2 = new BABYLON.StandardMaterial(&quot;texture2&quot;, scene); \t\t\tmaterialSphere2.diffuseColor = new BABYLON.Color3(1, 0, 0); \t\t\tmaterialSphere2.alpha = 0.3; \t\t\tsphere2.material = materialSphere2; \t\t\t\/\/ \u041d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \t\t\tvar sphere3 = BABYLON.Mesh.CreateSphere(&quot;sphere3&quot;, 10.0, 12.0, scene); \t\t\tvar materialSphere3 = new BABYLON.StandardMaterial(&quot;texture3&quot;, scene); \t\t\tmaterialSphere3.diffuseTexture = new BABYLON.Texture(&quot;one.png&quot;, scene); \t\t\tsphere3.material = materialSphere3; \t\t\t\/\/ \u041d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0441 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c  \t\t\tvar sphere4 = BABYLON.Mesh.CreateSphere(&quot;sphere4&quot;, 10.0, 12.0, scene); \t\t\tvar materialSphere4 = new BABYLON.StandardMaterial(&quot;texture4&quot;, scene); \t\t\tmaterialSphere4.diffuseTexture = new BABYLON.Texture(&quot;one.png&quot;, scene); \t\t\tmaterialSphere4.diffuseTexture.vOffset = 0.6; \/\/ 40% \t\t\tmaterialSphere4.diffuseTexture.uOffset = 0.4; \/\/ 60% \t\t\tsphere4.material = materialSphere4; \t\t\t\/\/ \u041d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0441 \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b\u043e\u043c \t\t\tvar sphere5 = BABYLON.Mesh.CreateSphere(&quot;sphere5&quot;, 10.0, 12.0, scene); \t\t\tvar materialSphere5 = new BABYLON.StandardMaterial(&quot;texture5&quot;, scene); \t\t\tmaterialSphere5.diffuseTexture = new BABYLON.Texture(&quot;two.png&quot;, scene); \t\t\tmaterialSphere5.diffuseTexture.hasAlpha = true; \t\t\tsphere5.material = materialSphere5; \t\t\t\/\/ \u041f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \t\t\tsphere1.position.x = 0; \t\t\tsphere2.position.x = 20; \t\t\tsphere3.position.x = 40; \t\t\tsphere4.position.x = 60; \t\t\tsphere5.position.x = 80;  \t\t\treturn scene; \t\t\t}; \t\t\t\/\/ ------------------------------------------------------------- \t\t\t\/\/ \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443, \u0447\u0442\u043e \u0441\u0446\u0435\u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0451 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \t\t\tvar scene = createScene(); \t\t\tengine.runRenderLoop(function (){ \t\t\t\tscene.render(); \t\t\t}); \t\t\t\/\/ \u041c\u0430\u0441\u0448\u0430\u0431\u0438\u0440\u0443\u0435\u043c \u0441\u0446\u0435\u043d\u044b \u043f\u043e\u0434 \u043b\u044e\u0431\u044b\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \t\t\twindow.addEventListener(&quot;resize&quot;, function (){ \t\t\t\tengine.resize(); \t\t\t}) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/267261\/\"> http:\/\/habrahabr.ru\/post\/267261\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u0442\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0448\u0438. \u041d\u043e \u043e\u043d\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043a\u0430\u043a-\u0442\u043e \u043c\u0440\u0430\u0447\u043d\u043e\u0432\u0430\u0442\u043e. \u0414\u0430\u0432\u0430\u0439 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430\u0434 \u0438\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0438\u0434\u043e\u043c. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/808\/619\/9cf\/8086199cfc184b67b8db679c2d98665a.png\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-266000","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266000"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266000\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}