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


TypeScript Vector3.copy方法代码示例

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


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

示例1: projectPointOnVector

    structure.eachAtom(function (ap: AtomProxy) {
      projectPointOnVector(p.copy(ap as any), ax1, center)  // TODO
      const dp1 = t.subVectors(p, center).normalize().dot(ax1)
      const dt1 = p.distanceTo(center)
      if (dp1 > 0) {
        if (dt1 > d1a) d1a = dt1
      } else {
        if (dt1 > d1b) d1b = dt1
      }

      projectPointOnVector(p.copy(ap as any), ax2, center)
      const dp2 = t.subVectors(p, center).normalize().dot(ax2)
      const dt2 = p.distanceTo(center)
      if (dp2 > 0) {
        if (dt2 > d2a) d2a = dt2
      } else {
        if (dt2 > d2b) d2b = dt2
      }

      projectPointOnVector(p.copy(ap as any), ax3, center)
      const dp3 = t.subVectors(p, center).normalize().dot(ax3)
      const dt3 = p.distanceTo(center)
      if (dp3 > 0) {
        if (dt3 > d3a) d3a = dt3
      } else {
        if (dt3 > d3b) d3b = dt3
      }
    })
开发者ID:arose,项目名称:ngl,代码行数:28,代码来源:principal-axes.ts

示例2: 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

示例3: _applyRotation

    private _applyRotation(camera: Camera): void {
        if (camera == null) {
            return;
        }

        let q: THREE.Quaternion = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3( 0, 0, 1 ));
        let qInverse: THREE.Quaternion = q.clone().inverse();

        let offset: THREE.Vector3 = new THREE.Vector3();
        offset.copy(camera.lookat).sub(camera.position);
        offset.applyQuaternion(q);
        let length: number = offset.length();

        let phi: number = Math.atan2(offset.y, offset.x);
        phi += this._rotationDelta.phi;

        let theta: number = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
        theta += this._rotationDelta.theta;
        theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));

        offset.x = Math.sin(theta) * Math.cos(phi);
        offset.y = Math.sin(theta) * Math.sin(phi);
        offset.z = Math.cos(theta);
        offset.applyQuaternion(qInverse);

        camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
    }
开发者ID:Caboosey,项目名称:mapillary-js,代码行数:27,代码来源:TraversingState.ts

示例4: function

		return function( deltaX, deltaY ) {

			var element = scope.domElement === document ? scope.domElement.body : scope.domElement;

			if ( scope.object instanceof three.PerspectiveCamera ) {

				// perspective
				var position = scope.object.position;
				offset.copy( position ).sub( scope.target );
				var targetDistance = offset.length();

				// half of the fov is center to top of screen
				targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );

				// we actually don't use screenWidth, since perspective camera is fixed to screen height
				panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
				panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );

			} else if ( scope.object instanceof three.OrthographicCamera ) {

				// orthographic
				panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
				panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );

			} else {

				// camera neither orthographic nor perspective
				console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
				scope.enablePan = false;

			}

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

示例5: _update

  _update () {
    if (!this.getVisibility()) return

    const s = this.element.style
    const cp = this._canvasPosition
    const vp = this._viewerPosition
    const cr = this._clientRect

    this._cameraPosition.copy(vp)
      .add(this.viewer.translationGroup.position)
      .applyMatrix4(this.viewer.rotationGroup.matrix)
      .sub(this.viewer.camera.position)

    if (this._cameraPosition.z < 0) {
      s.display = 'none'
      return
    } else {
      s.display = 'block'
    }

    const depth = this._cameraPosition.length()
    const fog = this.viewer.scene.fog as any  // TODO

    s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()
    s.zIndex = (Math.round((fog.far - depth) * 100)).toString()

    this.stage.viewerControls.getPositionOnCanvas(vp, cp)

    s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'
    s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'
  }
开发者ID:arose,项目名称:ngl,代码行数:31,代码来源:annotation.ts

示例6: setPosition

 setPosition(position: Vector3) {
     this.position.copy(position);
     this.mesh.position.copy(position);
     if (this.halo) {
         this.halo.position.copy(position);
     }
 }
开发者ID:yyjhao,项目名称:galaxy-tunnel,代码行数:7,代码来源:star.ts

示例7: setParameters

  /**
   * Set representation parameters
   * @alias SurfaceRepresentation#setParameters
   * @param {SurfaceRepresentationParameters} params - surface parameter object
   * @param {Object} [what] - buffer data attributes to be updated,
   *                        note that this needs to be implemented in the
   *                        derived classes. Generally it allows more
   *                        fine-grained control over updating than
   *                        forcing a rebuild.
   * @param {Boolean} what.position - update position data
   * @param {Boolean} what.color - update color data
   * @param {Boolean} [rebuild] - whether or not to rebuild the representation
   * @return {SurfaceRepresentation} this object
   */
  setParameters (params: Partial<SurfaceRepresentationParameters>, what?: SurfaceDataFields, rebuild?: boolean) {
    if (params && params.isolevelType !== undefined &&
      this.volume
    ) {
      if (this.isolevelType === 'value' &&
        params.isolevelType === 'sigma'
      ) {
        this.isolevel = this.volume.getSigmaForValue(this.isolevel)
      } else if (this.isolevelType === 'sigma' &&
        params.isolevelType === 'value'
      ) {
        this.isolevel = this.volume.getValueForSigma(this.isolevel)
      }

      this.isolevelType = params.isolevelType
    }

    if (params && params.boxCenter) {
      this.boxCenter.copy(params.boxCenter)
      delete params.boxCenter
    }

    // Forbid wireframe && contour as in molsurface
    if (params && params.wireframe && (
      params.contour || (params.contour === undefined && this.contour)
    )) {
      params.wireframe = false
    }

    super.setParameters(params, what, rebuild)

    if (this.volume) {
      this.volume.getBox(this.boxCenter, this.boxSize, this.box)
    }

    if (params && params.colorVolume !== undefined) {
      if (what) what.color = true
    }

    if (this.surface && (
      params.isolevel !== undefined ||
      params.negateIsolevel !== undefined ||
      params.smooth !== undefined ||
      params.wrap !== undefined ||
      params.boxSize !== undefined ||
      (this.boxSize > 0 &&
        !this.__box.equals(this.box))
    )) {
      this.build({
        'position': true,
        'color': true,
        'index': true,
        'normal': !this.contour
      })
    }

    return this
  }
开发者ID:arose,项目名称:ngl,代码行数:72,代码来源:surface-representation.ts

示例8: prepare

  prepare (callback: () => void) {
    if (this.volume) {
      let isolevel

      if (this.isolevelType === 'sigma') {
        isolevel = this.volume.getValueForSigma(this.isolevel)
      } else {
        isolevel = this.isolevel
      }
      if (this.negateIsolevel) isolevel *= -1

      if (!this.surface ||
        this.__isolevel !== isolevel ||
        this.__smooth !== this.smooth ||
        this.__contour !== this.contour ||
        this.__wrap !== this.wrap ||
        this.__boxSize !== this.boxSize ||
        (this.boxSize > 0 &&
            !this.__boxCenter.equals(this.boxCenter))
      ) {
        this.__isolevel = isolevel
        this.__smooth = this.smooth
        this.__contour = this.contour
        this.__wrap = this.wrap
        this.__boxSize = this.boxSize
        this.__boxCenter.copy(this.boxCenter)
        this.__box.copy(this.box)

        const onSurfaceFinish = (surface: Surface) => {
          this.surface = surface
          callback()
        }

        if (this.useWorker) {
          this.volume.getSurfaceWorker(
            isolevel, this.smooth, this.boxCenter, this.boxSize,
            this.contour, this.wrap, onSurfaceFinish
          )
        } else {
          onSurfaceFinish(
            this.volume.getSurface(
              isolevel, this.smooth, this.boxCenter, this.boxSize,
              this.contour, this.wrap
            )
          )
        }
      } else {
        callback()
      }
    } else {
      callback()
    }
  }
开发者ID:arose,项目名称:ngl,代码行数:53,代码来源:surface-representation.ts

示例9: handleVertex

        function handleVertex(v) {

            n.fromArray(normals, v * 3);
            n2.copy(n);

            t = tan1[v];

            // Gram-Schmidt orthogonalize

            tmp.copy(t);
            tmp.sub(n.multiplyScalar(n.dot(t))).normalize();

            // Calculate handedness

            tmp2.crossVectors(n2, t);
            test = tmp2.dot(tan2[v]);
            w = (test < 0.0) ? - 1.0 : 1.0;

            tangents[v * 4] = tmp.x;
            tangents[v * 4 + 1] = tmp.y;
            tangents[v * 4 + 2] = tmp.z;
            tangents[v * 4 + 3] = w;

        }
开发者ID:jkstrawn,项目名称:lighthouse,代码行数:24,代码来源:bufferGeometryUtils.ts


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