-
Notifications
You must be signed in to change notification settings - Fork 10
/
vtkjs.html
93 lines (61 loc) · 2.66 KB
/
vtkjs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript" src="https://unpkg.com/vtk.js">
</script>
<script type="text/javascript">
function vtkMyInteractorStyleTrackballExtender(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkMyInteractorStyleTrackball');
// Capture "parentClass" api for internal use
const superClass = Object.assign({}, publicAPI);
// Public API methods
publicAPI.sayHello = () => {
// This is a publicly exposed method of this object
console.log('hello from my custom subclass method');
};
publicAPI.handleKeyPress = (callData) => {
console.log(callData);
publicAPI.sayHello();
superClass.handleKeyPress(callData);
};
publicAPI.handleLeftButtonPress = (callData) => {
publicAPI.sayHello();
superClass.handleLeftButtonPress(callData);
};
}
// ----------------------------------------------------------------------------
function extend(publicAPI, model, initialValues = {}) {
// Inheritance
vtk.Interaction.Style.vtkInteractorStyleTrackballCamera.extend(publicAPI, model, initialValues);
// Create get-set macros
vtk.macro.setGet(publicAPI, model, ['interactionMode']);
// For more macro methods, see "Sources/macro.js"
// Object specific methods
vtkMyInteractorStyleTrackballExtender(publicAPI, model);
}
// ----------------------------------------------------------------------------
const newInstance = vtk.macro.newInstance(extend, 'vtkMyInteractorStyleTrackball');
const vtkMyInteractorStyleTrackball = {newInstance};
// ----------------------------------------------------------------------------
Object.assign({ newInstance, extend });
let renderWindow;
let interactorStyle;
window.addEventListener('DOMContentLoaded', function(e) {
var fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance();
var actor = vtk.Rendering.Core.vtkActor.newInstance();
var mapper = vtk.Rendering.Core.vtkMapper.newInstance();
var cone = vtk.Filters.Sources.vtkConeSource.newInstance();
actor.setMapper(mapper);
mapper.setInputConnection(cone.getOutputPort());
var renderer = fullScreenRenderer.getRenderer();
renderer.addActor(actor);
renderer.resetCamera();
renderWindow = fullScreenRenderer.getRenderWindow();
interactorStyle = vtkMyInteractorStyleTrackball.newInstance();
renderWindow.getInteractor().setInteractorStyle(interactorStyle);
renderWindow.render();
});
</script>
</body>
</html>