@abi-software/scaffoldvuer 0.2.3-alpha-2 → 0.3.1
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/.eslintrc.js +12 -12
- package/CHANGELOG.md +344 -316
- package/LICENSE +201 -201
- package/README.md +164 -164
- package/babel.config.js +14 -14
- package/dist/scaffoldvuer-wc.common.js +277 -34
- package/dist/scaffoldvuer-wc.umd.js +277 -34
- package/dist/scaffoldvuer-wc.umd.min.js +277 -34
- package/dist/scaffoldvuer.common.js +1252 -529
- package/dist/scaffoldvuer.common.js.map +1 -1
- package/dist/scaffoldvuer.css +1 -1
- package/dist/scaffoldvuer.umd.js +1252 -529
- 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 +18121 -18119
- package/package.json +89 -89
- package/public/index.html +17 -17
- package/src/App.vue +669 -669
- package/src/ScaffoldVuer-wc.js +13 -13
- package/src/app/DropZone.vue +114 -114
- package/src/app/ModelsInformation.js +35 -35
- package/src/app/ModelsTable.vue +113 -113
- package/src/app/TextureDemos.js +114 -114
- package/src/assets/_variables.scss +43 -43
- package/src/assets/styles.scss +7 -7
- package/src/components/OpacityControls.vue +123 -222
- package/src/components/PrimitiveControls.vue +173 -0
- package/src/components/ScaffoldTooltip.vue +142 -142
- package/src/components/ScaffoldVuer.md +44 -44
- package/src/components/ScaffoldVuer.vue +2007 -2007
- package/src/components/TextureSlidesControls.vue +272 -0
- package/src/components/TreeControls.vue +707 -699
- package/src/components/index.js +7 -7
- package/src/credential.json +12 -0
- package/src/main.js +14 -14
- package/src/scripts/BaseModule.js +80 -80
- package/src/scripts/RendererModule.js +289 -289
- package/src/scripts/WebGL.js +94 -94
- package/src/scripts/annotation.js +5 -5
- package/src/scripts/eventNotifier.js +66 -66
- package/src/scripts/graphicsHighlight.js +134 -134
- package/src/scripts/organsRenderer.js +587 -587
- package/src/scripts/search.js +182 -182
- package/src/scripts/utilities.js +146 -146
- package/styleguide.config.js +22 -22
- package/vue.config.js +41 -41
- package/src/components/test.pdf +0 -0
- package/src/searchControls.vue +0 -122
|
@@ -1,290 +1,290 @@
|
|
|
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
|
-
const Zinc = require('zincjs');
|
|
14
|
-
if (WEBGL.isWebGLAvailable()) {
|
|
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 {Zinc, "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
|
-
this.liveUpdatesObjects = undefined;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
RendererModule.prototype = Object.create((require('./BaseModule').BaseModule).prototype);
|
|
39
|
-
|
|
40
|
-
RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
41
|
-
if (intersects) {
|
|
42
|
-
const typeMap = intersects.map(intersect => {
|
|
43
|
-
if (intersect && intersect.object &&
|
|
44
|
-
intersect.object.userData) {
|
|
45
|
-
if (intersect.object.userData.isMarker) {
|
|
46
|
-
return 1;
|
|
47
|
-
} else if (intersect.object.name &&
|
|
48
|
-
intersect.object.userData.isZincObject) {
|
|
49
|
-
return 2;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return 0;
|
|
53
|
-
});
|
|
54
|
-
let i = typeMap.indexOf(1);
|
|
55
|
-
i = (i > -1) ? i : typeMap.indexOf(2);
|
|
56
|
-
return intersects[i];
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
RendererModule.prototype.getAnnotationsFromObjects = function(objects) {
|
|
63
|
-
const annotations = [];
|
|
64
|
-
for (var i = 0; i < objects.length; i++) {
|
|
65
|
-
const zincObject = objects[i].userData;
|
|
66
|
-
let annotation = undefined;
|
|
67
|
-
if (zincObject) {
|
|
68
|
-
if (zincObject.isGlyph || zincObject.isGlyphset) {
|
|
69
|
-
const glyphset = zincObject;
|
|
70
|
-
if (zincObject.isGlyph)
|
|
71
|
-
glyphset = zincObject.getGlyphset();
|
|
72
|
-
annotation = glyphset.userData ? glyphset.userData.annotation : undefined;
|
|
73
|
-
if (annotation && annotation.data) {
|
|
74
|
-
if (objects[i].name && objects[i].name != "")
|
|
75
|
-
annotation.data.id = objects[i].name;
|
|
76
|
-
else
|
|
77
|
-
annotation.data.id = glyphset.groupName;
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
annotation = zincObject.userData ? zincObject.userData.annotation : undefined;
|
|
81
|
-
if (annotation && annotation.data){
|
|
82
|
-
annotation.data.id = objects[i].name;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (annotation)
|
|
87
|
-
annotations.push(annotation);
|
|
88
|
-
}
|
|
89
|
-
return annotations;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
RendererModule.prototype.setHighlightedByObjects = function(
|
|
93
|
-
objects, coords, propagateChanges) {
|
|
94
|
-
const changed = this.graphicsHighlight.setHighlighted(objects);
|
|
95
|
-
const zincObjects = this.objectsToZincObjects(objects);
|
|
96
|
-
if (propagateChanges) {
|
|
97
|
-
eventType = require("./eventNotifier").EVENT_TYPE.MOVE;
|
|
98
|
-
if (changed)
|
|
99
|
-
eventType = require("./eventNotifier").EVENT_TYPE.HIGHLIGHTED;
|
|
100
|
-
const annotations = this.getAnnotationsFromObjects(objects);
|
|
101
|
-
if (annotations.length > 0)
|
|
102
|
-
annotations[0].coords = coords;
|
|
103
|
-
this.publishChanges(annotations, eventType, zincObjects);
|
|
104
|
-
}
|
|
105
|
-
return changed;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
RendererModule.prototype.setHighlightedByZincObjects = function(
|
|
110
|
-
zincObjects, coords, propagateChanges) {
|
|
111
|
-
let morphs = [];
|
|
112
|
-
if (zincObjects) {
|
|
113
|
-
zincObjects.forEach(zincObject => {
|
|
114
|
-
if (zincObject && zincObject.morph)
|
|
115
|
-
morphs.push(zincObject.morph);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this.setHighlightedByObjects(morphs, coords,propagateChanges);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
123
|
-
this.liveUpdatesObjects = zincObjects;
|
|
124
|
-
if (zincObjects && (zincObjects.length > 0)) {
|
|
125
|
-
const boundingBox = this.scene.getBoundingBoxOfZincObjects(zincObjects);
|
|
126
|
-
let newSelectedCenter = new THREE.Vector3();
|
|
127
|
-
boundingBox.getCenter(newSelectedCenter);
|
|
128
|
-
if (this.selectedCenter == undefined) {
|
|
129
|
-
this.selectedCenter = newSelectedCenter;
|
|
130
|
-
} else {
|
|
131
|
-
this.selectedCenter.copy(newSelectedCenter);
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
this.selectedCenter = undefined;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
RendererModule.prototype.objectsToZincObjects = function(objects) {
|
|
139
|
-
const zincObjects = [];
|
|
140
|
-
for (let i = 0; i < objects.length; i++) {
|
|
141
|
-
let zincObject = objects[i].userData;
|
|
142
|
-
if (zincObject) {
|
|
143
|
-
if (zincObject.isGlyph || zincObject.isGlyphset) {
|
|
144
|
-
let glyphset = zincObject;
|
|
145
|
-
if (zincObject.isGlyph)
|
|
146
|
-
glyphset = zincObject.getGlyphset();
|
|
147
|
-
zincObjects.
|
|
148
|
-
} else {
|
|
149
|
-
zincObjects.
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return zincObjects;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
RendererModule.prototype.setSelectedByObjects = function(
|
|
158
|
-
objects, coords, propagateChanges) {
|
|
159
|
-
const changed = this.graphicsHighlight.setSelected(objects);
|
|
160
|
-
if (changed) {
|
|
161
|
-
const zincObjects = this.objectsToZincObjects(objects);
|
|
162
|
-
this.setupLiveCoordinates(zincObjects);
|
|
163
|
-
if (propagateChanges) {
|
|
164
|
-
const eventType = require("./eventNotifier").EVENT_TYPE.SELECTED;
|
|
165
|
-
const annotations = this.getAnnotationsFromObjects(objects);
|
|
166
|
-
if (annotations.length > 0)
|
|
167
|
-
annotations[0].coords = coords;
|
|
168
|
-
this.publishChanges(annotations, eventType, zincObjects);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return changed;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
RendererModule.prototype.setSelectedByZincObjects = function(
|
|
175
|
-
zincObjects, coords, propagateChanges) {
|
|
176
|
-
let morphs = [];
|
|
177
|
-
if (zincObjects) {
|
|
178
|
-
zincObjects.forEach(zincObject => {
|
|
179
|
-
if (zincObject && zincObject.morph)
|
|
180
|
-
morphs.push(zincObject.morph);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return this.setSelectedByObjects(morphs, coords, propagateChanges);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const addGlyphToArray = function(objects) {
|
|
188
|
-
return function(glyph) {
|
|
189
|
-
objects.push(glyph.getMesh());
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
RendererModule.prototype.findObjectsByGroupName = function(groupName) {
|
|
194
|
-
const geometries = this.scene.findGeometriesWithGroupName(groupName);
|
|
195
|
-
const objects = [];
|
|
196
|
-
for (let i = 0; i < geometries.length; i ++ ) {
|
|
197
|
-
objects.push(geometries[i].morph);
|
|
198
|
-
}
|
|
199
|
-
const glyphsets = this.scene.findGlyphsetsWithGroupName(groupName);
|
|
200
|
-
for (let i = 0; i < glyphsets.length; i ++ ) {
|
|
201
|
-
glyphsets[i].forEachGlyph(addGlyphToArray(objects));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return objects;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
|
|
208
|
-
const objects = this.findObjectsByGroupName(groupName);
|
|
209
|
-
return this.setHighlightedByObjects(objects, undefined, propagateChanges);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
RendererModule.prototype.setSelectedByGroupName = function(groupName, propagateChanges) {
|
|
213
|
-
const objects = this.findObjectsByGroupName(groupName);
|
|
214
|
-
return this.setSelectedByObjects(objects, undefined, propagateChanges);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
RendererModule.prototype.changeBackgroundColour = function(backgroundColourString) {
|
|
218
|
-
const colour = new THREE.Color(backgroundColourString);
|
|
219
|
-
if (this.zincRenderer) {
|
|
220
|
-
let internalRenderer = this.zincRenderer.getThreeJSRenderer();
|
|
221
|
-
internalRenderer.setClearColor( colour, 1 );
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
RendererModule.prototype.resetView = function() {
|
|
226
|
-
if (this.zincRenderer)
|
|
227
|
-
this.zincRenderer.resetView();
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
RendererModule.prototype.viewAll = function() {
|
|
231
|
-
if (this.zincRenderer)
|
|
232
|
-
this.zincRenderer.viewAll();
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Start the animation and let the renderer to processs with
|
|
237
|
-
* time progression
|
|
238
|
-
*/
|
|
239
|
-
RendererModule.prototype.playAnimation = function(flag) {
|
|
240
|
-
if (this.zincRenderer)
|
|
241
|
-
this.zincRenderer.playAnimation = flag;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Set the speed of playback
|
|
246
|
-
*/
|
|
247
|
-
RendererModule.prototype.setPlayRate = function(value) {
|
|
248
|
-
if (this.zincRenderer)
|
|
249
|
-
this.zincRenderer.setPlayRate(value);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Get the speed of playback
|
|
254
|
-
*/
|
|
255
|
-
RendererModule.prototype.getPlayRate = function(value) {
|
|
256
|
-
if (this.zincRenderer)
|
|
257
|
-
return this.zincRenderer.getPlayRate();
|
|
258
|
-
else
|
|
259
|
-
return 0.0;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/** Initialise everything in the renderer, including the 3D renderer,
|
|
263
|
-
* and picker for the 3D renderer.
|
|
264
|
-
*
|
|
265
|
-
*/
|
|
266
|
-
RendererModule.prototype.initialiseRenderer = function(displayAreaIn) {
|
|
267
|
-
if (this.zincRenderer === undefined || this.rendererContainer === undefined) {
|
|
268
|
-
let returnedValue = createRenderer();
|
|
269
|
-
this.Zinc = returnedValue["Zinc"];
|
|
270
|
-
this.zincRenderer = returnedValue["renderer"];
|
|
271
|
-
this.rendererContainer = returnedValue["container"];
|
|
272
|
-
}
|
|
273
|
-
if (displayAreaIn) {
|
|
274
|
-
this.displayArea = displayAreaIn;
|
|
275
|
-
this.displayArea.appendChild( this.rendererContainer );
|
|
276
|
-
if (this.zincRenderer)
|
|
277
|
-
this.zincRenderer.animate();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
RendererModule.prototype.destroy = function() {
|
|
282
|
-
if (this.zincRenderer) {
|
|
283
|
-
this.zincRenderer.dispose();
|
|
284
|
-
this.zincRenderer.getThreeJSRenderer().dispose();
|
|
285
|
-
this.zincRenderer = undefined;
|
|
286
|
-
}
|
|
287
|
-
(require('./BaseModule').BaseModule).prototype.destroy.call( this );
|
|
288
|
-
}
|
|
289
|
-
|
|
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
|
+
const Zinc = require('zincjs');
|
|
14
|
+
if (WEBGL.isWebGLAvailable()) {
|
|
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 {Zinc, "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
|
+
this.liveUpdatesObjects = undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
RendererModule.prototype = Object.create((require('./BaseModule').BaseModule).prototype);
|
|
39
|
+
|
|
40
|
+
RendererModule.prototype.getIntersectedObject = function(intersects) {
|
|
41
|
+
if (intersects) {
|
|
42
|
+
const typeMap = intersects.map(intersect => {
|
|
43
|
+
if (intersect && intersect.object &&
|
|
44
|
+
intersect.object.userData) {
|
|
45
|
+
if (intersect.object.userData.isMarker) {
|
|
46
|
+
return 1;
|
|
47
|
+
} else if (intersect.object.name &&
|
|
48
|
+
intersect.object.userData.isZincObject) {
|
|
49
|
+
return 2;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
});
|
|
54
|
+
let i = typeMap.indexOf(1);
|
|
55
|
+
i = (i > -1) ? i : typeMap.indexOf(2);
|
|
56
|
+
return intersects[i];
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
RendererModule.prototype.getAnnotationsFromObjects = function(objects) {
|
|
63
|
+
const annotations = [];
|
|
64
|
+
for (var i = 0; i < objects.length; i++) {
|
|
65
|
+
const zincObject = objects[i].userData;
|
|
66
|
+
let annotation = undefined;
|
|
67
|
+
if (zincObject) {
|
|
68
|
+
if (zincObject.isGlyph || zincObject.isGlyphset) {
|
|
69
|
+
const glyphset = zincObject;
|
|
70
|
+
if (zincObject.isGlyph)
|
|
71
|
+
glyphset = zincObject.getGlyphset();
|
|
72
|
+
annotation = glyphset.userData ? glyphset.userData.annotation : undefined;
|
|
73
|
+
if (annotation && annotation.data) {
|
|
74
|
+
if (objects[i].name && objects[i].name != "")
|
|
75
|
+
annotation.data.id = objects[i].name;
|
|
76
|
+
else
|
|
77
|
+
annotation.data.id = glyphset.groupName;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
annotation = zincObject.userData ? zincObject.userData.annotation : undefined;
|
|
81
|
+
if (annotation && annotation.data){
|
|
82
|
+
annotation.data.id = objects[i].name;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (annotation)
|
|
87
|
+
annotations.push(annotation);
|
|
88
|
+
}
|
|
89
|
+
return annotations;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
RendererModule.prototype.setHighlightedByObjects = function(
|
|
93
|
+
objects, coords, propagateChanges) {
|
|
94
|
+
const changed = this.graphicsHighlight.setHighlighted(objects);
|
|
95
|
+
const zincObjects = this.objectsToZincObjects(objects);
|
|
96
|
+
if (propagateChanges) {
|
|
97
|
+
eventType = require("./eventNotifier").EVENT_TYPE.MOVE;
|
|
98
|
+
if (changed)
|
|
99
|
+
eventType = require("./eventNotifier").EVENT_TYPE.HIGHLIGHTED;
|
|
100
|
+
const annotations = this.getAnnotationsFromObjects(objects);
|
|
101
|
+
if (annotations.length > 0)
|
|
102
|
+
annotations[0].coords = coords;
|
|
103
|
+
this.publishChanges(annotations, eventType, zincObjects);
|
|
104
|
+
}
|
|
105
|
+
return changed;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
RendererModule.prototype.setHighlightedByZincObjects = function(
|
|
110
|
+
zincObjects, coords, propagateChanges) {
|
|
111
|
+
let morphs = [];
|
|
112
|
+
if (zincObjects) {
|
|
113
|
+
zincObjects.forEach(zincObject => {
|
|
114
|
+
if (zincObject && zincObject.morph)
|
|
115
|
+
morphs.push(zincObject.morph);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return this.setHighlightedByObjects(morphs, coords,propagateChanges);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
RendererModule.prototype.setupLiveCoordinates = function(zincObjects) {
|
|
123
|
+
this.liveUpdatesObjects = zincObjects;
|
|
124
|
+
if (zincObjects && (zincObjects.length > 0)) {
|
|
125
|
+
const boundingBox = this.scene.getBoundingBoxOfZincObjects(zincObjects);
|
|
126
|
+
let newSelectedCenter = new THREE.Vector3();
|
|
127
|
+
boundingBox.getCenter(newSelectedCenter);
|
|
128
|
+
if (this.selectedCenter == undefined) {
|
|
129
|
+
this.selectedCenter = newSelectedCenter;
|
|
130
|
+
} else {
|
|
131
|
+
this.selectedCenter.copy(newSelectedCenter);
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
this.selectedCenter = undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
RendererModule.prototype.objectsToZincObjects = function(objects) {
|
|
139
|
+
const zincObjects = [];
|
|
140
|
+
for (let i = 0; i < objects.length; i++) {
|
|
141
|
+
let zincObject = objects[i].userData;
|
|
142
|
+
if (zincObject) {
|
|
143
|
+
if (zincObject.isGlyph || zincObject.isGlyphset) {
|
|
144
|
+
let glyphset = zincObject;
|
|
145
|
+
if (zincObject.isGlyph)
|
|
146
|
+
glyphset = zincObject.getGlyphset();
|
|
147
|
+
zincObjects.push(glyphset);
|
|
148
|
+
} else {
|
|
149
|
+
zincObjects.push(zincObject);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return zincObjects;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
RendererModule.prototype.setSelectedByObjects = function(
|
|
158
|
+
objects, coords, propagateChanges) {
|
|
159
|
+
const changed = this.graphicsHighlight.setSelected(objects);
|
|
160
|
+
if (changed) {
|
|
161
|
+
const zincObjects = this.objectsToZincObjects(objects);
|
|
162
|
+
this.setupLiveCoordinates(zincObjects);
|
|
163
|
+
if (propagateChanges) {
|
|
164
|
+
const eventType = require("./eventNotifier").EVENT_TYPE.SELECTED;
|
|
165
|
+
const annotations = this.getAnnotationsFromObjects(objects);
|
|
166
|
+
if (annotations.length > 0)
|
|
167
|
+
annotations[0].coords = coords;
|
|
168
|
+
this.publishChanges(annotations, eventType, zincObjects);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return changed;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
RendererModule.prototype.setSelectedByZincObjects = function(
|
|
175
|
+
zincObjects, coords, propagateChanges) {
|
|
176
|
+
let morphs = [];
|
|
177
|
+
if (zincObjects) {
|
|
178
|
+
zincObjects.forEach(zincObject => {
|
|
179
|
+
if (zincObject && zincObject.morph)
|
|
180
|
+
morphs.push(zincObject.morph);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return this.setSelectedByObjects(morphs, coords, propagateChanges);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const addGlyphToArray = function(objects) {
|
|
188
|
+
return function(glyph) {
|
|
189
|
+
objects.push(glyph.getMesh());
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
RendererModule.prototype.findObjectsByGroupName = function(groupName) {
|
|
194
|
+
const geometries = this.scene.findGeometriesWithGroupName(groupName);
|
|
195
|
+
const objects = [];
|
|
196
|
+
for (let i = 0; i < geometries.length; i ++ ) {
|
|
197
|
+
objects.push(geometries[i].morph);
|
|
198
|
+
}
|
|
199
|
+
const glyphsets = this.scene.findGlyphsetsWithGroupName(groupName);
|
|
200
|
+
for (let i = 0; i < glyphsets.length; i ++ ) {
|
|
201
|
+
glyphsets[i].forEachGlyph(addGlyphToArray(objects));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return objects;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
|
|
208
|
+
const objects = this.findObjectsByGroupName(groupName);
|
|
209
|
+
return this.setHighlightedByObjects(objects, undefined, propagateChanges);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
RendererModule.prototype.setSelectedByGroupName = function(groupName, propagateChanges) {
|
|
213
|
+
const objects = this.findObjectsByGroupName(groupName);
|
|
214
|
+
return this.setSelectedByObjects(objects, undefined, propagateChanges);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
RendererModule.prototype.changeBackgroundColour = function(backgroundColourString) {
|
|
218
|
+
const colour = new THREE.Color(backgroundColourString);
|
|
219
|
+
if (this.zincRenderer) {
|
|
220
|
+
let internalRenderer = this.zincRenderer.getThreeJSRenderer();
|
|
221
|
+
internalRenderer.setClearColor( colour, 1 );
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
RendererModule.prototype.resetView = function() {
|
|
226
|
+
if (this.zincRenderer)
|
|
227
|
+
this.zincRenderer.resetView();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
RendererModule.prototype.viewAll = function() {
|
|
231
|
+
if (this.zincRenderer)
|
|
232
|
+
this.zincRenderer.viewAll();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Start the animation and let the renderer to processs with
|
|
237
|
+
* time progression
|
|
238
|
+
*/
|
|
239
|
+
RendererModule.prototype.playAnimation = function(flag) {
|
|
240
|
+
if (this.zincRenderer)
|
|
241
|
+
this.zincRenderer.playAnimation = flag;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set the speed of playback
|
|
246
|
+
*/
|
|
247
|
+
RendererModule.prototype.setPlayRate = function(value) {
|
|
248
|
+
if (this.zincRenderer)
|
|
249
|
+
this.zincRenderer.setPlayRate(value);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get the speed of playback
|
|
254
|
+
*/
|
|
255
|
+
RendererModule.prototype.getPlayRate = function(value) {
|
|
256
|
+
if (this.zincRenderer)
|
|
257
|
+
return this.zincRenderer.getPlayRate();
|
|
258
|
+
else
|
|
259
|
+
return 0.0;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Initialise everything in the renderer, including the 3D renderer,
|
|
263
|
+
* and picker for the 3D renderer.
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
266
|
+
RendererModule.prototype.initialiseRenderer = function(displayAreaIn) {
|
|
267
|
+
if (this.zincRenderer === undefined || this.rendererContainer === undefined) {
|
|
268
|
+
let returnedValue = createRenderer();
|
|
269
|
+
this.Zinc = returnedValue["Zinc"];
|
|
270
|
+
this.zincRenderer = returnedValue["renderer"];
|
|
271
|
+
this.rendererContainer = returnedValue["container"];
|
|
272
|
+
}
|
|
273
|
+
if (displayAreaIn) {
|
|
274
|
+
this.displayArea = displayAreaIn;
|
|
275
|
+
this.displayArea.appendChild( this.rendererContainer );
|
|
276
|
+
if (this.zincRenderer)
|
|
277
|
+
this.zincRenderer.animate();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
RendererModule.prototype.destroy = function() {
|
|
282
|
+
if (this.zincRenderer) {
|
|
283
|
+
this.zincRenderer.dispose();
|
|
284
|
+
this.zincRenderer.getThreeJSRenderer().dispose();
|
|
285
|
+
this.zincRenderer = undefined;
|
|
286
|
+
}
|
|
287
|
+
(require('./BaseModule').BaseModule).prototype.destroy.call( this );
|
|
288
|
+
}
|
|
289
|
+
|
|
290
290
|
exports.RendererModule = RendererModule;
|