Hack some fixes for the vtkjs renderer and pointFeature.
See the several TODO comments for things that need fixing.
MODIFY
src/vtkjs/pointFeature.js
src/vtkjs/pointFeature.js
@@ -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,
@@ -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();
};
@@ -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');

MODIFY
src/vtkjs/vtkjsRenderer.js
src/vtkjs/vtkjsRenderer.js
@@ -22,6 +22,9 @@ 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,
@@ -29,10 +32,11 @@ var vtkjsRenderer = function (arg) {
m_height = 0,
s_init = this._init;
- var fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
+ // TODO: don't draw a background. Does transparent work?
+ 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
@@ -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;
};
@@ -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();
};
@@ -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
});

Hack some fixes for the vtkjs renderer and pointFeature.

See the several TODO comments for things that need fixing.