Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8e1565e

Browse filesBrowse files
author
Alexei_D
committed
Major improvements.
Major improvements. Shader upgrade. Common infrastructure addition. Surface module functionality fixed after refactoring.
1 parent 17df181 commit 8e1565e
Copy full SHA for 8e1565e
Expand file treeCollapse file tree

27 files changed

+281
-270
lines changed
Open diff view settings
Collapse file

‎js/common/interactivitySystem/CameraHelper.js‎

Copy file name to clipboardExpand all lines: js/common/interactivitySystem/CameraHelper.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ define([
239239
const depth = size.getComponent(depthIndex);
240240

241241
const maxDimension = Math.max(horizontal, vertical) * multiplier;
242-
const maxDimensionWithDeps = Math.max(Math.abs(depth), Math.max(Math.abs(horizontal), Math.abs(vertical)));
242+
const maxDimensionWithDepth = Math.max(Math.abs(depth), Math.max(Math.abs(horizontal), Math.abs(vertical)));
243243

244244
const right = maxDimension / 2 * cameraAspect;
245245
const left = -right;
@@ -251,7 +251,7 @@ define([
251251
camera.top = top;
252252
camera.bottom = bottom;
253253
camera.near = 0.1;
254-
camera.far = maxDimensionWithDeps * 4;
254+
camera.far = maxDimensionWithDepth * 4;
255255
}
256256
camera.updateProjectionMatrix();
257257
}
Collapse file

‎js/common/orientationWidget/orientationWidget.css‎

Copy file name to clipboardExpand all lines: js/common/orientationWidget/orientationWidget.css
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.scene {
2+
user-select: none;
23
perspective: 400px;
34
background: rgba(0,0,0,0.29);
45
}
Collapse file

‎js/common/transferFunctionControl/TransferFunctionControl.js‎

Copy file name to clipboardExpand all lines: js/common/transferFunctionControl/TransferFunctionControl.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ define([
6767
}
6868

6969
_onPointerDown(event) {
70-
this._container.setPointerCapture(event.pointerId)
70+
this._container.setPointerCapture(event.pointerId)
7171
}
7272
_onPointerUp(event) {
7373
this._container.releasePointerCapture(event.pointerId)
Collapse file

‎js/common/ui/MapSelectorBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/MapSelectorBase.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ function(Utils, SpotsControllerBase, WorkspaceBase, SettingsControllerBase) {
2828
this._selectedIndex = -1;
2929
this._div.style.opacity = 0;
3030
this._active = false;
31-
this._spotsController.addEventListener(SpotsControllerBase.Events.INTENSITIES_LOADED, this._onIntencitiesLoaded.bind(this));
31+
this._spotsController.addEventListener(SpotsControllerBase.Events.MEASURES_LOADED, this._onMeasuresLoaded.bind(this));
3232
this._workspace.addEventListener(WorkspaceBase.Events.SETTINGS_CHANGE, this._onWorkspaceSettingsChange.bind(this));
3333
this._input.addEventListener('input', this._onInput.bind(this));
3434
this._input.addEventListener('blur', this._onBlur.bind(this));
3535

3636
this._input.addEventListener(Utils.keyPressEvent(), this._onKeyPress.bind(this), false);
3737
this._itemsContainer.addEventListener('mousedown', this._onItemMouseDown.bind(this), false);
3838
this._itemsContainer.addEventListener('click', this._onItemClick.bind(this), false);
39-
this._onIntencitiesLoaded();
39+
this._onMeasuresLoaded();
4040
}
4141

4242
MapSelectorBase.prototype = Object.create(null, {
43-
_onIntencitiesLoaded: {
43+
_onMeasuresLoaded: {
4444
value: function() {
4545
if (!this._spotsController.measures) {
4646
this._measures = [];
Collapse file

‎js/common/ui/Scene3DBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/Scene3DBase.js
+5-28Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,27 @@ function(EventSource, SpotsController, THREE, CameraHelper) {
2020
Scene3DBase.Events = {
2121
CHANGE: 'change',
2222
};
23-
24-
Scene3DBase.RecoloringMode = {
25-
USE_COLORMAP: 'colormap',
26-
NO_COLORMAP: 'no-colormap'
27-
};
28-
23+
2924
Scene3DBase.prototype = Object.create(EventSource.prototype, {
3025
backgroundColor: {
31-
get: function() {
32-
return '#' + this._backgroundColor.getHexString();
33-
},
34-
3526
set: function(value) {
36-
var color = new THREE.Color(value);
37-
if (!color.equals(this._backgroundColor)) {
38-
this._backgroundColor.set(color);
39-
this._notify(Scene3DBase.Events.CHANGE);
40-
}
41-
}
42-
},
43-
44-
backgroundColorValue: {
27+
this._backgroundColor = value;
28+
this._notify(Scene3DBase.Events.CHANGE);
29+
},
4530
get: function() {
4631
return this._backgroundColor;
4732
}
4833
},
4934

50-
refreshSpots: {
51-
value: function () {
52-
this._recolor(Scene3DBase.RecoloringMode.NO_COLORMAP);
53-
this._notify(Scene3DBase.Events.CHANGE);
54-
}
55-
},
56-
5735
position: {
5836
get: function() {
5937
return this._scene.position.clone();
6038
}
6139
},
6240

6341
render: {
64-
value: function(renderer, camera, orientationWidget) {
42+
value: function(renderer, camera) {
6543
renderer.render(this._scene, camera);
66-
orientationWidget.transform = `translateZ(-300px) ${CameraHelper.getCameraCSSMatrix(camera.matrixWorldInverse)}`;
6744
}
6845
},
6946

Collapse file

‎js/common/ui/SpotsControllerBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/SpotsControllerBase.js
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function (THREE, ColorMap, EventSource, Utils) {
3434
ATTR_CHANGE: 'attr-change',
3535
MAPPING_CHANGE: 'mapping-change',
3636
AUTO_MAPPING_CHANGE: 'auto-mapping-change',
37-
INTENSITIES_LOADED: 'intensities-loaded',
37+
MEASURES_LOADED: 'measures-loaded',
38+
ACTIVE_MEASURES_CHANGED: 'active-measures-loaded',
3839
INTENSITIES_CHANGE: 'intensities-change',
3940
BORDER_CHANGE: 'border-change'
4041
};
@@ -147,7 +148,7 @@ function (THREE, ColorMap, EventSource, Utils) {
147148
set: function (value) {
148149
this._measures = Array.isArray(value) && value ? value : [];
149150
this._activeMeasure = null;
150-
this._notify(SpotsControllerBase.Events.INTENSITIES_LOADED);
151+
this._notify(SpotsControllerBase.Events.MEASURES_LOADED);
151152
}
152153
},
153154

@@ -168,8 +169,9 @@ function (THREE, ColorMap, EventSource, Utils) {
168169
}
169170
this._hotspotQuantile = Utils.boundNumber(0.0, value, 1.0);
170171
if (this._autoMinMax) {
171-
this._updateMinMaxValues();
172-
this._updateIntensities();
172+
if (this._updateMinMaxValues()) {
173+
this._updateIntensities();
174+
}
173175
} else {
174176
console.log('Potential programming error: attempt to change "hotspot quantile" parameter with "auto min/max" disabled.');
175177
}
@@ -245,6 +247,7 @@ function (THREE, ColorMap, EventSource, Utils) {
245247
this._updateMinMaxValues();
246248
}
247249
this._updateIntensities();
250+
this._notify(SpotsControllerBase.Events.ACTIVE_MEASURES_CHANGED);
248251
}
249252
},
250253

@@ -291,8 +294,9 @@ function (THREE, ColorMap, EventSource, Utils) {
291294
set: function(value) {
292295
this._autoMinMax = !!value;
293296
if (this._autoMinMax) {
294-
this._updateMinMaxValues();
295-
this._updateIntensities();
297+
if (this._updateMinMaxValues()) {
298+
this._updateIntensities();
299+
}
296300
}
297301
this._notify(SpotsControllerBase.Events.AUTO_MAPPING_CHANGE);
298302
}
Collapse file

‎js/common/ui/TabControllerBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/TabControllerBase.js
+28-2Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
define([
44
'abcviewcontroller',
55
'controlsgrid',
6-
'utils'
6+
'utils',
7+
'three'
78
],
8-
function (EmperorViewControllerABC, ControlGrid, Utils) {
9+
function (EmperorViewControllerABC, ControlGrid, Utils, THREE) {
910
function TabControllerBase(container, title, description, workspace) {
1011
EmperorViewControllerABC['EmperorViewControllerABC'].call(this, container, title, description);
1112

@@ -93,6 +94,31 @@ function (EmperorViewControllerABC, ControlGrid, Utils) {
9394
}
9495
},
9596

97+
_makeProxyColorProperty: {
98+
value: function(owner, key) {
99+
const result = {};
100+
const proxyKey = `proxy_${key}_hex`;
101+
const proxyKeyColor = `proxy_${key}_color`;
102+
Object.defineProperty(result, key, {
103+
get: () => {
104+
return result[proxyKey];
105+
},
106+
set: (value) => {
107+
value = new THREE.Color(value);
108+
const current = owner[proxyKeyColor];
109+
if (current && current.equals(value)) {
110+
return;
111+
}
112+
owner[key] = value;
113+
result[proxyKeyColor] = value;
114+
result[proxyKey] = '#' + value.getHexString();
115+
}
116+
});
117+
result[key] = owner[key];
118+
return result;
119+
}
120+
},
121+
96122
_makeProxyProperty: {
97123
value: function(owner, key, converter) {
98124
const proxyResult = {};
Collapse file

‎js/common/ui/View3DBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/View3DBase.js
+14-5Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ function(THREE, EventSource, ActionController, CameraHelper, WorkspaceBase) {
8080
}
8181
},
8282

83+
render: {
84+
value: function(renderer, scene, parentHeight) {
85+
const v = this;
86+
if (!v.width || !v.height) return;
87+
const viewportBottom = parentHeight - v.top - v.height;
88+
renderer.setViewport(v.left, viewportBottom, v.width, v.height);
89+
renderer.setScissor(v.left, viewportBottom, v.width, v.height);
90+
renderer.setScissorTest(true);
91+
this._orientationWidget.transform = `translateZ(-300px) ${CameraHelper.getCameraCSSMatrix(v._camera.matrixWorldInverse)}`;
92+
scene.render(renderer, v.camera, v._orientationWidget);
93+
}
94+
},
95+
8396
prepareUpdateLayout: {
8497
value: function() {
8598
this._controls.stopAnimation();
@@ -164,11 +177,7 @@ function(THREE, EventSource, ActionController, CameraHelper, WorkspaceBase) {
164177

165178
onAnimationFrame: {
166179
value: function(now) {
167-
if (!this._controls.autoRotate) {
168-
return;
169-
} else {
170-
this._group.requestAnimationFrame();
171-
}
180+
this._group.requestAnimationFrame();
172181
}
173182
},
174183

Collapse file

‎js/common/ui/ViewContainerBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/ViewContainerBase.js
+27-3Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
define([],
4-
function() {
3+
define(['workspacebase'],
4+
function(WorkspaceBase) {
55
function ViewContainerBase(workspace, div) {
66
this._workspace = workspace;
77
this._div = div;
@@ -10,6 +10,9 @@ function() {
1010
this._widgetLayout = 'Top-left';
1111
this._defaultMargin = 20;
1212
this._extraMargin = 100;
13+
14+
this._workspace.addEventListener(WorkspaceBase.Events.MODE_CHANGE, this._onWorkspaceModeChange.bind(this));
15+
this._onWorkspaceModeChange();
1316
return this;
1417
}
1518

@@ -30,7 +33,7 @@ function() {
3033
}
3134
},
3235

33-
_createView: {
36+
createView: {
3437
value: function(constructor, selector) {
3538
var view = new constructor(this._workspace, this._div.querySelector(selector));
3639
this.all.push(view);
@@ -120,6 +123,27 @@ function() {
120123
}
121124
},
122125

126+
exportInner: {
127+
value: function(renderAction) {
128+
return new Promise(function(accept, reject) {
129+
var pixelRatio = window.devicePixelRatio * this._exportPixelRatio3d;
130+
var width = this._div.clientWidth * pixelRatio;
131+
var height = this._div.clientHeight * pixelRatio;
132+
133+
var canvas = document.createElement('canvas');
134+
var ctx = canvas.getContext('2d');
135+
var imageData = ctx.createImageData(width, height);
136+
137+
renderAction(imageData, pixelRatio);
138+
139+
canvas.width = width;
140+
canvas.height = height;
141+
ctx.putImageData(imageData, 0, 0);
142+
this.legend.export(canvas, pixelRatio).then(this.makeCanvasBlob.bind(this, canvas, accept)).catch(reject);
143+
}.bind(this));
144+
}
145+
},
146+
123147
fromJSON: {
124148
value: function (json) {
125149
for (var i = 0; i < json.length; i++) {
Collapse file

‎js/common/ui/ViewGroup3DBase.js‎

Copy file name to clipboardExpand all lines: js/common/ui/ViewGroup3DBase.js
+10-17Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function(THREE, Scene3DBase, SpotsControllerBase, CameraHelper, AnimationLoopMan
1717
this._canvas = div.querySelector('canvas');
1818
this._renderer = new THREE.WebGLRenderer({
1919
antialias: true,
20-
canvas: this._canvas,
20+
canvas: this._canvas
2121
});
2222
this._width = 0;
2323
this._height = 0;
@@ -27,12 +27,16 @@ function(THREE, Scene3DBase, SpotsControllerBase, CameraHelper, AnimationLoopMan
2727
this._animationFrameRequested = false;
2828

2929
// create animation controller responsible for abstract animation callbacks.
30+
this._animationLoopManager = new AnimationLoopManager({
31+
requestRedraw: () => this.requestAnimationFrame(),
32+
setAnimationLoop: (action) => this._renderer.setAnimationLoop(action),
33+
redraw: () => this._redraw()
34+
});
3035
this._animationController = {
31-
requestRedraw: () => this._redraw(),
36+
requestRedraw: () => this._animationLoopManager.requestRedraw(),
3237
setState: (state) => null,
33-
setAnimationLoop: (action) => this.setAnimationLoop(action)
38+
setAnimationLoop: (action) => this._animationLoopManager.setAnimationLoop(action)
3439
};
35-
this._animationLoopManager = new AnimationLoopManager(this._renderer);
3640

3741
this._scene = workspace.scene3d;
3842
this._scene.addEventListener(Scene3DBase.Events.CHANGE, this.requestAnimationFrame.bind(this));
@@ -54,12 +58,6 @@ function(THREE, Scene3DBase, SpotsControllerBase, CameraHelper, AnimationLoopMan
5458

5559
ViewGroup3DBase.prototype = Object.create(null, {
5660

57-
setAnimationLoop: {
58-
value: function(action) {
59-
return this._animationLoopManager.setAnimationLoop(action);
60-
}
61-
},
62-
6361
requestAnimationFrame: {
6462
value: function() {
6563
if (this._animationFrameRequested) {
@@ -72,15 +70,10 @@ function(THREE, Scene3DBase, SpotsControllerBase, CameraHelper, AnimationLoopMan
7270

7371
_renderTo: {
7472
value: function(renderer, scene) {
75-
renderer.setClearColor(scene.backgroundColorValue);
73+
renderer.setClearColor(scene.backgroundColor);
7674
for (var i = 0; i < this._views.length; i++) {
7775
var v = this._views[i];
78-
if (!v.width || !v.height) continue;
79-
var viewportBottom = this._height - v.top - v.height;
80-
renderer.setViewport(v.left, viewportBottom, v.width, v.height);
81-
renderer.setScissor(v.left, viewportBottom, v.width, v.height);
82-
renderer.setScissorTest(true);
83-
scene.render(renderer, v.camera, v._orientationWidget);
76+
v.render(renderer, scene, this._height);
8477
}
8578
}
8679
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.