x3d-image 2.0.30 → 2.0.32

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 +18 -2
  2. package/package.json +1 -1
  3. package/src/image.js +51 -11
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 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. The 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
 
@@ -66,6 +66,22 @@ Add an EnvironmentLight node to scene. Useful when rendering glTF files with Phy
66
66
 
67
67
  Creates a parent group with the model as children and sets the specified X3D rotation value.
68
68
 
69
+ ### -c *[SRGB, **LINEAR_WHEN_PHYSICAL_MATERIAL**, LINEAR]*
70
+
71
+ The color space in which color calculations take place.
72
+
73
+ ### -x *exposure*
74
+
75
+ The exposure of an image describes the amount of light that is captured.
76
+
77
+ ### -m *[**NONE**, ACES_NARKOWICZ, ACES_HILL, ACES_HILL_EXPOSURE_BOOST, KHR_PBR_NEUTRAL]*
78
+
79
+ Whether tone mapping should be applied.
80
+
81
+ ### -t *[**CHAR_SPACING**, SCALING]*
82
+
83
+ Controls how Text.length and Text.maxExtent are handled. Either by adjusting char spacing or by scaling text letters.
84
+
69
85
  ### -v
70
86
 
71
87
  Show version.
@@ -117,4 +133,4 @@ $ npx x3d-image -a -e CANNON -i file.gltf -o file.png
117
133
 
118
134
  ## See Also
119
135
 
120
- x3d-image is based on [X_ITE](https://create3000.github.io/x_ite/), so check it out.
136
+ * [x3d-tidy](https://www.npmjs.com/package/x3d-tidy) — X3D converter, beautifier and minimizer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x3d-image",
3
- "version": "2.0.30",
3
+ "version": "2.0.32",
4
4
  "description": "Render image files from X3D",
5
5
  "main": "src/main.js",
6
6
  "bin": {
package/src/image.js CHANGED
@@ -123,6 +123,40 @@ async function generate (argv)
123
123
  array: true,
124
124
  default: [ ],
125
125
  })
126
+ .option ("colorSpace",
127
+ {
128
+ type: "string",
129
+ alias: "c",
130
+ description: `The color space in which color calculations take place.`,
131
+ choices: ["SRGB", "LINEAR_WHEN_PHYSICAL_MATERIAL", "LINEAR"],
132
+ array: true,
133
+ default: ["LINEAR_WHEN_PHYSICAL_MATERIAL"],
134
+ })
135
+ .option ("exposure",
136
+ {
137
+ type: "number",
138
+ alias: "x",
139
+ description: `The exposure of an image describes the amount of light that is captured.`,
140
+ array: true,
141
+ default: [1],
142
+ })
143
+ .option ("tone-mapping",
144
+ {
145
+ 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"],
149
+ array: true,
150
+ default: ["NONE"],
151
+ })
152
+ .option ("text-compression",
153
+ {
154
+ type: "string",
155
+ alias: "t",
156
+ description: `Controls how Text.length and Text.maxExtent are handled. Either by adjusting char spacing or by scaling text letters.`,
157
+ array: true,
158
+ default: ["CHAR_SPACING"],
159
+ })
126
160
  .example ([
127
161
  [
128
162
  "npx x3d-image -s 1600x900 -i file.x3d -o file.jpg",
@@ -172,26 +206,37 @@ async function generate (argv)
172
206
  await browser .resize (width, height);
173
207
  await browser .loadURL (new X3D .MFString (input)) .catch (Function .prototype);
174
208
 
175
- if (arg (args .rotation, i))
176
- await addTransform (browser, browser .currentScene, arg (args .rotation, i));
177
-
178
209
  if (arg (args .background, i))
179
210
  await addBackground (browser, browser .currentScene, arg (args .background, i));
180
211
 
181
212
  if (arg (args ["environment-light"], i))
182
213
  await addEnvironmentLight (browser, browser .currentScene, arg (args ["environment-light"], i));
183
214
 
215
+ if (arg (args .rotation, i))
216
+ await addTransform (browser, browser .currentScene, arg (args .rotation, i));
217
+
218
+ if (arg (args .colorSpace, i))
219
+ browser .setBrowserOption ("ColorSpace", arg (args .colorSpace, i));
220
+
221
+ if (arg (args .exposure, i))
222
+ browser .setBrowserOption ("Exposure", arg (args .exposure, i));
223
+
224
+ if (arg (args ["tone-mapping"], i))
225
+ browser .setBrowserOption ("ToneMapping", arg (args ["tone-mapping"], i));
226
+
227
+ if (arg (args ["text-compression"], i))
228
+ browser .setBrowserOption ("TextCompression", arg (args ["text-compression"], i));
229
+
184
230
  if (arg (args ["view-all"], i))
185
- {
186
231
  browser .viewAll (0);
187
- await browser .nextFrame ();
188
- }
189
232
 
190
233
  browser .beginUpdate ();
191
234
 
192
235
  if (arg (args .delay, i))
193
236
  await sleep (arg (args .delay, i) * 1000);
194
237
 
238
+ await browser .nextFrame ();
239
+
195
240
  const blob = await generateImage (canvas, mimeType, arg (args .quality, i));
196
241
 
197
242
  fs .writeFileSync (output, new DataView (await blob .arrayBuffer ()));
@@ -243,8 +288,6 @@ async function addTransform (browser, scene, rotation)
243
288
  transform .rotation = r;
244
289
 
245
290
  scene .rootNodes = new X3D .MFNode (transform);
246
-
247
- await browser .nextFrame ();
248
291
  }
249
292
 
250
293
  let background = null;
@@ -271,8 +314,6 @@ async function addBackground (browser, scene, color)
271
314
  background .transparency = 1 - c .a;
272
315
 
273
316
  scene .addRootNode (background);
274
-
275
- await browser .nextFrame ();
276
317
  }
277
318
 
278
319
  const EnvironmentLights = new Map ([
@@ -330,7 +371,6 @@ async function addEnvironmentLight (browser, scene, name)
330
371
  scene .addRootNode (environmentLight);
331
372
 
332
373
  await Promise .all ([
333
- browser .nextFrame (),
334
374
  environmentLight .diffuseTexture .getValue () .requestImmediateLoad (),
335
375
  environmentLight .specularTexture .getValue () .requestImmediateLoad (),
336
376
  ]);