Answered step by step
Verified Expert Solution
Question
1 Approved Answer
all there require files are given. ple ans me in 30 min if possible. please. you will get best rating for sure. please help with
all there require files are given. ple ans me in 30 min if possible. please. you will get best rating for sure. please help with this question.
40. 41. 42. 43. 44. 45. cube.js 46. 47 48 50. 51 52 var canvas; var gli var NumVertices 36: var points var colors - 01: var xAxis = 0; var yaxis = 1; var ZAxis - 2; var axis - 2 var theta - [0, 0, 0; var thetaloc 53 54. 55 56 57. window.onload = function init() 58 59. canvas - document.getElementById( "ol-canvas" ); 60 59. canvas document.getElementById( "gl-canvas" ); 60. 61. gl WebGLUtils.setupWebGL ( canvas); if (!gl ) ( alert( "WebGL isn't available" ); colorCube (); 62. 63. 64. gl.viewport ( 0, 0, canvas.width, canvas.height); gi.clearColor ( 1.0, 1.0, 1.0, 1.0); 65. gl.enable (gl.DEPTH_TEST); 66. 67. W 77 Load shaders and initialize attrIbute buffers 68. 69 70. var program - initshaders ( 91, "vertex-shader","fragment-shader" ); g.use Program program); 71. 72. 73. var Butter - gl.createBuffer) gl.bindBuffer( gl.ARRAY BUFFER, CBuffer ); gl.bufferData( 91. ARRAY_BUFFER, flatten (colors), gl.STATIC_DRAW ); var vColor - gl.getAttriblocation program, "vColor" ); gl.vertexattribPointer( vColor, 4, g1.FLOAT, false, 0, 0); gl.enableVertexAttribarray( vcolor) 75. 76 77. 78 var vBuffer - gl.createBuffer(); gl.bindBuffer gl.ARRAY_BUFFER, VBuffer): 79. gl.bufferData( g1. ARRAY_BUFFER, Elatten (points), gl.STATIC_DRAW ); 80. 81. 82. var v Position = gl.getAttribLocation program, "position" ); gl.vertexAttribPointer Position, 3, g1.FLOAT, false, 0, 0); gl.enableVertexAttribArray ( v Position); thetaloc - gl.getUniformLocation (program, "theta"); 83. 84. //event listeners for buttons 85. 86. 87. document.getElementById("xButton").onclick-function () { axis Axis 88. 89 90. 91. 92 document.getElementById("Button").onclick - function() axis - yaxis ) document.getElementById("button").onclick - function() axis - Axis 93 render() 94. 95. 1 96. function colorCube) 98 99. 100 quad 10.3.2) quad 2, 3, 7, 6) 98. 99. 100. 101. 102. 103. 104. ) quad ( 1, 0, 3, 2); quad ( 2, 3, 7, 6); quad( 3, 0, 4, 7); quad ( 6, 5, 1, 2); quad ( 4, 5, 6, 7); quad( 5, 4, 0, 1); 105. function quad (a, b, c, d) 106. 107. var vertices - vec3( -0.5, -0.5, 0.5 vec3(-0.5, 0.5, 0.5), vec31 0.5, 0.5) 0.5), vec3(0.5, -0.5, 0.5), vec3(-0.5, -0.5, -0.5); vec3(-0.5, 0.5, -0.5), vec3c0.5, 0.5, -0.5), vee3 0.5, -0.5, -0.5) 108 109 var vertexColors - (0.0, 0.0, 0.0, 1.0), 17 black [ 1.0, 0.0, 0.0, 1.0). // red 1.0, 1.0, 0.0, 1.0), 1/ yellow 10.0, 1.0, 0.0, 1.0). // green 10.0, 0.0, 1.0, 1.0.1, 77 blue 11.0, 0.0, 1.0, 1.0). // magenta 1 1.0, 1.0, 1.0, 1.0 1. // white 10.0, 1.0, 1.0, 1.01 110. // cyan 111. 112. 113. // We need to parition the quad into two triangles in order for // WebGL to be able to render it. In this case, we create two // triangles from the quad indices 114. V/vertex color assigned by the index of the vertex 115. 116. var indices ta, b, c, a, c, d li for (var i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started