当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Matrix4.copy方法代码示例

本文整理汇总了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)
  }
开发者ID:arose,项目名称:ngl,代码行数:55,代码来源:volume.ts

示例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
    }
  })
}
开发者ID:arose,项目名称:ngl,代码行数:48,代码来源:viewer-utils.ts

示例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)
    }
  })
}
开发者ID:arose,项目名称:ngl,代码行数:20,代码来源:viewer-utils.ts


注:本文中的THREE.Matrix4.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。