x3d-image 2.0.32 → 2.1.0
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/README.md +36 -28
- package/package.json +2 -2
- package/src/image.js +80 -56
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ You can run *x3d-image* without installing it using **npx**:
|
|
|
14
14
|
|
|
15
15
|
## Overview
|
|
16
16
|
|
|
17
|
-
*x3d-image* is a command-line tool based on [X_ITE](https://create3000.github.io/x_ite/) that renders image files from X3D (Extensible 3D) and other 3D file formats. It allows users to convert 3D scenes into 2D images, supporting various input formats such as X3D (XML, JSON, Classic VRML), VRML, glTF, OBJ, STL, PLY, and SVG. Output can be in PNG or JPEG formats.
|
|
17
|
+
*x3d-image* is a command-line tool, based on [X_ITE](https://create3000.github.io/x_ite/), that renders image files from X3D (Extensible 3D) and other 3D file formats. It allows users to convert 3D scenes into 2D images, supporting various input formats such as X3D (XML, JSON, Classic VRML), VRML, glTF, OBJ, STL, PLY, and SVG. Output can be in PNG or JPEG formats.
|
|
18
18
|
|
|
19
19
|
Key Features:
|
|
20
20
|
|
|
@@ -30,54 +30,62 @@ Key Features:
|
|
|
30
30
|
|
|
31
31
|
**x3d-image** interprets the following options when it is invoked:
|
|
32
32
|
|
|
33
|
-
### -
|
|
34
|
-
|
|
35
|
-
Set input file(s). This can be either a local file path or a URL. If there are less input files than output files, the last input file is used for the remaining output files.
|
|
36
|
-
|
|
37
|
-
### -o *file(s)* ...
|
|
33
|
+
### -a
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
Modify the current view so that all objects fit in view volume.
|
|
40
36
|
|
|
41
|
-
### -
|
|
37
|
+
### -b *color*
|
|
42
38
|
|
|
43
|
-
Set
|
|
39
|
+
Set background to specified color. Color can be any X3D RGBA color or any CSS color. Use PNG as output image format for transparent backgrounds.
|
|
44
40
|
|
|
45
|
-
### -
|
|
41
|
+
### -c *[SRGB, **LINEAR_WHEN_PHYSICAL_MATERIAL**, LINEAR]*
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
The color space in which color calculations take place.
|
|
48
44
|
|
|
49
45
|
### -d *delay*
|
|
50
46
|
|
|
51
47
|
Wait the specified number of seconds before generating the image.
|
|
52
48
|
|
|
53
|
-
### -a
|
|
54
|
-
|
|
55
|
-
Modify the current view so that all objects fit in view volume.
|
|
56
|
-
|
|
57
|
-
### -b *color*
|
|
58
|
-
|
|
59
|
-
Set background to specified color. Color can be any X3D RGBA color or any CSS color. Use PNG as output image format for transparent backgrounds.
|
|
60
|
-
|
|
61
49
|
### -e *[**CANNON**, HELIPAD, FOOTPRINT]*
|
|
62
50
|
|
|
63
51
|
Add an EnvironmentLight node to scene. Useful when rendering glTF files with PhysicalMaterial nodes.
|
|
64
52
|
|
|
65
|
-
### -
|
|
53
|
+
### -h
|
|
66
54
|
|
|
67
|
-
|
|
55
|
+
Show help.
|
|
68
56
|
|
|
69
|
-
### -
|
|
57
|
+
### -i *file(s)* ...
|
|
70
58
|
|
|
71
|
-
|
|
59
|
+
Set input file(s). This can be either a local file path or a URL. If there are less input files than output files, the last input file is used for the remaining output files.
|
|
72
60
|
|
|
73
|
-
### -
|
|
61
|
+
### -l
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
Whether to use a logarithmic depth buffer. It may be necessary to use this if dealing with huge differences in scale in a single scene. It is automatically enabled if a GeoViewpoint is bound.
|
|
76
64
|
|
|
77
65
|
### -m *[**NONE**, ACES_NARKOWICZ, ACES_HILL, ACES_HILL_EXPOSURE_BOOST, KHR_PBR_NEUTRAL]*
|
|
78
66
|
|
|
79
67
|
Whether tone mapping should be applied.
|
|
80
68
|
|
|
69
|
+
### -n
|
|
70
|
+
|
|
71
|
+
Whether to use order independent transparency rendering technique.
|
|
72
|
+
|
|
73
|
+
### -o *file(s)* ...
|
|
74
|
+
|
|
75
|
+
Set output file(s). This can be either a PNG or JPEG file.
|
|
76
|
+
|
|
77
|
+
### -q *quality*
|
|
78
|
+
|
|
79
|
+
A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as JPEG).
|
|
80
|
+
|
|
81
|
+
### -r rotation
|
|
82
|
+
|
|
83
|
+
Creates a parent group with the model as children and sets the specified X3D rotation value.
|
|
84
|
+
|
|
85
|
+
### -s WIDTHxHEIGHT
|
|
86
|
+
|
|
87
|
+
Set image size in pixels, default is '1280x720'.
|
|
88
|
+
|
|
81
89
|
### -t *[**CHAR_SPACING**, SCALING]*
|
|
82
90
|
|
|
83
91
|
Controls how Text.length and Text.maxExtent are handled. Either by adjusting char spacing or by scaling text letters.
|
|
@@ -86,9 +94,9 @@ Controls how Text.length and Text.maxExtent are handled. Either by adjusting cha
|
|
|
86
94
|
|
|
87
95
|
Show version.
|
|
88
96
|
|
|
89
|
-
### -
|
|
97
|
+
### -x *exposure*
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
The exposure of an image describes the amount of light that is captured.
|
|
92
100
|
|
|
93
101
|
## Supported Input File Types
|
|
94
102
|
|
|
@@ -125,7 +133,7 @@ Render two PNG images from two X3D files.
|
|
|
125
133
|
$ npx x3d-image -s 1600x900 -i file1.x3d -o file1.png -i file2.x3d -o file2.png
|
|
126
134
|
```
|
|
127
135
|
|
|
128
|
-
Render image of glTF file with view-all
|
|
136
|
+
Render image of glTF file with view-all and environment light.
|
|
129
137
|
|
|
130
138
|
```sh
|
|
131
139
|
$ npx x3d-image -a -e CANNON -i file.gltf -o file.png
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x3d-image",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Render image files from X3D",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"colors": "^1.4.0",
|
|
55
55
|
"electron": "^35.2.1",
|
|
56
|
-
"x_ite": "^11.5.
|
|
56
|
+
"x_ite": "^11.5.5",
|
|
57
57
|
"yargs": "^17.7.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
package/src/image.js
CHANGED
|
@@ -48,39 +48,30 @@ async function generate (argv)
|
|
|
48
48
|
console .error (msg);
|
|
49
49
|
process .exit (1);
|
|
50
50
|
})
|
|
51
|
-
.option ("
|
|
51
|
+
.option ("view-all",
|
|
52
52
|
{
|
|
53
|
-
type: "
|
|
54
|
-
alias: "
|
|
55
|
-
description: "
|
|
53
|
+
type: "boolean",
|
|
54
|
+
alias: "a",
|
|
55
|
+
description: "Modify the current view so that all objects fit in view volume.",
|
|
56
56
|
array: true,
|
|
57
|
-
default: [
|
|
58
|
-
implies: "output",
|
|
57
|
+
default: [false],
|
|
59
58
|
})
|
|
60
|
-
.option ("
|
|
59
|
+
.option ("background",
|
|
61
60
|
{
|
|
62
61
|
type: "string",
|
|
63
|
-
alias: "
|
|
64
|
-
description:
|
|
62
|
+
alias: "b",
|
|
63
|
+
description: `Set background to specified color. Color can be any X3D RGBA color or any CSS color. Use PNG as output image format for transparent backgrounds.`,
|
|
65
64
|
array: true,
|
|
66
65
|
default: [ ],
|
|
67
|
-
implies: "input",
|
|
68
66
|
})
|
|
69
|
-
.option ("
|
|
67
|
+
.option ("colorSpace",
|
|
70
68
|
{
|
|
71
69
|
type: "string",
|
|
72
|
-
alias: "
|
|
73
|
-
description:
|
|
74
|
-
|
|
75
|
-
default: ["1280x720"],
|
|
76
|
-
})
|
|
77
|
-
.option ("quality",
|
|
78
|
-
{
|
|
79
|
-
type: "number",
|
|
80
|
-
alias: "q",
|
|
81
|
-
description: "A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as JPEG).",
|
|
70
|
+
alias: "c",
|
|
71
|
+
description: `The color space in which color calculations take place.`,
|
|
72
|
+
choices: ["SRGB", "LINEAR_WHEN_PHYSICAL_MATERIAL", "LINEAR"],
|
|
82
73
|
array: true,
|
|
83
|
-
default: [
|
|
74
|
+
default: ["LINEAR_WHEN_PHYSICAL_MATERIAL"],
|
|
84
75
|
})
|
|
85
76
|
.option ("delay",
|
|
86
77
|
{
|
|
@@ -90,64 +81,81 @@ async function generate (argv)
|
|
|
90
81
|
array: true,
|
|
91
82
|
default: [0],
|
|
92
83
|
})
|
|
93
|
-
.option ("
|
|
84
|
+
.option ("environment-light",
|
|
94
85
|
{
|
|
95
|
-
type: "
|
|
96
|
-
alias: "
|
|
97
|
-
description:
|
|
86
|
+
type: "string",
|
|
87
|
+
alias: "e",
|
|
88
|
+
description: `Add an EnvironmentLight node to scene. Useful when rendering glTF files with PhysicalMaterial nodes.`,
|
|
89
|
+
choices: ["CANNON", "HELIPAD", "FOOTPRINT"],
|
|
98
90
|
array: true,
|
|
99
|
-
default: [
|
|
91
|
+
default: [ ],
|
|
100
92
|
})
|
|
101
|
-
.option ("
|
|
93
|
+
.option ("input",
|
|
102
94
|
{
|
|
103
95
|
type: "string",
|
|
104
|
-
alias: "
|
|
105
|
-
description:
|
|
96
|
+
alias: "i",
|
|
97
|
+
description: "Set input file(s). If there are less input files than output files, the last input file is used for the remaining output files.",
|
|
106
98
|
array: true,
|
|
107
99
|
default: [ ],
|
|
100
|
+
implies: "output",
|
|
108
101
|
})
|
|
109
|
-
.option ("
|
|
102
|
+
.option ("logarithmic-depth-buffer",
|
|
110
103
|
{
|
|
111
|
-
type: "
|
|
112
|
-
alias: "
|
|
113
|
-
description: `
|
|
114
|
-
choices: ["CANNON", "HELIPAD", "FOOTPRINT"],
|
|
104
|
+
type: "boolean",
|
|
105
|
+
alias: "l",
|
|
106
|
+
description: `Whether to use a logarithmic depth buffer. It may be necessary to use this if dealing with huge differences in scale in a single scene. It is automatically enabled if a GeoViewpoint is bound.`,
|
|
115
107
|
array: true,
|
|
116
|
-
default: [
|
|
108
|
+
default: [false],
|
|
117
109
|
})
|
|
118
|
-
.option ("
|
|
110
|
+
.option ("tone-mapping",
|
|
119
111
|
{
|
|
120
112
|
type: "string",
|
|
121
|
-
alias: "
|
|
122
|
-
description: `
|
|
113
|
+
alias: "m",
|
|
114
|
+
description: `Whether tone mapping should be applied.`,
|
|
115
|
+
choices: ["NONE", "ACES_NARKOWICZ", "ACES_HILL", "ACES_HILL_EXPOSURE_BOOST", "KHR_PBR_NEUTRAL"],
|
|
123
116
|
array: true,
|
|
124
|
-
default: [
|
|
117
|
+
default: ["NONE"],
|
|
125
118
|
})
|
|
126
|
-
.option ("
|
|
119
|
+
.option ("order-independent-transparency",
|
|
120
|
+
{
|
|
121
|
+
type: "boolean",
|
|
122
|
+
alias: "n",
|
|
123
|
+
description: `Whether to use order independent transparency rendering technique.`,
|
|
124
|
+
array: true,
|
|
125
|
+
default: [false],
|
|
126
|
+
})
|
|
127
|
+
.option ("output",
|
|
127
128
|
{
|
|
128
129
|
type: "string",
|
|
129
|
-
alias: "
|
|
130
|
-
description:
|
|
131
|
-
choices: ["SRGB", "LINEAR_WHEN_PHYSICAL_MATERIAL", "LINEAR"],
|
|
130
|
+
alias: "o",
|
|
131
|
+
description: "Set output file(s). This can be either a *.png or *.jpg file.",
|
|
132
132
|
array: true,
|
|
133
|
-
default: [
|
|
133
|
+
default: [ ],
|
|
134
|
+
implies: "input",
|
|
134
135
|
})
|
|
135
|
-
.option ("
|
|
136
|
+
.option ("quality",
|
|
136
137
|
{
|
|
137
138
|
type: "number",
|
|
138
|
-
alias: "
|
|
139
|
-
description:
|
|
139
|
+
alias: "q",
|
|
140
|
+
description: "A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as JPEG).",
|
|
140
141
|
array: true,
|
|
141
142
|
default: [1],
|
|
142
143
|
})
|
|
143
|
-
.option ("
|
|
144
|
+
.option ("rotation",
|
|
144
145
|
{
|
|
145
146
|
type: "string",
|
|
146
|
-
alias: "
|
|
147
|
-
description: `
|
|
148
|
-
choices: ["NONE", "ACES_NARKOWICZ", "ACES_HILL", "ACES_HILL_EXPOSURE_BOOST", "KHR_PBR_NEUTRAL"],
|
|
147
|
+
alias: "r",
|
|
148
|
+
description: `Creates a parent group with the model as children and sets the specified X3D rotation value.`,
|
|
149
149
|
array: true,
|
|
150
|
-
default: [
|
|
150
|
+
default: [ ],
|
|
151
|
+
})
|
|
152
|
+
.option ("size",
|
|
153
|
+
{
|
|
154
|
+
type: "string",
|
|
155
|
+
alias: "s",
|
|
156
|
+
description: "Set image size in pixels.",
|
|
157
|
+
array: true,
|
|
158
|
+
default: ["1280x720"],
|
|
151
159
|
})
|
|
152
160
|
.option ("text-compression",
|
|
153
161
|
{
|
|
@@ -157,6 +165,14 @@ async function generate (argv)
|
|
|
157
165
|
array: true,
|
|
158
166
|
default: ["CHAR_SPACING"],
|
|
159
167
|
})
|
|
168
|
+
.option ("exposure",
|
|
169
|
+
{
|
|
170
|
+
type: "number",
|
|
171
|
+
alias: "x",
|
|
172
|
+
description: `The exposure of an image describes the amount of light that is captured.`,
|
|
173
|
+
array: true,
|
|
174
|
+
default: [1],
|
|
175
|
+
})
|
|
160
176
|
.example ([
|
|
161
177
|
[
|
|
162
178
|
"npx x3d-image -s 1600x900 -i file.x3d -o file.jpg",
|
|
@@ -168,7 +184,7 @@ async function generate (argv)
|
|
|
168
184
|
],
|
|
169
185
|
[
|
|
170
186
|
"npx x3d-image -a -e CANNON -i file.gltf -o file.png",
|
|
171
|
-
"Render image of glTF file with view-all
|
|
187
|
+
"Render image of glTF file with view-all and environment light."
|
|
172
188
|
],
|
|
173
189
|
])
|
|
174
190
|
.help ()
|
|
@@ -221,12 +237,18 @@ async function generate (argv)
|
|
|
221
237
|
if (arg (args .exposure, i))
|
|
222
238
|
browser .setBrowserOption ("Exposure", arg (args .exposure, i));
|
|
223
239
|
|
|
224
|
-
if (arg (args ["
|
|
225
|
-
browser .setBrowserOption ("
|
|
240
|
+
if (arg (args ["logarithmic-depth-buffer"], i))
|
|
241
|
+
browser .setBrowserOption ("LogarithmicDepthBuffer", arg (args ["logarithmic-depth-buffer"], i));
|
|
242
|
+
|
|
243
|
+
if (arg (args ["order-independent-transparency"], i))
|
|
244
|
+
browser .setBrowserOption ("OrderIndependentTransparency", arg (args ["order-independent-transparency"], i));
|
|
226
245
|
|
|
227
246
|
if (arg (args ["text-compression"], i))
|
|
228
247
|
browser .setBrowserOption ("TextCompression", arg (args ["text-compression"], i));
|
|
229
248
|
|
|
249
|
+
if (arg (args ["tone-mapping"], i))
|
|
250
|
+
browser .setBrowserOption ("ToneMapping", arg (args ["tone-mapping"], i));
|
|
251
|
+
|
|
230
252
|
if (arg (args ["view-all"], i))
|
|
231
253
|
browser .viewAll (0);
|
|
232
254
|
|
|
@@ -282,6 +304,7 @@ async function addTransform (browser, scene, rotation)
|
|
|
282
304
|
|
|
283
305
|
const r = new X3D .SFRotation ();
|
|
284
306
|
|
|
307
|
+
r .setName ("rotation");
|
|
285
308
|
r .fromString (rotation, scene);
|
|
286
309
|
|
|
287
310
|
transform .children = scene .rootNodes;
|
|
@@ -307,6 +330,7 @@ async function addBackground (browser, scene, color)
|
|
|
307
330
|
|
|
308
331
|
const c = new X3D .SFColorRGBA ();
|
|
309
332
|
|
|
333
|
+
c .setName ("background");
|
|
310
334
|
c .fromString (color, scene);
|
|
311
335
|
|
|
312
336
|
background .set_bind = true;
|