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 7403355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:03:31+00:00 2026-05-29T05:03:31+00:00

I have a cube in ThreeJS and I would like to rotate it 90

  • 0

I have a cube in ThreeJS and I would like to rotate it 90 degrees clockwise every time I press a button. I think I have the basic gist of it: create a Three.Animation instance, bind it to the cube, and then have the animation begin every time I press the correct button. However, I’m having a difficult time understanding ThreeJS’s API, because it doesn’t seem to contain any examples for its methods.

This is THREE.js’s Animation constructor: ( root, data, interpolationType, JITCompile ) I don’t understand what goes into the fields. I’m guessing root would be where I put my cube, but what about the rest?

Also can I just call animation.play() to cause the animation whenever I want? And how does the animationHandler work?

  • 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-05-29T05:03:32+00:00Added an answer on May 29, 2026 at 5:03 am

    I think for for rotating an object 90 degrees clockwise, using the TWEEN class will do. I think the Animation class is handy for heavier stuff (like bones/skin morphs/etc.)

    To use the tween class there are 3 basic steps:

    1. include the class in your file (<script src="js/Tween.js"></script>)
    2. add your tween for the event you need (new TWEEN.Tween( cube.rotation ).to( { y:Math.random()}, 1000 ).easing( TWEEN.Easing.Quadratic.EaseOut).start();)
    3. update the tween in your render loop (TWEEN.update();)

    You can have a have a look at the cubes tween example for a start.

    I’ve modified the default cube example to have the tween in:

    three.js cube tween

    <!doctype html>
    <html lang="en">
        <head>
            <title>three.js canvas - geometry - cube</title>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
            <style>
                body {
                    font-family: Monospace;
                    background-color: #f0f0f0;
                    margin: 0px;
                    overflow: hidden;
                }
            </style>
        </head>
        <body>
    
            <script src="../build/Three.js"></script>
            <script src="js/Tween.js"></script>
            <script src="js/RequestAnimationFrame.js"></script>
            <script src="js/Stats.js"></script>
    
            <script>
    
                var container, stats;
    
                var camera, scene, renderer;
    
                var cube, plane;
    
                var windowHalfX = window.innerWidth / 2;
                var windowHalfY = window.innerHeight / 2;
    
                var rad90 = Math.PI * .5;
    
                init();
                animate();
    
                function init() {
    
                    container = document.createElement( 'div' );
                    document.body.appendChild( container );
    
                    var info = document.createElement( 'div' );
                    info.style.position = 'absolute';
                    info.style.top = '10px';
                    info.style.width = '100%';
                    info.style.textAlign = 'center';
                    info.innerHTML = 'click to tween';
                    container.appendChild( info );
    
                    camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
                    camera.position.y = 150;
                    camera.position.z = 500;
    
                    scene = new THREE.Scene();
    
                    // Cube
    
                    var materials = [];
    
                    for ( var i = 0; i < 6; i ++ ) {
    
                        materials.push( [ new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ] );
    
                    }
    
                    cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() );
                    cube.position.y = 150;
                    cube.overdraw = true;
                    scene.add( cube );
    
                    // Plane
    
                    plane = new THREE.Mesh( new THREE.PlaneGeometry( 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xe0e0e0 } ) );
                    plane.rotation.x = - 90 * ( Math.PI / 180 );
                    plane.overdraw = true;
                    scene.add( plane );
    
                    renderer = new THREE.CanvasRenderer();
                    renderer.setSize( window.innerWidth, window.innerHeight );
    
                    container.appendChild( renderer.domElement );
    
                    stats = new Stats();
                    stats.domElement.style.position = 'absolute';
                    stats.domElement.style.top = '0px';
                    container.appendChild( stats.domElement );
    
                    document.addEventListener( 'mousedown', onDocumentMouseDown, false );
                }
    
                //
    
                function onDocumentMouseDown( event ) {
    
                    event.preventDefault();
                    new TWEEN.Tween( cube.rotation ).to( {  y:  cube.rotation.y + rad90}, 1000 ).easing( TWEEN.Easing.Quadratic.EaseOut).start();
                    new TWEEN.Tween( plane.rotation ).to( { z:  plane.rotation.z + rad90}, 1000 ).easing( TWEEN.Easing.Quadratic.EaseOut).start();
    
                    console.log("click");
                }
    
                //
    
                function animate() {
    
                    requestAnimationFrame( animate );
    
                    render();
                    stats.update();
    
                }
    
                function render() {
                    TWEEN.update();
                    renderer.render( scene, camera );
    
                }
    
            </script>
    
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cube which I want to rotate. I also have a light
I have a cube in SQL Server Analysis services 2008 that contains a time
I have drawn cube using c++. I need to rotate around the axis in
I have a Cube which I want to rotate using mouse motion. So if
I have a cube map texture in OpenGL, and I'd like to render one
I have ModelVisual3D of a cube. I want to translate and rotate it at
I have a line (actually a cube) going from (x1,y1,z1) to (x2,y2,z2). I would
I have a simple 3D cube that I can rotate using the following code:
I have a cube with a typical snapshot structure and daily granularity (like inventory
I have a ball moving inside a cube, and I detect when it goes

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.