gpt4 book ai didi

javascript - PDF3D - 如何提取网格颜色并更改按钮背景填充颜色

转载 作者:行者123 更新时间:2023-12-03 03:25:38 26 4
gpt4 key购买 nike

我目前正在编写一个脚本来提取网格 Material 颜色并将该值替换为某些按钮的 fillColor 属性。

这是按下按钮时运行的脚本:

var c3d = this.getAnnots3D(this.pageNum)[0].context3D;

function printObjectsNames() {
for (var i=0; i < c3d.scene.meshes.count; i++) {

//Creates an array of the 3D meshes in the scene
var array = c3d.scene.meshes.getByIndex(i);

//Extract the mesh name and populate some Text Fields
this.getField("Mesh "+(i+1)).value = array.name;

//Extract the mesh material color and replace
//some buttons background color
???????

//Print some values in the console
console.println("Object: "+array);
console.println("Object name: "+array.name);
console.println("Diffuse Color: "+array.material.diffuseColor);
}
}

printObjectsNames();

正如预期的那样,当我运行命令时,控制台会显示此内容

Object: [object Mesh]
Object name: STK1000
Diffuse Color: Color: ( 0, 1, 1 )
Object: [object Mesh]
Object name: LUCIDO
Diffuse Color: Color: ( 1, 0, 1 )
Object: [object Mesh]
Object name: STRUTTURA
Diffuse Color: Color: ( 0.7451, 0.7451, 0.7451 )

3个网格有不同的diffuseColor

问题是我无法将值diffuseColor放入背景颜色属性中,因为array.material.diffuseColor提取

颜色:( 0, 1, 1 ) 而不仅仅是 ( 0, 1, 1 )

如何仅提取 ( 0, 1, 1 ) 值?

非常感谢您的帮助,

胡里奥

最佳答案

OP 自己对问题的回答:

这是放入 for 循环中的解决方案:

 var objColor = array.material.diffuseColor
var r = objColor.r
var g = objColor.g
var b = objColor.b

this.getField("foo").fillColor = [ "RGB", r, g, b ];

关于javascript - PDF3D - 如何提取网格颜色并更改按钮背景填充颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46345993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com