Creating JSON data for three.js object matrices

Looking to create JSON for importing into three.js. My plan is to generate it in C# from my own geometry classes. While the schema provided by Three.js helps, I'm puzzled about the significance of the numbers in

jsonFormat4.object.children[1].matrix
within this sample JSON. The array values at that location are:

[1,0,0,0,0,1,0,0,0,0,1,0,100,200,150,1]

Through trial and error in the editor using File > Export Object, I've deciphered some values. For instance,

jsonFormat4.object.children[1].matrix[13]
appears to represent the x position,
jsonFormat4.object.children[1].matrix[14]
stands for the y position, and
jsonFormat4.object.children[1].matrix[15]
signifies the z position.

In addition, I'm curious about the other values and whether there's detailed documentation available on this topic (if not, perhaps this query could fill that void). How exactly are the numbers at the remaining indices determined? Appreciate any insights or guidance you can offer.

Answer №1

At the moment, we have successfully solved the rotation around the z-axis. This solution is sufficient for my current needs, but it could potentially be beneficial to others:

Z Rotation (Ψ) = (180/π) * ATAN(matrix[0]/[matrix[1])

Scale X = matrix[0] / cos(Ψ)

Scale Y = matrix[5] / cos(Ψ)

Scale Z = matrix[10]

Assuming X and Y rotations are both zero.

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

Video on YouTube restarts upon hiding and revealing its container div

Is there a way to retain the progress and playback position of a YouTube video embedded within a div on a webpage? Currently, when I hide and then show the div using jQuery/CSS, the video reloads and starts from the beginning. Is there a solution to avoid ...

What is the best way to update a Textfield in each row of a table using PHP and AJAX when a different textfield in the same row is changed

My JavaScript code adds a row with two cells to a table when a button is clicked. One cell contains a livesearch textfield, and the other cell has a quantity textfield whose value is supposed to dynamically change based on the livesearch results. I'v ...

Attempting to incorporate a Slide-In Navigation Menu

As a newcomer to front-end development, I am currently working on incorporating a Slide-in Sidebar snippet into my layout. I suspect that there may be an issue with the JavaScript code, but since I'm not familiar with JS, it's difficult for me t ...

I'm having trouble parsing JSON in a Powershell script and I'm unsure of the cause

Recently, I came across this JSON data retrieved from a REST API: { "QueryBD_REST_CI_01Response": { "rsStart": 0, "rsCount": 3, "rsTotal": 18872, "BD_REST_CI_01Set": { ...

Guide on managing firebase and webrtc tasks within a client-side component using Next.js 13

I developed a Next.js 13 application to share the camera feed using WebRTC and Firestore. Below is my page.tsx file where I am facing some challenges. I can't make this server-side because I'm using React hooks, and moving it to the client side i ...

JavaScript does not support clicking on an iframe

Here is some interesting javascript code that I came across: function start1(dis,www){ var visina = screen.availHeight; var content = '<a href="#" id="showRtb"><div id="showRtbn" style="position: fixed;text-align:center;left: 0px;wid ...

The use of anonymous arrow functions results in Fast Refresh not maintaining local component state

I am facing an issue with the code in my pages/index.js file: import React from 'react'; import dynamic from 'next/dynamic'; const TVChartContainer = dynamic( () => import('../components/TVChartContainer').then ...

Generating a TypeScript interface by focusing on an object

I am looking to set up a file factory, specifically for JSON files containing translations. { "field": "", "group": { "field_1": "", "field_2": "" }, ... } My goal is to create a template JSON file that includes all the f ...

Guide to obtaining context vnode within vue 3 custom directives

Unable to retrieve context from directive <template lang="pug"> div(class="form") select(name="name" v-model="form.input" v-select="form.inputs") option(v-for="(option, ke ...

`Incorporating components into React by string matching`

Currently, I am in the process of creating a Calendar that includes a header and a calendar. The purpose of the header is to select the type of calendar; either weekly or monthly. To achieve this functionality, I created a placeholder component called Cal ...

A guide on retrieving specific strings from a JSON array within an Android application

My server is sending me JSON data with the following structure: { "sub":"system", "created":1525944295496, "exp":1526001295, "user":{ "userId":"5af2e4f4dae7bb353ac9d9d2", "userFirstName":"Sastra", "userMiddleName":"Test", ...

Using mui-datatables to display an array of objects

Seeking help from users of mui-datatables. While it successfully handles data in the form of an array of strings, there is an issue when trying to load an array of objects resulting in the following error: bundle.js:126379 Uncaught (in promise) TypeEr ...

Javascript: creating a conditional based on elements within an array

Suppose I have an array with the following elements: thisarray = new Array("this", "that", "theotherthing"); Is it possible to create a conditional statement like this? if(thisarray[0] == thisvar && thisarray[1] == thisvar && thisarray[2 ...

I am encountering problems with converting Array to JSON format in PHP for utilization in Javascript

I always face challenges when it comes to converting Array into JSON format. Currently, I am utilizing a selectbox plugin developed by TexoTela. For this plugin to work, it requires a specific JSON structure as shown below: { "ajax1": "AJAX option 1 ...

Background image that is vertically responsive

I'm struggling with getting a full-page background image to maintain a consistent margin around all sides, especially at the bottom. I want the image to be vertically responsive using only CSS, without relying on Javascript. Any suggestions on how to ...

Submission of the form was cancelled, causing a loop to occur

I'm encountering an issue with submitting a file through a standard HTML form. After uploading the file, the process seems to get trapped in a continuous loop where the file keeps uploading repeatedly. The submission of the form is done using jQuery, ...

Generate a collection of items through replication

Develop a function that takes specific input and generates an array of objects with a length of 10 by incrementing the ID of each duplicate object. The first object in the output array should have "visible" set to true, while all others should have it set ...

formatting a JSON response in an HTML document

Can someone assist me with formatting the json return in html from my jquery json result? Please see below for my html code: $("document").ready(function(){ $(".js-ajax-php-json").submit(function(){ var data = { "action": "testerer" }; ...

NextJS is currently unable to identify and interpret TypeScript files

I am looking to build my website using TypeScript instead of JavaScript. I followed the NextJS official guide for installing TS from scratch, but when I execute npm run dev, a 404 Error page greets me. Okay, below is my tsconfig.json: { "compilerOption ...

What is the best way to conceal a menu that automatically scrolls to the content when it is clicked?

Below is a Codepen with a menu that isn't behaving as expected. var menu = document.querySelector('.nav__list'); var burger = document.querySelector('.burger'); var doc = $(document); var l = $('.scrolly'); var panel = $ ...