x_ite-vrml1-parser 0.0.0-stage → 1.0.1
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/LICENSE.md +21 -0
- package/README.md +37 -2
- package/dist/x_ite-vrml1-parser.js +2641 -0
- package/package.json +50 -4
|
@@ -0,0 +1,2641 @@
|
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
|
|
3
|
+
;// ./node_modules/x_ite-extension/dist/x_ite-extension.js
|
|
4
|
+
/******/ // The require scope
|
|
5
|
+
/******/ var __nested_webpack_require_43__ = {};
|
|
6
|
+
/******/
|
|
7
|
+
/************************************************************************/
|
|
8
|
+
/******/ /* webpack/runtime/define property getters */
|
|
9
|
+
/******/ (() => {
|
|
10
|
+
/******/ // define getter functions for harmony exports
|
|
11
|
+
/******/ __nested_webpack_require_43__.d = (exports, definition) => {
|
|
12
|
+
/******/ for(var key in definition) {
|
|
13
|
+
/******/ if(__nested_webpack_require_43__.o(definition, key) && !__nested_webpack_require_43__.o(exports, key)) {
|
|
14
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
15
|
+
/******/ }
|
|
16
|
+
/******/ }
|
|
17
|
+
/******/ };
|
|
18
|
+
/******/ })();
|
|
19
|
+
/******/
|
|
20
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
21
|
+
/******/ (() => {
|
|
22
|
+
/******/ __nested_webpack_require_43__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
23
|
+
/******/ })();
|
|
24
|
+
/******/
|
|
25
|
+
/************************************************************************/
|
|
26
|
+
var __nested_webpack_exports__ = {};
|
|
27
|
+
/* harmony export */ __nested_webpack_require_43__.d(__nested_webpack_exports__, {
|
|
28
|
+
/* harmony export */ A: () => (x_ite_extension)
|
|
29
|
+
/* harmony export */ });
|
|
30
|
+
function register (callback)
|
|
31
|
+
{
|
|
32
|
+
const X3D = window [Symbol .for ("X_ITE.X3D")];
|
|
33
|
+
|
|
34
|
+
if (X3D)
|
|
35
|
+
callback (X3D);
|
|
36
|
+
else
|
|
37
|
+
getExtensions () .push (callback);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function getExtensions ()
|
|
41
|
+
{
|
|
42
|
+
const
|
|
43
|
+
_extensions = Symbol .for ("X_ITE.extensions"),
|
|
44
|
+
extensions = window [_extensions];
|
|
45
|
+
|
|
46
|
+
if (Array .isArray (extensions))
|
|
47
|
+
return extensions;
|
|
48
|
+
|
|
49
|
+
return window [_extensions] = [ ];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* harmony default export */ const x_ite_extension = (register);
|
|
53
|
+
|
|
54
|
+
const __webpack_exports__default = __nested_webpack_exports__.A;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
;// ./src/nodes/BaseNode.js
|
|
58
|
+
|
|
59
|
+
class BaseNode
|
|
60
|
+
{
|
|
61
|
+
constructor (X3D, typeName, name)
|
|
62
|
+
{
|
|
63
|
+
this .X3D = X3D;
|
|
64
|
+
this .typeName = typeName;
|
|
65
|
+
this .name = name;
|
|
66
|
+
this .fields = new Map ();
|
|
67
|
+
|
|
68
|
+
this .fields .set ("children", [ ]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
use (converter)
|
|
72
|
+
{
|
|
73
|
+
try
|
|
74
|
+
{
|
|
75
|
+
if (!this .name)
|
|
76
|
+
return false;
|
|
77
|
+
|
|
78
|
+
const transform = converter .scene .etNamedNode (this .name);
|
|
79
|
+
|
|
80
|
+
// Add root node if needed or add as child.
|
|
81
|
+
|
|
82
|
+
if (converter .transforms .length)
|
|
83
|
+
converter .groups .at (-1) .children .push (transform);
|
|
84
|
+
else
|
|
85
|
+
converter .scene .rootNodes .push (transform);
|
|
86
|
+
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch
|
|
90
|
+
{
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
convert ()
|
|
96
|
+
{
|
|
97
|
+
console .log ("VRML1Parser: convert:", this .typeName);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
;// ./src/nodes/AsciiText.js
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class AsciiText extends BaseNode
|
|
105
|
+
{
|
|
106
|
+
constructor (X3D, typeName, name)
|
|
107
|
+
{
|
|
108
|
+
super (X3D, typeName, name);
|
|
109
|
+
|
|
110
|
+
this .fields .set ("string", new X3D .Fields .MFString ());
|
|
111
|
+
this .fields .set ("spacing", new X3D .Fields .SFFloat (1));
|
|
112
|
+
this .fields .set ("justification", new X3D .Fields .SFString ("LEFT"));
|
|
113
|
+
this .fields .set ("width", new X3D .Fields .MFFloat ());
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
;// ./src/nodes/Background.js
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class Background extends BaseNode
|
|
121
|
+
{
|
|
122
|
+
constructor (X3D, typeName, name)
|
|
123
|
+
{
|
|
124
|
+
super (X3D, typeName, name);
|
|
125
|
+
|
|
126
|
+
this .fields .set ("groundColors", new X3D .Fields .MFColor ());
|
|
127
|
+
this .fields .set ("skyColors", new X3D .Fields .MFColor (new X3D .Fields .SFColor ()));
|
|
128
|
+
this .fields .set ("scenery", new X3D .Fields .MFString (""));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
;// ./src/nodes/CollideStyle.js
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class CollideStyle extends BaseNode
|
|
136
|
+
{
|
|
137
|
+
constructor (X3D, typeName, name)
|
|
138
|
+
{
|
|
139
|
+
super (X3D, typeName, name);
|
|
140
|
+
|
|
141
|
+
this .fields .set ("collide", new X3D .Fields .SFBool ());
|
|
142
|
+
this .fields .set ("proxy", new X3D .Fields .SFNode ());
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
;// ./src/nodes/Cone.js
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class Cone extends BaseNode
|
|
150
|
+
{
|
|
151
|
+
constructor (X3D, typeName, name)
|
|
152
|
+
{
|
|
153
|
+
super (X3D, typeName, name);
|
|
154
|
+
|
|
155
|
+
this .fields .set ("parts", new X3D .Fields .SFString ("ALL"));
|
|
156
|
+
this .fields .set ("bottomRadius", new X3D .Fields .SFFloat (1));
|
|
157
|
+
this .fields .set ("height", new X3D .Fields .SFFloat (2));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
convert (converter)
|
|
161
|
+
{
|
|
162
|
+
if (this .use (converter))
|
|
163
|
+
return;
|
|
164
|
+
|
|
165
|
+
// Create nodes.
|
|
166
|
+
|
|
167
|
+
const
|
|
168
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
169
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
170
|
+
geometryNode = converter .scene .createNode ("Cone");
|
|
171
|
+
|
|
172
|
+
// Set name.
|
|
173
|
+
|
|
174
|
+
if (this .name)
|
|
175
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
176
|
+
|
|
177
|
+
// Assign values.
|
|
178
|
+
|
|
179
|
+
shapeNode .appearance = appearanceNode;
|
|
180
|
+
shapeNode .geometry = geometryNode;
|
|
181
|
+
|
|
182
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
183
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
184
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
185
|
+
|
|
186
|
+
if (converter .shapeHints .length)
|
|
187
|
+
geometryNode .solid = converter .shapeHints .at (-1) .solid;
|
|
188
|
+
|
|
189
|
+
geometryNode .side = this .fields .get ("parts") .getValue () .match (/ALL|SIDES/);
|
|
190
|
+
geometryNode .bottom = this .fields .get ("parts") .getValue () .match (/ALL|BOTTOM/);
|
|
191
|
+
geometryNode .bottomRadius = this .fields .get ("bottomRadius");
|
|
192
|
+
geometryNode .height = this .fields .get ("height");
|
|
193
|
+
|
|
194
|
+
if (converter .transforms .length)
|
|
195
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
196
|
+
else
|
|
197
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
;// ./src/nodes/Coordinate3.js
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class Coordinate3 extends BaseNode
|
|
205
|
+
{
|
|
206
|
+
constructor (X3D, typeName, name)
|
|
207
|
+
{
|
|
208
|
+
super (X3D, typeName, name);
|
|
209
|
+
|
|
210
|
+
this .fields .set ("point", new X3D .Fields .MFVec3f ());
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
use (converter)
|
|
214
|
+
{
|
|
215
|
+
try
|
|
216
|
+
{
|
|
217
|
+
if (!this .name)
|
|
218
|
+
return false;
|
|
219
|
+
|
|
220
|
+
converter .coords .push (converter .scene .getNamedNode (this .name));
|
|
221
|
+
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
catch
|
|
225
|
+
{
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
convert (converter)
|
|
231
|
+
{
|
|
232
|
+
if (this .use (converter))
|
|
233
|
+
return;
|
|
234
|
+
|
|
235
|
+
// Create nodes.
|
|
236
|
+
|
|
237
|
+
const coordNode = converter .scene .createNode ("Coordinate");
|
|
238
|
+
|
|
239
|
+
// Set name.
|
|
240
|
+
|
|
241
|
+
if (this .name)
|
|
242
|
+
converter .scene .updateNamedNode (this .name, coordNode);
|
|
243
|
+
|
|
244
|
+
// Assign values.
|
|
245
|
+
|
|
246
|
+
coordNode .point = this .fields .get ("point");
|
|
247
|
+
|
|
248
|
+
converter .coords .push (coordNode);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
;// ./src/nodes/Cube.js
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class Cube extends BaseNode
|
|
256
|
+
{
|
|
257
|
+
constructor (X3D, typeName, name)
|
|
258
|
+
{
|
|
259
|
+
super (X3D, typeName, name);
|
|
260
|
+
|
|
261
|
+
this .fields .set ("width", new X3D .Fields .SFFloat (2));
|
|
262
|
+
this .fields .set ("height", new X3D .Fields .SFFloat (2));
|
|
263
|
+
this .fields .set ("depth", new X3D .Fields .SFFloat (2));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
convert (converter)
|
|
267
|
+
{
|
|
268
|
+
if (this .use (converter))
|
|
269
|
+
return;
|
|
270
|
+
|
|
271
|
+
// Create nodes.
|
|
272
|
+
|
|
273
|
+
const
|
|
274
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
275
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
276
|
+
geometryNode = converter .scene .createNode ("Box");
|
|
277
|
+
|
|
278
|
+
// Set name.
|
|
279
|
+
|
|
280
|
+
if (this .name)
|
|
281
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
282
|
+
|
|
283
|
+
// Assign values.
|
|
284
|
+
|
|
285
|
+
shapeNode .appearance = appearanceNode;
|
|
286
|
+
shapeNode .geometry = geometryNode;
|
|
287
|
+
|
|
288
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
289
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
290
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
291
|
+
|
|
292
|
+
if (converter .shapeHints .length)
|
|
293
|
+
geometryNode .solid = converter .shapeHints .at (-1) .solid;
|
|
294
|
+
|
|
295
|
+
geometryNode .size .x = this .fields .get ("width") .getValue ();
|
|
296
|
+
geometryNode .size .y = this .fields .get ("height") .getValue ();
|
|
297
|
+
geometryNode .size .z = this .fields .get ("depth") .getValue ();
|
|
298
|
+
|
|
299
|
+
if (converter .transforms .length)
|
|
300
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
301
|
+
else
|
|
302
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
;// ./src/nodes/CustomNode.js
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class CustomNode extends BaseNode
|
|
310
|
+
{
|
|
311
|
+
constructor (X3D, typeName, name)
|
|
312
|
+
{
|
|
313
|
+
super (X3D, typeName, name);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
convert ()
|
|
317
|
+
{ }
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
;// ./src/nodes/Cylinder.js
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class Cylinder extends BaseNode
|
|
324
|
+
{
|
|
325
|
+
constructor (X3D, typeName, name)
|
|
326
|
+
{
|
|
327
|
+
super (X3D, typeName, name);
|
|
328
|
+
|
|
329
|
+
this .fields .set ("parts", new X3D .Fields .SFString ("ALL"));
|
|
330
|
+
this .fields .set ("radius", new X3D .Fields .SFFloat (1));
|
|
331
|
+
this .fields .set ("height", new X3D .Fields .SFFloat (2));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
convert (converter)
|
|
335
|
+
{
|
|
336
|
+
if (this .use (converter))
|
|
337
|
+
return;
|
|
338
|
+
|
|
339
|
+
// Create nodes.
|
|
340
|
+
|
|
341
|
+
const
|
|
342
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
343
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
344
|
+
geometryNode = converter .scene .createNode ("Cylinder");
|
|
345
|
+
|
|
346
|
+
// Set name.
|
|
347
|
+
|
|
348
|
+
if (this .name)
|
|
349
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
350
|
+
|
|
351
|
+
// Assign values.
|
|
352
|
+
|
|
353
|
+
shapeNode .appearance = appearanceNode;
|
|
354
|
+
shapeNode .geometry = geometryNode;
|
|
355
|
+
|
|
356
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
357
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
358
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
359
|
+
|
|
360
|
+
if (converter .shapeHints .length)
|
|
361
|
+
geometryNode .solid = converter .shapeHints .at (-1) .solid;
|
|
362
|
+
|
|
363
|
+
geometryNode .side = this .fields .get ("parts") .getValue () .match (/ALL|SIDES/);
|
|
364
|
+
geometryNode .top = this .fields .get ("parts") .getValue () .match (/ALL|TOP/);
|
|
365
|
+
geometryNode .bottom = this .fields .get ("parts") .getValue () .match (/ALL|BOTTOM/);
|
|
366
|
+
geometryNode .radius = this .fields .get ("radius");
|
|
367
|
+
geometryNode .height = this .fields .get ("height");
|
|
368
|
+
|
|
369
|
+
if (converter .transforms .length)
|
|
370
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
371
|
+
else
|
|
372
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
;// ./src/nodes/DirectedSound.js
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class DirectedSound extends BaseNode
|
|
380
|
+
{
|
|
381
|
+
constructor (X3D, typeName, name)
|
|
382
|
+
{
|
|
383
|
+
super (X3D, typeName, name);
|
|
384
|
+
|
|
385
|
+
this .fields .set ("name", new X3D .Fields .MFString ());
|
|
386
|
+
this .fields .set ("description", new X3D .Fields .SFString ());
|
|
387
|
+
this .fields .set ("intensity", new X3D .Fields .SFFloat (1));
|
|
388
|
+
this .fields .set ("location", new X3D .Fields .SFVec3f ());
|
|
389
|
+
this .fields .set ("direction", new X3D .Fields .SFVec3f (0, 0, 1));
|
|
390
|
+
this .fields .set ("minRange", new X3D .Fields .SFFloat (10));
|
|
391
|
+
this .fields .set ("maxRange", new X3D .Fields .SFFloat (10)),
|
|
392
|
+
this .fields .set ("minAngle", new X3D .Fields .SFFloat (0.785398));
|
|
393
|
+
this .fields .set ("maxAngle", new X3D .Fields .SFFloat (0.785398));
|
|
394
|
+
this .fields .set ("loop", new X3D .Fields .SFBool (false));
|
|
395
|
+
this .fields .set ("start", new X3D .Fields .SFTime ());
|
|
396
|
+
this .fields .set ("pause", new X3D .Fields .SFTime ());
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
;// ./src/nodes/DirectionalLight.js
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
class DirectionalLight extends BaseNode
|
|
404
|
+
{
|
|
405
|
+
constructor (X3D, typeName, name)
|
|
406
|
+
{
|
|
407
|
+
super (X3D, typeName, name);
|
|
408
|
+
|
|
409
|
+
this .fields .set ("on", new X3D .Fields .SFBool (true));
|
|
410
|
+
this .fields .set ("intensity", new X3D .Fields .SFFloat (1));
|
|
411
|
+
this .fields .set ("color", new X3D .Fields .SFColor (1, 1, 1));
|
|
412
|
+
this .fields .set ("direction", new X3D .Fields .SFVec3f (0, 0, -1));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
convert (converter)
|
|
416
|
+
{
|
|
417
|
+
if (this .use (converter))
|
|
418
|
+
return;
|
|
419
|
+
|
|
420
|
+
// Create nodes.
|
|
421
|
+
|
|
422
|
+
const lightNode = converter .scene .createNode ("DirectionalLight");
|
|
423
|
+
|
|
424
|
+
// Set name.
|
|
425
|
+
|
|
426
|
+
if (this .name)
|
|
427
|
+
converter .scene .updateNamedNode (this .name, lightNode);
|
|
428
|
+
|
|
429
|
+
// Assign values.
|
|
430
|
+
|
|
431
|
+
lightNode .on = this .fields .get ("on");
|
|
432
|
+
lightNode .intensity = this .fields .get ("intensity");
|
|
433
|
+
lightNode .color = this .fields .get ("color");
|
|
434
|
+
lightNode .direction = this .fields .get ("direction");
|
|
435
|
+
|
|
436
|
+
if (converter .transforms .length)
|
|
437
|
+
converter .groups .at (-1) .children .push (lightNode);
|
|
438
|
+
else
|
|
439
|
+
converter .scene .rootNodes .push (lightNode);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
;// ./src/nodes/ElevationGrid.js
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class ElevationGrid extends BaseNode
|
|
447
|
+
{
|
|
448
|
+
constructor (X3D, typeName, name)
|
|
449
|
+
{
|
|
450
|
+
super (X3D, typeName, name);
|
|
451
|
+
|
|
452
|
+
this .fields .set ("verticesPerRow", new X3D .Fields .SFInt32 ());
|
|
453
|
+
this .fields .set ("verticesPerColumn", new X3D .Fields .SFInt32 ());
|
|
454
|
+
this .fields .set ("gridStep", new X3D .Fields .SFVec2f ());
|
|
455
|
+
this .fields .set ("height", new X3D .Fields .MFFloat ());
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
;// ./src/nodes/Environment.js
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
class Environment extends BaseNode
|
|
463
|
+
{
|
|
464
|
+
constructor (X3D, typeName, name)
|
|
465
|
+
{
|
|
466
|
+
super (X3D, typeName, name);
|
|
467
|
+
|
|
468
|
+
this .fields .set ("ambientIntensity", new X3D .Fields .SFFloat (0.2));
|
|
469
|
+
this .fields .set ("ambientColor", new X3D .Fields .SFColor (1, 1, 1));
|
|
470
|
+
this .fields .set ("attenuation", new X3D .Fields .SFVec3f (0, 0, 1));
|
|
471
|
+
this .fields .set ("fogType", new X3D .Fields .SFString ("NONE"));
|
|
472
|
+
this .fields .set ("fogColor", new X3D .Fields .SFColor (1, 1, 1));
|
|
473
|
+
this .fields .set ("fogVisibility", new X3D .Fields .SFFloat ());
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
;// ./src/nodes/FontStyle.js
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
class FontStyle extends BaseNode
|
|
481
|
+
{
|
|
482
|
+
constructor (X3D, typeName, name)
|
|
483
|
+
{
|
|
484
|
+
super (X3D, typeName, name);
|
|
485
|
+
|
|
486
|
+
this .fields .set ("size", new X3D .Fields .SFFloat (10));
|
|
487
|
+
this .fields .set ("family", new X3D .Fields .SFString ("SERIF"));
|
|
488
|
+
this .fields .set ("style", new X3D .Fields .SFString ("NONE"));
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
;// ./src/nodes/GeneralCylinder.js
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
class GeneralCylinder extends BaseNode
|
|
496
|
+
{
|
|
497
|
+
constructor (X3D, typeName, name)
|
|
498
|
+
{
|
|
499
|
+
super (X3D, typeName, name);
|
|
500
|
+
|
|
501
|
+
this .fields .set ("spine", X3D .Fields .MFVec3f .fromArray ([ 0, 0, 0, 0, 1, 0]));
|
|
502
|
+
this .fields .set ("crossSection", X3D .Fields .MFVec2f .fromArray ([ -1, 1, -1, -1, 1, -1, 1, 1]));
|
|
503
|
+
this .fields .set ("profile", X3D .Fields .MFVec2f .fromArray ([ 1, -1, 1, 1 ]));
|
|
504
|
+
this .fields .set ("twist", X3D .Fields .MFVec2f .fromArray ([ 0, -1, 0, 1 ]));
|
|
505
|
+
this .fields .set ("parts", new X3D .Fields .SFString ("ALL"));
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
convert (converter)
|
|
509
|
+
{
|
|
510
|
+
if (this .use (converter))
|
|
511
|
+
return;
|
|
512
|
+
|
|
513
|
+
// Create nodes.
|
|
514
|
+
|
|
515
|
+
const
|
|
516
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
517
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
518
|
+
geometryNode = converter .scene .createNode ("Extrusion");
|
|
519
|
+
|
|
520
|
+
// Set name.
|
|
521
|
+
|
|
522
|
+
if (this .name)
|
|
523
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
524
|
+
|
|
525
|
+
// Assign values.
|
|
526
|
+
|
|
527
|
+
shapeNode .appearance = appearanceNode;
|
|
528
|
+
shapeNode .geometry = geometryNode;
|
|
529
|
+
|
|
530
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
531
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
532
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
533
|
+
|
|
534
|
+
if (converter .shapeHints .length)
|
|
535
|
+
{
|
|
536
|
+
const shapeHints = converter .shapeHints .at (-1);
|
|
537
|
+
|
|
538
|
+
geometryNode .ccw = shapeHints .ccw;
|
|
539
|
+
geometryNode .solid = shapeHints .solid;
|
|
540
|
+
geometryNode .convex = shapeHints .convex;
|
|
541
|
+
geometryNode .creaseAngle = shapeHints .creaseAngle;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
geometryNode .spine = this .fields .get ("spine");
|
|
545
|
+
geometryNode .crossSection = this .fields .get ("crossSection");
|
|
546
|
+
//geometryNode .orientation = this .fields .get ("twist");
|
|
547
|
+
//geometryNode .scale = this .fields .get ("profile");
|
|
548
|
+
geometryNode .beginCap = this .fields .get ("parts") .getValue () .match (/ALL|BOTTOM/);
|
|
549
|
+
geometryNode .endCap = this .fields .get ("parts") .getValue () .match (/ALL|TOP/);
|
|
550
|
+
|
|
551
|
+
if (converter .transforms .length)
|
|
552
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
553
|
+
else
|
|
554
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
;// ./src/nodes/Group.js
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
class Separator extends BaseNode
|
|
562
|
+
{
|
|
563
|
+
constructor (X3D, typeName, name)
|
|
564
|
+
{
|
|
565
|
+
super (X3D, typeName, name);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
convert (converter)
|
|
569
|
+
{
|
|
570
|
+
// Convert child
|
|
571
|
+
|
|
572
|
+
for (const node of this .fields .get ("children"))
|
|
573
|
+
node .convert (converter);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
;// ./src/nodes/IndexedFaceSet.js
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
class IndexedFaceSet extends BaseNode
|
|
581
|
+
{
|
|
582
|
+
constructor (X3D, typeName, name)
|
|
583
|
+
{
|
|
584
|
+
super (X3D, typeName, name);
|
|
585
|
+
|
|
586
|
+
this .fields .set ("vertexOrdering", new X3D .Fields .SFString ("COUNTERCLOCKWISE"));
|
|
587
|
+
this .fields .set ("coordIndex", new X3D .Fields .MFInt32 (0));
|
|
588
|
+
this .fields .set ("materialIndex", new X3D .Fields .MFInt32 (-1));
|
|
589
|
+
this .fields .set ("normalIndex", new X3D .Fields .MFInt32 (-1)),
|
|
590
|
+
this .fields .set ("textureCoordIndex", new X3D .Fields .MFInt32 (-1));
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
convert (converter)
|
|
594
|
+
{
|
|
595
|
+
if (this .use (converter))
|
|
596
|
+
return;
|
|
597
|
+
|
|
598
|
+
// Create nodes.
|
|
599
|
+
|
|
600
|
+
const
|
|
601
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
602
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
603
|
+
geometryNode = converter .scene .createNode ("IndexedFaceSet");
|
|
604
|
+
|
|
605
|
+
// Set name.
|
|
606
|
+
|
|
607
|
+
if (this .name)
|
|
608
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
609
|
+
|
|
610
|
+
// Assign values.
|
|
611
|
+
|
|
612
|
+
shapeNode .appearance = appearanceNode;
|
|
613
|
+
shapeNode .geometry = geometryNode;
|
|
614
|
+
|
|
615
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
616
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
617
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
618
|
+
|
|
619
|
+
if (converter .shapeHints .length)
|
|
620
|
+
{
|
|
621
|
+
const shapeHints = converter .shapeHints .at (-1);
|
|
622
|
+
|
|
623
|
+
geometryNode .ccw = shapeHints .ccw;
|
|
624
|
+
geometryNode .solid = shapeHints .solid;
|
|
625
|
+
geometryNode .convex = shapeHints .convex;
|
|
626
|
+
geometryNode .creaseAngle = shapeHints .creaseAngle;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// XXX: Always set solid to false.
|
|
630
|
+
geometryNode .solid = false;
|
|
631
|
+
|
|
632
|
+
if (converter .normalBindings .length)
|
|
633
|
+
{
|
|
634
|
+
if (converter .normalBindings .at (-1) .value === "OVERALL")
|
|
635
|
+
{
|
|
636
|
+
for (const index of this .fields .get ("coordIndex"))
|
|
637
|
+
geometryNode .normalIndex .push (index < 0 ? -1 : 0);
|
|
638
|
+
}
|
|
639
|
+
else if (converter .normalBindings .at (-1) .value === "PER_FACE")
|
|
640
|
+
{
|
|
641
|
+
geometryNode .normalPerVertex = false;
|
|
642
|
+
}
|
|
643
|
+
else if (converter .normalBindings .at (-1) .value === "PER_FACE_INDEXED")
|
|
644
|
+
{
|
|
645
|
+
geometryNode .normalPerVertex = false;
|
|
646
|
+
geometryNode .normalIndex = this .fields .get ("normalIndex");
|
|
647
|
+
}
|
|
648
|
+
else if (converter .normalBindings .at (-1) .value === "PER_VERTEX")
|
|
649
|
+
;
|
|
650
|
+
else //if (converter .normalBindings .at (-1) .value === "PER_VERTEX_INDEXED")
|
|
651
|
+
{
|
|
652
|
+
geometryNode .normalIndex = this .fields .get ("normalIndex");
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
else
|
|
656
|
+
{
|
|
657
|
+
geometryNode .normalIndex = this .fields .get ("normalIndex");
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
geometryNode .texCoordIndex = this .fields .get ("textureCoordIndex");
|
|
661
|
+
geometryNode .coordIndex = this .fields .get ("coordIndex");
|
|
662
|
+
|
|
663
|
+
geometryNode .texCoord = converter .texCoords .at (-1);
|
|
664
|
+
geometryNode .normal = converter .normals .at (-1);
|
|
665
|
+
geometryNode .coord = converter .coords .at (-1);
|
|
666
|
+
|
|
667
|
+
if (converter .transforms .length)
|
|
668
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
669
|
+
else
|
|
670
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
;// ./src/nodes/IndexedLineSet.js
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
class IndexedLineSet extends BaseNode
|
|
678
|
+
{
|
|
679
|
+
constructor (X3D, typeName, name)
|
|
680
|
+
{
|
|
681
|
+
super (X3D, typeName, name);
|
|
682
|
+
|
|
683
|
+
this .fields .set ("coordIndex", new X3D .Fields .MFInt32 (0));
|
|
684
|
+
this .fields .set ("materialIndex", new X3D .Fields .MFInt32 (-1));
|
|
685
|
+
this .fields .set ("normalIndex", new X3D .Fields .MFInt32 (-1)),
|
|
686
|
+
this .fields .set ("textureCoordIndex", new X3D .Fields .MFInt32 (-1));
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
convert (converter)
|
|
690
|
+
{
|
|
691
|
+
if (this .use (converter))
|
|
692
|
+
return;
|
|
693
|
+
|
|
694
|
+
// Create nodes.
|
|
695
|
+
|
|
696
|
+
const
|
|
697
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
698
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
699
|
+
geometryNode = converter .scene .createNode ("IndexedLineSet");
|
|
700
|
+
|
|
701
|
+
// Set name.
|
|
702
|
+
|
|
703
|
+
if (this .name)
|
|
704
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
705
|
+
|
|
706
|
+
// Assign values.
|
|
707
|
+
|
|
708
|
+
shapeNode .appearance = appearanceNode;
|
|
709
|
+
shapeNode .geometry = geometryNode;
|
|
710
|
+
|
|
711
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
712
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
713
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
714
|
+
|
|
715
|
+
geometryNode .coordIndex = this .fields .get ("coordIndex");
|
|
716
|
+
geometryNode .coord = converter .coords .at (-1);
|
|
717
|
+
|
|
718
|
+
if (converter .transforms .length)
|
|
719
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
720
|
+
else
|
|
721
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
;// ./src/nodes/Info.js
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
class Info extends BaseNode
|
|
729
|
+
{
|
|
730
|
+
constructor (X3D, typeName, name)
|
|
731
|
+
{
|
|
732
|
+
super (X3D, typeName, name);
|
|
733
|
+
|
|
734
|
+
this .fields .set ("string", new X3D .Fields .SFString ());
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
convert (converter)
|
|
738
|
+
{
|
|
739
|
+
// NO USE!
|
|
740
|
+
|
|
741
|
+
// Create nodes.
|
|
742
|
+
|
|
743
|
+
if (converter .transforms .length)
|
|
744
|
+
{
|
|
745
|
+
const metadataNode = converter .scene .createNode ("MetadataString");
|
|
746
|
+
|
|
747
|
+
// Set name.
|
|
748
|
+
|
|
749
|
+
if (this .name)
|
|
750
|
+
converter .scene .updateNamedNode (this .name, metadataNode);
|
|
751
|
+
|
|
752
|
+
// Assign values.
|
|
753
|
+
|
|
754
|
+
metadataNode .name = "Info";
|
|
755
|
+
metadataNode .reference = converter .scene .getBrowser () .providerURL;
|
|
756
|
+
metadataNode .value = [ this .fields .get ("string") .getValue () ];
|
|
757
|
+
|
|
758
|
+
converter .groups .at (-1) .metadata = metadataNode;
|
|
759
|
+
}
|
|
760
|
+
else
|
|
761
|
+
{
|
|
762
|
+
// Create nodes.
|
|
763
|
+
|
|
764
|
+
const infoNode = converter .scene .createNode ("WorldInfo");
|
|
765
|
+
|
|
766
|
+
// Set name.
|
|
767
|
+
|
|
768
|
+
// Assign values.
|
|
769
|
+
|
|
770
|
+
infoNode .title = "Info";
|
|
771
|
+
infoNode .info = [ this .fields .get ("string") .getValue () ];
|
|
772
|
+
|
|
773
|
+
converter .scene .rootNodes .push (infoNode);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
;// ./src/nodes/LOD.js
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
class LOD extends BaseNode
|
|
782
|
+
{
|
|
783
|
+
constructor (X3D, typeName, name)
|
|
784
|
+
{
|
|
785
|
+
super (X3D, typeName, name);
|
|
786
|
+
|
|
787
|
+
this .fields .set ("range", new X3D .Fields .MFFloat (-1));
|
|
788
|
+
this .fields .set ("center", new X3D .Fields .SFVec3f ());
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
convert (converter)
|
|
792
|
+
{
|
|
793
|
+
if (this .use (converter))
|
|
794
|
+
return;
|
|
795
|
+
|
|
796
|
+
// Create Transform node.
|
|
797
|
+
|
|
798
|
+
const
|
|
799
|
+
transformNode = converter .scene .createNode ("Transform"),
|
|
800
|
+
lodNode = converter .scene .createNode ("LOD");
|
|
801
|
+
|
|
802
|
+
// Set values.
|
|
803
|
+
|
|
804
|
+
transformNode .children .push (lodNode);
|
|
805
|
+
|
|
806
|
+
lodNode .range = this .fields .get ("range");
|
|
807
|
+
lodNode .center = this .fields .get ("center");
|
|
808
|
+
|
|
809
|
+
// Add root node if needed or add as child.
|
|
810
|
+
|
|
811
|
+
if (converter .transforms .length)
|
|
812
|
+
converter .groups .at (-1) .children .push (transformNode);
|
|
813
|
+
else
|
|
814
|
+
converter .scene .rootNodes .push (transformNode);
|
|
815
|
+
|
|
816
|
+
// Set name.
|
|
817
|
+
|
|
818
|
+
if (this .name)
|
|
819
|
+
converter .scene .updateNamedNode (this .name, transformNode);
|
|
820
|
+
|
|
821
|
+
// Convert children.
|
|
822
|
+
|
|
823
|
+
converter .save ();
|
|
824
|
+
converter .transforms .push (transformNode);
|
|
825
|
+
converter .groups .push (lodNode);
|
|
826
|
+
|
|
827
|
+
for (const node of this .fields .get ("children"))
|
|
828
|
+
node .convert (converter);
|
|
829
|
+
|
|
830
|
+
converter .restore ();
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
;// ./src/nodes/Material.js
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
class Material extends BaseNode
|
|
838
|
+
{
|
|
839
|
+
constructor (X3D, typeName, name)
|
|
840
|
+
{
|
|
841
|
+
super (X3D, typeName, name);
|
|
842
|
+
|
|
843
|
+
this .fields .set ("point", new X3D .Fields .MFVec3f ());
|
|
844
|
+
|
|
845
|
+
this .fields .set ("ambientColor", new X3D .Fields .MFColor (new X3D .Fields .SFColor (0.2, 0.2, 0.2)));
|
|
846
|
+
this .fields .set ("diffuseColor", new X3D .Fields .MFColor (new X3D .Fields .SFColor (0.8, 0.8, 0.8)));
|
|
847
|
+
this .fields .set ("specularColor", new X3D .Fields .MFColor (new X3D .Fields .SFColor (0, 0, 0)));
|
|
848
|
+
this .fields .set ("emissiveColor", new X3D .Fields .MFColor (new X3D .Fields .SFColor (0, 0, 0)));
|
|
849
|
+
this .fields .set ("shininess", new X3D .Fields .MFFloat (0.2));
|
|
850
|
+
this .fields .set ("transparency", new X3D .Fields .MFFloat (0));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
use (converter)
|
|
854
|
+
{
|
|
855
|
+
try
|
|
856
|
+
{
|
|
857
|
+
if (!this .name)
|
|
858
|
+
return false;
|
|
859
|
+
|
|
860
|
+
converter .materials .push (converter .scene .getNamedNode (this .name));
|
|
861
|
+
|
|
862
|
+
return true;
|
|
863
|
+
}
|
|
864
|
+
catch
|
|
865
|
+
{
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
convert (converter)
|
|
871
|
+
{
|
|
872
|
+
if (this .use (converter))
|
|
873
|
+
return;
|
|
874
|
+
|
|
875
|
+
// Create nodes.
|
|
876
|
+
|
|
877
|
+
const materialNode = converter .scene .createNode ("Material");
|
|
878
|
+
|
|
879
|
+
// Set name.
|
|
880
|
+
|
|
881
|
+
if (this .name)
|
|
882
|
+
converter .scene .updateNamedNode (this .name, materialNode);
|
|
883
|
+
|
|
884
|
+
// Assign values.
|
|
885
|
+
|
|
886
|
+
if (this .fields .get ("ambientColor") .length)
|
|
887
|
+
{
|
|
888
|
+
const hsv = this .fields .get ("ambientColor") [0] .getHSV ();
|
|
889
|
+
|
|
890
|
+
materialNode .ambientIntensity = hsv [2];
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (this .fields .get ("diffuseColor") .length)
|
|
894
|
+
materialNode .diffuseColor = this .fields .get ("diffuseColor") [0];
|
|
895
|
+
|
|
896
|
+
if (this .fields .get ("specularColor") .length)
|
|
897
|
+
materialNode .specularColor = this .fields .get ("specularColor") [0];
|
|
898
|
+
|
|
899
|
+
if (this .fields .get ("emissiveColor") .length)
|
|
900
|
+
materialNode .emissiveColor = this .fields .get ("emissiveColor") [0];
|
|
901
|
+
|
|
902
|
+
if (this .fields .get ("shininess") .length)
|
|
903
|
+
materialNode .shininess = this .fields .get ("shininess") [0];
|
|
904
|
+
|
|
905
|
+
if (this .fields .get ("transparency") .length)
|
|
906
|
+
materialNode .transparency = this .fields .get ("transparency") [0];
|
|
907
|
+
|
|
908
|
+
converter .materials .push (materialNode);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
;// ./src/nodes/MaterialBinding.js
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
class MaterialBinding extends BaseNode
|
|
916
|
+
{
|
|
917
|
+
constructor (X3D, typeName, name)
|
|
918
|
+
{
|
|
919
|
+
super (X3D, typeName, name);
|
|
920
|
+
|
|
921
|
+
this .fields .set ("value", new X3D .Fields .SFString ("OVERALL"));
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
convert (converter)
|
|
925
|
+
{
|
|
926
|
+
converter .materialBindings .push (this);
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
;// ./src/nodes/MatrixTransform.js
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
class MatrixTransform extends BaseNode
|
|
934
|
+
{
|
|
935
|
+
constructor (X3D, typeName, name)
|
|
936
|
+
{
|
|
937
|
+
super (X3D, typeName, name);
|
|
938
|
+
|
|
939
|
+
this .fields .set ("matrix", new X3D .Fields .SFMatrix4f ());
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
convert (converter)
|
|
943
|
+
{
|
|
944
|
+
const transform = converter .transforms .at (-1);
|
|
945
|
+
|
|
946
|
+
if (!transform)
|
|
947
|
+
return;
|
|
948
|
+
|
|
949
|
+
const { X3D } = this;
|
|
950
|
+
|
|
951
|
+
let matrix = new X3D .Fields .SFMatrix4f ();
|
|
952
|
+
|
|
953
|
+
matrix .setTransform (transform .translation,
|
|
954
|
+
transform .rotation,
|
|
955
|
+
transform .scale,
|
|
956
|
+
transform .scaleOrientation,
|
|
957
|
+
transform .center);
|
|
958
|
+
|
|
959
|
+
matrix = matrix .multLeft (this .fields .get ("matrix"));
|
|
960
|
+
|
|
961
|
+
matrix .getTransform (transform .translation,
|
|
962
|
+
transform .rotation,
|
|
963
|
+
transform .scale,
|
|
964
|
+
transform .scaleOrientation,
|
|
965
|
+
transform .center);
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
;// ./src/nodes/NavigationInfo.js
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
class NavigationInfo extends BaseNode
|
|
973
|
+
{
|
|
974
|
+
constructor (X3D, typeName, name)
|
|
975
|
+
{
|
|
976
|
+
super (X3D, typeName, name);
|
|
977
|
+
|
|
978
|
+
this .fields .set ("type", new X3D .Fields .MFString ("walk"));
|
|
979
|
+
this .fields .set ("speed", new X3D .Fields .SFFloat (1));
|
|
980
|
+
this .fields .set ("collisionRadius", new X3D .Fields .SFFloat (1));
|
|
981
|
+
this .fields .set ("headlight", new X3D .Fields .SFBool (true));
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
;// ./src/nodes/Normal.js
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
class Normal extends BaseNode
|
|
989
|
+
{
|
|
990
|
+
constructor (X3D, typeName, name)
|
|
991
|
+
{
|
|
992
|
+
super (X3D, typeName, name);
|
|
993
|
+
|
|
994
|
+
this .fields .set ("vector", new X3D .Fields .MFVec3f ());
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
use (converter)
|
|
998
|
+
{
|
|
999
|
+
try
|
|
1000
|
+
{
|
|
1001
|
+
if (!this .name)
|
|
1002
|
+
return false;
|
|
1003
|
+
|
|
1004
|
+
converter .normals .push (converter .scene .getNamedNode (this .name));
|
|
1005
|
+
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
catch
|
|
1009
|
+
{
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
convert (converter)
|
|
1015
|
+
{
|
|
1016
|
+
if (this .use (converter))
|
|
1017
|
+
return;
|
|
1018
|
+
|
|
1019
|
+
// Create nodes.
|
|
1020
|
+
|
|
1021
|
+
const normalNode = converter .scene .createNode ("Normal");
|
|
1022
|
+
|
|
1023
|
+
// Set name.
|
|
1024
|
+
|
|
1025
|
+
if (this .name)
|
|
1026
|
+
converter .scene .updateNamedNode (this .name, normalNode);
|
|
1027
|
+
|
|
1028
|
+
// Assign values.
|
|
1029
|
+
|
|
1030
|
+
normalNode .vector = this .fields .get ("vector");
|
|
1031
|
+
|
|
1032
|
+
converter .normals .push (normalNode);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
;// ./src/nodes/NormalBinding.js
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
class NormalBinding extends BaseNode
|
|
1040
|
+
{
|
|
1041
|
+
constructor (X3D, typeName, name)
|
|
1042
|
+
{
|
|
1043
|
+
super (X3D, typeName, name);
|
|
1044
|
+
|
|
1045
|
+
this .fields .set ("value", new X3D .Fields .SFString ());
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
get value ()
|
|
1049
|
+
{
|
|
1050
|
+
return this .fields .get ("value") .getValue ();
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
convert (converter)
|
|
1054
|
+
{
|
|
1055
|
+
converter .normalBindings .push (this);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
;// ./src/nodes/OrthographicCamera.js
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
class OrthographicCamera extends BaseNode
|
|
1063
|
+
{
|
|
1064
|
+
constructor (X3D, typeName, name)
|
|
1065
|
+
{
|
|
1066
|
+
super (X3D, typeName, name);
|
|
1067
|
+
|
|
1068
|
+
this .fields .set ("position", new X3D .Fields .SFVec3f (0, 0, 1));
|
|
1069
|
+
this .fields .set ("orientation", new X3D .Fields .SFRotation ());
|
|
1070
|
+
this .fields .set ("focalDistance", new X3D .Fields .SFFloat (5));
|
|
1071
|
+
this .fields .set ("height", new X3D .Fields .SFFloat (2));
|
|
1072
|
+
this .fields .set ("nearDistance", new X3D .Fields .SFFloat (1));
|
|
1073
|
+
this .fields .set ("farDistance", new X3D .Fields .SFFloat (10));
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
convert (converter)
|
|
1077
|
+
{
|
|
1078
|
+
if (this .use (converter))
|
|
1079
|
+
return;
|
|
1080
|
+
|
|
1081
|
+
// Create nodes.
|
|
1082
|
+
|
|
1083
|
+
const viewpointNode = converter .scene .createNode ("OrthoViewpoint");
|
|
1084
|
+
|
|
1085
|
+
// Set name.
|
|
1086
|
+
|
|
1087
|
+
if (this .name)
|
|
1088
|
+
converter .scene .updateNamedNode (this .name, viewpointNode);
|
|
1089
|
+
|
|
1090
|
+
// Assign values.
|
|
1091
|
+
|
|
1092
|
+
const height = this .fields .get ("height") .getValue ();
|
|
1093
|
+
|
|
1094
|
+
viewpointNode .position = this .fields .get ("position");
|
|
1095
|
+
viewpointNode .orientation = this .fields .get ("orientation");
|
|
1096
|
+
viewpointNode .fieldOfView = [ -height / 2, -height / 2, height / 2, height / 2 ];
|
|
1097
|
+
viewpointNode .nearDistance = this .fields .get ("nearDistance");
|
|
1098
|
+
viewpointNode .farDistance = this .fields .get ("farDistance");
|
|
1099
|
+
|
|
1100
|
+
if (converter .transforms .length)
|
|
1101
|
+
converter .groups .at (-1) .children .push (viewpointNode);
|
|
1102
|
+
else
|
|
1103
|
+
converter .scene .rootNodes .push (viewpointNode);
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
;// ./src/nodes/PerspectiveCamera.js
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
class PerspectiveCamera extends BaseNode
|
|
1111
|
+
{
|
|
1112
|
+
constructor (X3D, typeName, name)
|
|
1113
|
+
{
|
|
1114
|
+
super (X3D, typeName, name);
|
|
1115
|
+
|
|
1116
|
+
this .fields .set ("position", new X3D .Fields .SFVec3f (0, 0, 1));
|
|
1117
|
+
this .fields .set ("orientation", new X3D .Fields .SFRotation ());
|
|
1118
|
+
this .fields .set ("focalDistance", new X3D .Fields .SFFloat (5));
|
|
1119
|
+
this .fields .set ("heightAngle", new X3D .Fields .SFFloat (0.785398));
|
|
1120
|
+
this .fields .set ("nearDistance", new X3D .Fields .SFFloat (1));
|
|
1121
|
+
this .fields .set ("farDistance", new X3D .Fields .SFFloat (10));
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
convert (converter)
|
|
1125
|
+
{
|
|
1126
|
+
if (this .use (converter))
|
|
1127
|
+
return;
|
|
1128
|
+
|
|
1129
|
+
// Create nodes.
|
|
1130
|
+
|
|
1131
|
+
const viewpointNode = converter .scene .createNode ("Viewpoint");
|
|
1132
|
+
|
|
1133
|
+
// Set name.
|
|
1134
|
+
|
|
1135
|
+
if (this .name)
|
|
1136
|
+
converter .scene .updateNamedNode (this .name, viewpointNode);
|
|
1137
|
+
|
|
1138
|
+
// Assign values.
|
|
1139
|
+
|
|
1140
|
+
viewpointNode .position = this .fields .get ("position");
|
|
1141
|
+
viewpointNode .orientation = this .fields .get ("orientation");
|
|
1142
|
+
viewpointNode .fieldOfView = this .fields .get ("heightAngle");
|
|
1143
|
+
viewpointNode .nearDistance = this .fields .get ("nearDistance");
|
|
1144
|
+
viewpointNode .farDistance = this .fields .get ("farDistance");
|
|
1145
|
+
|
|
1146
|
+
if (converter .transforms .length)
|
|
1147
|
+
converter .groups .at (-1) .children .push (viewpointNode);
|
|
1148
|
+
else
|
|
1149
|
+
converter .scene .rootNodes .push (viewpointNode);
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
;// ./src/nodes/PointLight.js
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
class PointLight extends BaseNode
|
|
1157
|
+
{
|
|
1158
|
+
constructor (X3D, typeName, name)
|
|
1159
|
+
{
|
|
1160
|
+
super (X3D, typeName, name);
|
|
1161
|
+
|
|
1162
|
+
this .fields .set ("on", new X3D .Fields .SFBool (true));
|
|
1163
|
+
this .fields .set ("intensity", new X3D .Fields .SFFloat (1));
|
|
1164
|
+
this .fields .set ("color", new X3D .Fields .SFColor (1, 1, 1));
|
|
1165
|
+
this .fields .set ("location", new X3D .Fields .SFVec3f (0, 0, 1));
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
convert (converter)
|
|
1169
|
+
{
|
|
1170
|
+
if (this .use (converter))
|
|
1171
|
+
return;
|
|
1172
|
+
|
|
1173
|
+
// Create nodes.
|
|
1174
|
+
|
|
1175
|
+
const lightNode = converter .scene .createNode ("PointLight");
|
|
1176
|
+
|
|
1177
|
+
// Set name.
|
|
1178
|
+
|
|
1179
|
+
if (this .name)
|
|
1180
|
+
converter .scene .updateNamedNode (this .name, lightNode);
|
|
1181
|
+
|
|
1182
|
+
// Assign values.
|
|
1183
|
+
|
|
1184
|
+
lightNode .on = this .fields .get ("on");
|
|
1185
|
+
lightNode .intensity = this .fields .get ("intensity");
|
|
1186
|
+
lightNode .color = this .fields .get ("color");
|
|
1187
|
+
lightNode .location = this .fields .get ("location");
|
|
1188
|
+
|
|
1189
|
+
if (converter .transforms .length)
|
|
1190
|
+
converter .groups .at (-1) .children .push (lightNode);
|
|
1191
|
+
else
|
|
1192
|
+
converter .scene .rootNodes .push (lightNode);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
;// ./src/nodes/PointSet.js
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
class PointSet extends BaseNode
|
|
1200
|
+
{
|
|
1201
|
+
constructor (X3D, typeName, name)
|
|
1202
|
+
{
|
|
1203
|
+
super (X3D, typeName, name);
|
|
1204
|
+
|
|
1205
|
+
this .fields .set ("startIndex", new X3D .Fields .SFInt32 ());
|
|
1206
|
+
this .fields .set ("numPoints", new X3D .Fields .SFInt32 (-1));
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
convert (converter)
|
|
1210
|
+
{
|
|
1211
|
+
if (this .use (converter))
|
|
1212
|
+
return;
|
|
1213
|
+
|
|
1214
|
+
const
|
|
1215
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
1216
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
1217
|
+
geometryNode = converter .scene .createNode ("PointSet");
|
|
1218
|
+
|
|
1219
|
+
// Set name.
|
|
1220
|
+
|
|
1221
|
+
if (this .name)
|
|
1222
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
1223
|
+
|
|
1224
|
+
// Assign values.
|
|
1225
|
+
|
|
1226
|
+
shapeNode .appearance = appearanceNode;
|
|
1227
|
+
shapeNode .geometry = geometryNode;
|
|
1228
|
+
|
|
1229
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
1230
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
1231
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
1232
|
+
|
|
1233
|
+
const coord = converter .coords .at (-1);
|
|
1234
|
+
|
|
1235
|
+
if (coord)
|
|
1236
|
+
{
|
|
1237
|
+
if (this .fields .get ("startIndex") .getValue () === 0)
|
|
1238
|
+
{
|
|
1239
|
+
geometryNode .coord = coord;
|
|
1240
|
+
}
|
|
1241
|
+
else
|
|
1242
|
+
{
|
|
1243
|
+
const coordNode = converter .scene .createNode ("Coordinate");
|
|
1244
|
+
|
|
1245
|
+
const
|
|
1246
|
+
start = Math .max (this .fields .get ("startIndex") .getValue (), 0),
|
|
1247
|
+
length = Math .max (this .fields .get ("numPoints") .getValue (), 0);
|
|
1248
|
+
|
|
1249
|
+
coordNode .point = coord .point .slice (start, start + length);
|
|
1250
|
+
|
|
1251
|
+
geometryNode .coord = coordNode;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
if (converter .transforms .length)
|
|
1256
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
1257
|
+
else
|
|
1258
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
;// ./src/nodes/PointSound.js
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
class PointSound extends BaseNode
|
|
1266
|
+
{
|
|
1267
|
+
constructor (X3D, typeName, name)
|
|
1268
|
+
{
|
|
1269
|
+
super (X3D, typeName, name);
|
|
1270
|
+
|
|
1271
|
+
this .fields .set ("name", new X3D .Fields .MFString ());
|
|
1272
|
+
this .fields .set ("description", new X3D .Fields .SFString ());
|
|
1273
|
+
this .fields .set ("intensity", new X3D .Fields .SFFloat (1));
|
|
1274
|
+
this .fields .set ("location", new X3D .Fields .SFVec3f ());
|
|
1275
|
+
this .fields .set ("minRange", new X3D .Fields .SFFloat (10));
|
|
1276
|
+
this .fields .set ("maxRange", new X3D .Fields .SFFloat (10));
|
|
1277
|
+
this .fields .set ("loop", new X3D .Fields .SFBool ());
|
|
1278
|
+
this .fields .set ("start", new X3D .Fields .SFTime ());
|
|
1279
|
+
this .fields .set ("pause", new X3D .Fields .SFTime ());
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
;// ./src/nodes/Rotation.js
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
class Rotation extends BaseNode
|
|
1287
|
+
{
|
|
1288
|
+
constructor (X3D, typeName, name)
|
|
1289
|
+
{
|
|
1290
|
+
super (X3D, typeName, name);
|
|
1291
|
+
|
|
1292
|
+
this .fields .set ("rotation", new X3D .Fields .SFRotation ());
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
convert (converter)
|
|
1296
|
+
{
|
|
1297
|
+
const transform = converter .transforms .at (-1);
|
|
1298
|
+
|
|
1299
|
+
if (!transform)
|
|
1300
|
+
return;
|
|
1301
|
+
|
|
1302
|
+
const { X3D } = this;
|
|
1303
|
+
|
|
1304
|
+
let matrix = new X3D .Fields .SFMatrix4f ();
|
|
1305
|
+
|
|
1306
|
+
matrix .setTransform (transform .translation,
|
|
1307
|
+
transform .rotation,
|
|
1308
|
+
transform .scale,
|
|
1309
|
+
transform .scaleOrientation,
|
|
1310
|
+
transform .center);
|
|
1311
|
+
|
|
1312
|
+
matrix = matrix .rotate (this .fields .get ("rotation"));
|
|
1313
|
+
|
|
1314
|
+
matrix .getTransform (transform .translation,
|
|
1315
|
+
transform .rotation,
|
|
1316
|
+
transform .scale,
|
|
1317
|
+
transform .scaleOrientation,
|
|
1318
|
+
transform .center);
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
;// ./src/nodes/Scale.js
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
class Scale extends BaseNode
|
|
1326
|
+
{
|
|
1327
|
+
constructor (X3D, typeName, name)
|
|
1328
|
+
{
|
|
1329
|
+
super (X3D, typeName, name);
|
|
1330
|
+
|
|
1331
|
+
this .fields .set ("scaleFactor", new X3D .Fields .SFVec3f (1, 1, 1));
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
convert (converter)
|
|
1335
|
+
{
|
|
1336
|
+
const transform = converter .transforms .at (-1);
|
|
1337
|
+
|
|
1338
|
+
if (!transform)
|
|
1339
|
+
return;
|
|
1340
|
+
|
|
1341
|
+
const { X3D } = this;
|
|
1342
|
+
|
|
1343
|
+
let matrix = new X3D .Fields .SFMatrix4f ();
|
|
1344
|
+
|
|
1345
|
+
matrix .setTransform (transform .translation,
|
|
1346
|
+
transform .rotation,
|
|
1347
|
+
transform .scale,
|
|
1348
|
+
transform .scaleOrientation,
|
|
1349
|
+
transform .center);
|
|
1350
|
+
|
|
1351
|
+
matrix = matrix .scale (this .fields .get ("scaleFactor"));
|
|
1352
|
+
|
|
1353
|
+
matrix .getTransform (transform .translation,
|
|
1354
|
+
transform .rotation,
|
|
1355
|
+
transform .scale,
|
|
1356
|
+
transform .scaleOrientation,
|
|
1357
|
+
transform .center);
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
;// ./src/nodes/Separator.js
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
class Separator_Separator extends BaseNode
|
|
1365
|
+
{
|
|
1366
|
+
constructor (X3D, typeName, name)
|
|
1367
|
+
{
|
|
1368
|
+
super (X3D, typeName, name);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
convert (converter)
|
|
1372
|
+
{
|
|
1373
|
+
if (this .use (converter))
|
|
1374
|
+
return;
|
|
1375
|
+
|
|
1376
|
+
// Create Transform node.
|
|
1377
|
+
|
|
1378
|
+
const transformNode = converter .scene .createNode ("Transform");
|
|
1379
|
+
|
|
1380
|
+
// Add root node if needed or add as child.
|
|
1381
|
+
|
|
1382
|
+
if (converter .transforms .length)
|
|
1383
|
+
converter .groups .at (-1) .children .push (transformNode);
|
|
1384
|
+
else
|
|
1385
|
+
converter .scene .rootNodes .push (transformNode);
|
|
1386
|
+
|
|
1387
|
+
// Set name.
|
|
1388
|
+
|
|
1389
|
+
if (this .name)
|
|
1390
|
+
converter .scene .updateNamedNode (this .name, transformNode);
|
|
1391
|
+
|
|
1392
|
+
// Convert children.
|
|
1393
|
+
|
|
1394
|
+
converter .save ();
|
|
1395
|
+
converter .transforms .push (transformNode);
|
|
1396
|
+
converter .groups .push (transformNode);
|
|
1397
|
+
|
|
1398
|
+
for (const node of this .fields .get ("children"))
|
|
1399
|
+
node .convert (converter);
|
|
1400
|
+
|
|
1401
|
+
converter .restore ();
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
|
|
1405
|
+
;// ./src/nodes/ShapeHints.js
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
class ShapeHints extends BaseNode
|
|
1409
|
+
{
|
|
1410
|
+
constructor (X3D, typeName, name)
|
|
1411
|
+
{
|
|
1412
|
+
super (X3D, typeName, name);
|
|
1413
|
+
|
|
1414
|
+
this .fields .set ("vertexOrdering", new X3D .Fields .SFString ("COUNTERCLOCKWISE"));
|
|
1415
|
+
this .fields .set ("shapeType", new X3D .Fields .SFString ("SOLID"));
|
|
1416
|
+
this .fields .set ("faceType", new X3D .Fields .SFString ("CONVEX"));
|
|
1417
|
+
this .fields .set ("creaseAngle", new X3D .Fields .SFFloat ());
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
get ccw ()
|
|
1421
|
+
{
|
|
1422
|
+
return this .fields .get ("vertexOrdering") .getValue () !== "CLOCKWISE";
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
get solid ()
|
|
1426
|
+
{
|
|
1427
|
+
return this .fields .get ("shapeType") .getValue () !== "UNKNOWN_SHAPE_TYPE";
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
get convex ()
|
|
1431
|
+
{
|
|
1432
|
+
return this .fields .get ("shapeType") .getValue () !== "UNKNOWN_FACE_TYPE";
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
get creaseAngle ()
|
|
1436
|
+
{
|
|
1437
|
+
return this .fields .get ("creaseAngle") .getValue ();
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
convert (converter)
|
|
1441
|
+
{
|
|
1442
|
+
converter .shapeHints .push (this);
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
;// ./src/nodes/Sphere.js
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
class Sphere extends BaseNode
|
|
1450
|
+
{
|
|
1451
|
+
constructor (X3D, typeName, name)
|
|
1452
|
+
{
|
|
1453
|
+
super (X3D, typeName, name);
|
|
1454
|
+
|
|
1455
|
+
this .fields .set ("radius", new X3D .Fields .SFFloat (1));
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
convert (converter)
|
|
1459
|
+
{
|
|
1460
|
+
if (this .use (converter))
|
|
1461
|
+
return;
|
|
1462
|
+
|
|
1463
|
+
// Create nodes.
|
|
1464
|
+
|
|
1465
|
+
const
|
|
1466
|
+
shapeNode = converter .scene .createNode ("Shape"),
|
|
1467
|
+
appearanceNode = converter .scene .createNode ("Appearance"),
|
|
1468
|
+
geometryNode = converter .scene .createNode ("Sphere");
|
|
1469
|
+
|
|
1470
|
+
// Set name.
|
|
1471
|
+
|
|
1472
|
+
if (this .name)
|
|
1473
|
+
converter .scene .updateNamedNode (this .name, shapeNode);
|
|
1474
|
+
|
|
1475
|
+
// Assign values.
|
|
1476
|
+
|
|
1477
|
+
shapeNode .appearance = appearanceNode;
|
|
1478
|
+
shapeNode .geometry = geometryNode;
|
|
1479
|
+
|
|
1480
|
+
appearanceNode .material = converter .materials .at (-1);
|
|
1481
|
+
appearanceNode .texture = converter .textures .at (-1);
|
|
1482
|
+
appearanceNode .textureTransform = converter .textureTransforms .at (-1);
|
|
1483
|
+
|
|
1484
|
+
if (converter .shapeHints .length)
|
|
1485
|
+
geometryNode .solid = converter .shapeHints .at (-1) .solid;
|
|
1486
|
+
|
|
1487
|
+
geometryNode .radius = this .fields .get ("radius");
|
|
1488
|
+
|
|
1489
|
+
if (converter .transforms .length)
|
|
1490
|
+
converter .groups .at (-1) .children .push (shapeNode);
|
|
1491
|
+
else
|
|
1492
|
+
converter .scene .rootNodes .push (shapeNode);
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1496
|
+
;// ./src/nodes/SpotLight.js
|
|
1497
|
+
|
|
1498
|
+
|
|
1499
|
+
class SpotLight extends BaseNode
|
|
1500
|
+
{
|
|
1501
|
+
constructor (X3D, typeName, name)
|
|
1502
|
+
{
|
|
1503
|
+
super (X3D, typeName, name);
|
|
1504
|
+
|
|
1505
|
+
this .fields .set ("on", new X3D .Fields .SFBool (true));
|
|
1506
|
+
this .fields .set ("intensity", new X3D .Fields .SFFloat (1));
|
|
1507
|
+
this .fields .set ("color", new X3D .Fields .SFColor (1, 1, 1));
|
|
1508
|
+
this .fields .set ("location", new X3D .Fields .SFVec3f (0, 0, 1));
|
|
1509
|
+
this .fields .set ("direction", new X3D .Fields .SFVec3f (0, 0, -1));
|
|
1510
|
+
this .fields .set ("dropOffRate", new X3D .Fields .SFFloat ());
|
|
1511
|
+
this .fields .set ("cutOffAngle", new X3D .Fields .SFFloat (0.785398));
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
convert (converter)
|
|
1515
|
+
{
|
|
1516
|
+
if (this .use (converter))
|
|
1517
|
+
return;
|
|
1518
|
+
|
|
1519
|
+
// Create nodes.
|
|
1520
|
+
|
|
1521
|
+
const lightNode = converter .scene .createNode ("SpotLight");
|
|
1522
|
+
|
|
1523
|
+
// Set name.
|
|
1524
|
+
|
|
1525
|
+
if (this .name)
|
|
1526
|
+
converter .scene .updateNamedNode (this .name, lightNode);
|
|
1527
|
+
|
|
1528
|
+
// Assign values.
|
|
1529
|
+
|
|
1530
|
+
lightNode .on = this .fields .get ("on");
|
|
1531
|
+
lightNode .intensity = this .fields .get ("intensity");
|
|
1532
|
+
lightNode .color = this .fields .get ("color");
|
|
1533
|
+
lightNode .location = this .fields .get ("location");
|
|
1534
|
+
lightNode .direction = this .fields .get ("direction");
|
|
1535
|
+
lightNode .cutOffAngle = this .fields .get ("cutOffAngle");
|
|
1536
|
+
|
|
1537
|
+
if (converter .transforms .length)
|
|
1538
|
+
converter .groups .at (-1) .children .push (lightNode);
|
|
1539
|
+
else
|
|
1540
|
+
converter .scene .rootNodes .push (lightNode);
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
;// ./src/nodes/Switch.js
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
class Switch extends BaseNode
|
|
1548
|
+
{
|
|
1549
|
+
constructor (X3D, typeName, name)
|
|
1550
|
+
{
|
|
1551
|
+
super (X3D, typeName, name);
|
|
1552
|
+
|
|
1553
|
+
this .fields .set ("whichChild", new X3D .Fields .SFInt32 (-1));
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
convert (converter)
|
|
1557
|
+
{
|
|
1558
|
+
if (this .use (converter))
|
|
1559
|
+
return;
|
|
1560
|
+
|
|
1561
|
+
// Create Transform node.
|
|
1562
|
+
|
|
1563
|
+
const
|
|
1564
|
+
transformNode = converter .scene .createNode ("Transform"),
|
|
1565
|
+
switchNode = converter .scene .createNode ("Switch");
|
|
1566
|
+
|
|
1567
|
+
// Set values.
|
|
1568
|
+
|
|
1569
|
+
transformNode .children .push (switchNode);
|
|
1570
|
+
|
|
1571
|
+
switchNode .whichChoice = this .fields .get ("whichChild");
|
|
1572
|
+
|
|
1573
|
+
// Add root node if needed or add as child.
|
|
1574
|
+
|
|
1575
|
+
if (converter .transforms .length)
|
|
1576
|
+
converter .groups .at (-1) .children .push (transformNode);
|
|
1577
|
+
else
|
|
1578
|
+
converter .scene .rootNodes .push (transformNode);
|
|
1579
|
+
|
|
1580
|
+
// Set name.
|
|
1581
|
+
|
|
1582
|
+
if (this .name)
|
|
1583
|
+
converter .scene .updateNamedNode (this .name, transformNode);
|
|
1584
|
+
|
|
1585
|
+
// Convert children.
|
|
1586
|
+
|
|
1587
|
+
converter .save ();
|
|
1588
|
+
converter .transforms .push (transformNode);
|
|
1589
|
+
converter .groups .push (switchNode);
|
|
1590
|
+
|
|
1591
|
+
for (const node of this .fields .get ("children"))
|
|
1592
|
+
node .convert (converter);
|
|
1593
|
+
|
|
1594
|
+
converter .restore ();
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
;// ./src/nodes/Text.js
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
class Text extends BaseNode
|
|
1602
|
+
{
|
|
1603
|
+
constructor (X3D, typeName, name)
|
|
1604
|
+
{
|
|
1605
|
+
super (X3D, typeName, name);
|
|
1606
|
+
|
|
1607
|
+
this .fields .set ("string", new X3D .Fields .MFString (""));
|
|
1608
|
+
this .fields .set ("direction", new X3D .Fields .SFString ("LR"));
|
|
1609
|
+
this .fields .set ("justification", new X3D .Fields .SFString ("BEGIN"));
|
|
1610
|
+
this .fields .set ("spacing", new X3D .Fields .SFFloat (1));
|
|
1611
|
+
this .fields .set ("width", new X3D .Fields .MFFloat (0));
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
;// ./src/nodes/TextLanguage.js
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
class TextLanguage extends BaseNode
|
|
1619
|
+
{
|
|
1620
|
+
constructor (X3D, typeName, name)
|
|
1621
|
+
{
|
|
1622
|
+
super (X3D, typeName, name);
|
|
1623
|
+
|
|
1624
|
+
this .fields .set ("textLanguage", new X3D .Fields .SFString ());
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
;// ./src/nodes/Texture2.js
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
class Texture2 extends BaseNode
|
|
1632
|
+
{
|
|
1633
|
+
constructor (X3D, typeName, name)
|
|
1634
|
+
{
|
|
1635
|
+
super (X3D, typeName, name);
|
|
1636
|
+
|
|
1637
|
+
this .fields .set ("filename", new X3D .Fields .SFString ());
|
|
1638
|
+
this .fields .set ("image", new X3D .Fields .SFImage ());
|
|
1639
|
+
this .fields .set ("wrapS", new X3D .Fields .SFString ("REPEAT"));
|
|
1640
|
+
this .fields .set ("wrapT", new X3D .Fields .SFString ("REPEAT"));
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
use (converter)
|
|
1644
|
+
{
|
|
1645
|
+
try
|
|
1646
|
+
{
|
|
1647
|
+
if (!this .name)
|
|
1648
|
+
return false;
|
|
1649
|
+
|
|
1650
|
+
converter .textures .push (converter .scene .getNamedNode (this .name));
|
|
1651
|
+
|
|
1652
|
+
return true;
|
|
1653
|
+
}
|
|
1654
|
+
catch
|
|
1655
|
+
{
|
|
1656
|
+
return false;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
convert (converter)
|
|
1661
|
+
{
|
|
1662
|
+
if (this .use (converter))
|
|
1663
|
+
return;
|
|
1664
|
+
|
|
1665
|
+
if (this .fields .get ("filename") .length)
|
|
1666
|
+
{
|
|
1667
|
+
// Create nodes.
|
|
1668
|
+
|
|
1669
|
+
const textureNode = converter .scene .createNode ("ImageTexture");
|
|
1670
|
+
|
|
1671
|
+
// Set name.
|
|
1672
|
+
|
|
1673
|
+
if (this .name)
|
|
1674
|
+
converter .scene .updateNamedNode (this .name, textureNode);
|
|
1675
|
+
|
|
1676
|
+
// Assign values.
|
|
1677
|
+
|
|
1678
|
+
textureNode .url = [ this .fields .get ("filename") .getValue () ];
|
|
1679
|
+
textureNode .repeatS = this .fields .get ("wrapS") .getValue () !== "CLAMP";
|
|
1680
|
+
textureNode .repeatT = this .fields .get ("wrapT") .getValue () !== "CLAMP";
|
|
1681
|
+
|
|
1682
|
+
converter .textures .push (textureNode);
|
|
1683
|
+
}
|
|
1684
|
+
else
|
|
1685
|
+
{
|
|
1686
|
+
// Create nodes.
|
|
1687
|
+
|
|
1688
|
+
const textureNode = converter .scene .createNode ("PixelTexture");
|
|
1689
|
+
|
|
1690
|
+
// Set name.
|
|
1691
|
+
|
|
1692
|
+
if (this .name)
|
|
1693
|
+
converter .scene .updateNamedNode (this .name, textureNode);
|
|
1694
|
+
|
|
1695
|
+
// Assign values.
|
|
1696
|
+
|
|
1697
|
+
textureNode .image = this .fields .get ("image");
|
|
1698
|
+
textureNode .repeatS = this .fields .get ("wrapS") .getValue () !== "CLAMP";
|
|
1699
|
+
textureNode .repeatT = this .fields .get ("wrapT") .getValue () !== "CLAMP";
|
|
1700
|
+
|
|
1701
|
+
converter .textures .push (textureNode);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1706
|
+
;// ./src/nodes/Texture2Transform.js
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
class Texture2Transform extends BaseNode
|
|
1710
|
+
{
|
|
1711
|
+
constructor (X3D, typeName, name)
|
|
1712
|
+
{
|
|
1713
|
+
super (X3D, typeName, name);
|
|
1714
|
+
|
|
1715
|
+
this .fields .set ("translation", new X3D .Fields .SFVec2f ());
|
|
1716
|
+
this .fields .set ("rotation", new X3D .Fields .SFFloat ());
|
|
1717
|
+
this .fields .set ("scaleFactor", new X3D .Fields .SFVec2f (1, 1));
|
|
1718
|
+
this .fields .set ("center", new X3D .Fields .SFVec2f ());
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
use (converter)
|
|
1722
|
+
{
|
|
1723
|
+
try
|
|
1724
|
+
{
|
|
1725
|
+
if (!this .name)
|
|
1726
|
+
return false;
|
|
1727
|
+
|
|
1728
|
+
converter .textureTransforms .push (converter .scene .getNamedNode (this .name));
|
|
1729
|
+
|
|
1730
|
+
return true;
|
|
1731
|
+
}
|
|
1732
|
+
catch
|
|
1733
|
+
{
|
|
1734
|
+
return false;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
convert (converter)
|
|
1739
|
+
{
|
|
1740
|
+
if (this .use (converter))
|
|
1741
|
+
return;
|
|
1742
|
+
|
|
1743
|
+
// Create nodes.
|
|
1744
|
+
|
|
1745
|
+
const textureTransformNode = converter .scene .createNode ("TextureTransform");
|
|
1746
|
+
|
|
1747
|
+
// Set name.
|
|
1748
|
+
|
|
1749
|
+
if (this .name)
|
|
1750
|
+
converter .scene .updateNamedNode (this .name, textureTransformNode);
|
|
1751
|
+
|
|
1752
|
+
// Assign values.
|
|
1753
|
+
|
|
1754
|
+
textureTransformNode .translation = this .fields .get ("translation");
|
|
1755
|
+
textureTransformNode .rotation = this .fields .get ("rotation");
|
|
1756
|
+
textureTransformNode .scale = this .fields .get ("scaleFactor");
|
|
1757
|
+
textureTransformNode .center = this .fields .get ("center");
|
|
1758
|
+
|
|
1759
|
+
converter .textureTransforms .push (textureTransformNode);
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1763
|
+
;// ./src/nodes/TextureCoordinate2.js
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
class TextureCoordinate2 extends BaseNode
|
|
1767
|
+
{
|
|
1768
|
+
constructor (X3D, typeName, name)
|
|
1769
|
+
{
|
|
1770
|
+
super (X3D, typeName, name);
|
|
1771
|
+
|
|
1772
|
+
this .fields .set ("point", new X3D .Fields .MFVec2f (new X3D .Fields .SFVec2f ()));
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
use (converter)
|
|
1776
|
+
{
|
|
1777
|
+
try
|
|
1778
|
+
{
|
|
1779
|
+
if (!this .name)
|
|
1780
|
+
return false;
|
|
1781
|
+
|
|
1782
|
+
converter .texCoords .push (converter .scene .getNamedNode (this .name));
|
|
1783
|
+
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
catch
|
|
1787
|
+
{
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
convert (converter)
|
|
1793
|
+
{
|
|
1794
|
+
if (this .use (converter))
|
|
1795
|
+
return;
|
|
1796
|
+
|
|
1797
|
+
// Create nodes.
|
|
1798
|
+
|
|
1799
|
+
const texCoordNode = converter .scene .createNode ("TextureCoordinate");
|
|
1800
|
+
|
|
1801
|
+
// Set name.
|
|
1802
|
+
|
|
1803
|
+
if (this .name)
|
|
1804
|
+
converter .scene .updateNamedNode (this .name, texCoordNode);
|
|
1805
|
+
|
|
1806
|
+
// Assign values.
|
|
1807
|
+
|
|
1808
|
+
texCoordNode .point = this .fields .get ("point");
|
|
1809
|
+
|
|
1810
|
+
converter .texCoords .push (texCoordNode);
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
|
|
1814
|
+
;// ./src/nodes/Transform.js
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
class Transform extends BaseNode
|
|
1818
|
+
{
|
|
1819
|
+
constructor (X3D, typeName, name)
|
|
1820
|
+
{
|
|
1821
|
+
super (X3D, typeName, name);
|
|
1822
|
+
|
|
1823
|
+
this .fields .set ("translation", new X3D .Fields .SFVec3f ());
|
|
1824
|
+
this .fields .set ("rotation", new X3D .Fields .SFRotation ());
|
|
1825
|
+
this .fields .set ("scaleFactor", new X3D .Fields .SFVec3f (1, 1, 1));
|
|
1826
|
+
this .fields .set ("scaleOrientation", new X3D .Fields .SFRotation ());
|
|
1827
|
+
this .fields .set ("center", new X3D .Fields .SFVec3f ());
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
convert (converter)
|
|
1831
|
+
{
|
|
1832
|
+
const transform = converter .transforms .at (-1);
|
|
1833
|
+
|
|
1834
|
+
if (!transform)
|
|
1835
|
+
return;
|
|
1836
|
+
|
|
1837
|
+
const { X3D } = this;
|
|
1838
|
+
|
|
1839
|
+
let matrix = new X3D .Fields .SFMatrix4f ();
|
|
1840
|
+
|
|
1841
|
+
matrix .setTransform (transform .translation,
|
|
1842
|
+
transform .rotation,
|
|
1843
|
+
transform .scale,
|
|
1844
|
+
transform .scaleOrientation,
|
|
1845
|
+
transform .center);
|
|
1846
|
+
|
|
1847
|
+
let m = new X3D .Fields .SFMatrix4f ();
|
|
1848
|
+
|
|
1849
|
+
m .setTransform (this .fields .get ("translation"),
|
|
1850
|
+
this .fields .get ("rotation"),
|
|
1851
|
+
this .fields .get ("scale"),
|
|
1852
|
+
this .fields .get ("scaleOrientation"),
|
|
1853
|
+
this .fields .get ("center"));
|
|
1854
|
+
|
|
1855
|
+
matrix = matrix .multLeft (m);
|
|
1856
|
+
|
|
1857
|
+
matrix .getTransform (transform .translation,
|
|
1858
|
+
transform .rotation,
|
|
1859
|
+
transform .scale,
|
|
1860
|
+
transform .scaleOrientation,
|
|
1861
|
+
transform .center);
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
;// ./src/nodes/Translation.js
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
class Translation extends BaseNode
|
|
1869
|
+
{
|
|
1870
|
+
constructor (X3D, typeName, name)
|
|
1871
|
+
{
|
|
1872
|
+
super (X3D, typeName, name);
|
|
1873
|
+
|
|
1874
|
+
this .fields .set ("translation", new X3D .Fields .SFVec3f ());
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
convert (converter)
|
|
1878
|
+
{
|
|
1879
|
+
const transform = converter .transforms .at (-1);
|
|
1880
|
+
|
|
1881
|
+
if (!transform)
|
|
1882
|
+
return;
|
|
1883
|
+
|
|
1884
|
+
const { X3D } = this;
|
|
1885
|
+
|
|
1886
|
+
let matrix = new X3D .Fields .SFMatrix4f ();
|
|
1887
|
+
|
|
1888
|
+
matrix .setTransform (transform .translation,
|
|
1889
|
+
transform .rotation,
|
|
1890
|
+
transform .scale,
|
|
1891
|
+
transform .scaleOrientation,
|
|
1892
|
+
transform .center);
|
|
1893
|
+
|
|
1894
|
+
matrix = matrix .translate (this .fields .get ("translation"));
|
|
1895
|
+
|
|
1896
|
+
matrix .getTransform (transform .translation,
|
|
1897
|
+
transform .rotation,
|
|
1898
|
+
transform .scale,
|
|
1899
|
+
transform .scaleOrientation,
|
|
1900
|
+
transform .center);
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1904
|
+
;// ./src/nodes/WWWAnchor.js
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
class WWWAnchor extends BaseNode
|
|
1908
|
+
{
|
|
1909
|
+
constructor (X3D, typeName, name)
|
|
1910
|
+
{
|
|
1911
|
+
super (X3D, typeName, name);
|
|
1912
|
+
|
|
1913
|
+
this .fields .set ("name", new X3D .Fields .MFString ());
|
|
1914
|
+
this .fields .set ("description", new X3D .Fields .SFString (""));
|
|
1915
|
+
this .fields .set ("map", new X3D .Fields .SFString ("NONE"));
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
convert (converter)
|
|
1919
|
+
{
|
|
1920
|
+
if (this .use (converter))
|
|
1921
|
+
return;
|
|
1922
|
+
|
|
1923
|
+
// Create Transform node.
|
|
1924
|
+
|
|
1925
|
+
const
|
|
1926
|
+
transformNode = converter .scene .createNode ("Transform"),
|
|
1927
|
+
anchorNode = converter .scene .createNode ("Anchor");
|
|
1928
|
+
|
|
1929
|
+
// Set values.
|
|
1930
|
+
|
|
1931
|
+
transformNode .children .push (anchorNode);
|
|
1932
|
+
|
|
1933
|
+
anchorNode .url = this .fields .get ("name");
|
|
1934
|
+
anchorNode .description = this .fields .get ("description");
|
|
1935
|
+
|
|
1936
|
+
// Add root node if needed or add as child.
|
|
1937
|
+
|
|
1938
|
+
if (converter .transforms .length)
|
|
1939
|
+
converter .groups .at (-1) .children .push (transformNode);
|
|
1940
|
+
else
|
|
1941
|
+
converter .scene .rootNodes .push (transformNode);
|
|
1942
|
+
|
|
1943
|
+
// Set name.
|
|
1944
|
+
|
|
1945
|
+
if (this .name)
|
|
1946
|
+
converter .scene .updateNamedNode (this .name, transformNode);
|
|
1947
|
+
|
|
1948
|
+
// Convert children.
|
|
1949
|
+
|
|
1950
|
+
converter .save ();
|
|
1951
|
+
converter .transforms .push (transformNode);
|
|
1952
|
+
converter .groups .push (anchorNode);
|
|
1953
|
+
|
|
1954
|
+
for (const node of this .fields .get ("children"))
|
|
1955
|
+
node .convert (converter);
|
|
1956
|
+
|
|
1957
|
+
converter .restore ();
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
;// ./src/nodes/WWWInline.js
|
|
1962
|
+
|
|
1963
|
+
|
|
1964
|
+
class WWWInline extends BaseNode
|
|
1965
|
+
{
|
|
1966
|
+
constructor (X3D, typeName, name)
|
|
1967
|
+
{
|
|
1968
|
+
super (X3D, typeName, name);
|
|
1969
|
+
|
|
1970
|
+
this .fields .set ("name", new X3D .Fields .MFString ());
|
|
1971
|
+
this .fields .set ("bboxSize", new X3D .Fields .SFVec3f (-1, -1, -1));
|
|
1972
|
+
this .fields .set ("bboxCenter", new X3D .Fields .SFVec3f ());
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
convert (converter)
|
|
1976
|
+
{
|
|
1977
|
+
if (this .use (converter))
|
|
1978
|
+
return;
|
|
1979
|
+
|
|
1980
|
+
// Create nodes.
|
|
1981
|
+
|
|
1982
|
+
const inlineNode = converter .scene .createNode ("Inline");
|
|
1983
|
+
|
|
1984
|
+
// Set name.
|
|
1985
|
+
|
|
1986
|
+
if (this .name)
|
|
1987
|
+
converter .scene .updateNamedNode (this .name, inlineNode);
|
|
1988
|
+
|
|
1989
|
+
// Assign values.
|
|
1990
|
+
|
|
1991
|
+
inlineNode .url = this .fields .get ("name");
|
|
1992
|
+
|
|
1993
|
+
if (converter .transforms .length)
|
|
1994
|
+
converter .groups .at (-1) .children .push (inlineNode);
|
|
1995
|
+
else
|
|
1996
|
+
converter .scene .rootNodes .push (inlineNode);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
;// ./src/nodes/WorldInfo.js
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
class WorldInfo extends BaseNode
|
|
2004
|
+
{
|
|
2005
|
+
constructor (X3D, typeName, name)
|
|
2006
|
+
{
|
|
2007
|
+
super (X3D, typeName, name);
|
|
2008
|
+
|
|
2009
|
+
this .fields .set ("title", new X3D .Fields .SFString ());
|
|
2010
|
+
this .fields .set ("info", new X3D .Fields .MFString ());
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
convert (converter)
|
|
2014
|
+
{
|
|
2015
|
+
if (this .use (converter))
|
|
2016
|
+
return;
|
|
2017
|
+
|
|
2018
|
+
// Create nodes.
|
|
2019
|
+
|
|
2020
|
+
const infoNode = converter .scene .createNode ("WorldInfo");
|
|
2021
|
+
|
|
2022
|
+
// Set name.
|
|
2023
|
+
|
|
2024
|
+
if (this .name)
|
|
2025
|
+
converter .scene .updateNamedNode (this .name, infoNode);
|
|
2026
|
+
|
|
2027
|
+
// Assign values.
|
|
2028
|
+
|
|
2029
|
+
infoNode .title = this .fields .get ("title");
|
|
2030
|
+
infoNode .info = this .fields .get ("info");
|
|
2031
|
+
|
|
2032
|
+
if (converter .transforms .length)
|
|
2033
|
+
converter .groups .at (-1) .children .push (infoNode);
|
|
2034
|
+
else
|
|
2035
|
+
converter .scene .rootNodes .push (infoNode);
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
|
|
2039
|
+
;// ./src/Converter.js
|
|
2040
|
+
class Converter
|
|
2041
|
+
{
|
|
2042
|
+
transforms = [ ];
|
|
2043
|
+
groups = [ ];
|
|
2044
|
+
materials = [ ];
|
|
2045
|
+
textures = [ null ];
|
|
2046
|
+
textureTransforms = [ null ];
|
|
2047
|
+
texCoords = [ null ];
|
|
2048
|
+
normals = [ null ];
|
|
2049
|
+
coords = [ null ];
|
|
2050
|
+
|
|
2051
|
+
shapeHints = [ ];
|
|
2052
|
+
materialBindings = [ ];
|
|
2053
|
+
normalBindings = [ ];
|
|
2054
|
+
|
|
2055
|
+
// Private properties
|
|
2056
|
+
|
|
2057
|
+
#transformsSize = [ ];
|
|
2058
|
+
#groupsSize = [ ];
|
|
2059
|
+
#materialsSize = [ ];
|
|
2060
|
+
#texturesSize = [ ];
|
|
2061
|
+
#textureTransformsSize = [ ];
|
|
2062
|
+
#texCoordsSize = [ ];
|
|
2063
|
+
#normalsSize = [ ];
|
|
2064
|
+
#coordsSize = [ ];
|
|
2065
|
+
|
|
2066
|
+
#shapeHintsSize = [ ];
|
|
2067
|
+
#materialBindingsSize = [ ];
|
|
2068
|
+
#normalBindingsSize = [ ];
|
|
2069
|
+
|
|
2070
|
+
constructor (scene)
|
|
2071
|
+
{
|
|
2072
|
+
this .scene = scene;
|
|
2073
|
+
|
|
2074
|
+
this .materials .push (scene .createNode ("Material"));
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
save ()
|
|
2078
|
+
{
|
|
2079
|
+
this .#transformsSize .push (this .transforms .length);
|
|
2080
|
+
this .#groupsSize .push (this .groups .length);
|
|
2081
|
+
this .#materialsSize .push (this .materials .length);
|
|
2082
|
+
this .#texturesSize .push (this .textures .length);
|
|
2083
|
+
this .#textureTransformsSize .push (this .textureTransforms .length);
|
|
2084
|
+
this .#texCoordsSize .push (this .texCoords .length);
|
|
2085
|
+
this .#normalsSize .push (this .normals .length);
|
|
2086
|
+
this .#coordsSize .push (this .coords .length);
|
|
2087
|
+
this .#shapeHintsSize .push (this .shapeHints .length);
|
|
2088
|
+
this .#materialBindingsSize .push (this .materialBindings .length);
|
|
2089
|
+
this .#normalBindingsSize .push (this .normalBindings .length);
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
restore ()
|
|
2093
|
+
{
|
|
2094
|
+
this .transforms .length = this .#transformsSize .at (-1);
|
|
2095
|
+
this .groups .length = this .#groupsSize .at (-1);
|
|
2096
|
+
this .materials .length = this .#materialsSize .at (-1);
|
|
2097
|
+
this .textures .length = this .#texturesSize .at (-1);
|
|
2098
|
+
this .textureTransforms .length = this .#textureTransformsSize .at (-1);
|
|
2099
|
+
this .texCoords .length = this .#texCoordsSize .at (-1);
|
|
2100
|
+
this .normals .length = this .#normalsSize .at (-1);
|
|
2101
|
+
this .coords .length = this .#coordsSize .at (-1);
|
|
2102
|
+
this .shapeHints .length = this .#shapeHintsSize .at (-1);
|
|
2103
|
+
this .materialBindings .length = this .#materialBindingsSize .at (-1);
|
|
2104
|
+
this .normalBindings .length = this .#normalBindingsSize .at (-1);
|
|
2105
|
+
|
|
2106
|
+
this .#transformsSize .pop ();
|
|
2107
|
+
this .#groupsSize .pop ();
|
|
2108
|
+
this .#materialsSize .pop ();
|
|
2109
|
+
this .#texturesSize .pop ();
|
|
2110
|
+
this .#textureTransformsSize .pop ();
|
|
2111
|
+
this .#texCoordsSize .pop ();
|
|
2112
|
+
this .#normalsSize .pop ();
|
|
2113
|
+
this .#coordsSize .pop ();
|
|
2114
|
+
this .#shapeHintsSize .pop ();
|
|
2115
|
+
this .#materialBindingsSize .pop ();
|
|
2116
|
+
this .#normalBindingsSize .pop ();
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
;// ./src/x_ite-vrml1-parser.js
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
|
|
2135
|
+
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
|
|
2151
|
+
|
|
2152
|
+
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
|
|
2160
|
+
|
|
2161
|
+
|
|
2162
|
+
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
__webpack_exports__default (X3D =>
|
|
2172
|
+
{
|
|
2173
|
+
/*
|
|
2174
|
+
* Grammar
|
|
2175
|
+
*/
|
|
2176
|
+
|
|
2177
|
+
// VRML lexical elements
|
|
2178
|
+
const Grammar = X3D .Expressions ({
|
|
2179
|
+
// General
|
|
2180
|
+
Whitespaces: /[\x20\n,\t\r]+/y,
|
|
2181
|
+
Comment: /#\/\*.*?\*\/#|#[^\r\n]*(?=[\r\n]|$)/sy,
|
|
2182
|
+
LineFeed: /\n/g,
|
|
2183
|
+
|
|
2184
|
+
// Keywords
|
|
2185
|
+
DEF: /DEF/y,
|
|
2186
|
+
fields: /fields/y,
|
|
2187
|
+
NULL: /NULL/y,
|
|
2188
|
+
USE: /USE/y,
|
|
2189
|
+
|
|
2190
|
+
// Terminal symbols
|
|
2191
|
+
OpenBrace: /\{/y,
|
|
2192
|
+
CloseBrace: /\}/y,
|
|
2193
|
+
OpenBracket: /\[/y,
|
|
2194
|
+
CloseBracket: /\]/y,
|
|
2195
|
+
Period: /\./y,
|
|
2196
|
+
Colon: /:/y,
|
|
2197
|
+
VerticalBar: /\|/y,
|
|
2198
|
+
|
|
2199
|
+
// eslint-disable-next-line no-control-regex
|
|
2200
|
+
Id: /[^\x30-\x39\x00-\x20\x22\x23\x27\x2b\x2c\x2d\x2e\x5b\x5c\x5d\x7b\x7d\x7f]{1}[^\x00-\x20\x22\x23\x27\x2c\x2e\x5b\x5c\x5d\x7b\x7d\x7f]*/y,
|
|
2201
|
+
// eslint-disable-next-line no-control-regex
|
|
2202
|
+
ComponentNameId: /[^\x30-\x39\x00-\x20\x22\x23\x27\x2b\x2c\x2d\x2e\x5b\x5c\x5d\x7b\x7d\x7f\x3a]{1}[^\x00-\x20\x22\x23\x27\x2c\x2e\x5b\x5c\x5d\x7b\x7d\x7f\x3a]*/y,
|
|
2203
|
+
|
|
2204
|
+
// Values
|
|
2205
|
+
int32: /(?:0[xX][\da-fA-F]+)|(?:[+-]?\d+)/y,
|
|
2206
|
+
double: /(?!0[xX])[+-]?(?:(?:(?:\d*\.\d+)|(?:\d+(?:\.)?))(?:[eE][+-]?\d+)?)/y,
|
|
2207
|
+
});
|
|
2208
|
+
|
|
2209
|
+
return class VRML1Parser extends X3D .X3DParser
|
|
2210
|
+
{
|
|
2211
|
+
static {
|
|
2212
|
+
X3D .GoldenGate .addParsers (this);
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
static nodes = new Map ([
|
|
2216
|
+
["AsciiText", AsciiText],
|
|
2217
|
+
["Background", Background],
|
|
2218
|
+
["CollideStyle", CollideStyle],
|
|
2219
|
+
["Cone", Cone],
|
|
2220
|
+
["Coordinate3", Coordinate3],
|
|
2221
|
+
["Cube", Cube],
|
|
2222
|
+
["Cylinder", Cylinder],
|
|
2223
|
+
["DirectedSound", DirectedSound],
|
|
2224
|
+
["DirectionalLight", DirectionalLight],
|
|
2225
|
+
["ElevationGrid", ElevationGrid],
|
|
2226
|
+
["Environment", Environment],
|
|
2227
|
+
["FontStyle", FontStyle],
|
|
2228
|
+
["GeneralCylinder", GeneralCylinder],
|
|
2229
|
+
["Group", Separator],
|
|
2230
|
+
["IndexedFaceSet", IndexedFaceSet],
|
|
2231
|
+
["IndexedLineSet", IndexedLineSet],
|
|
2232
|
+
["Info", Info],
|
|
2233
|
+
["LOD", LOD],
|
|
2234
|
+
["Material", Material],
|
|
2235
|
+
["MaterialBinding", MaterialBinding],
|
|
2236
|
+
["MatrixTransform", MatrixTransform],
|
|
2237
|
+
["NavigationInfo", NavigationInfo],
|
|
2238
|
+
["Normal", Normal],
|
|
2239
|
+
["NormalBinding", NormalBinding],
|
|
2240
|
+
["OrthographicCamera", OrthographicCamera],
|
|
2241
|
+
["PerspectiveCamera", PerspectiveCamera],
|
|
2242
|
+
["PointLight", PointLight],
|
|
2243
|
+
["PointSet", PointSet],
|
|
2244
|
+
["PointSound", PointSound],
|
|
2245
|
+
["Rotation", Rotation],
|
|
2246
|
+
["Scale", Scale],
|
|
2247
|
+
["Separator", Separator_Separator],
|
|
2248
|
+
["ShapeHints", ShapeHints],
|
|
2249
|
+
["Sphere", Sphere],
|
|
2250
|
+
["SpotLight", SpotLight],
|
|
2251
|
+
["Switch", Switch],
|
|
2252
|
+
["Text", Text],
|
|
2253
|
+
["TextLanguage", TextLanguage],
|
|
2254
|
+
["Texture2", Texture2],
|
|
2255
|
+
["Texture2Transform", Texture2Transform],
|
|
2256
|
+
["TextureCoordinate2", TextureCoordinate2],
|
|
2257
|
+
["Transform", Transform],
|
|
2258
|
+
["Translation", Translation],
|
|
2259
|
+
["WWWAnchor", WWWAnchor],
|
|
2260
|
+
["WWWInline", WWWInline],
|
|
2261
|
+
["WorldInfo", WorldInfo],
|
|
2262
|
+
]);
|
|
2263
|
+
|
|
2264
|
+
static substitutions = new Map ([
|
|
2265
|
+
["SFBitMask", "SFString"],
|
|
2266
|
+
["SFEnum", "SFString"],
|
|
2267
|
+
["SFLong", "SFInt32"],
|
|
2268
|
+
["SFMatrix", "SFMatrix4f"],
|
|
2269
|
+
["MFBitMask", "MFString"],
|
|
2270
|
+
["MFEnum", "MFString"],
|
|
2271
|
+
["MFLong", "MFInt32"],
|
|
2272
|
+
["MFMatrix", "MFMatrix4f"],
|
|
2273
|
+
]);
|
|
2274
|
+
|
|
2275
|
+
getEncoding ()
|
|
2276
|
+
{
|
|
2277
|
+
return "STRING";
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
setInput (input)
|
|
2281
|
+
{
|
|
2282
|
+
this .input = input;
|
|
2283
|
+
this .lineNumber = 0;
|
|
2284
|
+
this .lastIndex = 0;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
isValid ()
|
|
2288
|
+
{
|
|
2289
|
+
return this .input .match (/^#VRML V1.0/);
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
parseIntoScene (resolve, reject)
|
|
2293
|
+
{
|
|
2294
|
+
this .parser = new X3D .VRMLParser (this .getScene ());
|
|
2295
|
+
this .namedNodes = new Map ();
|
|
2296
|
+
this .rootNodes = [ ];
|
|
2297
|
+
|
|
2298
|
+
this .parser [X3D .X3DConstants .SFNode] = this [X3D .X3DConstants .SFNode];
|
|
2299
|
+
this .parser [X3D .X3DConstants .SFString] = this [X3D .X3DConstants .SFString];
|
|
2300
|
+
|
|
2301
|
+
this .parser .pushExecutionContext (this .getScene ());
|
|
2302
|
+
this .parser .setInput (this .input);
|
|
2303
|
+
|
|
2304
|
+
this .vrml1 ()
|
|
2305
|
+
.then (resolve)
|
|
2306
|
+
.catch (reject);
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
static components = [
|
|
2310
|
+
"EnvironmentalSensor",
|
|
2311
|
+
"PointingDeviceSensor",
|
|
2312
|
+
"Scripting",
|
|
2313
|
+
"Sound",
|
|
2314
|
+
"Text",
|
|
2315
|
+
];
|
|
2316
|
+
|
|
2317
|
+
async vrml1 ()
|
|
2318
|
+
{
|
|
2319
|
+
const
|
|
2320
|
+
browser = this .getBrowser (),
|
|
2321
|
+
scene = this .getScene ();
|
|
2322
|
+
|
|
2323
|
+
// Parse input.
|
|
2324
|
+
|
|
2325
|
+
this .vrmlScene ();
|
|
2326
|
+
|
|
2327
|
+
// Convert and create scene.
|
|
2328
|
+
|
|
2329
|
+
scene .setEncoding ("VRML");
|
|
2330
|
+
scene .setProfile (browser .getProfile ("Interchange"));
|
|
2331
|
+
|
|
2332
|
+
for (const componentName of VRML1Parser .components)
|
|
2333
|
+
scene .updateComponent (browser .getComponent (componentName));
|
|
2334
|
+
|
|
2335
|
+
await this .loadComponents ();
|
|
2336
|
+
|
|
2337
|
+
this .convert ();
|
|
2338
|
+
|
|
2339
|
+
// // Optimize scene.
|
|
2340
|
+
|
|
2341
|
+
// const optimizer = new X3D .X3DOptimizer ();
|
|
2342
|
+
|
|
2343
|
+
// optimizer .removeEmptyGroups = true;
|
|
2344
|
+
// optimizer .combineGroupingNodes = true;
|
|
2345
|
+
// optimizer .optimizeInterpolators = true;
|
|
2346
|
+
|
|
2347
|
+
// optimizer .optimizeSceneGraph (scene .rootNodes);
|
|
2348
|
+
|
|
2349
|
+
// console .log (scene .toVRMLString ());
|
|
2350
|
+
|
|
2351
|
+
return scene;
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
convert ()
|
|
2355
|
+
{
|
|
2356
|
+
const converter = new Converter (this .getScene ());
|
|
2357
|
+
|
|
2358
|
+
for (const node of this .rootNodes)
|
|
2359
|
+
node .convert (converter);
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
vrmlScene ()
|
|
2363
|
+
{
|
|
2364
|
+
this .statements ();
|
|
2365
|
+
|
|
2366
|
+
if (this .lastIndex < this .input .length)
|
|
2367
|
+
throw new Error ("Unknown statement.");
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
comments ()
|
|
2371
|
+
{
|
|
2372
|
+
while (this .comment ())
|
|
2373
|
+
;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
comment ()
|
|
2377
|
+
{
|
|
2378
|
+
if (this .whitespaces ())
|
|
2379
|
+
return true;
|
|
2380
|
+
|
|
2381
|
+
return Grammar .Comment .parse (this);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
whitespaces ()
|
|
2385
|
+
{
|
|
2386
|
+
if (Grammar .Whitespaces .parse (this))
|
|
2387
|
+
{
|
|
2388
|
+
this .lines (this .result [0]);
|
|
2389
|
+
|
|
2390
|
+
return true;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
return false;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
lines (string)
|
|
2397
|
+
{
|
|
2398
|
+
const match = string .match (Grammar .LineFeed);
|
|
2399
|
+
|
|
2400
|
+
if (match)
|
|
2401
|
+
this .lineNumber += match .length;
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
statements ()
|
|
2405
|
+
{
|
|
2406
|
+
while (this .statement ())
|
|
2407
|
+
;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
statement ()
|
|
2411
|
+
{
|
|
2412
|
+
const node = this .nodeStatement ();
|
|
2413
|
+
|
|
2414
|
+
if (node)
|
|
2415
|
+
{
|
|
2416
|
+
this .rootNodes .push (node);
|
|
2417
|
+
return true;
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
return false;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
nodeStatement ()
|
|
2424
|
+
{
|
|
2425
|
+
this .comments ();
|
|
2426
|
+
|
|
2427
|
+
if (Grammar .DEF .parse (this))
|
|
2428
|
+
{
|
|
2429
|
+
if (this .Id ())
|
|
2430
|
+
return this .node (this .result [0]);
|
|
2431
|
+
|
|
2432
|
+
throw new Error ("No name given after DEF.");
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
if (Grammar .USE .parse (this))
|
|
2436
|
+
{
|
|
2437
|
+
if (this .Id ())
|
|
2438
|
+
{
|
|
2439
|
+
const nodeNameId = this .result [0];
|
|
2440
|
+
|
|
2441
|
+
return this .namedNodes .get (nodeNameId);
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
throw new Error ("No name given after USE.");
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
if (Grammar .NULL .parse (this))
|
|
2448
|
+
return null;
|
|
2449
|
+
|
|
2450
|
+
return this .node ("");
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
node (nodeNameId)
|
|
2454
|
+
{
|
|
2455
|
+
const { lastIndex, lineNumber } = this;
|
|
2456
|
+
|
|
2457
|
+
if (this .Id ())
|
|
2458
|
+
{
|
|
2459
|
+
const nodeTypeId = this .result [0];
|
|
2460
|
+
|
|
2461
|
+
this .comments ();
|
|
2462
|
+
|
|
2463
|
+
if (Grammar .OpenBrace .parse (this))
|
|
2464
|
+
{
|
|
2465
|
+
// console .log (nodeTypeId);
|
|
2466
|
+
|
|
2467
|
+
const
|
|
2468
|
+
nodeType = VRML1Parser .nodes .get (nodeTypeId) ?? CustomNode,
|
|
2469
|
+
node = new nodeType (X3D, nodeTypeId, nodeNameId);
|
|
2470
|
+
|
|
2471
|
+
if (nodeNameId)
|
|
2472
|
+
this .namedNodes .set (nodeNameId, node);
|
|
2473
|
+
|
|
2474
|
+
if (nodeType === CustomNode)
|
|
2475
|
+
this .fieldElements (node);
|
|
2476
|
+
|
|
2477
|
+
this .nodeBody (node);
|
|
2478
|
+
|
|
2479
|
+
this .comments ();
|
|
2480
|
+
|
|
2481
|
+
if (Grammar .CloseBrace .parse (this))
|
|
2482
|
+
return node;
|
|
2483
|
+
|
|
2484
|
+
throw new Error ("Expected '}' at the end of node body.");
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
this .lastIndex = lastIndex;
|
|
2488
|
+
this .lineNumber = lineNumber;
|
|
2489
|
+
|
|
2490
|
+
return false;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
return false;
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
nodeBody (node)
|
|
2497
|
+
{
|
|
2498
|
+
while (this .nodeBodyElement (node))
|
|
2499
|
+
;
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
nodeBodyElement (node)
|
|
2503
|
+
{
|
|
2504
|
+
const child = this .nodeStatement ();
|
|
2505
|
+
|
|
2506
|
+
if (child)
|
|
2507
|
+
{
|
|
2508
|
+
node .fields .get ("children") .push (child);
|
|
2509
|
+
return true;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
if (this .Id ())
|
|
2513
|
+
{
|
|
2514
|
+
const
|
|
2515
|
+
fieldId = this .result [0],
|
|
2516
|
+
field = node .fields .get (fieldId);
|
|
2517
|
+
|
|
2518
|
+
if (!field)
|
|
2519
|
+
throw new Error (`Unknown field '${fieldId}' in class '${node .typeName}'.`);
|
|
2520
|
+
|
|
2521
|
+
if (field .isInitializable ())
|
|
2522
|
+
{
|
|
2523
|
+
if (this .fieldValue (field))
|
|
2524
|
+
return true;
|
|
2525
|
+
|
|
2526
|
+
throw new Error (`Couldn't read value for field '${fieldId}' of node ${node .typeName}.`);
|
|
2527
|
+
}
|
|
2528
|
+
|
|
2529
|
+
throw new Error (`Couldn't assign value to field '${fieldId}'.`);
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
return false;
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
fieldElements (node)
|
|
2536
|
+
{
|
|
2537
|
+
this .comments ();
|
|
2538
|
+
|
|
2539
|
+
if (Grammar .fields .parse (this))
|
|
2540
|
+
{
|
|
2541
|
+
this .comments ();
|
|
2542
|
+
|
|
2543
|
+
if (Grammar .OpenBracket .parse (this))
|
|
2544
|
+
{
|
|
2545
|
+
while (this .fieldElement (node))
|
|
2546
|
+
;
|
|
2547
|
+
|
|
2548
|
+
if (Grammar .CloseBracket .parse (this))
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
throw new Error ("Couldn't parse custom fields.");
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
fieldElement (node)
|
|
2557
|
+
{
|
|
2558
|
+
this .comments ();
|
|
2559
|
+
|
|
2560
|
+
if (this .Id ())
|
|
2561
|
+
{
|
|
2562
|
+
const fieldType = VRML1Parser .substitutions .get (this .result [0])
|
|
2563
|
+
?? this .result [0];
|
|
2564
|
+
|
|
2565
|
+
this .comments ();
|
|
2566
|
+
|
|
2567
|
+
if (this .Id ())
|
|
2568
|
+
{
|
|
2569
|
+
const
|
|
2570
|
+
fieldName = this .result [0],
|
|
2571
|
+
field = new (this .getBrowser () .getFieldType (fieldType)) ();
|
|
2572
|
+
|
|
2573
|
+
node .fields .set (fieldName, field);
|
|
2574
|
+
|
|
2575
|
+
return true;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
return false;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
fieldValue (field)
|
|
2583
|
+
{
|
|
2584
|
+
this .parser .lineNumber = this .lineNumber;
|
|
2585
|
+
this .parser .lastIndex = this .lastIndex;
|
|
2586
|
+
|
|
2587
|
+
const result = this .parser [field .getType ()] (field, field .getUnit ());
|
|
2588
|
+
|
|
2589
|
+
this .lineNumber = this .parser .lineNumber;
|
|
2590
|
+
this .lastIndex = this .parser .lastIndex;
|
|
2591
|
+
|
|
2592
|
+
return result;
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
Id ()
|
|
2596
|
+
{
|
|
2597
|
+
this .comments ();
|
|
2598
|
+
|
|
2599
|
+
return Grammar .Id .parse (this);
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
[X3D .X3DConstants .SFNode] ()
|
|
2603
|
+
{
|
|
2604
|
+
return false;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
[X3D .X3DConstants .SFString] (field)
|
|
2608
|
+
{
|
|
2609
|
+
if (X3D .VRMLParser .prototype .sfstringValue .call (this, field))
|
|
2610
|
+
return true;
|
|
2611
|
+
|
|
2612
|
+
// Parse SFEnum and SFBitMask
|
|
2613
|
+
|
|
2614
|
+
field .setValue ("");
|
|
2615
|
+
|
|
2616
|
+
this .comments ();
|
|
2617
|
+
|
|
2618
|
+
while (this .Id ())
|
|
2619
|
+
{
|
|
2620
|
+
field .setValue (field .getValue () + this .result [0]);
|
|
2621
|
+
|
|
2622
|
+
this .comments ();
|
|
2623
|
+
|
|
2624
|
+
if (Grammar .VerticalBar .parse (this))
|
|
2625
|
+
{
|
|
2626
|
+
field .setValue (field .getValue () + "|");
|
|
2627
|
+
|
|
2628
|
+
this .comments ();
|
|
2629
|
+
continue;
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
return true;
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
return false;
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
});
|
|
2639
|
+
|
|
2640
|
+
/******/ })()
|
|
2641
|
+
;
|