Question
Solving for Task 2 and running the HTML (points.html) through Notepad++ in Chrome. Below will be as follows: The HTML (points.html) to run on the
Solving for Task 2 and running the HTML (points.html) through Notepad++ in Chrome. Below will be as follows:
The HTML (points.html) to run on the browser, the Javascript (points.js) to edit only in the "Vertpos" variable, and the last JS (util.js) class for fruther context. The goal is edit the first JS class (points.js) in the "vertpos" variable to make the HTML (points.html) print out a set of 4 points 100 times collectively, but the points must follow a pattern like a straight line, an X or a + sign. The math.random (in points.js) areas need to be edited ONLY to make the pattern. When the HTML (points.html) in the first pic is ran, the points must come out to some type of pattern. I'm trying to be as detailed as possible and thanks in advance. Pictures below:
Task 2: Modify example 2 to draw a pattern of points. The given example draws points at random location. Modify this example so that points have some simple pattern. For instance, you might consider the points moving along a circle, or you might draw the points tracing out an X or a cross (plus) sign, or generate points around the boundary in sequence. Or pick something else that is simple to generate. Note that the the WebGL display coordinate system ranges from (-1,-1) in the lower left corner to (+1, +1) in the upper right corner. So the points you generate must be within this range ((0, 0) is at the center of the display). Use floats for your point coordinates. You should be able to put your point generation within the render() function or you can define a separate a function. Implementation: The only modification to the application is the method used to generate the points. The render() method executes continuously, so you are generating 1 point within the function in some order to generate the desired pattern (in the given application a single point at random position is being generated and drawn). The shaders (in the HTML) should remain the same. JOUW NA 9 NO 8.; points.html X points.js X utils.js x 1 2 ] 3" + gl.getShaderInfoLog( fragshdr ) + ""; alert(msg); return -1; } } // create a shader program let program gl.create Program(); = // attach the two chaders to the noram T! let msg points.html x points.js x utils.js X 99 let program gl.create Program(); 100 101 // attach the two shaders to the program 102 gl.attachShader (program, vertshdr); 103 gl.attachShader (program, fragshdr); 104 105 // link the program 106 gl.linkProgram program ); 107 108 // if linking failed, print error log 109 if (!gl.getProgramParameter (program, gl.LINK_STATUS)) { 110 "Shader program failed to link. The error log is:" 111 + "
" + gl.getProgramInfoLog( program) + ""; 112 alert(msg); 113 return -1; 114 } 115 return program; 116 } 117 118 function flatten( v ) { 119 120 // This function takes Javascript arrays and flattens it into 121 // a set of floating point values; this is required since Javascript 122 // arrays, being objects, cannot be passed to GL buffers directly, 123 // buffers expect raw float (or whatever type chose) values 124 125 // For matrices, column major is expected by it, so this function 126 // transposes them for convenience and then flattens it 127 128 if (v.matrix === true) { 129 v = transpose (v); 130 } 131 132 var n = v.length; 133 var elemsAreArrays false; 134 135 if (Array.isArray ( [0])) { 136 elemsAreArrays = true; 137 n *= v[0] .length; 138 } 139 140 var float_vals new Float32Array (n); 141 142 if (elemsAreArrays) { 143 var idx 144 for ( var i 0; i 2 ] 3
" + gl.getShaderInfoLog( fragshdr ) + ""; alert(msg); return -1; } } // create a shader program let program gl.create Program(); = // attach the two chaders to the noram T! let msg points.html x points.js x utils.js X 99 let program gl.create Program(); 100 101 // attach the two shaders to the program 102 gl.attachShader (program, vertshdr); 103 gl.attachShader (program, fragshdr); 104 105 // link the program 106 gl.linkProgram program ); 107 108 // if linking failed, print error log 109 if (!gl.getProgramParameter (program, gl.LINK_STATUS)) { 110 "Shader program failed to link. The error log is:" 111 + "
" + gl.getProgramInfoLog( program) + ""; 112 alert(msg); 113 return -1; 114 } 115 return program; 116 } 117 118 function flatten( v ) { 119 120 // This function takes Javascript arrays and flattens it into 121 // a set of floating point values; this is required since Javascript 122 // arrays, being objects, cannot be passed to GL buffers directly, 123 // buffers expect raw float (or whatever type chose) values 124 125 // For matrices, column major is expected by it, so this function 126 // transposes them for convenience and then flattens it 127 128 if (v.matrix === true) { 129 v = transpose (v); 130 } 131 132 var n = v.length; 133 var elemsAreArrays false; 134 135 if (Array.isArray ( [0])) { 136 elemsAreArrays = true; 137 n *= v[0] .length; 138 } 139 140 var float_vals new Float32Array (n); 141 142 if (elemsAreArrays) { 143 var idx 144 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