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

  • SEARCH
  • Home
  • 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 8562823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:48:57+00:00 2026-06-11T16:48:57+00:00

I have an three.js object which is a given colour. I want to animate

  • 0

I have an three.js object which is a given colour. I want to animate it smoothly to another colour. During the animation, it should only show a direct gradation between the start and end. That is, it should not perform the tween linearly in RGB colour space. I’m not even sure that a linear tween within HSV space would look good either.

How can I get this kind of colour tween on a three.js object?

  • 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-11T16:48:58+00:00Added an answer on June 11, 2026 at 4:48 pm

    I have a version of this that makes a tween in HSV space. It’s not perfect, as many different hues can appear along the way.

    Three.js doesn’t include a method for getting the HSV values from a THREE.Color. So, add one:

    THREE.Color.prototype.getHSV = function()
    {
        var rr, gg, bb,
            h, s,
            r = this.r,
            g = this.g,
            b = this.b,
            v = Math.max(r, g, b),
            diff = v - Math.min(r, g, b),
            diffc = function(c)
            {
                return (v - c) / 6 / diff + 1 / 2;
            };
    
        if (diff == 0) {
            h = s = 0;
        } else {
            s = diff / v;
            rr = diffc(r);
            gg = diffc(g);
            bb = diffc(b);
    
            if (r === v) {
                h = bb - gg;
            } else if (g === v) {
                h = (1 / 3) + rr - bb;
            } else if (b === v) {
                h = (2 / 3) + gg - rr;
            }
            if (h < 0) {
                h += 1;
            } else if (h > 1) {
                h -= 1;
            }
        }
        return {
            h: h,
            s: s,
            v: v
        };
    };
    

    Then, the tween is relatively straightforward:

    new TWEEN.Tween(mesh.material.color.getHSV())
        .to({h: h, s: s, v: v}, 200)
        .easing(TWEEN.Easing.Quartic.In)
        .onUpdate(
            function()
            {
                mesh.material.color.setHSV(this.h, this.s, this.v);
            }
        )
        .start();
    

    I’d be interested to hear of a more perceptually natural transition.

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

Sidebar

Related Questions

I have a data object which has a base class with three derived classes,
In my application, I have three collection objects which store data. The data which
I have a business object project, which contains composite structure: public class Tree {
I'm planning to try contours on some image. Lets say I have three object
I have three vectors in an xts R object. Call them V1, V2, V3.
I have three lists, I need to move Animal object from list animalSource to
In my model I have three complex scopes returning the Discount object arrays. Each
As per the title I have three parts to this question... Is db4o object
I have this object I'm loading with THREE.objLoader and then create a mesh with
I have a simple object that allows you to assign three properties (x,y,z) (lets

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.