Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:23:00+00:00 2026-06-16T21:23:00+00:00

I have a CSS 3D cube that I’m trying to rotate left/right/up/down straight as

  • 0

I have a CSS 3D cube that I’m trying to rotate left/right/up/down straight as it appears to user. If I use css rotation functions, then I rotate the axis, not the cube.

There are lots of articles on the web about X,Y,Z matrix rotation calculation, but I’ve spend days now trying to set this thing and none of this information really helps me.

The work around to my problem would be a WebKitCSSMatrix object, which has its own rotation functions that work as magic. An example on Fiddle: http://jsfiddle.net/joecritch/tZBDW/. But again, that relies only uppon Webkit, but I need to be crossbrowsy here.

Now, there are 3 steps on the way of success:

1) I need to get current matrix, set directional vector (1,0,0 for up/down and 0,1,0 for left/right rotations) and set the angle. DONE.

2) I need to calculate new rotation vector based on current matrix. DONE.

3) I need to actually rotate my current matrix by new vector and angle. PROBLEM.

var newMArray = deMatrix(".cube");//getting current matrix from CSS

var v = [vecX, vecY, vecZ, 0];//current vector (1,0,0) or (0,1,0)

var newV = newMVector(newMArray, v);//calculating new vector for current matrix

//getting the angle for each axis based on new vector
angleX = newV[0]*angle;
angleY = newV[1]*angle;
angleZ = newV[2]*angle;

this.rotateX -= angleX;
this.rotateY -= angleY;
this.rotateZ -= angleZ; 

//calculating the rotation matrix
var rotationXMatrix, rotationYMatrix, rotationZMatrix, s, transformationMatrix;
rotationXMatrix = $M([[1, 0, 0, 0], [0, Math.cos(this.rotateX * deg2rad), Math.sin(-this.rotateX * deg2rad), 0], [0, Math.sin(this.rotateX * deg2rad), Math.cos(this.rotateX * deg2rad), 0], [0, 0, 0, 1]]);
rotationYMatrix = $M([[Math.cos(this.rotateY * deg2rad), 0, Math.sin(this.rotateY * deg2rad), 0], [0, 1, 0, 0], [Math.sin(-this.rotateY * deg2rad), 0, Math.cos(this.rotateY * deg2rad), 0], [0, 0, 0, 1]]);
rotationZMatrix = $M([[Math.cos(this.rotateZ * deg2rad), Math.sin(-this.rotateZ * deg2rad), 0, 0], [Math.sin(this.rotateZ * deg2rad), Math.cos(this.rotateZ * deg2rad), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]);

transformationMatrix = rotationXMatrix.x(rotationYMatrix).x(rotationZMatrix);//getting all axis rotation into one matrix

Than I’m setting new transformation matrix to my CSS Cube. The problem is – it doesn’t rotate as it should. Now I’m using Sylvester plugin to do all matrix calculation.

So, please help me on how to use my new vector for proper matrix rotation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:23:01+00:00Added an answer on June 16, 2026 at 9:23 pm

    Sylvester can generate rotation matrixes as well. Looking at the fiddle example – the webkit function that seems to do the rotation:

    // Rotate the Matrix around the transformed vector
    var newMatrix = m.rotateAxisAngle(vector.x, vector.y, vector.z, angle);
    

    Looks like it’s more along the lines of the Matrix.Rotation(angle [, axis]) function, I think you’d provide axis as a Sylvester Vector object, rather than the webkit x,y,z arguments – http://sylvester.jcoglan.com/api/matrix.html#rotation

    Multiplying the x,y,z matrices doesn’t work too well because the additional transforms will be applied on the new context. I’ve just fallen into this trap with this js/canvas page: http://benjaminbenben.com/projects/twittny_test/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have CSS that looks like this: div#sbar {position:absolute;top: 10px;bottom: 10px;left:10px; right: 10px;} There's
I have defined CSS in MasterPage so that all pages can use the same
we have CSS: #left,#right{width:450px;height:450px;} #left{position:absolute;left:20px;top:30px;} #right{position:absolute;left:420px;top:30px;float:center;} #left img, #right img{float:center; vertical-align:middle;cursor:pointer} Image is horizotal
It is advisable to use tables in HTML pages (now that we have CSS)?
I have css hover over images for my tabs and I'm trying to get
I have some CSS and HTML for horizontal tabs that works perfectly in jsfiddle.
I have a folder inside that folder I have css file and images.. I
I'm trying to use the > CSS child selector in IE7, and it doesn't
I have css that which follows.. <style> .body{ width:2px; height:3px; } </style> <style> .anotherOne{
suppose i have css like position: fixed; width: 200px; height: 100px; top: 50%; left:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.