87,910
社区成员
发帖
与我相关
我的任务
分享
复制函数定义:
module.exports.duplicate = function duplicate(nestedArray, mirror) {
var out = []
nestedArray.forEach(x => {
let x1 = mirror ? -x : x
out.push(x1, x)
})
return out
}
path数组的创建:
//first create a circle with a small radius
let path = arc(0, 0, 1, 0, Math.PI*1.5, false, 256)
path = path.map((point, i) => {
let [x, y, z] = point
let v3 = [x||0, y||0, z||0]
mat4.rotateY(spin, spin, Math.sin(x/10 * Math.sin(time/1)))
transformMat4(v3, v3, spin)
return v3
})
//each pair has a mirrored direction
let direction = duplicate(path.map(x => 1), true) // 这里x=>1怎么理解
//now get the positional data for each vertex
let positions = duplicate(path)
let previous = duplicate(path.map(relative(-1))) // 这里两个relative函数嘛意思,结合map以后了,
let next = duplicate(path.map(relative(+1)))
let indexUint16 = createIndices(path.length)