Robotic Arm in Motion

GOAL: The aim of the code below is to create a robotic arm that consists of three layers (upper, lower, and middle), all connected to the base. There are four sliders provided to independently move each part except for the base which moves the entire arm.

ISSUE: When attempting to run this code, there is no visual output on the screen and no errors in the console. I'm unable to identify the root cause of this issue despite troubleshooting. An image of the output has been attached for reference.

RESOLUTION: Solution pending further investigation.


var NumVertices = 36;

var points = [];
var colors = [];

var vertices = [
    vec4( -0.5, -0.5,  0.5, 1.0 ),
    vec4( -0.5,  0.5,  0.5, 1.0 ),
    vec4(  0.5,  0.5,  0.5, 1.0 ),
    vec4(  0.5, -0.5,  0.5, 1.0 ),
    vec4( -0.5, -0.5, -0.5, 1.0 ),
    vec4( -0.5,  0.5, -0.5, 1.0 ),
    vec4(  0.5,  0.5, -0.5, 1.0 ),
    vec4(  0.5, -0.5, -0.5, 1.0 )
];

var vertexColors = [
    vec4( 0.0, 0.0, 0.0, 1.0 ),  // black
    vec4( 1.0, 0.0, 0.0, 1.0 ),  // red
    vec4( 1.0, 1.0, 0.0, 1.0 ),  // yellow
    vec4( 0.0, 1.0, 0.0, 1.0 ),  // green
    vec4( 0.0, 0.0, 1.0, 1.0 ),  // blue
    vec4( 1.0, 0.0, 1.0, 1.0 ),  // magenta
    vec4( 1.0, 1.0, 1.0, 1.0 ),  // white
    vec4( 0.0, 1.0, 1.0, 1.0 )   // cyan
];
...

<html>

<script id="vertex-shader" type="x-shader/x-vertex">
...
// Additional HTML content and scripts have been omitted for brevity.
...
</body>
<canvas id="gl-canvas" width="512"" height="512"
Oops ... your browser doesn't support the HTML5 canvas element
</canvas>
</body>
</html>

https://i.sstatic.net/g3oai.png

Answer №1

One of the initial steps I took was incorporating webgl-lint

<script src="https://greggman.github.io/webgl-lint/webgl-lint.js" crossorigin></script>

Upon doing so, an error was immediately detected:

Uncaught Error: https://greggman.github.io/webgl-lint/webgl-lint.js:2843: 
error in 
uniformMatrix4fv(WebGLUniformLocation("modelViewMatrix"),
false,
[5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 5, 0, NaN, NaN, NaN, NaN]): element 12 of argument 2 is NaN
: trying to set uniform 'modelViewMatrix'
    at reportError (webgl-lint.js:2163)
    at reportFunctionError (webgl-lint.js:2924)
    at checkArrayForUniformImpl (webgl-lint.js:2843)
    at webgl-lint.js:2869
    at checkArgs (webgl-lint.js:2972)
    at WebGLRenderingContext.ctx.<computed> [as uniformMatrix4fv] (webgl-lint.js:3016)
    at base (js:230)
    at render (js:267)
    at init (js:223)

It was noticed within the code that the problem was with the usage of rotate, which should only take 2 arguments - an angle and an axis:

   r = rotate(angle, x, y, z); // BAD!
   r = rotate(angle, [x, y, z]); // Good

Resolving this issue brought forth a new error from webgl-lint indicating that scale4 requires 4 arguments:

   s = scale4(x, y, z); // BAD!
   s = scale4(x, y, z, w); // good

The correct value for w in this case would be 1.

With the rendering fixed, attention was then given to the sliders. It was suggested to call render within each onchange function and possibly switch to using oninput instead of onchange.

... Rest of the content follows ...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The relative positioning is currently being obstructed

Having some trouble using position:relative to shift my logo to the left of my webpage. Oddly, moving it 20px seems to have no effect, but shifting it by 300px downwards causes it to vanish completely. Here's a snippet of my current code: .container ...

Once the Ajax request is finished, the cookie deletion function ceases to function

When the website loads, a cookie is generated using PHP before any other content or headers are sent. This is done with the following code: $steam_login_verify = SteamSignIn::validate(); if(isset($_COOKIE['userid'])) { //work with cookie va ...

Personalizing Material-UI's select component: A step-by-step guide

Desired Outcome: https://i.stack.imgur.com/khNHn.png https://i.stack.imgur.com/dQzVz.png Progress So Far: https://i.stack.imgur.com/CUixn.png Struggling to Position SVG Icon Next to Text: https://i.stack.imgur.com/4GFtA.png Issue with Black Line Whe ...

Styling Process Steps in CSS

Just starting out with CSS! I'm looking to replicate the Process Step design shown in the image. https://i.stack.imgur.com/Cq0jY.png Here's the code I've experimented with so far: .inline-div{ padding: 1rem; border: 0.04rem gray ...

In React Native, you can pass native component properties as props, while also defining custom ones using a TypeScript interface

I am working on a component called AppText where I need to utilize a Props interface and also be able to accept additional props that can be spread using the spread operator. However, I encountered this error: Type '{ children: string; accessible: tru ...

Modifying the dimensions of media:thumbnail in Blogger's RSS Feed

I came across this post, but it seems like there have been updates in the past 4 years regarding how thumbnails are generated for Blogger posts. I've attempted various methods, but so far none of them have been successful. If anyone could assist me in ...

Is there a way to access the value of a variable that is defined in FileReader.onloadend from within the callback function of XMLHttpRequest.onreadystatechange

I'm trying to access the value of the variable ext (defined within the function reader.onloadend) in the function xhr.onreadystatechange. Currently, it is returning undefined. Does anyone have any suggestions on how to resolve this issue? function pr ...

Learn how to import MarkerClusterer from the React Google Maps library without using the require method

The sample provided utilizes const { MarkerClusterer } = require("react-google-maps/lib/components/addons/MarkerClusterer");, however, I would prefer to use the import method. I attempted using: import { MarkerClusterer } from 'react-google-maps/lib ...

Utilize Javascript to convert centimeters into inches

Can anyone help me with a JavaScript function that accurately converts CM to IN? I've been using the code below: function toFeet(n) { var realFeet = ((n*0.393700) / 12); var feet = Math.floor(realFeet); var inches = Math.round(10*((realFeet ...

useEffect does not trigger a rerender on the primary parent component

I am facing an issue where the main parent component does not re-render when I change the state 'click button' in another component while using useEffect. Oddly enough, the main <App /> component only re-renders properly when I reload the p ...

Utilizing browser's local storage to dynamically update text in buttons and panels

In my file, I have the following code snippet (I've removed other irrelevant code) <div data-role="panel" id="loc_panel"> <h2>Panel Header</h2> <p>info about this stop</p> </div> <!-- /panel --> < ...

I recently started learning Next.js and I'm interested in organizing my website with multiple page folders but still using a single dynamic route labeled as [id]

my-nextjs-app/ |-- .next/ |-- node_modules/ |-- public/ |-- src/ | |-- components/ | |-- men/ | | |-- [id]/ | | |-- page.tsx # Specific ID static page for Men's category | | |-- page.tsx # General stat ...

Converting a string to an HTML object in Angular using Typescript and assigning it to a variable

I am facing an issue with passing HTML content from a service to a div element. I have a function that fetches HTML content as a string from a file and converts it into an HTML object, which I can see working in the console. However, when trying to assign ...

The JQuery TextNTags plugin eliminates tag formatting once the trigger syntax has been modified

I have incorporated the JQuery TextNTags plugin into my web application. Here is the original code snippet: $.browser = { webkit: true }; $(function () { $('textarea.tagged_text').textntags({ triggers: {'!': { ...

What is the best approach to styling a sub-child element within the first child using TailwindCSS?

Currently working with React (Next.js) and TailwindCSS. <ul> <li> <h1 className="bg-red-400">first</h1> </li> <li> <h1 className="bg-green-400">second</h1> </li> &l ...

Activating GL extension EXT_blend_minmax

As per the information on this MDN page, the support for EXT_blend_minmax began with Chrome 38 and Firefox 47. Despite trying to utilize it in Three.js, I have encountered issues with both the latest versions of Chrome and Firefox: const renderer = new TH ...

A step-by-step guide on submitting a CSV file with Ajax along with additional form information

Imagine you have an HTML form with input fields for Name, Location, Address, and Family members (to be uploaded as a CSV file), along with a Submit button. However, when you click on submit, the data from the CSV file is not being passed to the PHP script. ...

Unlock the mystery of identifying which trace is selected in the plot.ly JS legend

When using plot.ly, it is possible to set up a listener for legend click events. I am wondering how to determine which trace in the legend was clicked on. To provide a more specific example, let's say there are two traces (trace0, trace1) in a line gr ...

Showing Firestore Data as a map type: Issue encountered - React child cannot be an Object

Retrieving data from firestore: const [product, setProduct] = useState([]); const fetchProducts = async () => { const querySnapshot = await getDocs(collection(db, "products")); const productsArray = []; querySnapshot.forEach((doc) => { ...

Change the background color of cells according to the value they contain

I have a scenario where I am populating a table with random numbers, and I want the background color of each cell to change based on the value of the number in that cell. Since these numbers refresh periodically, I need the colors to update accordingly as ...