x3d-image 2.0.24 → 2.0.25

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 CHANGED
@@ -54,6 +54,10 @@ Wait the specified number of seconds before generating the image.
54
54
 
55
55
  Modify the current view so that all objects fit in view volume.
56
56
 
57
+ ### -b
58
+
59
+ Set background to transparent. Use PNG as output image format.
60
+
57
61
  ### -e *[**CANNON**, HELIPAD, FOOTPRINT]*
58
62
 
59
63
  Add an EnvironmentLight node to scene, default is "CANNON". Useful when rendering glTF files with PhysicalMaterial nodes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x3d-image",
3
- "version": "2.0.24",
3
+ "version": "2.0.25",
4
4
  "description": "Render image files from X3D",
5
5
  "main": "src/main.js",
6
6
  "bin": {
package/src/image.js CHANGED
@@ -98,6 +98,14 @@ async function generate (argv)
98
98
  array: true,
99
99
  default: [false],
100
100
  })
101
+ .option ("background",
102
+ {
103
+ type: "boolean",
104
+ alias: "b",
105
+ description: `Set background to transparent. Use PNG as output image format.`,
106
+ array: true,
107
+ default: [false],
108
+ })
101
109
  .option ("environment-light",
102
110
  {
103
111
  type: "string",
@@ -157,6 +165,9 @@ async function generate (argv)
157
165
 
158
166
  await browser .loadURL (new X3D .MFString (input)) .catch (Function .prototype);
159
167
 
168
+ if (arg (args .background, i))
169
+ await addBackground (browser, browser .currentScene);
170
+
160
171
  if (arg (args ["environment-light"], i))
161
172
  await addEnvironmentLight (browser, browser .currentScene, arg (args ["environment-light"], i));
162
173
 
@@ -210,6 +221,32 @@ const EnvironmentLights = new Map ([
210
221
  ["FOOTPRINT", "footprint-court:1"],
211
222
  ]);
212
223
 
224
+ let background = null;
225
+
226
+ async function addBackground (browser, scene)
227
+ {
228
+ browser .endUpdate ();
229
+
230
+ if (!background)
231
+ {
232
+ scene .addComponent (browser .getComponent ("EnvironmentalEffects"));
233
+
234
+ await browser .loadComponents (scene);
235
+
236
+ background = scene .createNode ("Background");
237
+
238
+ background .transparency = 1;
239
+ }
240
+
241
+ scene .addRootNode (background);
242
+
243
+ background .set_bind = true;
244
+
245
+ await browser .nextFrame ();
246
+
247
+ browser .beginUpdate ();
248
+ }
249
+
213
250
  let environmentLight = null;
214
251
 
215
252
  async function addEnvironmentLight (browser, scene, name)
@@ -259,9 +296,9 @@ async function addEnvironmentLight (browser, scene, name)
259
296
  environmentLight .specularTexture .url = specularURL;
260
297
 
261
298
  scene .addRootNode (environmentLight);
262
- await browser .nextFrame ();
263
299
 
264
300
  await Promise .all ([
301
+ browser .nextFrame (),
265
302
  environmentLight .diffuseTexture .getValue () .requestImmediateLoad (),
266
303
  environmentLight .specularTexture .getValue () .requestImmediateLoad (),
267
304
  ]);