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


TypeScript Mesh.rotateY方法代码示例

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


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

示例1:

const largerWallGeometry = new THREE.PlaneBufferGeometry(shared.court.width + shared.court.border * 2, 5);
const smallerWallGeometry = new THREE.PlaneBufferGeometry(shared.court.depth + shared.court.border * 2, 5);

const backWall = new THREE.Mesh(largerWallGeometry, wallMaterial);
(backWall.geometry as THREE.BufferGeometry).getAttribute("uv").setX(1, 2.8);
(backWall.geometry as THREE.BufferGeometry).getAttribute("uv").setX(3, 2.8);
backWall.receiveShadow = true;
backWall.position.y = 2.5;
backWall.position.z = -5;
root.add(backWall);

const frontWall = new THREE.Mesh(largerWallGeometry, wallMaterial);
(frontWall.geometry as THREE.BufferGeometry).getAttribute("uv").setX(1, 2.8);
(frontWall.geometry as THREE.BufferGeometry).getAttribute("uv").setX(3, 2.8);
frontWall.receiveShadow = true;
frontWall.rotateY(Math.PI);
frontWall.position.y = 2.5;
frontWall.position.z = 5;
root.add(frontWall);

const leftWall = new THREE.Mesh(smallerWallGeometry, wallMaterial);
leftWall.receiveShadow = true;
leftWall.rotateY(Math.PI / 2);
leftWall.position.y = 2.5;
leftWall.position.x = -7;
root.add(leftWall);

const rightWall = new THREE.Mesh(smallerWallGeometry, wallMaterial);
rightWall.receiveShadow = true;
rightWall.rotateY(-Math.PI / 2);
rightWall.position.y = 2.5;
开发者ID:elisee,项目名称:bball,代码行数:31,代码来源:courtModel.ts

示例2: makeModel

export function makeModel(avatar: Game.AvatarPub, name: string, isMe: boolean): Model {
  const root = new THREE.Group();
  root.position.x = avatar.x;
  root.position.z = avatar.z;

  const nametagCanvas = document.createElement("canvas");
  nametagCanvas.width = 256;
  nametagCanvas.height = 64;
  const nametagCtx = nametagCanvas.getContext("2d");

  const nametagTexture = new THREE.Texture(nametagCanvas, null, THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearFilter);
  const nametag = new THREE.Mesh(nametagGeometry, new THREE.MeshBasicMaterial({ transparent: true, opacity: 0.5, map: nametagTexture }));
  nametag.position.y = 1.8;
  root.add(nametag);

  const body = new THREE.Mesh(bodyGeometry, teamMaterials[avatar.teamIndex]);
  body.rotateY(avatar.angleY);
  body.castShadow = true;
  body.receiveShadow = true;
  body.position.y = 0.7;
  root.add(body);

  const head = new THREE.Mesh(headGeometry, headMaterial);
  head.castShadow = true;
  head.receiveShadow = true;
  head.position.y = 0.5;
  body.add(head);

  const shoulders = new THREE.Group();
  // NOTE: Global Y must match up with shared.shoulderHeight
  shoulders.position.y = 0.2;
  shoulders.rotateX(avatar.angleX);
  body.add(shoulders);

  // NOTE: Arm length must match up with shared.armLength
  const leftArm = new THREE.Mesh(armGeometry, skinMaterial);
  leftArm.castShadow = true;
  leftArm.receiveShadow = true;
  leftArm.position.z = 0.3;
  shoulders.add(leftArm);

  const rightArm = new THREE.Mesh(armGeometry, skinMaterial);
  rightArm.castShadow = true;
  rightArm.receiveShadow = true;
  rightArm.position.z = -0.3;
  shoulders.add(rightArm);

  const pelvis = new THREE.Group();
  pelvis.position.y = -0.1;
  body.add(pelvis);

  const leftLeg = new THREE.Mesh(legGeometry, skinMaterial);
  leftLeg.castShadow = true;
  leftLeg.receiveShadow = true;
  leftLeg.position.z = 0.1;
  pelvis.add(leftLeg);

  const rightLeg = new THREE.Mesh(legGeometry, skinMaterial);
  rightLeg.castShadow = true;
  rightLeg.receiveShadow = true;
  rightLeg.position.z = -0.1;
  pelvis.add(rightLeg);

  const model = { root, nametag, nametagCtx, body, head, shoulders, leftArm, rightArm, leftLeg, rightLeg };
  updateNametag(model, name, isMe);

  return model;
}
开发者ID:elisee,项目名称:bball,代码行数:68,代码来源:character.ts


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