How to use the expo-three.loadAsync 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 expo / expo-three / example / screens / Loaders / PlyLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models.ply.ascii['dolphins.ply'];
    const geometry = await ExpoTHREE.loadAsync(model);

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

    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
    ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
    this.scene.add(mesh);
    this.mesh = mesh; // Save reference for rotation
  }
github expo / expo-three / example / screens / Loaders / PlyBinaryLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models.ply.binary['Lucy100k.ply'];
    const geometry = await ExpoTHREE.loadAsync(model);

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

    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
    ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
    this.scene.add(mesh);
    this.mesh = mesh; // Save reference for rotation
  }
github expo / expo-three / example / screens / Loaders / VtpNonCompressedLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models.vtk['cube_no_compression.vtp'];

    const geometry = await ExpoTHREE.loadAsync(model);

    geometry.center();
    geometry.computeVertexNormals();
    const material = new THREE.MeshLambertMaterial({
      color: 0xff0000,
      side: THREE.DoubleSide,
    });
    const mesh = new THREE.Mesh(geometry, material);

    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
    ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
    this.scene.add(mesh);
    this.mesh = mesh; // Save reference for rotation
  }
github expo / expo-three / examples / loader / App.js View on Github external
async function load3MF() {
  const object = await ExpoTHREE.loadAsync(require('./models/3mf/cube_gears.3mf'), onProgress);
  return object;
}
github expo / expo-three / examples / loader / App.js View on Github external
async function loadBasicDAE() {
  const model = {
    'Body_tex_003.jpg': require(`./models/collada/elf/Body_tex_003.jpg`),
    'Face_tex_002_toObj.jpg': require(`./models/collada/elf/Face_tex_002_toObj.jpg`),
    'Hair_tex_001.jpg': require(`./models/collada/elf/Hair_tex_001.jpg`),
    'ce.jpg': require(`./models/collada/elf/ce.jpg`),
    'elf.dae': require(`./models/collada/elf/elf.dae`),
  };

  const collada = await ExpoTHREE.loadAsync(model['elf.dae'], onProgress, name => model[name]);

  return collada;
}
github expo / expo-three / examples / loader / App.js View on Github external
async function loadAMF() {
  const object = await ExpoTHREE.loadAsync(require('./models/amf/rook.amf'), onProgress);
  return object;
}
github expo / expo-three / example / screens / Loaders / AssimpLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models.assimp.octaminator;

    const object = await ExpoTHREE.loadAsync(
      model['Octaminator.assimp'],
      null,
      model
    );

    if (!object) {
      throw new Error('Failed to load model!');
    }

    const { object: mesh, animation } = object;
    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
    this.scene.add(mesh);
    this.animation = animation;
  }
github EvanBacon / Expo-Crossy-Road / src / Node / Generic.js View on Github external
_downloadAssets = async ({ model, texture, castShadow, receiveShadow }) => {
    let _model = await ExpoTHREE.loadAsync(model);
    const _texture = await ExpoTHREE.loadAsync(texture);

    _texture.magFilter = THREE.NearestFilter;
    _texture.minFilter = THREE.NearestFilter;

    _model.traverse(child => {
      if (child instanceof THREE.Mesh) {
        child.material.map = _texture;
        child.castShadow = castShadow;
        child.receiveShadow = receiveShadow;
      }
    });

    _model.castShadow = castShadow;
    _model.receiveShadow = receiveShadow;

    return _model;
github EvanBacon / Expo-Crossy-Road / Game / nodes / Ground.js View on Github external
loadAsync = async scene => {
    const geometry = new THREE.PlaneGeometry(1000, 1000, 1, 1);

    const texture = await ExpoTHREE.loadAsync({
      uri:
        'http://fc06.deviantart.net/fs71/f/2012/185/9/2/tileable_futuristic_grid_by_ndugger-d55yz5h.png',
    });
    texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
    texture.repeat.set(70, 70);
    const material = new THREE.MeshBasicMaterial({
      map: texture,
      side: THREE.DoubleSide,
    });

    const mesh = new THREE.Mesh(geometry, material);

    this.add(mesh);
    await super.loadAsync(scene);
  };
}