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


TypeScript Vector3.toArray方法代码示例

本文整理汇总了TypeScript中THREE.Vector3.toArray方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.toArray方法的具体用法?TypeScript Vector3.toArray怎么用?TypeScript Vector3.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THREE.Vector3的用法示例。


在下文中一共展示了Vector3.toArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

 const addAxis = function (v1: Vector3, v2: Vector3) {
   v1.toArray(vertexPosition as any, offset * 2)
   v2.toArray(vertexPosition as any, offset * 2 + 3)
   v1.toArray(edgePosition1 as any, offset)
   v2.toArray(edgePosition2 as any, offset)
   offset += 3
 }
开发者ID:arose,项目名称:ngl,代码行数:7,代码来源:axes-representation.ts

示例2: nearest

  nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {
    // Log.time( "Kdtree nearest" );

    if (point instanceof Vector3) {
      point.toArray(pointArray as any)
    } else if (point instanceof AtomProxy) {
      point.positionToArray(pointArray)
    }

    const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)

    const indices = this.kdtree.indices
    const nodes = this.kdtree.nodes
    const atomIndices = this.atomIndices
    const resultList = []

    for (let i = 0, n = nodeList.length; i < n; ++i) {
      const d = nodeList[ i ]
      const nodeIndex = d[ 0 ]
      const dist = d[ 1 ]

      resultList.push({
        index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],
        distance: dist
      })
    }

    // Log.timeEnd( "Kdtree nearest" );

    return resultList
  }
开发者ID:arose,项目名称:ngl,代码行数:31,代码来源:kdtree.ts

示例3: rotateToBoundingBox

export function rotateToBoundingBox(camera: CameraProps, bb: BoundingBox): CameraProps {
    const orientation = new Quaternion(0, 0, 0, 1);
    const {center, target} = getBoundingBoxCenter(bb);

    const position = getPositionForRotation({
        ...camera,
        target: target.toArray(),
        position: FORWARD.toArray()
    }, orientation);

    return {
        position: position.toArray(),
        orientation: orientation.toArray(),
        target: center.toArray()
    };
}
开发者ID:chevtche,项目名称:Brayns,代码行数:16,代码来源:camera.ts

示例4: getAxis

  getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {
    localAngle = localAngle || 30
    centerDist = centerDist || 2.5
    ssBorder = ssBorder === undefined ? false : ssBorder

    const polymer = this.polymer
    const structure = polymer.structure
    const n = polymer.residueCount
    const residueIndexStart = polymer.residueIndexStart

    const pos = this.position

    const cp = colorParams || {}
    cp.structure = structure

    const colormaker = ColormakerRegistry.getScheme(cp)

    const radiusFactory = new RadiusFactory(radiusParams)

    let j = 0
    let k = 0

    const axis: number[] = []
    const center: number[] = []
    const beg: number[] = []
    const end: number[] = []
    const col: number[] = []
    const pick = []
    const size = []
    const residueOffset = []
    const residueCount = []

    let tmpAxis = new Float32Array(n * 3)
    let tmpCenter = new Float32Array(n * 3)

    let _axis, _center
    const _beg = new Vector3()
    const _end = new Vector3()

    const rp1 = structure.getResidueProxy()
    const rp2 = structure.getResidueProxy()
    const ap = structure.getAtomProxy()

    const c1 = new Vector3()
    const c2 = new Vector3()

    let split = false

    for (let i = 0; i < n; ++i) {
      rp1.index = residueIndexStart + i
      c1.fromArray(pos.center as any, i * 3)

      if (i === n - 1) {
        split = true
      } else {
        rp2.index = residueIndexStart + i + 1
        c2.fromArray(pos.center as any, i * 3 + 3)

        if (ssBorder && rp1.sstruc !== rp2.sstruc) {
          split = true
        } else if (c1.distanceTo(c2) > centerDist) {
          split = true
        } else if (pos.bending[ i ] > localAngle) {
          split = true
        }
      }

      if (split) {
        if (i - j < 4) {
          j = i
          split = false
          continue
        }

        ap.index = rp1.traceAtomIndex

        // ignore first and last axis
        tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)
        tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)

        _axis = calculateMeanVector3(tmpAxis).normalize()
        _center = calculateMeanVector3(tmpCenter)

        _beg.fromArray(tmpCenter as any)
        projectPointOnVector(_beg, _axis, _center)

        _end.fromArray(tmpCenter as any, tmpCenter.length - 3)
        projectPointOnVector(_end, _axis, _center)

        _axis.subVectors(_end, _beg)

        _axis.toArray(axis as any, k)
        _center.toArray(center as any, k)
        _beg.toArray(beg as any, k)
        _end.toArray(end as any, k)

        colormaker.atomColorToArray(ap, col, k)

        pick.push(ap.index)

//.........这里部分代码省略.........
开发者ID:arose,项目名称:ngl,代码行数:101,代码来源:helixbundle.ts

示例5: getPosition

  getPosition (): HelixPosition {
    const polymer = this.polymer
    const structure = polymer.structure
    const n = polymer.residueCount
    const n3 = n - 3

    const center = new Float32Array(3 * n)
    const axis = new Float32Array(3 * n)
    const diff = new Float32Array(n)
    const radius = new Float32Array(n)
    const rise = new Float32Array(n)
    const twist = new Float32Array(n)
    const resdir = new Float32Array(3 * n)

    const r12 = new Vector3()
    const r23 = new Vector3()
    const r34 = new Vector3()

    const diff13 = new Vector3()
    const diff24 = new Vector3()

    const v1 = new Vector3()
    const v2 = new Vector3()
    const vt = new Vector3()

    const _axis = new Vector3()
    const _prevAxis = new Vector3()

    const _resdir = new Vector3()
    const _center = new Vector3(0, 0, 0)

    const type = 'trace'
    const a1 = structure.getAtomProxy()
    const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))
    const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))
    const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))

    for (let i = 0; i < n3; ++i) {
      a1.index = a2.index
      a2.index = a3.index
      a3.index = a4.index
      a4.index = polymer.getAtomIndexByType(i + 3, type)!  // TODO

      const j = 3 * i

      // ported from GROMACS src/tools/gmx_helixorient.c

      r12.subVectors(a2 as any, a1 as any)  // TODO
      r23.subVectors(a3 as any, a2 as any)  // TODO
      r34.subVectors(a4 as any, a3 as any)  // TODO

      diff13.subVectors(r12, r23)
      diff24.subVectors(r23, r34)

      _axis.crossVectors(diff13, diff24).normalize()
      _axis.toArray(axis as any, j)  // TODO

      if (i > 0) {
        diff[ i ] = _axis.angleTo(_prevAxis)
      }

      const tmp = Math.cos(diff13.angleTo(diff24))
      twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)

      const diff13Length = diff13.length()
      const diff24Length = diff24.length()

      radius[ i ] = (
        Math.sqrt(diff24Length * diff13Length) /
        // clamp, to avoid instabilities for when
        // angle between diff13 and diff24 is near 0
        Math.max(2.0, 2.0 * (1.0 - tmp))
      )

      rise[ i ] = Math.abs(r23.dot(_axis))

      //

      v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)
      v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)

      v1.subVectors(a2 as any, v1)  // TODO
      v2.subVectors(a3 as any, v2)  // TODO

      v1.toArray(center as any, j + 3)  // TODO
      v2.toArray(center as any, j + 6)  // TODO

      //

      _resdir.subVectors(a1 as any, _center)  // TODO
      _resdir.toArray(resdir as any, j)  // TODO

      _prevAxis.copy(_axis)
      _center.copy(v1)
    }

    //

    // calc axis as dir of second and third center pos
    // project first traceAtom onto axis to get first center pos
//.........这里部分代码省略.........
开发者ID:arose,项目名称:ngl,代码行数:101,代码来源:helixorient.ts

示例6: getPotentialEdges

    /**
     * Returns the potential edges to destination nodes for a set
     * of nodes with respect to a source node.
     *
     * @param {Node} node The source node
     * @param {Array<Node>} nodes Potential destination nodes
     * @param {Array<string>} fallbackKeys Keys for destination nodes that should
     *                                     be returned even if they do not meet
     *                                     the criteria for a potential edge.
     */
    public getPotentialEdges(node: Node, nodes: Node[], fallbackKeys: string[]): IPotentialEdge[] {
        if (!node.worthy || !node.merged) {
            return [];
        }

        let currentDirection: THREE.Vector3 =
            this._spatial.viewingDirection(node.apiNavImIm.rotation);
        let currentVerticalDirection: number =
            this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);

        let potentialEdges: IPotentialEdge[] = [];

        for (let potential of nodes) {
            if (!potential.merged ||
                potential.key === node.key) {
                continue;
            }

            let enu: number[] = this._geoCoords.geodeticToEnu(
                potential.latLon.lat,
                potential.latLon.lon,
                potential.apiNavImIm.calt,
                node.latLon.lat,
                node.latLon.lon,
                node.apiNavImIm.calt);

            let motion: THREE.Vector3 = new THREE.Vector3(enu[0], enu[1], enu[2]);
            let distance: number = motion.length();

            if (distance > this._settings.maxDistance &&
                fallbackKeys.indexOf(potential.key) < 0) {
                continue;
            }

            let motionChange: number = this._spatial.angleBetweenVector2(
                currentDirection.x,
                currentDirection.y,
                motion.x,
                motion.y);

            let verticalMotion: number = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);

            let direction: THREE.Vector3 =
                this._spatial.viewingDirection(potential.apiNavImIm.rotation);

            let directionChange: number = this._spatial.angleBetweenVector2(
                currentDirection.x,
                currentDirection.y,
                direction.x,
                direction.y);

            let verticalDirection: number = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
            let verticalDirectionChange: number = verticalDirection - currentVerticalDirection;

            let rotation: number = this._spatial.relativeRotationAngle(
                node.apiNavImIm.rotation,
                potential.apiNavImIm.rotation);

            let worldMotionAzimuth: number =
                this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);

            let sameSequence: boolean = potential.sequence != null &&
                node.sequence != null &&
                potential.sequence.key === node.sequence.key;

            let sameMergeCc: boolean =
                 (potential.apiNavImIm.merge_cc == null && node.apiNavImIm.merge_cc == null) ||
                 potential.apiNavImIm.merge_cc === node.apiNavImIm.merge_cc;

            let potentialEdge: IPotentialEdge = {
                apiNavImIm: potential.apiNavImIm,
                directionChange: directionChange,
                distance: distance,
                fullPano: potential.fullPano,
                motionChange: motionChange,
                rotation: rotation,
                sameMergeCc: sameMergeCc,
                sameSequence: sameSequence,
                verticalDirectionChange: verticalDirectionChange,
                verticalMotion: verticalMotion,
                worldMotionAzimuth: worldMotionAzimuth,
            };

            potentialEdges.push(potentialEdge);
        }

        return potentialEdges;
    }
开发者ID:BogusCurry,项目名称:mapillary-js,代码行数:98,代码来源:EdgeCalculator.ts


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