Skip to content

Commit e152552

Browse files
committed
electron fixes
1 parent ea1b413 commit e152552

35 files changed

+13635
-10
lines changed

app/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ app.get('/cert', function (req, res) { //??
369369
app.get('/version', function (req, res) {
370370
res.set('Content-Type', 'image/svg+xml');
371371
var badge={
372-
text: { name:"marlin-conf", version:pjson.version },
372+
text: { name:pjson.name, version:pjson.version },
373373
width: { text:83, version:39, total:122 },
374374
position: { version:88 }
375375
};
@@ -384,7 +384,7 @@ app.get('/version/:screen', function (req, res) {
384384
res.set('Content-Type', 'text/plain');
385385
visitor.screenview({
386386
cd:req.params.screen,
387-
an:pjson.name,
387+
an:pjson.name+(isElectron&&"-electron"||''),
388388
av:pjson.version,
389389
ua:req.headers['user-agent'],
390390
ul:req.headers['accept-language'].split(',')[0],

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const {app, BrowserWindow, Menu, dialog} = require('electron');
3+
//require('electron-debug')({showDevTools: true, enabled: true}); //runtime debug
34
console.log('Node',process.version);
45
const notifier = require('node-notifier');
56

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "marlin-conf",
3-
"version": "2.7.7",
3+
"version": "2.7.8",
44
"description": "configuration tool for Marlin project",
55
"main": "./index.js",
66
"scripts": {
77
"start": "electron . -G ~/TEST",
88
"build": "build --dir",
9+
"build-dev": "build -l --x64",
910
"dist": "node builder.js",
1011
"test": "echo \"Error: no test specified\" && exit 1",
1112
"lint": "eslint .",
@@ -53,8 +54,8 @@
5354
"dependencies": {
5455
"body-parser": "^1.17.2",
5556
"bootstrap": "4.0.0-alpha.6",
56-
"bootstrap-treeview": "^1.2.0",
5757
"cropper": "^3.0.0-rc.2",
58+
"electron-debug": "^1.2.0",
5859
"express": "^4.15.2",
5960
"font-awesome": "^4.7.0",
6061
"formidable": "^1.1.1",
@@ -81,6 +82,7 @@
8182
"which": "^1.2.14"
8283
},
8384
"devDependencies": {
85+
"devtron": "^1.4.0",
8486
"electron": "^1.6.10",
8587
"electron-builder": "^18.1.0",
8688
"eslint": "^3.19.0",

static/consoles.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<script src="libs/bootstrap/dist/js/bootstrap.min.js"></script>
2020
<script src="libs/socket.io-client/dist/socket.io.js"></script>
2121
<script src="libs/three/build/three.js"></script>
22-
<script src="libs/three/examples/js/renderers/Projector.js"></script>
23-
<script src="libs/three/examples/js/renderers/CanvasRenderer.js"></script>
24-
<script src="libs/three/examples/js/controls/OrbitControls.js"></script>
25-
<script src="libs/three/examples/js/exporters/STLBinaryExporter.js"></script>
22+
<script src="git/three/examples/js/renderers/Projector.js"></script>
23+
<script src="git/three/examples/js/renderers/CanvasRenderer.js"></script>
24+
<script src="git/three/examples/js/controls/OrbitControls.js"></script>
25+
<script src="git/three/examples/js/exporters/STLBinaryExporter.js"></script>
2626
<script src="ui.js"></script>
2727

2828
<link href="css/toggle.css" rel="stylesheet">

static/git/bootstrap-treeview/bootstrap-treeview.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/git/bootstrap-treeview/bootstrap-treeview.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/git/three/examples/fonts/helvetiker_bold.typeface.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

static/git/three/examples/fonts/helvetiker_regular.typeface.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* @author richt / http://richt.me
3+
* @author WestLangley / http://github.com/WestLangley
4+
*
5+
* W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
6+
*/
7+
8+
THREE.DeviceOrientationControls = function( object ) {
9+
10+
var scope = this;
11+
12+
this.object = object;
13+
this.object.rotation.reorder( "YXZ" );
14+
15+
this.enabled = true;
16+
17+
this.deviceOrientation = {};
18+
this.screenOrientation = 0;
19+
20+
this.alpha = 0;
21+
this.alphaOffsetAngle = 0;
22+
23+
24+
var onDeviceOrientationChangeEvent = function( event ) {
25+
26+
scope.deviceOrientation = event;
27+
28+
};
29+
30+
var onScreenOrientationChangeEvent = function() {
31+
32+
scope.screenOrientation = window.orientation || 0;
33+
34+
};
35+
36+
// The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''
37+
38+
var setObjectQuaternion = function() {
39+
40+
var zee = new THREE.Vector3( 0, 0, 1 );
41+
42+
var euler = new THREE.Euler();
43+
44+
var q0 = new THREE.Quaternion();
45+
46+
var q1 = new THREE.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis
47+
48+
return function( quaternion, alpha, beta, gamma, orient ) {
49+
50+
euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us
51+
52+
quaternion.setFromEuler( euler ); // orient the device
53+
54+
quaternion.multiply( q1 ); // camera looks out the back of the device, not the top
55+
56+
quaternion.multiply( q0.setFromAxisAngle( zee, - orient ) ); // adjust for screen orientation
57+
58+
}
59+
60+
}();
61+
62+
this.connect = function() {
63+
64+
onScreenOrientationChangeEvent(); // run once on load
65+
66+
window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
67+
window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
68+
69+
scope.enabled = true;
70+
71+
};
72+
73+
this.disconnect = function() {
74+
75+
window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );
76+
window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );
77+
78+
scope.enabled = false;
79+
80+
};
81+
82+
this.update = function() {
83+
84+
if ( scope.enabled === false ) return;
85+
86+
var alpha = scope.deviceOrientation.alpha ? THREE.Math.degToRad( scope.deviceOrientation.alpha ) + this.alphaOffsetAngle : 0; // Z
87+
var beta = scope.deviceOrientation.beta ? THREE.Math.degToRad( scope.deviceOrientation.beta ) : 0; // X'
88+
var gamma = scope.deviceOrientation.gamma ? THREE.Math.degToRad( scope.deviceOrientation.gamma ) : 0; // Y''
89+
var orient = scope.screenOrientation ? THREE.Math.degToRad( scope.screenOrientation ) : 0; // O
90+
91+
setObjectQuaternion( scope.object.quaternion, alpha, beta, gamma, orient );
92+
this.alpha = alpha;
93+
94+
};
95+
96+
this.updateAlphaOffsetAngle = function( angle ) {
97+
98+
this.alphaOffsetAngle = angle;
99+
this.update();
100+
101+
};
102+
103+
this.dispose = function() {
104+
105+
this.disconnect();
106+
107+
};
108+
109+
this.connect();
110+
111+
};
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
/*
2+
* @author zz85 / https://github.com/zz85
3+
* @author mrdoob / http://mrdoob.com
4+
* Running this will allow you to drag three.js objects around the screen.
5+
*/
6+
7+
THREE.DragControls = function ( _objects, _camera, _domElement ) {
8+
9+
if ( _objects instanceof THREE.Camera ) {
10+
11+
console.warn( 'THREE.DragControls: Constructor now expects ( objects, camera, domElement )' );
12+
var temp = _objects; _objects = _camera; _camera = temp;
13+
14+
}
15+
16+
var _plane = new THREE.Plane();
17+
var _raycaster = new THREE.Raycaster();
18+
19+
var _mouse = new THREE.Vector2();
20+
var _offset = new THREE.Vector3();
21+
var _intersection = new THREE.Vector3();
22+
23+
var _selected = null, _hovered = null;
24+
25+
//
26+
27+
var scope = this;
28+
29+
function activate() {
30+
31+
_domElement.addEventListener( 'mousemove', onDocumentMouseMove, false );
32+
_domElement.addEventListener( 'mousedown', onDocumentMouseDown, false );
33+
_domElement.addEventListener( 'mouseup', onDocumentMouseUp, false );
34+
35+
}
36+
37+
function deactivate() {
38+
39+
_domElement.removeEventListener( 'mousemove', onDocumentMouseMove, false );
40+
_domElement.removeEventListener( 'mousedown', onDocumentMouseDown, false );
41+
_domElement.removeEventListener( 'mouseup', onDocumentMouseUp, false );
42+
43+
}
44+
45+
function dispose() {
46+
47+
deactivate();
48+
49+
}
50+
51+
function onDocumentMouseMove( event ) {
52+
53+
event.preventDefault();
54+
55+
var rect = _domElement.getBoundingClientRect();
56+
57+
_mouse.x = ( (event.clientX - rect.left) / rect.width ) * 2 - 1;
58+
_mouse.y = - ( (event.clientY - rect.top) / rect.height ) * 2 + 1;
59+
60+
_raycaster.setFromCamera( _mouse, _camera );
61+
62+
if ( _selected && scope.enabled ) {
63+
64+
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
65+
66+
_selected.position.copy( _intersection.sub( _offset ) );
67+
68+
}
69+
70+
scope.dispatchEvent( { type: 'drag', object: _selected } );
71+
72+
return;
73+
74+
}
75+
76+
_raycaster.setFromCamera( _mouse, _camera );
77+
78+
var intersects = _raycaster.intersectObjects( _objects );
79+
80+
if ( intersects.length > 0 ) {
81+
82+
var object = intersects[ 0 ].object;
83+
84+
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), object.position );
85+
86+
if ( _hovered !== object ) {
87+
88+
scope.dispatchEvent( { type: 'hoveron', object: object } );
89+
90+
_domElement.style.cursor = 'pointer';
91+
_hovered = object;
92+
93+
}
94+
95+
} else {
96+
97+
if ( _hovered !== null ) {
98+
99+
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
100+
101+
_domElement.style.cursor = 'auto';
102+
_hovered = null;
103+
104+
}
105+
106+
}
107+
108+
}
109+
110+
function onDocumentMouseDown( event ) {
111+
112+
event.preventDefault();
113+
114+
_raycaster.setFromCamera( _mouse, _camera );
115+
116+
var intersects = _raycaster.intersectObjects( _objects );
117+
118+
if ( intersects.length > 0 ) {
119+
120+
_selected = intersects[ 0 ].object;
121+
122+
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
123+
124+
_offset.copy( _intersection ).sub( _selected.position );
125+
126+
}
127+
128+
_domElement.style.cursor = 'move';
129+
130+
scope.dispatchEvent( { type: 'dragstart', object: _selected } );
131+
132+
}
133+
134+
135+
}
136+
137+
function onDocumentMouseUp( event ) {
138+
139+
event.preventDefault();
140+
141+
if ( _selected ) {
142+
143+
scope.dispatchEvent( { type: 'dragend', object: _selected } );
144+
145+
_selected = null;
146+
147+
}
148+
149+
_domElement.style.cursor = 'auto';
150+
151+
}
152+
153+
activate();
154+
155+
// API
156+
157+
this.enabled = true;
158+
159+
this.activate = activate;
160+
this.deactivate = deactivate;
161+
this.dispose = dispose;
162+
163+
// Backward compatibility
164+
165+
this.setObjects = function () {
166+
167+
console.error( 'THREE.DragControls: setObjects() has been removed.' );
168+
169+
};
170+
171+
this.on = function ( type, listener ) {
172+
173+
console.warn( 'THREE.DragControls: on() has been deprecated. Use addEventListener() instead.' );
174+
scope.addEventListener( type, listener );
175+
176+
};
177+
178+
this.off = function ( type, listener ) {
179+
180+
console.warn( 'THREE.DragControls: off() has been deprecated. Use removeEventListener() instead.' );
181+
scope.removeEventListener( type, listener );
182+
183+
};
184+
185+
this.notify = function ( type ) {
186+
187+
console.error( 'THREE.DragControls: notify() has been deprecated. Use dispatchEvent() instead.' );
188+
scope.dispatchEvent( { type: type } );
189+
190+
};
191+
192+
};
193+
194+
THREE.DragControls.prototype = Object.create( THREE.EventDispatcher.prototype );
195+
THREE.DragControls.prototype.constructor = THREE.DragControls;

0 commit comments

Comments
 (0)