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


TypeScript Vector3.add方法代码示例

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


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

示例1: update

    update(world: World, control: Control) {
        var beta = control.motionTracker.getBeta();
        this._acceleration.copy(this._speed).divideScalar(30).clampLength(0.1, 3);
        this._acceleration.applyAxisAngle(yAxis, horizontalRotation(beta));

        this._speed.add(this._acceleration);
        this._speed.clampLength(0, 80);

        var newPos = new Vector3().addVectors(this._position, this._speed);
        this._playerTracker.updateSection(newPos);
        var collision = this._playerTracker.getCollision();
        if (collision) {
            newPos = collision;
            this._speed.multiplyScalar(0.3);
            newPos = this._playerTracker.getAdjusted(newPos);
            this._position.copy(newPos);
        } else {
            newPos = this._playerTracker.getAdjusted(newPos);

            this._acceleration.subVectors(newPos, this._position).sub(this._speed).clampLength(0, 5);
            this._speed.add(this._acceleration);
            this._position.add(this._speed);
        }

        this._direction.setFromUnitVectors(
            new Vector3(0, 0, 1),
            this._speed.clone().setY(0).setLength(1));

    }
开发者ID:yyjhao,项目名称:galaxy-tunnel,代码行数:29,代码来源:player.ts

示例2: closeAtom

  /**
   * Close-by atom
   * @type {AtomProxy}
   */
  get closeAtom () {
    const cp = this.canvasPosition
    const ca = this.closestBondAtom!
    if (!ca) return undefined

    const acp = this.controls.getPositionOnCanvas(ca as any)  // TODO

    ca.positionToVector3(tmpVec)
    if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)
    tmpVec.applyMatrix4(this.component.matrix)
    const viewer = this.controls.viewer
    tmpVec.add(viewer.translationGroup.position)
    tmpVec.applyMatrix4(viewer.rotationGroup.matrix)

    const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)
    const sc = this.component as StructureComponent
    const radius = sc.getMaxRepresentationRadius(ca.index)
    //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)

    if (cp.distanceTo(acp) <= radius/scaleFactor) {
      return ca
    } else {
      return undefined
    }
  }
开发者ID:arose,项目名称:ngl,代码行数:29,代码来源:picking-proxy.ts

示例3: panUp

		return function panUp( distance, objectMatrix ) {

			v.setFromMatrixColumn( objectMatrix, 1 ); // get Y column of objectMatrix
			v.multiplyScalar( distance );

			panOffset.add( v );

		};
开发者ID:timofeevda,项目名称:seismic-beachballs-demo,代码行数:8,代码来源:three.orbitcontrols.ts

示例4: panAtom

  panAtom (x: number, y: number) {
    if (!this.atom || !this.component) return

    this.atom.positionToVector3(tmpAtomVector)
    tmpAtomVector.add(this.viewer.translationGroup.position)
    tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)

    this._setPanVector(x, y, tmpAtomVector.z)
    this._transformPanVector()

    this.atom.positionAdd(tmpPanVector)
    this.component.updateRepresentations({ 'position': true })
  }
开发者ID:arose,项目名称:ngl,代码行数:13,代码来源:trackball-controls.ts

示例5: if

 path.forEach((point, ind) => {
     if (ind === 0 || ind === path.length - 1) {
         newPath.push(point);
         return;
     }
     var tmpNeighbour = neighbour;
     if (ind < neighbour) {
         tmpNeighbour = ind;
     } else if (ind >= path.length - neighbour) {
         tmpNeighbour = path.length - 1 - ind;
     }
     var newPoint = new Vector3();
     for (var i = ind - tmpNeighbour; i <= ind + tmpNeighbour; i++) {
         newPoint.add(path[i]);
     }
     newPoint.divideScalar(tmpNeighbour * 2 + 1);
     var starInd = pointToStar[ind];
     if (starInd !== null) {
         var star = this._stars[starInd];
         newPoint.sub(star.position).clampLength(this._getDist(star), 1/0).add(star.position);
     }
     newPath.push(newPoint);
 });
开发者ID:yyjhao,项目名称:galaxy-tunnel,代码行数:23,代码来源:map_generator.ts


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