{"id":387,"date":"2009-08-22T17:13:29","date_gmt":"2009-08-23T00:13:29","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2043"},"modified":"2009-08-22T17:13:29","modified_gmt":"2009-08-23T00:13:29","slug":"3d-bezier","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=387","title":{"rendered":"3D Bezier"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n&#x5B;SWF(backgroundColor=0x000000, width=800, height=600)];\r\nx = stage.stageWidth \/ 2;\r\ny = stage.stageHeight \/ 2;\r\nvar verts:Vector.&lt;Number&gt;  = new Vector.&lt;Number&gt;();\r\nvar tVerts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;();\r\nvar pVerts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;();\r\nvar uvts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;();\r\n\r\nvar igraph:Vector.&lt;IGraphicsData&gt; = new Vector.&lt;IGraphicsData&gt;();\r\n\r\nvar tVect:Vector3D = new Vector3D();\r\nvar m:Matrix3D = new Matrix3D();\r\nfor (var i:int = 0; i&lt;300; i++){\r\n\tfor (var j:int = 0; j&lt;3; j++){\r\n\t\ttVect.x = Math.random() * 0.15;\r\n\t\tm.identity();\r\n\t\tm.appendRotation(Math.random()*360, Vector3D.X_AXIS);\r\n\t\tm.appendRotation(Math.random()*360, Vector3D.Y_AXIS);\r\n\t\tm.appendRotation(Math.random()*360, Vector3D.Z_AXIS);\r\n\t\ttVect = m.transformVector(tVect);\r\n\t    verts.push(tVect.x, tVect.y, tVect.z);\r\n\t}\r\n\t\r\n\t \r\n\tvar stroke:IGraphicsData = new GraphicsStroke();\r\n\t\r\n\tvar col:int = &#x5B;0xFFFFFF, 0x000000, 0xFFCC00, 0xFF0000]&#x5B;int(Math.random() * 4)];\r\n    with (stroke) thickness = (Math.random()*Math.random())*10, fill = new GraphicsSolidFill(col);\r\n\r\n\tvar bez:GraphicsPath = new GraphicsPath();\r\n\tbez.commands = Vector.&lt;int&gt;(&#x5B;1, 3]);\r\n\tigraph.push(stroke);\r\n    igraph.push(bez);\r\n}\r\n\r\nvar perspective:PerspectiveProjection = new PerspectiveProjection();\r\nperspective.fieldOfView = 45;\r\nvar trans:Matrix3D = new Matrix3D();\r\nvar proj:Matrix3D = perspective.toMatrix3D();\r\nvar dx:Number = 0, dy:Number = 0;\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\tdx += (mouseX - dx) \/ 4;\r\n\tdy += (mouseY - dy) \/ 4;\r\n\t   \r\n\ttrans.identity();\r\n\ttrans.appendRotation(dy, Vector3D.X_AXIS);\r\n\ttrans.appendRotation(dx, Vector3D.Y_AXIS);\r\n\ttrans.appendTranslation(0,0,0.5);\r\n\ttrans.transformVectors(verts, tVerts);\r\n\tUtils3D.projectVectors(proj, tVerts, pVerts, uvts);\r\n\t\r\n\tvar inc:int = 0;\r\n\tfor (var i:int = 1; i&lt;igraph.length; i+=2){\r\n\t\tGraphicsPath(igraph&#x5B;i]).data = pVerts.slice(inc, inc + 6);\r\n\t\tinc += 6;\r\n\t}\r\n\t \r\n\tgraphics.clear();\r\n\tgraphics.drawGraphicsData(igraph);\r\n}\r\n<\/pre>\n<p>After a few hours of trying to get a super optimized fp10 z-sorting demo happening, I gave up (for now) and decided to just let loose with something easy. The result is this 3D Bezier example&#8230;<\/p>\n<p><a data-asruffle-linked=\"true\" href=\"http:\/\/www.actionsnippet.com\/swfs\/bez3D.html\" target=\"blank\"><br \/>\nCheck out the swf&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/3dbez.gif\" \/><\/a> <span class=\"asruffle-link\" data-swf=\"{&quot;url&quot;:&quot;https:\\\/\\\/actionsnippet.com\\\/swfs\\\/bez3D.swf&quot;,&quot;title&quot;:&quot;bez3D&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\">: bez3D<\/span><\/button><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x5B;SWF(backgroundColor=0x000000, width=800, height=600)]; x = stage.stageWidth \/ 2; y = stage.stageHeight \/ 2; var verts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(); var tVerts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(); var pVerts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(); var uvts:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(); var igraph:Vector.&lt;IGraphicsData&gt; = new Vector.&lt;IGraphicsData&gt;(); var tVect:Vector3D = new Vector3D(); var m:Matrix3D = new Matrix3D(); for (var i:int = 0; i&lt;300; i++){ [&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,30,33],"tags":[3,14,4,126],"class_list":["post-387","post","type-post","status-publish","format-standard","hentry","category-3d","category-bezier","category-graphics","tag-actionscript","tag-as3","tag-flash","tag-fp10"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/387","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=387"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/387\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}