Skip to content

Commit

Permalink
Hack some fixes for the vtkjs renderer and pointFeature.
Browse files Browse the repository at this point in the history
See the several TODO comments for things that need fixing.
  • Loading branch information
manthey committed Oct 29, 2018
1 parent 3472f2b commit 0a490be
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
22 changes: 15 additions & 7 deletions src/vtkjs/pointFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var vtkjs_pointFeature = function (arg) {
* @private
*/
var m_this = this,
s_init = this._init,
s_exit = this._exit,
m_actor = null,
m_pointSet = null,
Expand All @@ -59,6 +60,7 @@ var vtkjs_pointFeature = function (arg) {
* Initialize
*/
this._init = function () {
s_init.call(m_this, arg);
m_this.renderer().contextRenderer().setLayer(1);
this._createPipeline();
};
Expand All @@ -85,26 +87,32 @@ var vtkjs_pointFeature = function (arg) {
position[i3 + 1] = posVal.y;
position[i3 + 2] = posVal.z || 0;
nonzeroZ = nonzeroZ || position[i3 + 2];
// TODO: fix the opacity per point.
m_actor.getProperty().setOpacity(opacityFunc(data[i]));
}
position = transform.transformCoordinates(
m_this.gcs(), m_this.layer().map().gcs(),
position, 3);

/* Some transforms modify the z-coordinate. If we started with all zero z
* coordinates, don't modify them. This could be changed if the
* z-coordinate space of the gl cube is scaled appropriately. */
if (!nonzeroZ && m_this.gcs() !== m_this.layer().map().gcs()) {
for (i = i3 = 0; i < numPts; i += 1, i3 += 3) {
position[i3 + 2] = 0;
}
}

/* Some transforms modify the z-coordinate. If we started with all zero z
* coordinates, don't modify them. This could be changed if the
* z-coordinate space of the gl cube is scaled appropriately. */
// TODO: points can vary, this needs to be refactors to have a distinct
// size per point. What should be done with the strokeColor, strokeWidth,
// and strokeOpacity? Honor the fill/stroke options or document that we
// don't honot them.
var rad = radFunc(), clr = colorFunc();
rad *= m_this.layer().map().unitsPerPixel(m_this.layer().map().zoom());
m_pointSet.getPoints().setData(position, 3);
m_source.setRadius(radFunc());
m_actor.getProperty().setColor(colorFunc()['r'],
colorFunc()['g'],
colorFunc()['b']);
m_source.setRadius(rad);
// TODO: This is not setting the color of the rendered points
m_actor.getProperty().setColor(clr.r, clr.g, clr.b);
m_this.buildTime().modified();

console.debug('built vtkjs point feature');
Expand Down
24 changes: 21 additions & 3 deletions src/vtkjs/vtkjsRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ var vtkjsRenderer = function (arg) {
var mat4 = require('gl-mat4');
var geo_event = require('../event');
var vtkjs = vtkjsRenderer.vtkjs;
// TODO: use the GenericRenderWindow, match the size of the parent div, and
// call setContainer to attach it to the parent div. The parent div is:
// m_this.layer().node().get(0)
var vtkFullScreenRenderWindow = vtkjs.Rendering.Misc.vtkFullScreenRenderWindow;

var m_this = this,
m_width = 0,
m_height = 0,
s_init = this._init;

var fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
// TODO: don't draw a background. Does transparent work?

This comment has been minimized.

Copy link
@zachmullen

zachmullen Oct 29, 2018

Contributor

Transparent does work, e.g. [0,0,0,0].

var vtkRenderer = vtkFullScreenRenderWindow.newInstance({
background: [0.1, 0.5, 0.5] });
var vtkjsren = fullScreenRenderer.getRenderer();
var renderWindow = fullScreenRenderer.getRenderWindow();
var vtkjsren = vtkRenderer.getRenderer();
var renderWindow = vtkRenderer.getRenderWindow();

/**
* Return width of the renderer
Expand Down Expand Up @@ -76,6 +80,9 @@ var vtkjsRenderer = function (arg) {
var map = m_this.layer().map(),
mapSize = map.size();
m_this._resize(0, 0, mapSize.width, mapSize.height);
// TODO: figure out what the clipbounds actually should be and handle
// perspective modes properly.
map.camera().clipbounds = {near: -map.unitsPerPixel(), far: map.unitsPerPixel()};
return m_this;
};

Expand Down Expand Up @@ -106,6 +113,15 @@ var vtkjsRenderer = function (arg) {
* This clears the render timer and actually renders.
*/
this._renderFrame = function () {
var layer = m_this.layer(),
features = layer.features(),
i;
// TODO: draw something else should trigger feature update
for (i = 0; i < features.length; i += 1) {
if (features[i].visible()) {
features[i]._update();
}
}
m_this._updateRendererCamera();
renderWindow.render();
};
Expand Down Expand Up @@ -135,6 +151,8 @@ var vtkjsRenderer = function (arg) {
*produce a pan
*/
m_this.layer().geoOn(geo_event.pan, function (evt) {
// TODO: If the zoom level has changed, our point size needs to be
// recalculated, so we should call m_this._render
// DO NOTHING
});

Expand Down

0 comments on commit 0a490be

Please sign in to comment.