How to use the three.Mesh function in three

To help you get started, we’ve selected a few 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 zya / apophenia / lib / 3d / scene3D.js View on Github external
var geom = new THREE.SphereGeometry(0.005);
  groupMaterial = new THREE.MeshStandardMaterial({
    metalness: 0.5,
    roughness: 0.5,
    // color: new THREE.Color(colours.lightBlue.r, colours.lightBlue.g, colours.lightBlue.b),
    emissive: 'red',
    emissiveIntensity: 0.1,
    transparent: true,
    opacity: 0,
    normalMap: materials.dotsNormalMap
  });


  group = new THREE.Group();
  for (var i = 0; i < 1000; i++) {
    var mesh = new THREE.Mesh(geom, groupMaterial);
    mesh.position.set(_.random(-3.5, 3.5, true), _.random(-3.5, 3.5, true), _.random(-8, 8, true));
    group.add(mesh);
  }

  // group.castShadow = true;
  scene.add(group);
}
github vaalentin / 2015 / app / src / js / objects3D / _face.js View on Github external
loader.load('./app/public/3D/face.js', function (geometry) {
        
    var face = new THREE.Mesh(geometry, material);
    face.rotation.set(0, 0.2, 0.2);
    face.scale.set(18, 18, 18);
    _this.el.add(face);

    function flick () {
      face.material = material;

      setTimeout(function () {
        face.material = wireframeMaterial;
      }, random(50, 100));
    }

    // animations
    var steps = 0;
    var totalSteps = 3;
github cvdlab / react-planner / demo / src / catalog / holes / panic-door-double / planner-element.jsx View on Github external
function makeHandleBase() {

  let base = new Three.Object3D();
  let BaseGeometry1 = new Three.BoxGeometry(0.038, 0.14, 0.01);
  let BaseGeometry2 = new Three.CylinderGeometry(0.023, 0.023, 0.01, Math.round(32 ));
  let lock = makeLockKey();
  let base1 = new Three.Mesh(BaseGeometry1, black);
  let base2 = new Three.Mesh(BaseGeometry2, black);
  lock.rotation.x = Math.PI / 2;
  lock.position.y = -0.03;
  base2.rotation.x = Math.PI / 2;
  base2.position.y = -0.033;
  base2.scale.z = 1.5;
  base1.add(lock);
  base1.add(base2);
  base.add(base1);

  return base;
}
github cvdlab / react-planner / demo / src / catalog / holes / panic-door-double / planner-element.jsx View on Github external
function makeLockKey() {

  let lock = new Three.Object3D();
  let geometryLock1 = new Three.CylinderGeometry(0.005, 0.005, 0.02, Math.round(32 ));
  let geometryLock2 = new Three.BoxGeometry(0.008, 0.02, 0.02);
  let geometryLock3 = new Three.BoxGeometry(0.007, 0.0203, 0.0018);
  let lockPiece1 = new Three.Mesh(geometryLock1, metalBlue);
  let lockPiece2 = new Three.Mesh(geometryLock2, metalBlue);
  let lockPiece3 = new Three.Mesh(geometryLock3, metalBlueGrey);
  lockPiece2.position.z = 0.01;
  lockPiece1.add(lockPiece2);
  lockPiece1.add(lockPiece3);
  lock.add(lockPiece1);

  return lock;
}
github cvdlab / react-planner / demo / src / catalog / items / sink / planner-element.jsx View on Github external
depth: newHeight/4,
    bevelEnabled: false,
    bevelThickness: newHeight,
    bevelSize: newHeight,
    bevelSegments: 2
  };

  let geometry2 = new Three.ExtrudeGeometry( rectShape2, extrudeSettings2 );
  let mesh2 = new Three.Mesh( geometry2, steel ) ;
  mesh2.rotation.x+=Math.PI/2;
  mesh2.position.y+=newHeight/2;
  sink.add(mesh2);

  //tap
  let cylinderGeometry66 = new Three.CylinderGeometry(1.25,1.25,8,12);
  let tap_p1 = new Three.Mesh(cylinderGeometry66,grey);
  tap_p1.position.set(newWidth/2,newHeight/1.45,3);
  tap_p1.rotation.z-=Math.PI/2;
  tap_p1.rotation.y+=Math.PI/2;
  sink.add(tap_p1);

  let cylinderGeometry5 = new Three.CylinderGeometry(2.7,3,5,12);
  let tap_p2 = new Three.Mesh(cylinderGeometry5,grey);
  tap_p2.position.set(newWidth/2, newHeight/1.45,10);
  tap_p2.rotation.z-=Math.PI/2;
  tap_p2.rotation.y+=Math.PI/2;
  sink.add(tap_p2);

  let cylinderGeometry6 = new Three.CylinderGeometry(2,2,5.5,80);
  let tap_p3 = new Three.Mesh(cylinderGeometry6,blue);
  tap_p3.position.set(newWidth/2, newHeight/1.45,10);
  tap_p3.rotation.z-=Math.PI/2;
github agrande / lba2remake / src / game / points.ts View on Github external
function makeFlag(texture) {
    const stickGeom = new THREE.CylinderBufferGeometry(0.036, 0.036, 0.96, 6, 1, false);
    const stick = new THREE.Mesh(stickGeom, stickMaterial);
    stick.position.set(0, 0.48, 0);
    stick.name = 'stick';

    const clothMaterial = new THREE.MeshBasicMaterial({
        map: texture,
        transparent: true
    });

    const clothGeom = new THREE.PlaneBufferGeometry(0.7, 0.7);
    const cloth = new THREE.Mesh(clothGeom, clothMaterial);
    cloth.position.set(0.35, 0.61, 0);
    cloth.name = 'cloth';

    const flag = new THREE.Object3D();
    flag.add(stick);
    flag.add(cloth);

    return flag;
}
github cvdlab / react-planner / demo / src / catalog / items / schneider / planner-element.jsx View on Github external
let panelSideElemLeft = new Three.Mesh(panelSideElemGeometry, boxMaterials);
  panelSideElemLeft.rotation.y+=Math.PI;
  schneider.add(panelSideElemLeft);

  let panelSideElemRight = new Three.Mesh(panelSideElemGeometry, boxMaterials);
  panelSideElemRight.position.x+=258;
  schneider.add(panelSideElemRight);

  let panelSideBackElemGeometry = new Three.BoxGeometry(width,height,5);
  let panelSideElemBack = new Three.Mesh(panelSideBackElemGeometry, boxMaterials3);
  panelSideElemBack.position.x+=129;
  panelSideElemBack.position.z-=43.5;
  schneider.add(panelSideElemBack);

  let boxElemGeometry = new Three.BoxGeometry(width/3,height/3,depth/8);
  let boxElem = new Three.Mesh(boxElemGeometry, grey);
  boxElem.position.x+=212;
  boxElem.position.y+=65;
  boxElem.position.z+=35;
  schneider.add(boxElem);

  let panelSideFrontElemGeometry = new Three.BoxGeometry(width/3,height,5);
  let panelSideElemFront_P1 = new Three.Mesh(panelSideFrontElemGeometry, boxMaterials2);
  panelSideElemFront_P1.position.x+=43.5;
  panelSideElemFront_P1.position.z+=43.5;
  schneider.add(panelSideElemFront_P1);

  let panelSideElemFront_P2 = new Three.Mesh(panelSideFrontElemGeometry, boxMaterials2);
  panelSideElemFront_P2.position.x+=130;
  panelSideElemFront_P2.position.z+=43.5;
  schneider.add(panelSideElemFront_P2);
github vpdb / server / src / app / vpinball / gltf / lib / OBJLoader.js View on Github external
var sourceMaterial = materials[ mi ];
						buffergeometry.addGroup( sourceMaterial.groupStart, sourceMaterial.groupCount, mi );

					}

					if ( isLine ) {

						mesh = new LineSegments( buffergeometry, createdMaterials );

					} else if ( isPoints ) {

						mesh = new Points( buffergeometry, createdMaterials );

					} else {

						mesh = new Mesh( buffergeometry, createdMaterials );

					}

				} else {

					if ( isLine ) {

						mesh = new LineSegments( buffergeometry, createdMaterials[ 0 ] );

					} else if ( isPoints ) {

						mesh = new Points( buffergeometry, createdMaterials[ 0 ] );

					} else {

						mesh = new Mesh( buffergeometry, createdMaterials[ 0 ] );
github funwithtriangles / polyx0x-001 / app / Block.js View on Github external
color: colors[1]
      }),
      new MeshLambertMaterial({
        color: 0x222222
      }),
      new MeshLambertMaterial({
        color: 0x222222
      }),
      new MeshLambertMaterial({
        color: 0x222222
      })
    ]

    this.mats = this.defaultMats.slice(0)

    this.cube = new Mesh(cubeGeom, this.mats)
    this.group = new Object3D()
    this.group.add(this.cube)

    this.flash()

    this.visible = true
  }
github cvdlab / react-planner / demo / src / catalog / items / router-wifi / planner-element.jsx View on Github external
mesh2.position.set(-0.4,1,5.5);
  routerWifi.add(mesh2);

  let cylinderGeometry = new Three.CylinderGeometry(RADIUS/20,RADIUS/20,DEPTH,32,32);
  let led = new Three.Mesh(cylinderGeometry,greenMaterial);
  led.rotation.x+=Math.PI/2;
  led.position.set(WIDTH/2,WIDTH/2,1.2*DEPTH);
  routerWifi.add(led);

  let led2 = new Three.Mesh(cylinderGeometry,greenMaterial);
  led2.rotation.x+=Math.PI/2;
  led2.position.set(WIDTH/2+5,WIDTH/2,1.2*DEPTH);
  routerWifi.add(led2);

  let led3 = new Three.Mesh(cylinderGeometry,greenMaterial);
  led3.rotation.x+=Math.PI/2;
  led3.position.set(WIDTH/2-5,WIDTH/2,1.2*DEPTH);
  routerWifi.add(led3);

  return routerWifi;
}