x3d-image 1.0.45 → 1.0.47
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/package.json +3 -3
- package/src/image.js +34 -31
- package/src/main.js +18 -18
- package/src/window.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x3d-image",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "Render image files from X3D",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"colors": "^1.4.0",
|
|
55
|
-
"electron": "^29.1.
|
|
56
|
-
"x_ite": "^9.
|
|
55
|
+
"electron": "^29.1.5",
|
|
56
|
+
"x_ite": "^9.4.0",
|
|
57
57
|
"yargs": "^17.7.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
package/src/image.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
const
|
|
4
4
|
X3D = require ("x_ite"),
|
|
@@ -7,29 +7,29 @@ const
|
|
|
7
7
|
yargs = require ("yargs"),
|
|
8
8
|
path = require ("path"),
|
|
9
9
|
fs = require ("fs"),
|
|
10
|
-
DEBUG = false
|
|
10
|
+
DEBUG = false;
|
|
11
11
|
|
|
12
12
|
// Redirect console messages.
|
|
13
13
|
|
|
14
|
-
process .exit = (code) => electron .ipcRenderer .send ("exit", code)
|
|
15
|
-
console .log = (... messages) => electron .ipcRenderer .send ("log", messages)
|
|
16
|
-
console .warn = (... messages) => electron .ipcRenderer .send ("warn", messages)
|
|
17
|
-
console .error = (... messages) => electron .ipcRenderer .send ("error", messages)
|
|
14
|
+
process .exit = (code) => electron .ipcRenderer .send ("exit", code);
|
|
15
|
+
console .log = (... messages) => electron .ipcRenderer .send ("log", messages);
|
|
16
|
+
console .warn = (... messages) => electron .ipcRenderer .send ("warn", messages);
|
|
17
|
+
console .error = (... messages) => electron .ipcRenderer .send ("error", messages);
|
|
18
18
|
|
|
19
|
-
electron .ipcRenderer .on ("main", async (event, argv) => main (argv))
|
|
19
|
+
electron .ipcRenderer .on ("main", async (event, argv) => main (argv));
|
|
20
20
|
|
|
21
21
|
async function main (argv)
|
|
22
22
|
{
|
|
23
23
|
try
|
|
24
24
|
{
|
|
25
|
-
await generate (argv)
|
|
25
|
+
await generate (argv);
|
|
26
26
|
|
|
27
|
-
process .exit ()
|
|
27
|
+
process .exit ();
|
|
28
28
|
}
|
|
29
29
|
catch (error)
|
|
30
30
|
{
|
|
31
|
-
console .error (error .message || error)
|
|
32
|
-
process .exit (1)
|
|
31
|
+
console .error (error .message || error);
|
|
32
|
+
process .exit (1);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -43,8 +43,8 @@ async function generate (argv)
|
|
|
43
43
|
.alias ("v", "version")
|
|
44
44
|
.fail ((msg, error, yargs) =>
|
|
45
45
|
{
|
|
46
|
-
console .error (msg)
|
|
47
|
-
process .exit (1)
|
|
46
|
+
console .error (msg);
|
|
47
|
+
process .exit (1);
|
|
48
48
|
})
|
|
49
49
|
.option ("cwd",
|
|
50
50
|
{
|
|
@@ -93,10 +93,13 @@ async function generate (argv)
|
|
|
93
93
|
description: "Modify the current view so that all objects fit in view volume.",
|
|
94
94
|
})
|
|
95
95
|
.help ()
|
|
96
|
-
.alias ("help", "h") .argv
|
|
96
|
+
.alias ("help", "h") .argv;
|
|
97
|
+
|
|
98
|
+
if (args .version)
|
|
99
|
+
return;
|
|
97
100
|
|
|
98
101
|
if (args .help)
|
|
99
|
-
return
|
|
102
|
+
return;
|
|
100
103
|
|
|
101
104
|
const
|
|
102
105
|
canvas = document .getElementById ("browser"),
|
|
@@ -106,35 +109,35 @@ async function generate (argv)
|
|
|
106
109
|
size = args .size .split ("x"),
|
|
107
110
|
width = parseInt (size [0]) || 1280,
|
|
108
111
|
height = parseInt (size [1]) || 720,
|
|
109
|
-
mimeType = mimeTypeFromPath (output)
|
|
112
|
+
mimeType = mimeTypeFromPath (output);
|
|
110
113
|
|
|
111
|
-
canvas .setAttribute ("style", `width: ${width}px; height: ${height}px;`)
|
|
114
|
+
canvas .setAttribute ("style", `width: ${width}px; height: ${height}px;`);
|
|
112
115
|
|
|
113
|
-
Browser .setBrowserOption ("PrimitiveQuality", "HIGH")
|
|
114
|
-
Browser .setBrowserOption ("TextureQuality", "HIGH")
|
|
116
|
+
Browser .setBrowserOption ("PrimitiveQuality", "HIGH");
|
|
117
|
+
Browser .setBrowserOption ("TextureQuality", "HIGH");
|
|
115
118
|
|
|
116
|
-
await Browser .loadURL (new X3D .MFString (input))
|
|
119
|
+
await Browser .loadURL (new X3D .MFString (input));
|
|
117
120
|
|
|
118
121
|
if (args ["view-all"])
|
|
119
122
|
{
|
|
120
|
-
Browser .viewAll (0)
|
|
121
|
-
await wait ()
|
|
123
|
+
Browser .viewAll (0);
|
|
124
|
+
await wait ();
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
if (args .delay)
|
|
125
|
-
await sleep (args .delay * 1000)
|
|
128
|
+
await sleep (args .delay * 1000);
|
|
126
129
|
|
|
127
|
-
const blob = await generateImage (canvas, mimeType, args .quality)
|
|
130
|
+
const blob = await generateImage (canvas, mimeType, args .quality);
|
|
128
131
|
|
|
129
|
-
fs .writeFileSync (output, new DataView (await blob .arrayBuffer ()))
|
|
132
|
+
fs .writeFileSync (output, new DataView (await blob .arrayBuffer ()));
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
async function generateImage (canvas, mimeType, quality)
|
|
133
136
|
{
|
|
134
137
|
return new Promise ((resolve, reject) =>
|
|
135
138
|
{
|
|
136
|
-
canvas .toBlob (blob => resolve (blob), mimeType, quality)
|
|
137
|
-
})
|
|
139
|
+
canvas .toBlob (blob => resolve (blob), mimeType, quality);
|
|
140
|
+
});
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
function mimeTypeFromPath (filename)
|
|
@@ -143,12 +146,12 @@ function mimeTypeFromPath (filename)
|
|
|
143
146
|
{
|
|
144
147
|
case ".jpg":
|
|
145
148
|
case ".jpeg":
|
|
146
|
-
return "image/jpeg"
|
|
149
|
+
return "image/jpeg";
|
|
147
150
|
default:
|
|
148
|
-
return "image/png"
|
|
151
|
+
return "image/png";
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
|
|
152
|
-
const wait = () => new Promise (resolve => requestAnimationFrame (resolve))
|
|
155
|
+
const wait = () => new Promise (resolve => requestAnimationFrame (resolve));
|
|
153
156
|
|
|
154
|
-
const sleep = delay => new Promise (resolve => setTimeout (resolve, delay))
|
|
157
|
+
const sleep = delay => new Promise (resolve => setTimeout (resolve, delay));
|
package/src/main.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
const
|
|
4
4
|
electron = require ("electron"),
|
|
5
5
|
path = require ("path"),
|
|
6
|
-
colors = require ("colors")
|
|
6
|
+
colors = require ("colors");
|
|
7
7
|
|
|
8
|
-
process .env .ELECTRON_DISABLE_SECURITY_WARNINGS = "true"
|
|
9
|
-
// process .env .ELECTRON_ENABLE_LOGGING = 1
|
|
8
|
+
process .env .ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
|
|
9
|
+
// process .env .ELECTRON_ENABLE_LOGGING = 1;
|
|
10
10
|
|
|
11
11
|
if (process .platform === "darwin")
|
|
12
12
|
{
|
|
13
|
-
electron .app .setActivationPolicy ("accessory")
|
|
14
|
-
electron .app .dock .hide ()
|
|
13
|
+
electron .app .setActivationPolicy ("accessory");
|
|
14
|
+
electron .app .dock .hide ();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
electron .app .whenReady () .then (async () =>
|
|
@@ -25,29 +25,29 @@ electron .app .whenReady () .then (async () =>
|
|
|
25
25
|
nodeIntegration: true,
|
|
26
26
|
contextIsolation: false,
|
|
27
27
|
},
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
electron .ipcMain .on ("log", (event, messages) =>
|
|
31
31
|
{
|
|
32
|
-
console .log (... messages)
|
|
33
|
-
})
|
|
32
|
+
console .log (... messages);
|
|
33
|
+
});
|
|
34
34
|
|
|
35
35
|
electron .ipcMain .on ("warn", (event, messages) =>
|
|
36
36
|
{
|
|
37
|
-
console .warn (... messages .map (string => colors .yellow (string)))
|
|
38
|
-
})
|
|
37
|
+
console .warn (... messages .map (string => colors .yellow (string)));
|
|
38
|
+
});
|
|
39
39
|
|
|
40
40
|
electron .ipcMain .on ("error", (event, messages) =>
|
|
41
41
|
{
|
|
42
|
-
console .error (... messages .map (string => colors .red (string)))
|
|
43
|
-
})
|
|
42
|
+
console .error (... messages .map (string => colors .red (string)));
|
|
43
|
+
});
|
|
44
44
|
|
|
45
45
|
electron .ipcMain .on ("exit", (event, code = 0) =>
|
|
46
46
|
{
|
|
47
|
-
electron .app .exit (code)
|
|
48
|
-
})
|
|
47
|
+
electron .app .exit (code);
|
|
48
|
+
});
|
|
49
49
|
|
|
50
|
-
await window .loadFile (path .join (__dirname, "window.html"))
|
|
50
|
+
await window .loadFile (path .join (__dirname, "window.html"));
|
|
51
51
|
|
|
52
|
-
window .webContents .send ("main", process .argv)
|
|
53
|
-
})
|
|
52
|
+
window .webContents .send ("main", process .argv);
|
|
53
|
+
});
|
package/src/window.js
CHANGED