Fixed build that works with vtk.js
MODIFY
examples/points/main.js
examples/points/main.js
@@ -73,7 +73,7 @@ $(function () {
var svgLayer = map.createLayer(
'feature',
{
- renderer: 'd3'
+ renderer: 'vtkjs'
}
);

MODIFY
package.json
package.json
"hammerjs": "^2.0.8"
},
"devDependencies": {
+<<<<<<< HEAD
+=======
+ "babel-core": "^6.0.0",
+ "babel-loader": "^6.0.0",
+ "babel-plugin-istanbul": "2.0.0",
+ "babel-polyfill": "6.13.0",
+ "babel-preset-react": "^6.16.0",
+ "babel-preset-stage-2": "^6.18.0",
+ "blanket": "~1.2",
+>>>>>>> Fixed build that works with vtk.js
"body-parser": "^1.15.0",
"bootstrap": "^3.3.6",
"bootswatch": "^3.3.6",
"raw-body": "^2.1.6",
"sinon": "1.17.3",
"string-replace-webpack-plugin": "^0.1.3",
+ "string-replace-loader": "1.0.5",
"style-loader": "^0.13.1",
"stylus": "^0.54.5",
"stylus-loader": "^2.4.0",
"typeface-lato": "^0.0.44",
"url-loader": "^0.5.7",
"vgl": "0.3.10",
+ "vtk.js": "github:kitware/vtk-js",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1",
- "xmlbuilder": "^8.2.2",
- "vtk.js": "^2.0.0"
+ "xmlbuilder": "^8.2.2"
},
"scripts": {
"build": "webpack --config webpack.config.js && webpack --config external.config.js",

MODIFY
src/vtkjs/pointFeature.js
src/vtkjs/pointFeature.js
+var vtkjs = require('vtk.js');
var inherit = require('../inherit');
var registerFeature = require('../registry').registerFeature;
var pointFeature = require('../pointFeature');
+// import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';
+// import vtkSphereSource from 'vtk.js/Sources/Filters/Sources/SphereSource';
+// import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
+
+var vtkActor = require('vtk.js/Sources/Rendering/Core/Actor');
+
+// import vtkActor from '../../../../../Sources/Rendering/Core/Actor';
+// import vtkSphereSource from '../../../../../Sources/Filters/Sources/SphereSource';
+// import vtkMapper from '../../../../../Sources/Rendering/Core/Mapper';
+
//////////////////////////////////////////////////////////////////////////////
/**
* Create a new instance of pointFeature
@@ -194,15 +205,19 @@ var vtkjs_pointFeature = function (arg) {
////////////////////////////////////////////////////////////////////////////
this._build = function () {
- // if (m_actor) {
- // m_this.renderer().contextRenderer().removeActor(m_actor);
- // }
-
- // createGLPoints();
+ if (m_actor) {
+ m_this.renderer().contextRenderer().removeActor(m_actor);
+ }
- // m_this.renderer().contextRenderer().addActor(m_actor);
- // m_this.renderer().contextRenderer().render();
- // m_this.buildTime().modified();
+ const sphereSource = vtkSphereSource.newInstance();
+ const actor = vtkActor.newInstance();
+ const mapper = vtkMapper.newInstance();
+ actor.getProperty().setEdgeVisibility(true);
+ mapper.setInputConnection(sphereSource.getOutputPort());
+ actor.setMapper(mapper);
+ m_this.renderer().contextRenderer().addActor(actor);
+ m_actor = actor;
+ m_this.buildTime().modified();
};
////////////////////////////////////////////////////////////////////////////

MODIFY
src/vtkjs/vtkjsRenderer.js
src/vtkjs/vtkjsRenderer.js
var inherit = require('../inherit');
var registerRenderer = require('../registry').registerRenderer;
var renderer = require('../renderer');
+var vtkOpenGLRenderWindow = require('vtk.js/Sources/Rendering/OpenGL/RenderWindow');
+var vtkRenderer = require('vtk.js/Sources/Rendering/Core/Renderer');
+var vtkRenderWindow = require('vtk.js/Sources/Rendering/Core/RenderWindow');
//////////////////////////////////////////////////////////////////////////////
@@ -38,6 +41,10 @@ var vtkjsRenderer = function (arg) {
s_init = this._init,
s_exit = this._exit;
+ const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] });
+ const vtkjsren = fullScreenRenderer.getRenderer();
+ const renderWindow = fullScreenRenderer.getRenderWindow();
+
/// TODO: Move this API to the base class
////////////////////////////////////////////////////////////////////////////
/**
@@ -63,7 +70,7 @@ var vtkjsRenderer = function (arg) {
*/
////////////////////////////////////////////////////////////////////////////
this.contextRenderer = function () {
- return m_contextRenderer;
+ return renderWindow.getRenderer();
};
////////////////////////////////////////////////////////////////////////////
@@ -72,7 +79,7 @@ var vtkjsRenderer = function (arg) {
*/
////////////////////////////////////////////////////////////////////////////
this.api = function () {
- return 'vgl';
+ return 'vtkjs';
};
////////////////////////////////////////////////////////////////////////////
@@ -142,6 +149,7 @@ var vtkjsRenderer = function (arg) {
* until a subsequent frame). */
// m_this.layer().map().scheduleAnimationFrame(this._renderFrame, true);
// return m_this;
+ renderWindow.render();
};
/**
@@ -153,6 +161,7 @@ var vtkjsRenderer = function (arg) {
// m_this._updateRendererCamera();
// }
// m_viewer.render();
+ renderWindow.render();
};
////////////////////////////////////////////////////////////////////////////

MODIFY
webpack-examples.config.js
webpack-examples.config.js
@@ -8,6 +8,12 @@ var external = require('./external.config');
var loaders = base.module.loaders.concat([{
test: /\.pug$/,
loader: 'pug'
+}, {
+ test: /\.css$/,
+ loader: 'style-loader!css-loader'
+}, {
+ test: /\.jade$/,
+ loader: 'jade'
}, {
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'

MODIFY
webpack.config.js
webpack.config.js
@@ -2,6 +2,7 @@ var path = require('path');
var webpack = require('webpack');
var exec = require('child_process').execSync;
var sha = '';
+var loaders = require('./node_modules/vtk.js/Utilities/config/webpack.loaders.js');
if (!exec) {
console.warn('Node 0.12 or greater is required for detecting the git hash.');
@@ -66,7 +67,8 @@ module.exports = {
}, {
test: /vgl\.js$/,
loader: 'expose?vgl!imports?mat4=gl-mat4,vec4=gl-vec4,vec3=gl-vec3,vec2=gl-vec2,$=jquery'
- }]
+ }
+ ].concat(loaders)
},
// These are plugins that we want to run in Karma as well

Fixed build that works with vtk.js