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


TypeScript THREE.Vector3类代码示例

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


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

示例1: function

	var panUp = function() {

		var v = new three.Vector3();

		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,代码行数:14,代码来源:three.orbitcontrols.ts

示例2: store

  const onDocumentMouseDown = (event) => {
    let state: State = store().getState()
    let scene: THREE.Scene = getScene(state)
    let camera: THREE.Camera = getCamera(state)
    let renderer: THREE.Renderer = getRenderer(state)

    event.preventDefault()

    mouse.x = (event.clientX / renderer.domElement.width) * 2 - 1
    mouse.y = -(event.clientY / renderer.domElement.height) * 2 + 1

    let vector = new THREE.Vector3(mouse.x, mouse.y, 0.5)
    vector.unproject(camera)
    let dir = vector.sub(camera.position).normalize()
    let distance = -camera.position.z / dir.z
    let pos = camera.position.clone().add(dir.multiplyScalar(distance))
    pos.z = 250

    store().dispatch({
      type: 'MOUSE_DOWN',
      pos: pos
    })
  }
开发者ID:wwju,项目名称:economics_game,代码行数:23,代码来源:listeners.ts

示例3: function

  const cgPolymer = function (p: Polymer) {
    const localAngle = 20
    const centerDist = 2.0

    const residueStore = p.residueStore
    const offset = p.residueIndexStart

    const helixbundle = new Helixbundle(p)
    const pos = helixbundle.position

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

    for (let i = 0, il = p.residueCount; i < il; ++i) {
      c1.fromArray(pos.center as any, i * 3)  // TODO
      c2.fromArray(pos.center as any, i * 3 + 3)  // TODO
      const d = c1.distanceTo(c2)

      if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {
        residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)
        residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)
      }
    }
  }
开发者ID:arose,项目名称:ngl,代码行数:24,代码来源:structure-utils.ts

示例4: getControlPoints

function getControlPoints(p1: Vector3, p2: Vector3, p3: Vector3, tension: number){
    var d12 = p1.clone().sub(p2).length();
    var d23 = p2.clone().sub(p3).length();
    var fa = tension * d12 / (d12+d23);
    var fb = tension * d23 / (d12+d23);
    var c1 = p2.clone().sub(p3.clone().sub(p1).multiplyScalar(fa));
    var c2 = p2.clone().add(p3.clone().sub(p1).multiplyScalar(fb));

    return {
        left: c1,
        right: c2
    };
}
开发者ID:yyjhao,项目名称:galaxy-tunnel,代码行数:13,代码来源:map_generator.ts

示例5: _genStarPoint

 private _genStarPoint(point: Vector3, star: Star, radius: number) {
     var distAdd = Section.size * 3;
     if (star) {
         distAdd += this._getDist(star);
     }
     var count = 0;
     while (count < 10) {
         var mag = radius * 0.7;
         var p = point.clone().add(new Vector3(
             randomRange(-mag, mag),
             randomRange(-mag / 10, mag / 10),
             randomRange(-mag, mag)
         ));
         if (this._stars.every((star) => {
             return dist(p, star.position) > distAdd + this._getDist(star);
         })) {
             return p;
         }
     }
     throw "no";
 }
开发者ID:yyjhao,项目名称:galaxy-tunnel,代码行数:21,代码来源:map_generator.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

示例7: closer

function closer (x: Vector3, a: Vector3, b: Vector3) {
  return x.distanceTo(a) < x.distanceTo(b)
}
开发者ID:arose,项目名称:ngl,代码行数:3,代码来源:picking-proxy.ts

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

示例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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。