How to use the expo-three.THREE.Object3D 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
createPlayerObject = scene => {
    var headgroup = new THREE.Object3D();
    var upperbody = (this.upperbody = new THREE.Object3D());

    // Left leg
    var leftleggeo = new THREE.CubeGeometry(4, 12, 4);
    for (var i = 0; i < 8; i += 1) {
      leftleggeo.vertices[i].y -= 6;
    }
    var leftleg = (this.leftLeg = new THREE.Mesh(
      leftleggeo,
      this.charMaterial,
    ));
    leftleg.position.z = -2;
    leftleg.position.y = -6;
    this.UVMap(leftleg, 0, 8, 20, -4, 12);
    this.UVMap(leftleg, 1, 16, 20, -4, 12);
    this.UVMap(leftleg, 2, 4, 16, 4, 4, 3);
    this.UVMap(leftleg, 3, 8, 20, 4, -4, 1);
github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
this.UVMap(leftear, 2, 25, 0, 6, 1, 1); // Top edge
    this.UVMap(leftear, 3, 31, 0, 6, 1, 1); // Bottom edge

    this.UVMap(leftear, 4, 24, 1, 1, 6); // Left edge
    this.UVMap(leftear, 5, 31, 1, 1, 6); // Right edge

    ears.add(leftear);
    ears.add(rightear);

    leftear.visible = rightear.visible = false;

    headgroup.add(ears);
    headgroup.position.y = 8;

    var playerModel = (this.playerModel = new THREE.Object3D());

    playerModel.add(leftleg);
    playerModel.add(rightleg);

    playerModel.add(upperbody);

    var playerRotation = new THREE.Object3D();
    playerRotation.rotation.y = Math.PI / 2;
    playerRotation.position.y = 12;
    playerRotation.add(playerModel);

    var rotatedHead = new THREE.Object3D();
    rotatedHead.rotation.y = -Math.PI / 2;
    rotatedHead.add(headgroup);

    playerModel.add(rotatedHead);
github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
var playerRotation = new THREE.Object3D();
    playerRotation.rotation.y = Math.PI / 2;
    playerRotation.position.y = 12;
    playerRotation.add(playerModel);

    var rotatedHead = new THREE.Object3D();
    rotatedHead.rotation.y = -Math.PI / 2;
    rotatedHead.add(headgroup);

    playerModel.add(rotatedHead);
    playerModel.position.y = 6;

    var playerGroup = new THREE.Object3D();
    playerGroup.cameraInside = new THREE.Object3D();
    playerGroup.cameraOutside = new THREE.Object3D();

    playerGroup.cameraInside.position.x = 0;
    playerGroup.cameraInside.position.y = 2;
    playerGroup.cameraInside.position.z = 0;

    playerGroup.head = headgroup;
    headgroup.add(playerGroup.cameraInside);
    playerGroup.cameraInside.add(playerGroup.cameraOutside);

    playerGroup.cameraOutside.position.z = 100;

    playerGroup.add(playerRotation);
    playerGroup.scale.set(this.scale.x, this.scale.y, this.scale.z); // = this.scale
    return playerGroup;
  };
}
github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
createPlayerObject = scene => {
    var headgroup = new THREE.Object3D();
    var upperbody = (this.upperbody = new THREE.Object3D());

    // Left leg
    var leftleggeo = new THREE.CubeGeometry(4, 12, 4);
    for (var i = 0; i < 8; i += 1) {
      leftleggeo.vertices[i].y -= 6;
    }
    var leftleg = (this.leftLeg = new THREE.Mesh(
      leftleggeo,
      this.charMaterial,
    ));
    leftleg.position.z = -2;
    leftleg.position.y = -6;
    this.UVMap(leftleg, 0, 8, 20, -4, 12);
    this.UVMap(leftleg, 1, 16, 20, -4, 12);
    this.UVMap(leftleg, 2, 4, 16, 4, 4, 3);
github expo / expo-three / example / screens / AR / Image.js View on Github external
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
    this.scene.add(this.mesh);
    this.mesh.visible = false;
  };
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;
github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
playerModel.add(upperbody);

    var playerRotation = new THREE.Object3D();
    playerRotation.rotation.y = Math.PI / 2;
    playerRotation.position.y = 12;
    playerRotation.add(playerModel);

    var rotatedHead = new THREE.Object3D();
    rotatedHead.rotation.y = -Math.PI / 2;
    rotatedHead.add(headgroup);

    playerModel.add(rotatedHead);
    playerModel.position.y = 6;

    var playerGroup = new THREE.Object3D();
    playerGroup.cameraInside = new THREE.Object3D();
    playerGroup.cameraOutside = new THREE.Object3D();

    playerGroup.cameraInside.position.x = 0;
    playerGroup.cameraInside.position.y = 2;
    playerGroup.cameraInside.position.z = 0;

    playerGroup.head = headgroup;
    headgroup.add(playerGroup.cameraInside);
    playerGroup.cameraInside.add(playerGroup.cameraOutside);

    playerGroup.cameraOutside.position.z = 100;

    playerGroup.add(playerRotation);
    playerGroup.scale.set(this.scale.x, this.scale.y, this.scale.z); // = this.scale
    return playerGroup;
github EvanBacon / Sunset-Cyberspace / game / Level.js View on Github external
makeObstacle = (scale, materialID, color = Colors.red) => {
    const obstacle = new THREE.Object3D();
    const cone = new THREE.Mesh(this.obstacleGeom, this.floorMaterial);
    cone.add(
      new THREE.LineSegments(
        new THREE.WireframeGeometry(this.obstacleGeom),
        new THREE.LineBasicMaterial({
          color,
          transparent: true,
          linewidth: LINE_WIDTH,
        }),
      ),
    );
    obstacle.add(cone);
    obstacle.scale.set(scale, scale, scale);
    obstacle.myheight = 1400 * obstacle.scale.y;
    return obstacle;
  };
github EvanBacon / Sunset-Cyberspace / game / Level.js View on Github external
init = async () => {
    const lighting = new Lighting();
    await lighting.setupAsync();
    this.game.scene.add(lighting);

    this.moverGroup = new THREE.Object3D();
    this.game.scene.add(this.moverGroup);

    //make floor
    const floorGroup = new THREE.Object3D();

    this.floorMaterial = new THREE.MeshLambertMaterial({
      color: Colors.floor, //diffuse
      emissive: Colors.dark,
      side: THREE.DoubleSide,
    });
    this.floorMaterial.flatShading = true;

    //add extra x width
    this.floorGeometry = new THREE.PlaneGeometry(
      Settings.FLOOR_WIDTH + 1200,
      Settings.FLOOR_DEPTH,
github EvanBacon / Expo-Voxel / js / lib / minecraft-skin.js View on Github external
upperbody.add(rightarm);

    //Head
    var headgeo = new THREE.CubeGeometry(8, 8, 8);
    var headmesh = (this.head = new THREE.Mesh(headgeo, this.charMaterial));
    headmesh.position.y = 2;
    this.UVMap(headmesh, 0, 8, 8, 8, 8);
    this.UVMap(headmesh, 1, 24, 8, 8, 8);

    this.UVMap(headmesh, 2, 8, 0, 8, 8, 1);
    this.UVMap(headmesh, 3, 16, 0, 8, 8, 3);

    this.UVMap(headmesh, 4, 0, 8, 8, 8);
    this.UVMap(headmesh, 5, 16, 8, 8, 8);

    var unrotatedHeadMesh = new THREE.Object3D();
    unrotatedHeadMesh.rotation.y = Math.PI / 2;
    unrotatedHeadMesh.add(headmesh);

    headgroup.add(unrotatedHeadMesh);

    var helmet = this.cubeFromPlanes(9, this.charMaterialTrans);
    helmet.position.y = 2;
    this.UVMap(helmet.children[0], 0, 32 + 8, 8, 8, 8);
    this.UVMap(helmet.children[1], 0, 32 + 24, 8, 8, 8);
    this.UVMap(helmet.children[2], 0, 32 + 8, 0, 8, 8, 1);
    this.UVMap(helmet.children[3], 0, 32 + 16, 0, 8, 8, 3);
    this.UVMap(helmet.children[4], 0, 32 + 0, 8, 8, 8);
    this.UVMap(helmet.children[5], 0, 32 + 16, 8, 8, 8);

    headgroup.add(helmet);