我在一个项目中使用了三个多个数组,我必须能够交叉引用它们无论如何我可以为数组中的元素设置多个数据位吗?
例如,我有一个名为ballArray []的数组,我这样使用它:
function createBall(tempPosSize)
{
geometry = new THREE.SphereGeometry(tempPosSize,16,16),
new THREE.MeshLambertMaterial({color: 0xff0000,reflectivity: 0.0});
ball = new THREE.Mesh( geometry, material );
ballArray[i] = ball;
}
有没有办法像JSON一样设置[I]
元素。所以我会ballArray[i] = {Name : foobar, BallData: ball}
?
答案 0 :(得分:1)
可能的确如此,但设置变量时存在一些小问题:
var ballArray = new Array();
function createBall(tempPosSize)
{
var geometry = new THREE.SphereGeometry(tempPosSize,16,16),
material = new THREE.MeshLambertMaterial({color: 0xff0000,reflectivity: 0.0});
var ball = new THREE.Mesh( geometry, material );
ballArray.push({Name: 'test', BallData: ball});
}