【问题标题】:convert color hex values for use in three.js json files转换颜色十六进制值以在 three.js json 文件中使用
【发布时间】:2016-06-14 07:28:20
【问题描述】:

问题 - 当我使用 three.js 编辑器时,它会输出一个 app.json 文件,其中颜色值被列为整数,例如:

"materials": [
{
    "uuid": "26C18ACF-3733-4B92-AC67-E25A132B27D0",
    "type": "MeshPhongMaterial",
    "color": 16777215,

我想直接在 JSON 文件中将该颜色修改为一些十六进制或 RGBA 等价物,但我不知道如何转换为该 JSON 文件使用的任何颜色系统。有人知道怎么做吗?

【问题讨论】:

    标签: javascript json colors three.js


    【解决方案1】:

    您可以使用 three.js 库将 base 10 颜色值转换为十六进制:

    var c = new THREE.Color( 123456789 ).getHexString();
    console.log( '0x' + c  );
    

    或者使用谷歌,只需输入

    0xff0000 in base 10
    

    16711680 in hex
    

    three.js r.74

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-18
      • 1970-01-01
      • 2019-10-29
      • 1970-01-01
      • 2020-08-06
      • 2012-09-14
      • 1970-01-01
      相关资源
      最近更新 更多