本文整理汇总了TypeScript中THREE.Matrix4.multiplyMatrices方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Matrix4.multiplyMatrices方法的具体用法?TypeScript Matrix4.multiplyMatrices怎么用?TypeScript Matrix4.multiplyMatrices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Matrix4
的用法示例。
在下文中一共展示了Matrix4.multiplyMatrices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
scene.traverseVisible(function (o) {
if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {
return
}
const attributes = (o.geometry as any).attributes // TODO
const n = attributes.position.count
if (n === 0) return
matrix.multiplyMatrices(
camera.matrixWorldInverse, o.matrixWorld
)
modelViewProjectionMatrix.multiplyMatrices(
camera.projectionMatrix, matrix
)
let sortData, sortArray, zArray: Float32Array, cmpFn
if (!o.userData.sortData) {
zArray = new Float32Array(n)
sortArray = new Uint32Array(n)
cmpFn = function (ai: number, bi: number) {
const a = zArray[ ai ]
const b = zArray[ bi ]
if (a > b) return 1
if (a < b) return -1
return 0
}
sortData = {
__zArray: zArray,
__sortArray: sortArray,
__cmpFn: cmpFn
}
o.userData.sortData = sortData
} else {
sortData = o.userData.sortData
zArray = sortData.__zArray
sortArray = sortData.__sortArray
cmpFn = sortData.__cmpFn
}
for (let i = 0; i < n; ++i) {
vertex.fromArray(attributes.position.array, i * 3)
vertex.applyMatrix4(modelViewProjectionMatrix)
// negate, so that sorting order is reversed
zArray[ i ] = -vertex.z
sortArray[ i ] = i
}
quicksortCmp(sortArray, cmpFn)
let index, indexSrc, indexDst, tmpTab
for (let name in attributes) {
const attr = attributes[ name ]
const array = attr.array
const itemSize = attr.itemSize
if (!sortData[ name ]) {
sortData[ name ] = new Float32Array(itemSize * n)
}
tmpTab = sortData[ name ]
sortData[ name ] = array
for (let i = 0; i < n; ++i) {
index = sortArray[ i ]
for (let j = 0; j < itemSize; ++j) {
indexSrc = index * itemSize + j
indexDst = i * itemSize + j
tmpTab[ indexDst ] = array[ indexSrc ]
}
}
attributes[ name ].array = tmpTab
attributes[ name ].needsUpdate = true
}
})