I'm currently delving into the intricacies of three.js in order to experiment with a basic mechanism. My end goal is to visualize board tilt (front view) in relation to axle orientation (plan view) for different designs on an XY plot, although that's more like step five or six in my process. Right now, I'm grappling with step one, trying to grasp the concept of obtaining an axis of rotation, symbolized by a small diameter cylinder.
This image clearly illustrates a setback. https://i.sstatic.net/akqtW.png
- I aim to use the matrix functions already available in Three.js for data visualization and system analysis.
- The purpose of the worldMatrix object within a mesh object is not entirely clear. I presume it contains information about location, orientation, and scaling, but I'm unsure how to extract this data for translating or rotating other components in the 3D space.
- Perhaps it would be better to create duplicates of original component locations and matrix values, and then work from those copies. Reaching the same point after tilting left and right seems to pose a challenge when working directly with the original.
The model features a simple skateboard. My objective is to rotate the front truck hanger (housing an axle and two wheels) along a tilted axis based on user input from a slider element.
var euler;
const rotateMeshGroup =( meshGroup, rotationAxis, angleOfRotation) =>{
euler = new THREE.Euler().setFromRotationMatrix(rotationAxis.matrixWorld);
meshGroup.children.forEach(item => {
item.rotateOnAxis(euler, THREE.MathUtils.degToRad(angleOfRotation));
})
}
I'm struggling with creating an axis of rotation. While I grasp the concept of a 3D angle, I'm unsure about determining the distance from the axis. Is it calculated using a matrix cross product (shortest distance to a 3D axis with perpendicular distance)?
edit: I'm still grappling with this issue. After sifting through numerous console.logs, I haven't found any information in the predefined matrices that could help me. I've converted the pivot axis from a small diameter cylinder mesh object into a line defined by two vector endpoints. Currently, I'm contemplating delta-x, delta-y, delta-z calculations (translate, rotate, translate back) within the RotateMeshGroup function.
Any pointers or suggestions?