How to use the expo-three.utils 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 / VtpNonCompressedLoaderExample.js View on Github external
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 / example / screens / Loaders / MtlLoaderExample.js View on Github external
child.material.side = THREE.FrontSide;

        /// Apply other maps - maybe this is supposed to be automatic :[
        child.material.normalMap = await ExpoTHREE.loadAsync(
          model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_N.png']
        );
        child.material.specularMap = await ExpoTHREE.loadAsync(
          model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_S.png']
        );
        child.material.envMap = await ExpoTHREE.loadAsync(
          model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_DM_ENV.png']
        );
      }
    });

    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 5);
    ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
    this.scene.add(mesh);
    this.mesh = mesh; // Save reference for rotation
  }
github expo / expo-three / example / screens / Loaders / TdsLoaderExample.js View on Github external
const model = Assets.models['3ds'].portalgun;

    const mesh = await ExpoTHREE.loadAsync(
      model['portalgun.3ds'],
      null,
      name => model.textures[name]
    );
    const normal = await ExpoTHREE.loadAsync(model.textures['normal.jpg']);

    mesh.traverse(function(child) {
      if (child instanceof THREE.Mesh) {
        child.material.normalMap = normal;
      }
    });
    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 / VtkLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models.vtk['bunny.vtk'];
    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 / example / screens / AR / Image.js View on Github external
const model = Assets.models.collada.stormtrooper;
    const collada = await ExpoTHREE.loadDaeAsync({
      asset: model['stormtrooper.dae'],
      onAssetRequested: model,
    });
    const { scene: mesh, animations } = collada;
    mesh.traverse(child => {
      if (child instanceof THREE.Mesh) {
        child.castShadow = true;
        child.receiveShadow = true;
      }
    });

    mesh.castShadow = true;

    ExpoTHREE.utils.scaleLongestSideToSize(mesh, 0.1);

    this.mixer = new THREE.AnimationMixer(mesh);
    this.mixer.clipAction(animations[0]).play();

    const geometry = new THREE.PlaneBufferGeometry(1, 1, 32, 32);
    const material = new THREE.ShadowMaterial();
    material.opacity = 0.7;
    const plane = new THREE.Mesh(geometry, material);
    plane.receiveShadow = true;
    plane.rotation.x = -Math.PI / 2;

    let _mesh = new THREE.Object3D();

    _mesh.add(mesh);
    _mesh.add(plane);
    this.mesh = _mesh; // Save reference for rotation
github expo / expo-three / example / screens / Loaders / TmfLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models['3mf']['cube_gears.3mf'];
    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 / example / screens / Loaders / VtpLoaderExample.js View on Github external
await super.setupModels();

    const model = Assets.models.vtk['cube_ascii.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 / example / screens / Loaders / VtkLoaderExample.js View on Github external
async setupModels() {
    await super.setupModels();

    const model = Assets.models.vtk['bunny.vtk'];
    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 / example / screens / Loaders / AssimpLoaderExample.js View on Github external
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;
  }