{"id":404,"date":"2009-09-13T10:04:00","date_gmt":"2009-09-13T17:04:00","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2158"},"modified":"2009-09-13T10:04:00","modified_gmt":"2009-09-13T17:04:00","slug":"drawtriangles-cubes","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=404","title":{"rendered":"drawTriangles() Cubes"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nprivate function addCube(xp:Number, yp:Number, zp:Number, w:Number, h:Number, leng:Number):void{\r\n\t\t\tvar hw:Number = w * 0.5;\r\n\t\t\tvar hh:Number = h * 0.5;\r\n\t\t\tvar hl:Number = leng * 0.5;\r\n\t\t\tvar xA:Number = xp - hw;\r\n\t\t\tvar xB:Number = hw + xp;\r\n\t\t\tvar yA:Number = yp - hh;\r\n\t\t\tvar yB:Number = hh + yp;\r\n\t\t\tvar zA:Number = zp - hl;\r\n\t\t\tvar zB:Number = hl + zp;\r\n        \t_verts.push(xA, yA, zA,\r\n\t\t\t\t        xB, yA, zA,\r\n\t\t\t\t        xA, yB, zA,\r\n\t\t\t\t        xB, yB, zA,\r\n\t\t\t\t\t\txA, yA, zB,\r\n\t\t\t\t        xB, yA, zB,\r\n\t\t\t\t        xA, yB, zB,\r\n\t\t\t\t        xB, yB, zB);\r\n\t\t\t\r\n\t\t\tvar index:int = _boxIndex * 8;\r\n\t\t\tvar i0:int = index, i1:int = index + 1, i2:int = index + 2;\r\n\t\t\tvar i3:int = index + 3,  i4:int = index + 4, i5:int = index + 5;\r\n\t\t\tvar i6:int = index + 6, i7:int = index + 7;\r\n\t        _indices.push(i0, i1, i2,\r\n\t\t\t\t          i1, i3, i2,\r\n\t\t\t\t\t\t  i6, i7, i4, \r\n\t\t\t\t          i7, i5, i4, \r\n\t\t\t\t\t\t  i1, i5, i3,\r\n\t\t\t\t\t\t  i7, i3, i5,\r\n\t\t\t\t\t\t  i4, i5, i0,\r\n\t\t\t\t\t\t  i1, i0, i5,\r\n\t\t\t\t\t\t  i2, i6, i0,\r\n\t\t\t\t\t\t  i0, i6, i4,\r\n\t\t\t\t\t\t  i2, i3, i6,\r\n\t\t\t\t\t\t  i3, i7, i6);\r\n\t\t\t\t\t\t  \r\n\t\t\t_faces.push(new Face(), new Face(), new Face(), \r\n\t\t\t\t\t    new Face(),  new Face(), new Face(), \r\n\t\t\t\t\t\tnew Face(), new Face(), new Face(),\r\n\t\t\t\t\t\tnew Face(), new Face(), new Face());\r\n\t\t\t_uvts.push(Math.random(), Math.random(), 0, \r\n\t\t\t\t\t   Math.random(), Math.random(), 0, \r\n\t\t\t\t\t   Math.random(), Math.random(), 0,\r\n\t\t\t\t\t   Math.random(), Math.random(), 0, \r\n\t\t\t\t\t   Math.random(), Math.random(), 0, \r\n\t\t\t\t\t   Math.random(), Math.random(), 0,\r\n\t\t\t\t\t   Math.random(), Math.random(), 0, \r\n\t\t\t\t\t   Math.random(), Math.random(), 0);\r\n\t\t\t_boxIndex++;\r\n\t\t}\r\n<\/pre>\n<p>Lately I&#8217;ve been posting large code snippets&#8230; so today I&#8217;m highlighting part of a larger snippet &#8211; The above code is the heart of a small experiment I created this morning. It sets up a cube for use with drawTraingles(). <\/p>\n<p>The rest of the code can be read here:<br \/>\n<a href=\"https:\/\/actionsnippet.com\/source\/Cubes3D.as\" target=\"blank\">Cubes3D.as<\/a><br \/>\n<a data-asruffle-linked=\"true\" href=\"https:\/\/actionsnippet.com\/swfs\/cubes3d.html\" target=\"blank\"><br \/>\nHave a look at the swf here&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/cubes3d.jpg\" \/><\/a> <span class=\"asruffle-link\" data-swf=\"{&quot;url&quot;:&quot;https:\\\/\\\/actionsnippet.com\\\/swfs\\\/cubes3d.swf&quot;,&quot;title&quot;:&quot;cubes3d&quot;,&quot;width&quot;:800,&quot;height&quot;:600,&quot;missing&quot;:false,&quot;allowScriptAccess&quot;:false,&quot;backgroundColor&quot;:&quot;#000000&quot;}\"><button type=\"button\" hidden aria-expanded=\"false\">Play demo<span class=\"screen-reader-text\">: cubes3d<\/span><\/button><\/span><br \/>\n<a href=\"http:\/\/wonderfl.net\/code\/5ef49fadb583a2dfa63a53de68944fda2ef01627\" target=\"blank\">I also put it on wonderfl&#8230;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>private function addCube(xp:Number, yp:Number, zp:Number, w:Number, h:Number, leng:Number):void{ var hw:Number = w * 0.5; var hh:Number = h * 0.5; var hl:Number = leng * 0.5; var xA:Number = xp &#8211; hw; var xB:Number = hw + xp; var yA:Number = yp &#8211; hh; var yB:Number = hh + yp; var zA:Number = zp &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,33,118,13,79],"tags":[3,14,4],"class_list":["post-404","post","type-post","status-publish","format-standard","hentry","category-3d","category-graphics","category-matrix","category-motion","category-vector","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=404"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/404\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}