@abi-software/scaffoldvuer 0.1.5-1.beta.1 → 0.1.5-1.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scaffoldvuer.common.js +1246 -1510
- package/dist/scaffoldvuer.common.js.map +1 -1
- package/dist/scaffoldvuer.css +1 -1
- package/dist/scaffoldvuer.umd.js +1246 -1510
- package/dist/scaffoldvuer.umd.js.map +1 -1
- package/dist/scaffoldvuer.umd.min.js +1 -1
- package/dist/scaffoldvuer.umd.min.js.map +1 -1
- package/package-lock.json +459 -399
- package/package.json +3 -4
- package/src/App.vue +48 -4
- package/src/components/ScaffoldVuer.vue +8 -5
- package/src/scripts/BaseModule.js +80 -0
- package/src/scripts/RendererModule.js +261 -0
- package/src/scripts/WebGL.js +94 -0
- package/src/scripts/annotation.js +5 -0
- package/src/scripts/eventNotifier.js +65 -0
- package/src/scripts/graphicsHighlight.js +132 -0
- package/src/scripts/organsRenderer.js +536 -0
- package/vue.config.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/scaffoldvuer",
|
|
3
|
-
"version": "0.1.51.beta.
|
|
3
|
+
"version": "0.1.51.beta.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,16 +29,15 @@
|
|
|
29
29
|
"element-ui": "^2.13.0",
|
|
30
30
|
"google-spreadsheet": "^3.1.15",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
|
-
"physiomeportal": "^0.4.27",
|
|
33
32
|
"query-string": "^6.11.1",
|
|
34
33
|
"vue": "^2.6.10",
|
|
35
34
|
"vue-drag-resize": "^1.3.2",
|
|
36
35
|
"vue-router": "^3.5.1",
|
|
37
|
-
"zincjs": "^0.
|
|
36
|
+
"zincjs": "^0.41.0-beta.0"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
39
|
"@vue/cli-plugin-babel": "^4.0.0",
|
|
41
|
-
"@vue/cli-plugin-eslint": "^4.
|
|
40
|
+
"@vue/cli-plugin-eslint": "^4.5.15",
|
|
42
41
|
"@vue/cli-service": "^4.5.13",
|
|
43
42
|
"babel-eslint": "^10.0.3",
|
|
44
43
|
"babel-plugin-component": "^1.1.1",
|
package/src/App.vue
CHANGED
|
@@ -107,15 +107,50 @@
|
|
|
107
107
|
Export GLTF
|
|
108
108
|
</el-button>
|
|
109
109
|
</el-row>
|
|
110
|
-
<el-row :gutter="
|
|
111
|
-
<el-
|
|
110
|
+
<el-row :gutter="30">
|
|
111
|
+
<el-col
|
|
112
|
+
:span="7"
|
|
113
|
+
:offset="4"
|
|
114
|
+
>
|
|
112
115
|
<el-switch
|
|
113
116
|
v-model="render"
|
|
114
117
|
active-text="Rendering"
|
|
115
118
|
active-color="#8300bf"
|
|
116
119
|
/>
|
|
117
|
-
</el-
|
|
120
|
+
</el-col>
|
|
121
|
+
<el-col
|
|
122
|
+
:span="8"
|
|
123
|
+
:offset="1"
|
|
124
|
+
>
|
|
125
|
+
<el-switch
|
|
126
|
+
v-model="renderInfoOn"
|
|
127
|
+
active-text="Renderer Info"
|
|
128
|
+
active-color="#8300bf"
|
|
129
|
+
/>
|
|
130
|
+
</el-col>
|
|
118
131
|
</el-row>
|
|
132
|
+
<template v-if="renderInfoOn && rendererInfo">
|
|
133
|
+
<el-row>
|
|
134
|
+
<el-col
|
|
135
|
+
v-for="(value, name) in rendererInfo.memory"
|
|
136
|
+
:key="name"
|
|
137
|
+
:offset="4"
|
|
138
|
+
:span="6"
|
|
139
|
+
>
|
|
140
|
+
{{ name }} : {{ value }}
|
|
141
|
+
</el-col>
|
|
142
|
+
</el-row>
|
|
143
|
+
<el-row>
|
|
144
|
+
<el-col
|
|
145
|
+
v-for="(value, name) in rendererInfo.render"
|
|
146
|
+
:key="name"
|
|
147
|
+
:offset="1"
|
|
148
|
+
:span="6"
|
|
149
|
+
>
|
|
150
|
+
{{ name }} : {{ value }}
|
|
151
|
+
</el-col>
|
|
152
|
+
</el-row>
|
|
153
|
+
</template>
|
|
119
154
|
<el-input
|
|
120
155
|
v-model="input"
|
|
121
156
|
type="textarea"
|
|
@@ -218,7 +253,9 @@ export default {
|
|
|
218
253
|
},
|
|
219
254
|
render: true,
|
|
220
255
|
region: "",
|
|
221
|
-
viewURL: ""
|
|
256
|
+
viewURL: "",
|
|
257
|
+
renderInfoOn: false,
|
|
258
|
+
rendererInfo: undefined
|
|
222
259
|
};
|
|
223
260
|
},
|
|
224
261
|
watch: {
|
|
@@ -238,6 +275,7 @@ export default {
|
|
|
238
275
|
mounted: function() {
|
|
239
276
|
this._sceneSettings = [];
|
|
240
277
|
this.selectedCoordinates = this.$refs.scaffold.getDynamicSelectedCoordinates();
|
|
278
|
+
this.rendererInfo = this.$refs.scaffold.getRendererInfo();
|
|
241
279
|
},
|
|
242
280
|
methods: {
|
|
243
281
|
exportGLTF: function() {
|
|
@@ -356,6 +394,12 @@ body {
|
|
|
356
394
|
|
|
357
395
|
.options-container {
|
|
358
396
|
text-align: center;
|
|
397
|
+
.el-row {
|
|
398
|
+
margin-bottom: 8px;
|
|
399
|
+
&:last-child {
|
|
400
|
+
margin-bottom: 0;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
359
403
|
}
|
|
360
404
|
|
|
361
405
|
.vuer {
|
|
@@ -268,10 +268,8 @@ Vue.use(Slider);
|
|
|
268
268
|
Vue.use(TabPane);
|
|
269
269
|
Vue.use(Tabs);
|
|
270
270
|
|
|
271
|
-
const OrgansViewer = require("
|
|
272
|
-
|
|
273
|
-
const EventNotifier = require("physiomeportal/src/utilities/eventNotifier")
|
|
274
|
-
.EventNotifier;
|
|
271
|
+
const OrgansViewer = require("../scripts/organsRenderer").OrgansViewer;
|
|
272
|
+
const EventNotifier = require("../scripts/eventNotifier").EventNotifier;
|
|
275
273
|
|
|
276
274
|
/**
|
|
277
275
|
* A vue component of the scaffold viewer.
|
|
@@ -535,7 +533,6 @@ export default {
|
|
|
535
533
|
this.$module.addOrganPartAddedCallback(this.organsAdded);
|
|
536
534
|
this.$module.initialiseRenderer(this.$refs.display);
|
|
537
535
|
this.toggleRendering(this.render);
|
|
538
|
-
this.$module.toolTip = undefined;
|
|
539
536
|
this.ro = new ResizeObserver(this.adjustLayout).observe(
|
|
540
537
|
this.$refs.scaffoldContainer
|
|
541
538
|
);
|
|
@@ -695,6 +692,12 @@ export default {
|
|
|
695
692
|
}
|
|
696
693
|
}
|
|
697
694
|
},
|
|
695
|
+
getRendererInfo: function() {
|
|
696
|
+
if (this.$module.zincRenderer) {
|
|
697
|
+
return this.$module.zincRenderer.getThreeJSRenderer().info;
|
|
698
|
+
}
|
|
699
|
+
return undefined;
|
|
700
|
+
},
|
|
698
701
|
/**
|
|
699
702
|
* Function used to rotate the scene.
|
|
700
703
|
* Also called when the associated button is pressed.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const MODULE_CHANGE = { ALL: 0, DESTROYED: 1, NAME_CHANGED: 2, SETTINGS_CHANGED: 3 };
|
|
2
|
+
|
|
3
|
+
const BaseModule = function() {
|
|
4
|
+
this.typeName = "Base Module";
|
|
5
|
+
this.instanceName = "default";
|
|
6
|
+
this.onChangedCallbacks = [];
|
|
7
|
+
/** Notifier handle for informing other modules of any changes **/
|
|
8
|
+
this.eventNotifiers = [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
BaseModule.prototype.setName = function(name) {
|
|
12
|
+
if (name && this.instanceName !== name) {
|
|
13
|
+
this.instanceName = name;
|
|
14
|
+
const callbackArray = this.onChangedCallbacks.slice();
|
|
15
|
+
for (let i = 0; i < callbackArray.length; i++) {
|
|
16
|
+
callbackArray[i]( this, MODULE_CHANGE.NAME_CHANGED );
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BaseModule.prototype.settingsChanged = function() {
|
|
22
|
+
const callbackArray = this.onChangedCallbacks.slice();
|
|
23
|
+
for (let i = 0; i < callbackArray.length; i++) {
|
|
24
|
+
callbackArray[i]( this, MODULE_CHANGE.SETTINGS_CHANGED );
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
BaseModule.prototype.exportSettings = function() {
|
|
29
|
+
const settings = {};
|
|
30
|
+
settings.dialog = this.typeName;
|
|
31
|
+
settings.name = this.instanceName;
|
|
32
|
+
return settings;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
BaseModule.prototype.importSettings = function(settings) {
|
|
36
|
+
if (settings.dialog == this.typeName) {
|
|
37
|
+
this.setName(settings.name);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
BaseModule.prototype.publishChanges = function(annotations, eventType) {
|
|
44
|
+
for (let i = 0; i < this.eventNotifiers.length; i++) {
|
|
45
|
+
this.eventNotifiers[i].publish(this, eventType, annotations);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
BaseModule.prototype.getName = function() {
|
|
50
|
+
return this.instanceName;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
BaseModule.prototype.destroy = function() {
|
|
54
|
+
//Make a temorary copy as the array may be altered during the loop
|
|
55
|
+
const callbackArray = this.onChangedCallbacks.slice();
|
|
56
|
+
for (let i = 0; i < callbackArray.length; i++) {
|
|
57
|
+
callbackArray[i]( this, MODULE_CHANGE.DESTROYED );
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
delete this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
BaseModule.prototype.addChangedCallback = function(callback) {
|
|
64
|
+
if (this.onChangedCallbacks.includes(callback) == false)
|
|
65
|
+
this.onChangedCallbacks.push(callback);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
BaseModule.prototype.removeChangedCallback = function(callback) {
|
|
69
|
+
const index = this.onChangedCallbacks.indexOf(callback);
|
|
70
|
+
if (index > -1) {
|
|
71
|
+
this.onChangedCallbacks.splice(index, 1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
BaseModule.prototype.addNotifier = function(eventNotifier) {
|
|
76
|
+
this.eventNotifiers.push(eventNotifier);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.BaseModule = BaseModule;
|
|
80
|
+
exports.MODULE_CHANGE = MODULE_CHANGE;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
const THREE = require('zincjs').THREE;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a {@link Zinc.Renderer} on the dom element with corresponding elementID.
|
|
5
|
+
* @param {String} elementID - id of the target dom element.
|
|
6
|
+
* @returns {Zinc.Renderer}
|
|
7
|
+
*/
|
|
8
|
+
const createRenderer = function () {
|
|
9
|
+
const WEBGL = require('./WebGL').WEBGL;
|
|
10
|
+
const localContainer = document.createElement( 'div' );
|
|
11
|
+
let localRenderer = undefined;;
|
|
12
|
+
localContainer.style.height = "100%";
|
|
13
|
+
if (WEBGL.isWebGLAvailable()) {
|
|
14
|
+
const Zinc = require('zincjs');
|
|
15
|
+
localRenderer = new Zinc.Renderer(localContainer, window);
|
|
16
|
+
Zinc.defaultMaterialColor = 0xFFFF9C;
|
|
17
|
+
localRenderer.initialiseVisualisation();
|
|
18
|
+
localRenderer.playAnimation = false;
|
|
19
|
+
} else {
|
|
20
|
+
const warning = WEBGL.getWebGLErrorMessage();
|
|
21
|
+
localContainer.appendChild(warning);
|
|
22
|
+
}
|
|
23
|
+
return {"renderer":localRenderer, "container":localContainer};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const RendererModule = function() {
|
|
27
|
+
(require('./BaseModule').BaseModule).call(this);
|
|
28
|
+
this.scene = undefined;
|
|
29
|
+
this.rendererContainer = undefined;
|
|
30
|
+
this.displayArea = undefined;
|
|
31
|
+
this.graphicsHighlight = new (require("./graphicsHighlight").GraphicsHighlight)();
|
|
32
|
+
this.zincRenderer = null;
|
|
33
|
+
this.selectedScreenCoordinates = new THREE.Vector3();
|
|
34
|
+
this.selectedCenter = undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
RendererModule.prototype = Object.create((require('./BaseModule').BaseModule).prototype);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* This function will get the the first intersected object with name or
|
|
41
|
+
* the first glyph object with name.
|
|
42
|
+
*/
|
|
43
|
+
RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
44
|
+
if (intersects) {
|
|
45
|
+
for (let i = 0; i < intersects.length; i++) {
|
|
46
|
+
if (intersects[i] !== undefined) {
|
|
47
|
+
if (intersects[i].object &&
|
|
48
|
+
intersects[i].object.userData &&
|
|
49
|
+
intersects[i].object.userData.isZincObject &&
|
|
50
|
+
(intersects[i].object.name ||
|
|
51
|
+
intersects[i].object.userData.isMarker))
|
|
52
|
+
return intersects[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
RendererModule.prototype.getAnnotationsFromObjects = function(objects) {
|
|
60
|
+
const annotations = [];
|
|
61
|
+
for (var i = 0; i < objects.length; i++) {
|
|
62
|
+
const zincObject = objects[i].userData;
|
|
63
|
+
let annotation = undefined;
|
|
64
|
+
if (zincObject) {
|
|
65
|
+
if (zincObject.isGlyph || zincObject.isGlyphset) {
|
|
66
|
+
const glyphset = zincObject;
|
|
67
|
+
if (zincObject.isGlyph)
|
|
68
|
+
glyphset = zincObject.getGlyphset();
|
|
69
|
+
annotation = glyphset.userData ? glyphset.userData[0] : undefined;
|
|
70
|
+
if (annotation && annotation.data) {
|
|
71
|
+
if (objects[i].name && objects[i].name != "")
|
|
72
|
+
annotation.data.id = objects[i].name;
|
|
73
|
+
else
|
|
74
|
+
annotation.data.id = glyphset.groupName;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
annotation = zincObject.userData ? zincObject.userData[0] : undefined;
|
|
78
|
+
if (annotation && annotation.data){
|
|
79
|
+
annotation.data.id = objects[i].name;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
annotations[i] = annotation;
|
|
84
|
+
}
|
|
85
|
+
return annotations;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
RendererModule.prototype.setHighlightedByObjects = function(objects, propagateChanges) {
|
|
89
|
+
const changed = this.graphicsHighlight.setHighlighted(objects);
|
|
90
|
+
if (changed && propagateChanges) {
|
|
91
|
+
const eventType = require("./eventNotifier").EVENT_TYPE.HIGHLIGHTED;
|
|
92
|
+
const annotations = this.getAnnotationsFromObjects(objects);
|
|
93
|
+
this.publishChanges(annotations, eventType);
|
|
94
|
+
}
|
|
95
|
+
return changed;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
RendererModule.prototype.setHighlightedByZincObject = function(
|
|
100
|
+
zincObject, propagateChanges) {
|
|
101
|
+
return this.setHighlightedByObjects([zincObject ? zincObject.morph : undefined], propagateChanges);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
105
|
+
if (zincObjects && (zincObjects.length > 0)) {
|
|
106
|
+
const boundingBox = this.scene.getBoundingBoxOfZincObjects(zincObjects);
|
|
107
|
+
let newSelectedCenter = new THREE.Vector3();
|
|
108
|
+
boundingBox.getCenter(newSelectedCenter);
|
|
109
|
+
if (this.selectedCenter == undefined)
|
|
110
|
+
this.selectedCenter = newSelectedCenter;
|
|
111
|
+
else {
|
|
112
|
+
this.selectedCenter.x = newSelectedCenter.x;
|
|
113
|
+
this.selectedCenter.y = newSelectedCenter.y;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
this.selectedCenter = undefined;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
RendererModule.prototype.objectsToZincObjects = function(objects) {
|
|
121
|
+
const zincObjects = [];
|
|
122
|
+
for (let i = 0; i < objects.length; i++) {
|
|
123
|
+
let zincObject = objects[i].userData;
|
|
124
|
+
if (zincObject) {
|
|
125
|
+
if (zincObject.isGlyph || zincObject.isGlyphset) {
|
|
126
|
+
let glyphset = zincObject;
|
|
127
|
+
if (zincObject.isGlyph)
|
|
128
|
+
glyphset = zincObject.getGlyphset();
|
|
129
|
+
zincObjects. push(glyphset);
|
|
130
|
+
} else {
|
|
131
|
+
zincObjects. push(zincObject);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return zincObjects;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
RendererModule.prototype.setSelectedByObjects = function(
|
|
140
|
+
objects, propagateChanges) {
|
|
141
|
+
const changed = this.graphicsHighlight.setSelected(objects);
|
|
142
|
+
if (changed) {
|
|
143
|
+
const zincObjects = this.objectsToZincObjects(objects);
|
|
144
|
+
this.setupLiveCoordinates(zincObjects);
|
|
145
|
+
if (propagateChanges) {
|
|
146
|
+
const eventType = require("./eventNotifier").EVENT_TYPE.SELECTED;
|
|
147
|
+
const annotations = this.getAnnotationsFromObjects(objects);
|
|
148
|
+
this.publishChanges(annotations, eventType);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return changed;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
RendererModule.prototype.setSelectedByZincObject = function(
|
|
155
|
+
zincObject, propagateChanges) {
|
|
156
|
+
return this.setSelectedByObjects([zincObject ? zincObject.morph : undefined], propagateChanges);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const addGlyphToArray = function(objects) {
|
|
160
|
+
return function(glyph) {
|
|
161
|
+
objects.push(glyph.getMesh());
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
RendererModule.prototype.findObjectsByGroupName = function(groupName) {
|
|
166
|
+
const geometries = this.scene.findGeometriesWithGroupName(groupName);
|
|
167
|
+
const objects = [];
|
|
168
|
+
for (let i = 0; i < geometries.length; i ++ ) {
|
|
169
|
+
objects.push(geometries[i].morph);
|
|
170
|
+
}
|
|
171
|
+
const glyphsets = this.scene.findGlyphsetsWithGroupName(groupName);
|
|
172
|
+
for (let i = 0; i < glyphsets.length; i ++ ) {
|
|
173
|
+
glyphsets[i].forEachGlyph(addGlyphToArray(objects));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return objects;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
|
|
180
|
+
const objects = this.findObjectsByGroupName(groupName);
|
|
181
|
+
return this.setHighlightedByObjects(objects, propagateChanges);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
RendererModule.prototype.setSelectedByGroupName = function(groupName, propagateChanges) {
|
|
185
|
+
const objects = this.findObjectsByGroupName(groupName);
|
|
186
|
+
return this.setSelectedByObjects(objects, propagateChanges);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
RendererModule.prototype.changeBackgroundColour = function(backgroundColourString) {
|
|
190
|
+
const colour = new THREE.Color(backgroundColourString);
|
|
191
|
+
if (this.zincRenderer) {
|
|
192
|
+
let internalRenderer = this.zincRenderer.getThreeJSRenderer();
|
|
193
|
+
internalRenderer.setClearColor( colour, 1 );
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
RendererModule.prototype.resetView = function() {
|
|
198
|
+
if (this.zincRenderer)
|
|
199
|
+
this.zincRenderer.resetView();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
RendererModule.prototype.viewAll = function() {
|
|
203
|
+
if (this.zincRenderer)
|
|
204
|
+
this.zincRenderer.viewAll();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Start the animation and let the renderer to processs with
|
|
209
|
+
* time progression
|
|
210
|
+
*/
|
|
211
|
+
RendererModule.prototype.playAnimation = function(flag) {
|
|
212
|
+
if (this.zincRenderer)
|
|
213
|
+
this.zincRenderer.playAnimation = flag;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Set the speed of playback
|
|
218
|
+
*/
|
|
219
|
+
RendererModule.prototype.setPlayRate = function(value) {
|
|
220
|
+
if (this.zincRenderer)
|
|
221
|
+
this.zincRenderer.setPlayRate(value);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Get the speed of playback
|
|
226
|
+
*/
|
|
227
|
+
RendererModule.prototype.getPlayRate = function(value) {
|
|
228
|
+
if (this.zincRenderer)
|
|
229
|
+
return this.zincRenderer.getPlayRate();
|
|
230
|
+
else
|
|
231
|
+
return 0.0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Initialise everything in the renderer, including the 3D renderer,
|
|
235
|
+
* and picker for the 3D renderer.
|
|
236
|
+
*
|
|
237
|
+
*/
|
|
238
|
+
RendererModule.prototype.initialiseRenderer = function(displayAreaIn) {
|
|
239
|
+
if (this.zincRenderer === undefined || this.rendererContainer === undefined) {
|
|
240
|
+
let returnedValue = createRenderer();
|
|
241
|
+
this.zincRenderer = returnedValue["renderer"];
|
|
242
|
+
this.rendererContainer = returnedValue["container"];
|
|
243
|
+
}
|
|
244
|
+
if (displayAreaIn) {
|
|
245
|
+
this.displayArea = displayAreaIn;
|
|
246
|
+
this.displayArea.appendChild( this.rendererContainer );
|
|
247
|
+
if (this.zincRenderer)
|
|
248
|
+
this.zincRenderer.animate();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
RendererModule.prototype.destroy = function() {
|
|
253
|
+
if (this.zincRenderer) {
|
|
254
|
+
this.zincRenderer.dispose();
|
|
255
|
+
this.zincRenderer.getThreeJSRenderer().dispose();
|
|
256
|
+
this.zincRenderer = undefined;
|
|
257
|
+
}
|
|
258
|
+
(require('./BaseModule').BaseModule).prototype.destroy.call( this );
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
exports.RendererModule = RendererModule;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author alteredq / http://alteredqualia.com/
|
|
3
|
+
* @author mr.doob / http://mrdoob.com/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
exports.WEBGL = {
|
|
7
|
+
|
|
8
|
+
isWebGLAvailable: function () {
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
|
|
12
|
+
var canvas = document.createElement( 'canvas' );
|
|
13
|
+
return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
|
|
14
|
+
|
|
15
|
+
} catch ( e ) {
|
|
16
|
+
|
|
17
|
+
return false;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
isWebGL2Available: function () {
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
|
|
27
|
+
var canvas = document.createElement( 'canvas' );
|
|
28
|
+
return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
|
|
29
|
+
|
|
30
|
+
} catch ( e ) {
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
getWebGLErrorMessage: function () {
|
|
39
|
+
|
|
40
|
+
return this.getErrorMessage( 1 );
|
|
41
|
+
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
getWebGL2ErrorMessage: function () {
|
|
45
|
+
|
|
46
|
+
return this.getErrorMessage( 2 );
|
|
47
|
+
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
getErrorMessage: function ( version ) {
|
|
51
|
+
|
|
52
|
+
var names = {
|
|
53
|
+
1: 'WebGL',
|
|
54
|
+
2: 'WebGL 2'
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var contexts = {
|
|
58
|
+
1: window.WebGLRenderingContext,
|
|
59
|
+
2: window.WebGL2RenderingContext
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var message = 'This module requires <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#008">$1</a> support but your $0 does not seem to support it.';
|
|
63
|
+
|
|
64
|
+
var element = document.createElement( 'div' );
|
|
65
|
+
element.id = 'webglmessage';
|
|
66
|
+
element.style.fontFamily = 'monospace';
|
|
67
|
+
element.style.fontSize = '20px';
|
|
68
|
+
element.style.fontWeight = 'normal';
|
|
69
|
+
element.style.textAlign = 'center';
|
|
70
|
+
element.style.background = '#fff';
|
|
71
|
+
element.style.color = '#000';
|
|
72
|
+
element.style.padding = '1.5em';
|
|
73
|
+
element.style.width = '400px';
|
|
74
|
+
element.style.margin = '5em auto 0';
|
|
75
|
+
|
|
76
|
+
if ( contexts[ version ] ) {
|
|
77
|
+
|
|
78
|
+
message = message.replace( '$0', 'graphics card' );
|
|
79
|
+
|
|
80
|
+
} else {
|
|
81
|
+
|
|
82
|
+
message = message.replace( '$0', 'browser' );
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
message = message.replace( '$1', names[ version ] );
|
|
87
|
+
|
|
88
|
+
element.innerHTML = message;
|
|
89
|
+
|
|
90
|
+
return element;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const EVENT_TYPE = { ALL: 0, SELECTED: 1, HIGHLIGHTED: 2 };
|
|
2
|
+
|
|
3
|
+
const SelectionEvent = function(eventTypeIn, identifiersIn) {
|
|
4
|
+
this.eventType = eventTypeIn;
|
|
5
|
+
this.identifiers = identifiersIn;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const returnFullID = function(sourceId) {
|
|
9
|
+
//return full annotations with all different name
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Subscription = function(subscriberIn, callbackIn, eventType) {
|
|
13
|
+
this.targetedID = [];
|
|
14
|
+
const subscriber = subscriberIn;
|
|
15
|
+
const callback = callbackIn;
|
|
16
|
+
this.targetEventType = eventType;
|
|
17
|
+
const _this = this;
|
|
18
|
+
|
|
19
|
+
if (eventType === undefined)
|
|
20
|
+
this.targetEventType = EVENT_TYPE.ALL;
|
|
21
|
+
|
|
22
|
+
this.getEventType = function() {
|
|
23
|
+
return eventType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.notify = function(source, eventType, ids) {
|
|
27
|
+
if (source !== subscriber && (_this.targetEventType === EVENT_TYPE.ALL ||
|
|
28
|
+
_this.targetEventType === eventType)) {
|
|
29
|
+
//should support different type of id e.g lyph, name, fmas...
|
|
30
|
+
//need a function that finds all relavant ids
|
|
31
|
+
const event = new SelectionEvent(eventType, ids);
|
|
32
|
+
callback(event);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.EventNotifier = function() {
|
|
38
|
+
const subscriptions = [];
|
|
39
|
+
|
|
40
|
+
this.publish = function(source, eventType, id) {
|
|
41
|
+
for (let i = 0; i < subscriptions.length;i++) {
|
|
42
|
+
subscriptions[i].notify(source, eventType, id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.subscribe = function(subscriber, callbackFunction, eventType) {
|
|
47
|
+
if (typeof callbackFunction === "function") {
|
|
48
|
+
const subscription = new Subscription(subscriber, callbackFunction, eventType);
|
|
49
|
+
subscriptions.push(subscription);
|
|
50
|
+
return subscription;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.unsubscribe = function(subscription) {
|
|
56
|
+
for (let i = 0; i < subscriptions.length;i++) {
|
|
57
|
+
if (subscription === subscriptions[i]) {
|
|
58
|
+
subscriptions.splice(i, 1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.EVENT_TYPE = EVENT_TYPE;
|