Skip to content

Commit

Permalink
Merge d2f41c7 into 3a5b4d8
Browse files Browse the repository at this point in the history
  • Loading branch information
tensorflow-graphics-github-robot committed Aug 14, 2019
2 parents 3a5b4d8 + d2f41c7 commit 3045c18
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class MeshViewer extends THREE.EventDispatcher {
/** @type {!Object} Contains width and height of the canvas. */
this._canvasSize = null;
this._runColor = runColor;
/** @type {!Object} Describes what layers must be rendered in addition
to mesh or point cloud. */
this._layersConfig = null;
}

// TODO(b/130030314) replace with some thirdparty library call.
Expand Down Expand Up @@ -74,6 +77,31 @@ class MeshViewer extends THREE.EventDispatcher {
return mergedConfig;
}

/**
* Creates additional layers to render on top of mesh or point cloud.
* @private
*/
_createLayers() {
if (!this._layersConfig || !this._scene || !this._lastMesh) return;
if (this._layersConfig.showBoundingBox) {
var box = new THREE.BoxHelper(this._lastMesh, "rgb(0, 0, 255)");
this._scene.add(box);
}
if (this._layersConfig.showAxes) {
var axesHelper = new THREE.AxesHelper(5);
this._scene.add(axesHelper);
}
}

/**
* Sets layers config.
* @public
*/
setLayers(layersConfig) {
this._layersConfig = this._applyDefaults(
layersConfig, this._layersConfig || {});
}

/**
* Creates scene, camera and renderer.
* @param {!Object} config Scene rendering configuration.
Expand Down Expand Up @@ -214,6 +242,7 @@ class MeshViewer extends THREE.EventDispatcher {
this._clearScene();
this._createLights(this._scene, config);
this._createGeometry(currentStep, config);
this._createLayers();
this.draw();
}

Expand Down Expand Up @@ -296,7 +325,6 @@ class MeshViewer extends THREE.EventDispatcher {
});
}


var material = new THREE[pc_config.material.cls](pc_config.material);
var mesh = new THREE.Points(geometry, material);
this._scene.add(mesh);
Expand Down

0 comments on commit 3045c18

Please sign in to comment.