How to use the expo-three.THREE.Mesh function in expo-three

To help you get started, we’ve selected a few expo-three examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
var rightleg = (this.rightLeg = new THREE.Mesh(
      rightleggeo,
      this.charMaterial,
    ));
    rightleg.position.z = 2;
    rightleg.position.y = -6;
    this.UVMap(rightleg, 0, 4, 20, 4, 12);
    this.UVMap(rightleg, 1, 12, 20, 4, 12);
    this.UVMap(rightleg, 2, 8, 16, -4, 4, 3);
    this.UVMap(rightleg, 3, 12, 20, -4, -4, 1);
    this.UVMap(rightleg, 4, 0, 20, 4, 12);
    this.UVMap(rightleg, 5, 8, 20, 4, 12);

    // Body
    var bodygeo = new THREE.CubeGeometry(4, 12, 8);
    var bodymesh = (this.body = new THREE.Mesh(bodygeo, this.charMaterial));
    this.UVMap(bodymesh, 0, 20, 20, 8, 12);
    this.UVMap(bodymesh, 1, 32, 20, 8, 12);
    this.UVMap(bodymesh, 2, 20, 16, 8, 4, 1);
    this.UVMap(bodymesh, 3, 28, 16, 8, 4, 3);
    this.UVMap(bodymesh, 4, 16, 20, 4, 12);
    this.UVMap(bodymesh, 5, 28, 20, 4, 12);
    upperbody.add(bodymesh);

    // Left arm
    var leftarmgeo = new THREE.CubeGeometry(4, 12, 4);
    for (var i = 0; i < 8; i += 1) {
      leftarmgeo.vertices[i].y -= 4;
    }
    var leftarm = (this.leftArm = new THREE.Mesh(
      leftarmgeo,
      this.charMaterial,
github expo / expo-three / examples / loader / App.js View on Github external
async function loadPLY(key = 'binary') {
  /// This works for both `ASCII` & `Binary` `.ply` files
  /// PLY files will return a geometry, we must add it to a mesh with a material.

  const binary = require('./models/ply/binary/Lucy100k.ply');
  const ascii = require('./models/ply/ascii/dolphins.ply');
  const models = { binary, ascii };
  const geometry = await ExpoTHREE.loadAsync(models[key], onProgress);

  geometry.computeVertexNormals();
  const material = new THREE.MeshStandardMaterial({
    color: 0x0055ff,
    flatShading: true,
  });
  const mesh = new THREE.Mesh(geometry, material);

  return mesh;
}
github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
cubeFromPlanes = (size, mat) => {
    var cube = new THREE.Object3D();
    var meshes = [];
    for (var i = 0; i < 6; i++) {
      var mesh = new THREE.Mesh(new THREE.PlaneGeometry(size, size), mat);
      mesh.doubleSided = true;
      cube.add(mesh);
      meshes.push(mesh);
    }
    // Front
    meshes[0].rotation.x = Math.PI / 2;
    meshes[0].rotation.z = -Math.PI / 2;
    meshes[0].position.x = size / 2;

    // Back
    meshes[1].rotation.x = Math.PI / 2;
    meshes[1].rotation.z = Math.PI / 2;
    meshes[1].position.x = -size / 2;

    // Top
    meshes[2].position.y = size / 2;
github EvanBacon / Expo-Nitro-Roll / Game / engine / core / Particles.js View on Github external
loadAsync = async (parent, colors) => {
    const big = new THREE.Mesh(
      new THREE.BoxBufferGeometry(20, 20, 20, 1),
      Factory.shared.materials[colors[0]],
    );
    const small = new THREE.Mesh(
      new THREE.BoxBufferGeometry(10, 10, 10, 1),
      Factory.shared.materials[colors[1]],
    );

    this.parts = [];
    for (var i = 0; i < 5; i++) {
      const a = big.clone();
      const b = small.clone();
      this.parts.push(a);
      this.parts.push(b);
      this.add(a);
      this.add(b);
github tidepool-org / viz / src / components / Graph / gl / GraphBasalGl.js View on Github external
renderBasalRect({ startTimeOffset, endTimeOffset, value }) {
    const { contentOffsetX, pixelsPerSecond } = this;
    const width = endTimeOffset - startTimeOffset;
    const height = this.yAxisBasalPixelsPerValue * value;

    const shape = new THREE.Shape();
    shape.moveTo(0, 0);
    shape.lineTo(width * this.pixelRatio, 0);
    shape.lineTo(width * this.pixelRatio, height * this.pixelRatio);
    shape.lineTo(0, height * this.pixelRatio);
    shape.moveTo(0, 0);
    const geometry = new THREE.ShapeGeometry(shape);
    const object = new THREE.Mesh(geometry, this.basalRectMaterial);
    this.addAutoScrollableObjectToScene(this.scene, object, {
      x: startTimeOffset,
      y: this.yAxisBottomOfBasal,
      z: this.zStart,
      contentOffsetX,
      pixelsPerSecond,
      shouldScrollX: true,
      shouldScaleX: true,
    });

    return {
      x: startTimeOffset,
      y: 0,
      width,
      height,
    };
github EvanBacon / Expo-Nitro-Roll / Game / engine / entities / Platform.js View on Github external
loadAsync = async scene => {
    const materials = Object.keys(Factory.shared.materials);
    let key = materials[global.platformMatIndex];
    while (key === 'red') {
      global.platformMatIndex =
        (global.platformMatIndex + 1) % materials.length;
      key = materials[global.platformMatIndex];
    }
    const material = Factory.shared.materials[key]; //.clone();

    const mesh = new THREE.Mesh(global.platformGeom, material);
    this.y = -250 + radius / 2;
    this.add(mesh);
    await super.loadAsync(scene);
  };
}
github expo / expo-three / example / screens / Loaders / ObjLoaderExample.js View on Github external
metalness: 0.5,
      roughness: 0.6,
      displacementMap: displacementMap,
      displacementScale: SCALE,
      displacementBias: BIAS,
      aoMap: aoMap,
      normalMap: normalMap,
      normalScale: new THREE.Vector2(1, -1),
      //flatShading: true,
      side: THREE.DoubleSide,
    });

    const geometry = object.children[0].geometry;
    geometry.attributes.uv2 = geometry.attributes.uv;
    geometry.center();
    const mesh = new THREE.Mesh(geometry, materialStandard);
    mesh.scale.multiplyScalar(0.25);

    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 1);
    ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
    this.scene.add(mesh);
    this.mesh = mesh;
  }