Rotating and translating Matrix4 in THREE.JS through manual adjustment

As I delve into the complexities of three.js coordinate spaces, I have come to understand the significance of object.matrix and object.matrixWorld.

After discovering a thought-provoking blog post titled Matrix Basics. How to step away from storing an orientation as ’3 angles’, I was inspired to explore manual manipulation of Matrix4 properties as opposed to relying on Euler rotations.

My objective seems simple - translating my cube away from the origin at 0,0,0 and then rotating it in world space. The envisioned result is for the cube to first translate along the y-axis before executing a rotation that brings it back to the plane in a sweeping arc. However, in reality, it simply reverts back to the origin without acknowledging the translation.

Despite delving into extensive readings on vectors and matrices, I struggle to grasp how three.js manages the matrixWorld and matrix. My attempts with both have left me perplexed!

To showcase my dilemma, I have created a fiddle: http://jsfiddle.net/SCXNQ/151/

Please review the render() function to witness my endeavor firsthand!

EDIT - [solved] UPDATED JS FIDDLE OF WORKING VERSION 14/09/12

Thanks to the insightful answer below, I have updated my fiddle to demonstrate the intended outcome - http://jsfiddle.net/SCXNQ/363/

Answer №1

Check out this link for the solution you're looking for.

UPDATE: Oops, I made a mistake with the Matrix order (another concept you should understand well) -> give this one a try too.

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

Choose a Superclass or Interface for your Subclass

I currently have the following setup: class Dog extends Animal{} class Animal{} This is a simple inheritance structure. Now, I have another class that contains all types of animals. class Farm{ animals: Animal[]; } At a certain point in my applic ...

Troubleshooting issue: Failure in proper functionality of Jquery's slideDown

My form is divided into 3 sections, with the latter two initially hidden using CSS. When users click the next button in the first section, the second section is supposed to slide down into view. However, I'm experiencing an issue where the animation s ...

The JavaScript .load() function fails to run

Attempting to create a straightforward Newsfeed page based on user interests. Here is the code I have implemented for this purpose. The issue I'm facing is that while the code works fine on my local server, it encounters problems when running on an on ...

What is the best way to generate a new Object using an Object that contains Arrays?

I currently have a global array saved with a catalog and a list of items that the user has saved. My task is to generate a new array of Objects (with arrays) containing only the items saved by the user. I am working with javascript in react-native, and I ...

Unforeseen outcomes when setting background colors with Anime.js

I've recently started experimenting with Anime.js. I have a piece of code that I'm using to animate a div element with an id of a. anime({ targets: "#a", translateX: 250, color: "#fff", backgroundColor: "hsl(200, 50%, 50%)", ...

Error in material mapping: glDrawElements is trying to access vertices that are out of range in attribute 2

I have developed an algorithm that allows users to input data or a function and then generates a graphical representation of the function. It essentially creates a surface map, similar to the one you can see here. The graphing functionality is working well ...

Exploring nested JavaScript attributes using a personalized, dynamic approach

When working with this JavaScript object, the goal is to access its nested properties dynamically using a method that begins with 'get' followed by a CamelCased attribute name (provided that the attribute is defined in the initial object). While ...

Ways to display a block within the visible window by simply clicking on another block

I'm in need of assistance with this issue. Please take a look at the fiddle link below to understand the specific requirement. $(document).ready(function(){ $('a.n-stand-b, a.n-stand-a, a.e-stand-b, a.e-stand-a, a.w-stand-b, a.w-stand-a, a.s-s ...

What is the process for displaying a texture on a spherical object?

// defining scene size var WIDTH = 1650, HEIGHT = 700; // setting camera attributes var VIEW_ANGLE = 100, ASPECT = WIDTH / HEIGHT, NEAR = 0.1, FAR = 10000; // selecting DOM element to attach to var $container = $('#container'); ...

Unlocking the Secret: How to Bind a Global Touch Event Handler in Angular 4 to Prevent iOS Safari Page Drag

The issue at hand is that within my Angular 4 application, there is a D3.js chart that relies on user touch input for dragging a needle to a specific value. The drag functionality is triggered by 'touchstart', while the registration of the final ...

Creating self-transparency effects with intersecting polygons in Three.js

I am currently experimenting with creating a simple tree billboard using two crossed planes with a partially transparent texture. However, I am facing an issue where the self-transparency only seems to work for one plane due to potential depth-sorting prob ...

Tips for enhancing a JSON array by including attributes through JavaScripts

I need help in dynamically constructing JSON using Javascript. { "Events": [{ "Name": "Code Change", "Enabled": "true", "Properties": [{ "Name": "url", "Value": "val" }] }], "Properti ...

implementing datepicker on multiple textboxes in jQuery upon button click

I have the ability to show multiple text boxes using jQuery. I am now looking to add a datepicker to those text boxes. Any assistance in finding a solution would be greatly appreciated. Thank you in advance. ...

Top Margin: Supported by Chrome and Safari

After troubleshooting why the margin-top is not working on Safari, but works fine on Chrome, I discovered a discrepancy. Chrome Upon hovering over an item in the image, the cursor changes as expected. This feature operates smoothly in Chrome. https://i. ...

Incorporating multiple canvases into a single Canvas Texture

This question is somewhat similar to this [reference][1]. My goal is to enable users to add multiple text layers and image layers to a single mesh. For each text/image, I create a separate layer using its own canvas, like so: getTextCanvas(textLayer) { ...

Having trouble with the copy to clipboard function of Prism JS on my NextJs application

I am facing an issue while trying to integrate a copy to clipboard plugin from prismjs into my next.js app. I have searched for documentation on this but couldn't find any relevant information. Despite going through various websites and implementing t ...

AngularJS factory or filter failing to update properly

I have been working on a system that manages translations in my factory. I set the language as a string and then use a filter to update the view when the language changes. Everything works fine if I define the language in the view beforehand, but when I t ...

The value 'true' was returned for an attribute 'exact' that is not of boolean type

How can I resolve this warning? Sample Code const Main = (header, navigation) => { return ( <> <div> {navigation !== false && <Navigation />} </div> </> ) } I attempted this soluti ...

Helper for Three.js edges

As a beginner in Threejs, I have been using the EdgesHelper to achieve the desired look. However, I have encountered two questions: How is the default edge width calculated? Is it possible to change the edge width? After searching extensively, it seems ...

403 Forbidden error occurs when AJAX value %27 is triggered

Stack Overflow has seen a multitude of inquiries related to apostrophes in form fields, particularly concerning unencoded values. An insightful post sheds light on the limitations of using encodeURIComponent(str) for handling apostrophes and suggests crea ...