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


TypeScript THREE.Euler类代码示例

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


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

示例1: toEuler

export function toEuler(quaternion: number[]) {
    const e = new Euler();
    const q = new Quaternion(...quaternion);
    return e.setFromQuaternion(q)
        .toArray();
}
开发者ID:chevtche,项目名称:Brayns,代码行数:6,代码来源:quaternion.ts

示例2: animate

function animate(time: number) {
  animationId = requestAnimationFrame(animate);

  if (previousTime != null) {
    const elapsedTime = time - previousTime;
    accumulatedTime = Math.min(accumulatedTime + elapsedTime, maxAccumulatedTime);
  }
  previousTime = time;

  const ticks = Math.floor(accumulatedTime / clientTickDuration);
  accumulatedTime -= ticks * clientTickDuration;

  if (pub != null && pub.match == null) {
    sceneAngleY += Math.PI / 640;
  } else {
    if (Math.abs(sceneAngleY) > 0.1) sceneAngleY = lerp(sceneAngleY, 0, 0.15);
    else sceneAngleY = 0;
  }
  if (sceneAngleY > Math.PI) sceneAngleY -= Math.PI * 2;
  scene.setRotationFromEuler(tmpEuler.set(0, sceneAngleY, 0));

  let width = canvas.parentElement.clientWidth;
  let height = canvas.parentElement.clientHeight;
  if (width > height * 4 / 3) width = height * 4 / 3;
  if (height > width * 3 / 4) height = width * 3 / 4;

  canvas.width = width;
  canvas.height = height;

  camera.updateProjectionMatrix();

  threeRenderer.setSize(canvas.width, canvas.height, false);
  threeRenderer.render(scene, camera);

  input.gather();
  if (input.hasJustPressedLeftTrigger) { socket.emit("throwBall"); }

  for (const playerId in modelsById) {
    const model = modelsById[playerId];
    const { avatar } = players.byId[playerId];
    const hasBall = pub.ball.playerId === playerId;

    model.nametag.setRotationFromEuler(tmpEuler.set(0, -sceneAngleY, 0));

    if (playerId === myPlayerId) {
      for (let i = 0; i < ticks; i++) input.predict(pub.match != null, pub.ball.playerId === myPlayerId, ballThrownTimer > 0);

      model.root.position.set(input.prediction.x, 0, input.prediction.z);
      model.body.setRotationFromEuler(tmpEuler.set(0, -input.prediction.angleY, 0));
      model.shoulders.setRotationFromEuler(tmpEuler.set(0, 0, input.prediction.catching || hasBall ? input.prediction.angleX : -Math.PI * 0.4));
    } else {
      // TODO: Lerp between previous and current!
      model.root.position.set(avatar.x, 0, avatar.z);
      model.body.setRotationFromEuler(tmpEuler.set(0, -avatar.angleY, 0));
      model.shoulders.setRotationFromEuler(tmpEuler.set(0, 0, avatar.catching || hasBall ? avatar.angleX : -Math.PI * 0.4));
    }

    model.root.position.y = shared.getAvatarY(avatar.jump);
  }

  if (pub != null && pub.ball.playerId == null) {
    ballModel.position.set(pub.ball.x, pub.ball.y, pub.ball.z);
    ballMarker.position.set(pub.ball.x, 0.01, pub.ball.z);
  }
}
开发者ID:elisee,项目名称:bball,代码行数:65,代码来源:index.ts


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