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.
Files changed (3) hide show
  1. package/README.md +36 -28
  2. package/package.json +2 -2
  3. 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
- ### -i *file(s)* ...
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
- Set output file(s). This can be either a PNG or JPEG file.
35
+ Modify the current view so that all objects fit in view volume.
40
36
 
41
- ### -s WIDTHxHEIGHT
37
+ ### -b *color*
42
38
 
43
- Set image size in pixels, default is '1280x720'.
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
- ### -q *quality*
41
+ ### -c *[SRGB, **LINEAR_WHEN_PHYSICAL_MATERIAL**, LINEAR]*
46
42
 
47
- 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).
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
- ### -r rotation
53
+ ### -h
66
54
 
67
- Creates a parent group with the model as children and sets the specified X3D rotation value.
55
+ Show help.
68
56
 
69
- ### -c *[SRGB, **LINEAR_WHEN_PHYSICAL_MATERIAL**, LINEAR]*
57
+ ### -i *file(s)* ...
70
58
 
71
- The color space in which color calculations take place.
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
- ### -x *exposure*
61
+ ### -l
74
62
 
75
- The exposure of an image describes the amount of light that is captured.
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
- ### -h
97
+ ### -x *exposure*
90
98
 
91
- Show help.
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 end environment light.
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.32",
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.4",
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 ("input",
51
+ .option ("view-all",
52
52
  {
53
- type: "string",
54
- alias: "i",
55
- 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.",
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 ("output",
59
+ .option ("background",
61
60
  {
62
61
  type: "string",
63
- alias: "o",
64
- description: "Set output file(s). This can be either a *.png or *.jpg file.",
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 ("size",
67
+ .option ("colorSpace",
70
68
  {
71
69
  type: "string",
72
- alias: "s",
73
- description: "Set image size in pixels.",
74
- array: true,
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: [1],
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 ("view-all",
84
+ .option ("environment-light",
94
85
  {
95
- type: "boolean",
96
- alias: "a",
97
- description: "Modify the current view so that all objects fit in view volume.",
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: [false],
91
+ default: [ ],
100
92
  })
101
- .option ("background",
93
+ .option ("input",
102
94
  {
103
95
  type: "string",
104
- alias: "b",
105
- 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.`,
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 ("environment-light",
102
+ .option ("logarithmic-depth-buffer",
110
103
  {
111
- type: "string",
112
- alias: "e",
113
- description: `Add an EnvironmentLight node to scene. Useful when rendering glTF files with PhysicalMaterial nodes.`,
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 ("rotation",
110
+ .option ("tone-mapping",
119
111
  {
120
112
  type: "string",
121
- alias: "r",
122
- description: `Creates a parent group with the model as children and sets the specified X3D rotation value.`,
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 ("colorSpace",
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: "c",
130
- description: `The color space in which color calculations take place.`,
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: ["LINEAR_WHEN_PHYSICAL_MATERIAL"],
133
+ default: [ ],
134
+ implies: "input",
134
135
  })
135
- .option ("exposure",
136
+ .option ("quality",
136
137
  {
137
138
  type: "number",
138
- alias: "x",
139
- description: `The exposure of an image describes the amount of light that is captured.`,
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 ("tone-mapping",
144
+ .option ("rotation",
144
145
  {
145
146
  type: "string",
146
- alias: "m",
147
- description: `Whether tone mapping should be applied.`,
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: ["NONE"],
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 end environment light."
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 ["tone-mapping"], i))
225
- browser .setBrowserOption ("ToneMapping", arg (args ["tone-mapping"], i));
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;