【问题标题】:Three.js animated color change control三.js动画换色控制
【发布时间】:2019-08-09 02:49:41
【问题描述】:

我正在努力在 Three.js 中为这个动画应用正确的色调。即使我应用正确的色调,例如:#008080,实际颜色也不是绿色,而是蓝色或其他颜色。看起来有一些高亮颜色的计算。如何关闭或控制它?

  const PARTICLE_SIZE = 1;
  const textureAttr = {
    resolution: 64,
    radius: 32,
    color: '#008080'
  };

这里的工作示例:

https://jsfiddle.net/6cq1re9o/

【问题讨论】:

    标签: javascript animation three.js


    【解决方案1】:

    颜色被片段着色器修改:

    // noise RGB values
    float r = 1. - 2.0 * noise;
    float g = 0.0;
    float b = 1. - 1.0 * noise;
    vec3 foo = vec3(r*2.0, g, b*1.5);
    
    // calculate a new color using the above noise
    gl_FragColor = vec4( foo, 1.0 ) * texture2D( texture, gl_PointCoord );
    


    由于您只需要提供的十六进制颜色,只需取消注释并使用此位:
    // grab the textel
    gl_FragColor = texture2D( texture, vec2(pos.x, pos.y) );
    // or just use the noisy bit without the noise
    // gl_FragColor = texture2D( texture, gl_PointCoord );
    

    texture2D 文档here。它只是返回纹理上一个点的颜色。

    fiddle 中查看。


    如果要“控制”它,则需要修改用作噪点的foo RGB 颜色。


    这可能只是我的看法,但这个 webpack blob 非常不可读。下次请尝试制作minimal example focusing only on the problem

    【讨论】:

    • Piotr,你的例子看起来坏了?动画不再流畅,有正方形而不是圆点?
    • 好的,我已经搞定了:jsfiddle.net/6mqo2usj/2 谢谢你的帮助
    猜你喜欢
    • 1970-01-01
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 1970-01-01
    • 2012-10-02
    • 2016-01-29
    相关资源
    最近更新 更多