コード例 #1
0
ファイル: index.js プロジェクト: axilleas/gitlabhq
  constructor(container) {
    this.renderWrapper = this.render.bind(this);
    this.objects = [];

    this.container = container;
    this.width = this.container.offsetWidth;
    this.height = 500;

    this.loader = new STLLoader();

    this.fov = 45;
    this.camera = new THREE.PerspectiveCamera(this.fov, this.width / this.height, 1, 1000);

    this.scene = new THREE.Scene();

    this.scene.add(this.camera);

    // Set up the viewer
    this.setupRenderer();
    this.setupGrid();
    this.setupLight();

    // Set up OrbitControls
    this.controls = new OrbitControls(this.camera, this.renderer.domElement);
    this.controls.minDistance = 5;
    this.controls.maxDistance = 30;
    this.controls.enableKeys = false;

    this.loadFile();
  }
コード例 #2
0
ファイル: index.js プロジェクト: axilleas/gitlabhq
    this.loader.load(this.container.dataset.endpoint, geo => {
      const obj = new MeshObject(geo);

      this.objects.push(obj);
      this.scene.add(obj);

      this.start();
      this.setDefaultCameraPosition();
    });
コード例 #3
0
ファイル: index.js プロジェクト: DavidPesta/gitlabhq
  setupGrid() {
    this.grid = new THREE.GridHelper(
      20,
      20,
      0x000000,
      0x000000,
    );

    this.scene.add(this.grid);
  }
コード例 #4
0
ファイル: index.js プロジェクト: axilleas/gitlabhq
  setupLight() {
    // Point light illuminates the object
    const pointLight = new THREE.PointLight(0xffffff, 2, 0);

    pointLight.castShadow = true;

    this.camera.add(pointLight);

    // Ambient light illuminates the scene
    const ambientLight = new THREE.AmbientLight(0xffffff, 1);
    this.scene.add(ambientLight);
  }