Created
November 2, 2016 22:40
-
-
Save llliiu/1b9ea93453feb110ce6a045356a2cb37 to your computer and use it in GitHub Desktop.
HW4 200C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src = "https://rawgit.com/wolftype/200c/gh-pages/js/gfx.js"></script> | |
<script type="text/javascript"> | |
var app = new GFX.App(); | |
var flower; | |
/// On Initialization of the WebGL Application (this happens once) | |
app.onInit = function(){ | |
// A CUBE! | |
// We include each vertex on the back side TWICE so that we can attach | |
// TWO separate uv coordinates to each | |
var vertices = new Float32Array( [ | |
-0.077174,-0.050983,0.000000, | |
-0.077174,-0.050983,-0.295452, | |
-0.117610,-0.078085,0.000000, | |
-0.117610,-0.078085,-0.295452, | |
-0.186242,-0.117511,0.000000, | |
-0.186242,-0.117511,-0.295452, | |
-0.304612,-0.177555,0.000000, | |
-0.304612,-0.177555,-0.295452, | |
-0.371378,-0.205047,0.000000, | |
-0.371378,-0.205047,-0.295452, | |
-0.436215,-0.224363,0.000000, | |
-0.436215,-0.224363,-0.295452, | |
-0.494603,-0.231754,0.000000, | |
-0.494603,-0.231754,-0.295452, | |
-0.544905,-0.227977,0.000000, | |
-0.544905,-0.227977,-0.295452, | |
-0.586199,-0.214920,0.000000, | |
-0.586199,-0.214920,-0.295452, | |
-0.617567,-0.194463,0.000000, | |
-0.617567,-0.194463,-0.295452, | |
-0.638499,-0.168449,0.000000, | |
-0.638499,-0.168449,-0.295452, | |
-0.650101,-0.138526,0.000000, | |
-0.650101,-0.138526,-0.295452, | |
-0.653893,-0.106308,0.000000, | |
-0.653893,-0.106308,-0.295452, | |
-0.651389,-0.073398,0.000000, | |
-0.651389,-0.073398,-0.295452, | |
-0.643921,-0.041111,0.000000, | |
-0.643921,-0.041111,-0.295452, | |
-0.632088,-0.009557,0.000000, | |
-0.632088,-0.009557,-0.295452, | |
-0.596981,0.052079,0.000000, | |
-0.596981,0.052079,-0.295452, | |
-0.573883,0.081969,0.000000, | |
-0.573883,0.081969,-0.295452, | |
-0.544169,0.108506,0.000000, | |
-0.544169,0.108506,-0.295452, | |
-0.504345,0.128518,0.000000, | |
-0.504345,0.128518,-0.295452, | |
-0.450919,0.138834,0.000000, | |
-0.450919,0.138834,-0.295452, | |
-0.382836,0.137684,0.000000, | |
-0.382836,0.137684,-0.295452, | |
-0.308777,0.128909,0.000000, | |
-0.308777,0.128909,-0.295452, | |
-0.187222,0.109425,0.000000, | |
-0.187222,0.109425,-0.295452, | |
-0.154577,0.109744,0.000000, | |
-0.154577,0.109744,-0.295452, | |
-0.155056,0.112795,0.000000, | |
-0.155056,0.112795,-0.295452, | |
-0.170060,0.121901,0.000000, | |
-0.170060,0.121901,-0.295452, | |
-0.290520,0.161625,0.000000, | |
-0.290520,0.161625,-0.295452, | |
-0.340927,0.181828,0.000000, | |
-0.340927,0.181828,-0.295452, | |
-0.388670,0.208924,0.000000, | |
-0.388670,0.208924,-0.295452, | |
-0.429514,0.244107,0.000000, | |
-0.429514,0.244107,-0.295452, | |
-0.461029,0.284897,0.000000, | |
-0.461029,0.284897,-0.295452, | |
-0.481240,0.327891,0.000000, | |
-0.481240,0.327891,-0.295452, | |
-0.488171,0.369690,0.000000, | |
-0.488171,0.369690,-0.295452, | |
-0.486103,0.389161,0.000000, | |
-0.486103,0.389161,-0.295452, | |
-0.480366,0.407540,0.000000, | |
-0.480366,0.407540,-0.295452, | |
-0.458454,0.441252,0.000000, | |
-0.458454,0.441252,-0.295452, | |
-0.423586,0.471289,0.000000, | |
-0.423586,0.471289,-0.295452, | |
-0.376908,0.498108,0.000000, | |
-0.376908,0.498108,-0.295452, | |
-0.320135,0.520962,0.000000, | |
-0.320135,0.520962,-0.295452, | |
-0.257252,0.534256,0.000000, | |
-0.257252,0.534256,-0.295452, | |
-0.224940,0.535195,0.000000, | |
-0.224940,0.535195,-0.295452, | |
-0.192805,0.531193,0.000000, | |
-0.192805,0.531193,-0.295452, | |
-0.161418,0.521403,0.000000, | |
-0.161418,0.521403,-0.295452, | |
-0.131346,0.504971,0.000000, | |
-0.131346,0.504971,-0.295452, | |
-0.103089,0.481503,0.000000, | |
-0.103089,0.481503,-0.295452, | |
-0.076871,0.452410,0.000000, | |
-0.076871,0.452410,-0.295452, | |
-0.031173,0.384825,0.000000, | |
-0.031173,0.384825,-0.295452, | |
0.043974,0.233872,0.000000, | |
0.043974,0.233872,-0.295452, | |
0.000135,0.359581,0.000000, | |
0.000135,0.359581,-0.295452, | |
-0.009484,0.405861,0.000000, | |
-0.009484,0.405861,-0.295452, | |
-0.011751,0.454485,0.000000, | |
-0.011751,0.454485,-0.295452, | |
-0.004093,0.503348,0.000000, | |
-0.004093,0.503348,-0.295452, | |
0.012389,0.548348,0.000000, | |
0.012389,0.548348,-0.295452, | |
0.035671,0.584895,0.000000, | |
0.035671,0.584895,-0.295452, | |
0.063731,0.608391,0.000000, | |
0.063731,0.608391,-0.295452, | |
0.078966,0.613978,0.000000, | |
0.078966,0.613978,-0.295452, | |
0.094902,0.615582,0.000000, | |
0.094902,0.615582,-0.295452, | |
0.128920,0.608574,0.000000, | |
0.128920,0.608574,-0.295452, | |
0.165880,0.590815,0.000000, | |
0.165880,0.590815,-0.295452, | |
0.247726,0.536057,0.000000, | |
0.247726,0.536057,-0.295452, | |
0.285215,0.501357,0.000000, | |
0.285215,0.501357,-0.295452, | |
0.299982,0.481768,0.000000, | |
0.299982,0.481768,-0.295452, | |
0.310848,0.460497,0.000000, | |
0.310848,0.460497,-0.295452, | |
0.316878,0.437401,0.000000, | |
0.316878,0.437401,-0.295452, | |
0.317135,0.412333,0.000000, | |
0.317135,0.412333,-0.295452, | |
0.311069,0.385321,0.000000, | |
0.311069,0.385321,-0.295452, | |
0.299666,0.357054,0.000000, | |
0.299666,0.357054,-0.295452, | |
0.266345,0.300213,0.000000, | |
0.266345,0.300213,-0.295452, | |
0.175599,0.182061,0.000000, | |
0.175599,0.182061,-0.295452, | |
0.175782,0.181937,0.000000, | |
0.175782,0.181937,-0.295452, | |
0.262545,0.261185,0.000000, | |
0.262545,0.261185,-0.295452, | |
0.299452,0.286589,0.000000, | |
0.299452,0.286589,-0.295452, | |
0.340172,0.304503,0.000000, | |
0.340172,0.304503,-0.295452, | |
0.383328,0.310690,0.000000, | |
0.383328,0.310690,-0.295452, | |
0.426254,0.304013,0.000000, | |
0.426254,0.304013,-0.295452, | |
0.465963,0.284100,0.000000, | |
0.465963,0.284100,-0.295452, | |
0.483678,0.269066,0.000000, | |
0.483678,0.269066,-0.295452, | |
0.499468,0.250586,0.000000, | |
0.499468,0.250586,-0.295452, | |
0.512898,0.228766,0.000000, | |
0.512898,0.228766,-0.295452, | |
0.523271,0.204321,0.000000, | |
0.523271,0.204321,-0.295452, | |
0.529831,0.178118,0.000000, | |
0.529831,0.178118,-0.295452, | |
0.531818,0.151026,0.000000, | |
0.531818,0.151026,-0.295452, | |
0.528475,0.123909,0.000000, | |
0.528475,0.123909,-0.295452, | |
0.519044,0.097640,0.000000, | |
0.519044,0.097640,-0.295452, | |
0.502766,0.073079,0.000000, | |
0.502766,0.073079,-0.295452, | |
0.478882,0.051098,0.000000, | |
0.478882,0.051098,-0.295452, | |
0.447164,0.032374,0.000000, | |
0.447164,0.032374,-0.295452, | |
0.409489,0.016818,0.000000, | |
0.409489,0.016818,-0.295452, | |
0.325897,-0.005882,0.000000, | |
0.325897,-0.005882,-0.295452, | |
0.177315,-0.026834,0.000000, | |
0.177315,-0.026834,-0.295452, | |
0.177316,-0.026840,0.000000, | |
0.177316,-0.026840,-0.295452, | |
0.232141,-0.031154,0.000000, | |
0.232141,-0.031154,-0.295452, | |
0.280375,-0.042030,0.000000, | |
0.280375,-0.042030,-0.295452, | |
0.328968,-0.063213,0.000000, | |
0.328968,-0.063213,-0.295452, | |
0.373195,-0.094230,0.000000, | |
0.373195,-0.094230,-0.295452, | |
0.409611,-0.133701,0.000000, | |
0.409611,-0.133701,-0.295452, | |
0.434770,-0.180250,0.000000, | |
0.434770,-0.180250,-0.295452, | |
0.442119,-0.205673,0.000000, | |
0.442119,-0.205673,-0.295452, | |
0.445776,-0.231899,0.000000, | |
0.445776,-0.231899,-0.295452, | |
0.441938,-0.284282,0.000000, | |
0.441938,-0.284282,-0.295452, | |
0.434411,-0.309200,0.000000, | |
0.434411,-0.309200,-0.295452, | |
0.423121,-0.332439,0.000000, | |
0.423121,-0.332439,-0.295452, | |
0.408052,-0.353382,0.000000, | |
0.408052,-0.353382,-0.295452, | |
0.389187,-0.371406,0.000000, | |
0.389187,-0.371406,-0.295452, | |
0.366645,-0.385973,0.000000, | |
0.366645,-0.385973,-0.295452, | |
0.341098,-0.396871,0.000000, | |
0.341098,-0.396871,-0.295452, | |
0.313359,-0.403965,0.000000, | |
0.313359,-0.403965,-0.295452, | |
0.284235,-0.407125,0.000000, | |
0.284235,-0.407125,-0.295452, | |
0.254536,-0.406219,0.000000, | |
0.254536,-0.406219,-0.295452, | |
0.225073,-0.401113,0.000000, | |
0.225073,-0.401113,-0.295452, | |
0.196655,-0.391677,0.000000, | |
0.196655,-0.391677,-0.295452, | |
0.170092,-0.377777,0.000000, | |
0.170092,-0.377777,-0.295452, | |
0.146057,-0.359531,0.000000, | |
0.146057,-0.359531,-0.295452, | |
0.124670,-0.338037,0.000000, | |
0.124670,-0.338037,-0.295452, | |
0.089770,-0.290716,0.000000, | |
0.089770,-0.290716,-0.295452, | |
0.046379,-0.208873,0.000000, | |
0.046379,-0.208873,-0.295452, | |
0.045527,-0.209413,0.000000, | |
0.045527,-0.209413,-0.295452, | |
0.033136,-0.268905,0.000000, | |
0.033136,-0.268905,-0.295452, | |
0.010306,-0.335136,0.000000, | |
0.010306,-0.335136,-0.295452, | |
-0.031540,-0.421669,0.000000, | |
-0.031540,-0.421669,-0.295452, | |
-0.086988,-0.509443,0.000000, | |
-0.086988,-0.509443,-0.295452, | |
-0.117285,-0.546657,0.000000, | |
-0.117285,-0.546657,-0.295452, | |
-0.147950,-0.575618,0.000000, | |
-0.147950,-0.575618,-0.295452, | |
-0.177971,-0.593473,0.000000, | |
-0.177971,-0.593473,-0.295452, | |
-0.206337,-0.597362,0.000000, | |
-0.206337,-0.597362,-0.295452, | |
-0.232188,-0.585449,0.000000, | |
-0.232188,-0.585449,-0.295452, | |
-0.255246,-0.559949,0.000000, | |
-0.255246,-0.559949,-0.295452, | |
-0.275385,-0.524101,0.000000, | |
-0.275385,-0.524101,-0.295452, | |
-0.292481,-0.481136,0.000000, | |
-0.292481,-0.481136,-0.295452, | |
-0.317034,-0.386791,0.000000, | |
-0.317034,-0.386791,-0.295452, | |
-0.327893,-0.302785,0.000000, | |
-0.327893,-0.302785,-0.295452, | |
-0.327923,-0.271944,0.000000, | |
-0.327923,-0.271944,-0.295452, | |
-0.324456,-0.248579,0.000000, | |
-0.324456,-0.248579,-0.295452, | |
-0.317665,-0.231119,0.000000, | |
-0.317665,-0.231119,-0.295452, | |
-0.307736,-0.217990,0.000000, | |
-0.307736,-0.217990,-0.295452, | |
-0.279162,-0.198431,0.000000, | |
-0.279162,-0.198431,-0.295452, | |
-0.240158,-0.177309,0.000000, | |
-0.240158,-0.177309,-0.295452, | |
-0.153188,-0.114626,0.000000, | |
-0.153188,-0.114626,-0.295452, | |
-0.077174,-0.050983,0.000000, | |
-0.077174,-0.050983,-0.295452, | |
]); | |
var texCoord = new Float32Array([ | |
0.0,0.0 | |
,0.0,1.0 | |
, | |
0.01335983257740736,0.0 | |
,0.01335983257740736,1.0 | |
,0.02671966515481472,0.0 | |
,0.02671966515481472,1.0 | |
,0.04150981456041336,0.0 | |
,0.04150981456041336,1.0 | |
,0.04890488833189011,0.0 | |
,0.04890488833189011,1.0 | |
,0.05629996210336685,0.0 | |
,0.05629996210336685,1.0 | |
,0.0636950358748436,0.0 | |
,0.0636950358748436,1.0 | |
,0.07109010964632034,0.0 | |
,0.07109010964632034,1.0 | |
,0.07848518341779709,0.0 | |
,0.07848518341779709,1.0 | |
,0.08588025718927383,0.0 | |
,0.08588025718927383,1.0 | |
,0.09327533096075058,0.0 | |
,0.09327533096075058,1.0 | |
,0.1006704047322273,0.0 | |
,0.1006704047322273,1.0 | |
,0.1080654859542847,0.0 | |
,0.1080654859542847,1.0 | |
,0.1154605597257614,0.0 | |
,0.1154605597257614,1.0 | |
,0.1228556334972382,0.0 | |
,0.1228556334972382,1.0 | |
,0.1302507072687149,0.0 | |
,0.1302507072687149,1.0 | |
,0.1450408548116684,0.0 | |
,0.1450408548116684,1.0 | |
,0.1524359285831451,0.0 | |
,0.1524359285831451,1.0 | |
,0.1598310023546219,0.0 | |
,0.1598310023546219,1.0 | |
,0.1672260761260986,0.0 | |
,0.1672260761260986,1.0 | |
,0.1746211498975754,0.0 | |
,0.1746211498975754,1.0 | |
,0.1820162236690521,0.0 | |
,0.1820162236690521,1.0 | |
,0.1894112974405289,0.0 | |
,0.1894112974405289,1.0 | |
,0.2042014449834824,0.0 | |
,0.2042014449834824,1.0 | |
,0.2152940630912781,0.0 | |
,0.2152940630912781,1.0 | |
,0.2189915925264359,0.0 | |
,0.2189915925264359,1.0 | |
,0.2263866662979126,0.0 | |
,0.2263866662979126,1.0 | |
,0.2485718876123428,0.0 | |
,0.2485718876123428,1.0 | |
,0.2559669613838196,0.0 | |
,0.2559669613838196,1.0 | |
,0.2633620500564575,0.0 | |
,0.2633620500564575,1.0 | |
,0.2707571089267731,0.0 | |
,0.2707571089267731,1.0 | |
,0.278152197599411,0.0 | |
,0.278152197599411,1.0 | |
,0.2855472564697266,0.0 | |
,0.2855472564697266,1.0 | |
,0.2929423451423645,0.0 | |
,0.2929423451423645,1.0 | |
,0.2966398894786835,0.0 | |
,0.2966398894786835,1.0 | |
,0.3003374040126801,0.0 | |
,0.3003374040126801,1.0 | |
,0.307732492685318,0.0 | |
,0.307732492685318,1.0 | |
,0.3151275515556335,0.0 | |
,0.3151275515556335,1.0 | |
,0.3225226402282715,0.0 | |
,0.3225226402282715,1.0 | |
,0.329917699098587,0.0 | |
,0.329917699098587,1.0 | |
,0.337312787771225,0.0 | |
,0.337312787771225,1.0 | |
,0.3410103321075439,0.0 | |
,0.3410103321075439,1.0 | |
,0.3447078466415405,0.0 | |
,0.3447078466415405,1.0 | |
,0.3484053909778595,0.0 | |
,0.3484053909778595,1.0 | |
,0.3521029353141785,0.0 | |
,0.3521029353141785,1.0 | |
,0.3558004796504974,0.0 | |
,0.3558004796504974,1.0 | |
,0.359497994184494,0.0 | |
,0.359497994184494,1.0 | |
,0.366893082857132,0.0 | |
,0.366893082857132,1.0 | |
,0.3937002122402191,0.0 | |
,0.3937002122402191,1.0 | |
,0.4260536730289459,0.0 | |
,0.4260536730289459,1.0 | |
,0.4334487617015839,0.0 | |
,0.4334487617015839,1.0 | |
,0.4408438205718994,0.0 | |
,0.4408438205718994,1.0 | |
,0.4482389092445374,0.0 | |
,0.4482389092445374,1.0 | |
,0.4556339681148529,0.0 | |
,0.4556339681148529,1.0 | |
,0.4630290567874908,0.0 | |
,0.4630290567874908,1.0 | |
,0.4704241156578064,0.0 | |
,0.4704241156578064,1.0 | |
,0.4741216599941254,0.0 | |
,0.4741216599941254,1.0 | |
,0.4778192043304443,0.0 | |
,0.4778192043304443,1.0 | |
,0.4852142632007599,0.0 | |
,0.4852142632007599,1.0 | |
,0.4926093518733978,0.0 | |
,0.4926093518733978,1.0 | |
,0.5073994994163513,0.0 | |
,0.5073994994163513,1.0 | |
,0.5147945880889893,0.0 | |
,0.5147945880889893,1.0 | |
,0.5184921026229858,0.0 | |
,0.5184921026229858,1.0 | |
,0.5221896171569824,0.0 | |
,0.5221896171569824,1.0 | |
,0.5258871912956238,0.0 | |
,0.5258871912956238,1.0 | |
,0.5295847058296204,0.0 | |
,0.5295847058296204,1.0 | |
,0.5332822799682617,0.0 | |
,0.5332822799682617,1.0 | |
,0.5369797945022583,0.0 | |
,0.5369797945022583,1.0 | |
,0.5443748831748962,0.0 | |
,0.5443748831748962,1.0 | |
,0.5721064209938049,0.0 | |
,0.5721064209938049,1.0 | |
,0.5730307698249817,0.0 | |
,0.5730307698249817,1.0 | |
,0.6035354733467102,0.0 | |
,0.6035354733467102,1.0 | |
,0.6109305620193481,0.0 | |
,0.6109305620193481,1.0 | |
,0.6183255910873413,0.0 | |
,0.6183255910873413,1.0 | |
,0.6257206797599792,0.0 | |
,0.6257206797599792,1.0 | |
,0.6331157684326172,0.0 | |
,0.6331157684326172,1.0 | |
,0.6405108571052551,0.0 | |
,0.6405108571052551,1.0 | |
,0.6442083716392517,0.0 | |
,0.6442083716392517,1.0 | |
,0.6479058861732483,0.0 | |
,0.6479058861732483,1.0 | |
,0.6516034603118896,0.0 | |
,0.6516034603118896,1.0 | |
,0.6553009748458862,0.0 | |
,0.6553009748458862,1.0 | |
,0.6589984893798828,0.0 | |
,0.6589984893798828,1.0 | |
,0.6626960635185242,0.0 | |
,0.6626960635185242,1.0 | |
,0.6663935780525208,0.0 | |
,0.6663935780525208,1.0 | |
,0.6700911521911621,0.0 | |
,0.6700911521911621,1.0 | |
,0.6737886667251587,0.0 | |
,0.6737886667251587,1.0 | |
,0.6774861812591553,0.0 | |
,0.6774861812591553,1.0 | |
,0.6811837553977966,0.0 | |
,0.6811837553977966,1.0 | |
,0.6848812699317932,0.0 | |
,0.6848812699317932,1.0 | |
,0.6922763586044312,0.0 | |
,0.6922763586044312,1.0 | |
,0.7138838171958923,0.0 | |
,0.7138838171958923,1.0 | |
,0.7139993906021118,0.0 | |
,0.7139993906021118,1.0 | |
,0.7292517423629761,0.0 | |
,0.7292517423629761,1.0 | |
,0.7366467714309692,0.0 | |
,0.7366467714309692,1.0 | |
,0.7440418601036072,0.0 | |
,0.7440418601036072,1.0 | |
,0.7514369487762451,0.0 | |
,0.7514369487762451,1.0 | |
,0.7588320374488831,0.0 | |
,0.7588320374488831,1.0 | |
,0.7662270665168762,0.0 | |
,0.7662270665168762,1.0 | |
,0.7699246406555176,0.0 | |
,0.7699246406555176,1.0 | |
,0.7736221551895142,0.0 | |
,0.7736221551895142,1.0 | |
,0.7810172438621521,0.0 | |
,0.7810172438621521,1.0 | |
,0.7847147583961487,0.0 | |
,0.7847147583961487,1.0 | |
,0.78841233253479,0.0 | |
,0.78841233253479,1.0 | |
,0.7921098470687866,0.0 | |
,0.7921098470687866,1.0 | |
,0.795807421207428,0.0 | |
,0.795807421207428,1.0 | |
,0.7995049357414246,0.0 | |
,0.7995049357414246,1.0 | |
,0.8032024502754211,0.0 | |
,0.8032024502754211,1.0 | |
,0.8069000244140625,0.0 | |
,0.8069000244140625,1.0 | |
,0.8105975389480591,0.0 | |
,0.8105975389480591,1.0 | |
,0.8142950534820557,0.0 | |
,0.8142950534820557,1.0 | |
,0.817992627620697,0.0 | |
,0.817992627620697,1.0 | |
,0.8216901421546936,0.0 | |
,0.8216901421546936,1.0 | |
,0.825387716293335,0.0 | |
,0.825387716293335,1.0 | |
,0.8290852308273315,0.0 | |
,0.8290852308273315,1.0 | |
,0.8327827453613281,0.0 | |
,0.8327827453613281,1.0 | |
,0.8401778340339661,0.0 | |
,0.8401778340339661,1.0 | |
,0.8605142831802368,0.0 | |
,0.8605142831802368,1.0 | |
,0.8623630404472351,0.0 | |
,0.8623630404472351,1.0 | |
,0.877153217792511,0.0 | |
,0.877153217792511,1.0 | |
,0.8845483064651489,0.0 | |
,0.8845483064651489,1.0 | |
,0.8919433355331421,0.0 | |
,0.8919433355331421,1.0 | |
,0.89933842420578,0.0 | |
,0.89933842420578,1.0 | |
,0.9030359983444214,0.0 | |
,0.9030359983444214,1.0 | |
,0.906733512878418,0.0 | |
,0.906733512878418,1.0 | |
,0.9104310274124146,0.0 | |
,0.9104310274124146,1.0 | |
,0.9141286015510559,0.0 | |
,0.9141286015510559,1.0 | |
,0.9178261160850525,0.0 | |
,0.9178261160850525,1.0 | |
,0.9215236306190491,0.0 | |
,0.9215236306190491,1.0 | |
,0.9252212047576904,0.0 | |
,0.9252212047576904,1.0 | |
,0.928918719291687,0.0 | |
,0.928918719291687,1.0 | |
,0.936313807964325,0.0 | |
,0.936313807964325,1.0 | |
,0.9437088966369629,0.0 | |
,0.9437088966369629,1.0 | |
,0.9474064111709595,0.0 | |
,0.9474064111709595,1.0 | |
,0.9511039257049561,0.0 | |
,0.9511039257049561,1.0 | |
,0.9548014998435974,0.0 | |
,0.9548014998435974,1.0 | |
,0.958499014377594,0.0 | |
,0.958499014377594,1.0 | |
,0.9658941030502319,0.0 | |
,0.9658941030502319,1.0 | |
,0.9732891917228699,0.0 | |
,0.9732891917228699,1.0 | |
,0.9866445660591125,0.0 | |
,0.9866445660591125,1.0 | |
,1.0,0.0 | |
,1.0,1.0 | |
]); | |
//Break Object Vertices Triangles | |
var indices = new Uint16Array([ | |
4,0,2,3,1,4, | |
4,6,7,5,4,12, | |
14,15,13,4,14, | |
16,17,15,4,22, | |
24,25,23,4,24, | |
26,27,25,4,26, | |
28,29,27,4,28,30, | |
31,29,4,30,32,33, | |
31,4,32,34,35,33, | |
4,38,40,41,39,4, | |
4,42,43,41,4,42, | |
44,45,43,4,44,46, | |
47,45,4,48,50,51, | |
49,4,50,52,53,51, | |
4,52,54,55,53,4, | |
54,56,57,55,4,58, | |
60,61,59,4,60,62, | |
63,61,4,62,64,65, | |
63,4,64,66,67,65, | |
4,66,68,69,67,4, | |
68,70,71,69,4,70, | |
72,73,71,4,72,74, | |
75,73,4,78,80,81, | |
79,4,80,82,83,81, | |
4,86,88,89,87,4, | |
88,90,91,89,4,92, | |
94,95,93,4,94,96, | |
97,95,4,96,98,99, | |
97,4,98,100,101,99, | |
4,100,102,103,101,4, | |
102,104,105,103,4,104, | |
106,107,105,4,106,108, | |
109,107,4,108,110,111, | |
109,4,110,112,113,111, | |
4,112,114,115,113, | |
4,114,116,117,115, | |
4,116,118,119,117, | |
4,122,124,125,123, | |
4,124,126,127,125, | |
4,126,128,129,127, | |
4,128,130,131,129, | |
4,130,132,133,131, | |
4,132,134,135,133, | |
4,136,138,139,137, | |
4,140,142,143,141, | |
4,142,144,145,143, | |
4,144,146,147,145, | |
4,148,150,151,149, | |
4,150,152,153,151, | |
4,154,156,157,155, | |
4,156,158,159,157, | |
4,158,160,161,159, | |
4,160,162,163,161, | |
4,162,164,165,163, | |
4,166,168,169,167, | |
4,168,170,171,169, | |
4,170,172,173,171, | |
4,174,176,177,175, | |
4,180,182,183,181, | |
4,182,184,185,183, | |
4,186,188,189,187, | |
4,192,194,195,193, | |
4,194,196,197,195, | |
4,196,198,199,197, | |
4,198,200,201,199, | |
4,200,202,203,201, | |
4,202,204,205,203, | |
4,204,206,207,205, | |
4,210,212,213,211, | |
4,212,214,215,213, | |
4,214,216,217,215, | |
4,216,218,219,217, | |
4,222,224,225,223, | |
4,224,226,227,225, | |
4,226,228,229,227, | |
4,228,230,231,229, | |
4,230,232,233,231, | |
4,232,234,235,233, | |
4,234,236,237,235, | |
4,236,238,239,237, | |
4,240,242,243,241, | |
4,242,244,245,243, | |
4,244,246,247,245, | |
4,246,248,249,247, | |
4,248,250,251,249, | |
4,250,252,253,251, | |
4,254,256,257,255, | |
4,258,260,261,259, | |
4,260,262,263,261, | |
4,262,264,265,263, | |
4,264,266,267,265, | |
4,266,268,269,267, | |
4,268,270,271,269, | |
4,270,272,273,271, | |
4,274,276,277,275, | |
3,2,4,3, | |
3,4,5,3, | |
3,6,8,7, | |
3,8,9,7, | |
3,8,10,9, | |
3,10,11,9, | |
3,10,12,11, | |
3,12,13,11, | |
3,16,18,17, | |
3,18,19,17, | |
3,18,20,19, | |
3,20,21,19, | |
3,20,22,21, | |
3,22,23,21, | |
3,34,36,35, | |
3,36,37,35, | |
3,36,38,37, | |
3,38,39,37, | |
3,46,48,47, | |
3,48,49,47, | |
3,56,58,57, | |
3,58,59,57, | |
3,74,76,75, | |
3,76,77,75, | |
3,76,78,77, | |
3,78,79,77, | |
3,82,84,83, | |
3,84,85,83, | |
3,84,86,85, | |
3,86,87,85, | |
3,90,92,91, | |
3,92,93,91, | |
3,118,120,119, | |
3,120,121,119, | |
3,120,122,121, | |
3,122,123,121, | |
3,134,136,135, | |
3,136,137,135, | |
3,138,140,139, | |
3,140,141,139, | |
3,146,148,147, | |
3,148,149,147, | |
3,152,154,153, | |
3,154,155,153, | |
3,164,166,165, | |
3,166,167,165, | |
3,172,174,173, | |
3,174,175,173, | |
3,176,178,177, | |
3,178,179,177, | |
3,178,180,179, | |
3,180,181,179, | |
3,184,186,185, | |
3,186,187,185, | |
3,188,190,189, | |
3,190,191,189, | |
3,190,192,191, | |
3,192,193,191, | |
3,206,208,207, | |
3,208,209,207, | |
3,208,210,209, | |
3,210,211,209, | |
3,218,220,219, | |
3,220,221,219, | |
3,220,222,221, | |
3,222,223,221, | |
3,238,240,239, | |
3,240,241,239, | |
3,252,254,253, | |
3,254,255,253, | |
3,256,258,257, | |
3,258,259,257, | |
3,272,274,273, | |
3,274,275,273, | |
3,276,278,277, | |
3,278,279,277, | |
]); | |
//Create and Bind two new array buffers and a new element array buffer | |
flower = new GFX.Mesh(GFX.Mesh.Frame); | |
//flower.frame.position.set(2,0,0); | |
//Allocate Some Data on the GPU and copy position data over | |
flower.vertexBuffer.bind(); | |
flower.vertexBuffer.alloc( vertices.byteLength ); | |
flower.vertexBuffer.data(vertices); | |
//Allocate Some Data on the GPU and copy tex data over | |
flower.texBuffer.bind(); | |
flower.texBuffer.alloc( texCoord.byteLength ); | |
flower.texBuffer.data(texCoord); | |
//Allocate Some Data on the GPU and copy index data over | |
flower.indexBuffer.bind(); | |
flower.indexBuffer.alloc( indices.byteLength ); | |
flower.indexBuffer.data(indices); | |
} | |
// Render the scene | |
app.onRender = function() { | |
var scene = this.scene; | |
scene.color = [0.95,0.95,0.95,1.0]; | |
//begin scene render, send matrices over to shader uniform | |
scene.begin(); | |
//Send Time Variable over to GPU | |
scene.shader.setUniformFloat("u_time", scene.time ) | |
scene.matrix.translate(0,0,0); | |
scene.matrix.push(); | |
scene.matrix.translate(0, 0, 3); | |
scene.matrix.scale(.75,.75,.75); | |
scene.matrix.push(); | |
scene.matrix.translate(0, 0,(3/5-.5)*2); | |
scene.matrix.push(); | |
scene.matrix.rotate(2*Math.cos(scene.time),1.5,1.5,1); | |
scene.matrix.scale(3/5,3/5,3/5); | |
scene.draw(flower); | |
scene.matrix.pop(); | |
scene.matrix.pop(); | |
scene.matrix.pop(); | |
//enable attributes in shader | |
scene.shader.enableAttribute( "position" ); | |
scene.shader.enableAttribute( "uv" ); | |
flower.frame.rotateX( scene.time ); | |
//upload model matrix | |
flower.uploadModel(scene.shader) | |
//Bind Vertex Buffer | |
flower.vertexBuffer.bind(); | |
//Point Buffer to Attribute in shader | |
scene.shader.pointAttribute("position", 3); | |
// //Bind TexCoord Buffer | |
flower.texBuffer.bind(); | |
//Point Buffer to Attribute in Shader | |
scene.shader.pointAttribute("uv", 2) | |
// //Bind Index Buffer and Draw based on Indices | |
flower.indexBuffer.bind(); | |
// //Draw the indices | |
flower.indexBuffer.drawElements(GL.TRIANGLES); | |
//or just draw the vertex array buffer directly as points (can also use GL.LINES, GL.LINE_STRIP, GL.TRIANGLES, etc) | |
// box.vertexBuffer.bind(); | |
// box.vertexBuffer.drawArrays(GL.POINTS); | |
scene.end(); | |
} | |
</script> | |
<!-- VERTEX SHADER --> | |
<script id="gfxvert" type="text/glsl"> | |
#ifdef GL_ES | |
precision lowp float; | |
#endif | |
attribute vec3 position; //Position | |
attribute vec2 uv; //Texture; | |
uniform mat4 model; //Model Matrix | |
uniform mat4 view; //View Matrix | |
uniform mat4 projection; //Projection Matrix | |
varying vec2 vuv; //Texture Coordiante to Output to Fragment Shader | |
void main() { | |
vuv = uv; | |
gl_Position = projection * view * model * vec4(position, 1.0); | |
gl_PointSize = 10.0; | |
} | |
</script> | |
<!-- FRAGMENT SHADER --> | |
<script id="gfxfrag" type="text/glsl"> | |
#ifdef GL_ES | |
precision lowp float; | |
#endif | |
uniform float u_time; | |
varying vec2 vuv; | |
void main() { | |
vec2 st = vuv; | |
st = fract(st*2.0); | |
vec3 color = vec3(st.x/abs(sin(u_time)), | |
sin(u_time), | |
st.y * abs(cos(u_time))*3.14*3.14); | |
gl_FragColor = vec4(color,1.0); | |
} | |
</script> | |
<body onload=app.start()> | |
<canvas id="gfxcanvas" width=640 height=480> No <code> canvas </code> tag support </canvas> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment