本文整理汇总了TypeScript中THREE.Object3D.traverse方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Object3D.traverse方法的具体用法?TypeScript Object3D.traverse怎么用?TypeScript Object3D.traverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Object3D
的用法示例。
在下文中一共展示了Object3D.traverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateMaterialUniforms
export function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {
const {width, height} = renderer.getSize()
const canvasHeight = height
const pixelRatio = renderer.getPixelRatio()
const ortho = camera.type === 'OrthographicCamera'
resolution.set(width, height)
projectionMatrixInverse.getInverse(camera.projectionMatrix)
projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()
group.traverse(function (o: any) {
const m = o.material
if (!m) return
const u = m.uniforms
if (!u) return
if (m.clipNear) {
const nearFactor = (50 - m.clipNear) / 50
const nearClip = cDist - (bRadius * nearFactor)
u.clipNear.value = nearClip
}
if (u.canvasHeight) {
u.canvasHeight.value = canvasHeight
}
if (u.resolution) {
u.resolution.value.copy(resolution)
}
if (u.pixelRatio) {
u.pixelRatio.value = pixelRatio
}
if (u.projectionMatrixInverse) {
u.projectionMatrixInverse.value.copy(projectionMatrixInverse)
}
if (u.projectionMatrixTranspose) {
u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)
}
if (u.ortho) {
u.ortho.value = ortho
}
})
}
示例2: updateCameraUniforms
export function updateCameraUniforms (group: Object3D, camera: Camera) {
projectionMatrixInverse.getInverse(camera.projectionMatrix)
projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()
group.traverse(function (o: any) {
const m = o.material
if (!m) return
const u = m.uniforms
if (!u) return
if (u.projectionMatrixInverse) {
u.projectionMatrixInverse.value.copy(projectionMatrixInverse)
}
if (u.projectionMatrixTranspose) {
u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)
}
})
}