本文整理汇总了TypeScript中THREE.Matrix4.copy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Matrix4.copy方法的具体用法?TypeScript Matrix4.copy怎么用?TypeScript Matrix4.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Matrix4
的用法示例。
在下文中一共展示了Matrix4.copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setMatrix
/**
* set transformation matrix
* @param {Matrix4} matrix - 4x4 transformation matrix
* @return {undefined}
*/
setMatrix (matrix: Matrix4) {
this.matrix.copy(matrix)
const bb = this.boundingBox
const v = this.center // temporary re-purposing
const x = this.nx - 1
const y = this.ny - 1
const z = this.nz - 1
bb.makeEmpty()
bb.expandByPoint(v.set(x, y, z))
bb.expandByPoint(v.set(x, y, 0))
bb.expandByPoint(v.set(x, 0, z))
bb.expandByPoint(v.set(x, 0, 0))
bb.expandByPoint(v.set(0, y, z))
bb.expandByPoint(v.set(0, 0, z))
bb.expandByPoint(v.set(0, y, 0))
bb.expandByPoint(v.set(0, 0, 0))
bb.applyMatrix4(this.matrix)
bb.getCenter(this.center)
// make normal matrix
const me = this.matrix.elements
const r0 = new Vector3(me[0], me[1], me[2])
const r1 = new Vector3(me[4], me[5], me[6])
const r2 = new Vector3(me[8], me[9], me[10])
const cp = new Vector3()
// [ r0 ] [ r1 x r2 ]
// M3x3 = [ r1 ] N = [ r2 x r0 ]
// [ r2 ] [ r0 x r1 ]
const ne = this.normalMatrix.elements
cp.crossVectors(r1, r2)
ne[ 0 ] = cp.x
ne[ 1 ] = cp.y
ne[ 2 ] = cp.z
cp.crossVectors(r2, r0)
ne[ 3 ] = cp.x
ne[ 4 ] = cp.y
ne[ 5 ] = cp.z
cp.crossVectors(r0, r1)
ne[ 6 ] = cp.x
ne[ 7 ] = cp.y
ne[ 8 ] = cp.z
this.inverseMatrix.getInverse(this.matrix)
}
示例2: 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
}
})
}
示例3: 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)
}
})
}