x_ite-off-parser 1.0.4 → 1.0.5
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 +2 -2
- package/dist/x_ite-off-parser.js +49 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ Include the script after X_ITE:
|
|
|
13
13
|
|
|
14
14
|
```html
|
|
15
15
|
<script defer src="https://cdn.jsdelivr.net/npm/x_ite@15.0.3/dist/x_ite.min.js"></script>
|
|
16
|
-
<script defer src="https://cdn.jsdelivr.net/npm/x_ite-off-parser@1.0.
|
|
16
|
+
<script defer src="https://cdn.jsdelivr.net/npm/x_ite-off-parser@1.0.5/dist/x_ite-off-parser.min.js"></script>
|
|
17
17
|
<!-- or as ES module -->
|
|
18
18
|
<script type="module" src="https://cdn.jsdelivr.net/npm/x_ite@15.0.3/dist/x_ite.min.mjs"></script>
|
|
19
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/x_ite-off-parser@1.0.
|
|
19
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/x_ite-off-parser@1.0.5/dist/x_ite-off-parser.min.js"></script>
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Now you can load OFF files:
|
package/dist/x_ite-off-parser.js
CHANGED
|
@@ -28,6 +28,7 @@ class OffParser extends X3D .X3DParser
|
|
|
28
28
|
{
|
|
29
29
|
super (scene);
|
|
30
30
|
|
|
31
|
+
this .lineNumber = 1;
|
|
31
32
|
this .coordIndex = [ ];
|
|
32
33
|
this .colors = [ ];
|
|
33
34
|
this .points = [ ];
|
|
@@ -62,7 +63,7 @@ class OffParser extends X3D .X3DParser
|
|
|
62
63
|
scene = this .getScene ();
|
|
63
64
|
|
|
64
65
|
if (!this .statements ())
|
|
65
|
-
throw new Error (
|
|
66
|
+
throw new Error (`Couldn't parse OFF file: Invalid file structure at line ${this .lineNumber}.`);
|
|
66
67
|
|
|
67
68
|
scene .setEncoding ("OFF");
|
|
68
69
|
scene .setProfile (browser .getProfile ("Interchange"));
|
|
@@ -78,7 +79,7 @@ class OffParser extends X3D .X3DParser
|
|
|
78
79
|
geometry = scene .createNode ("IndexedFaceSet"),
|
|
79
80
|
coordinate = scene .createNode ("Coordinate");
|
|
80
81
|
|
|
81
|
-
if (this .colors .length)
|
|
82
|
+
if (this .colors .length / 3 === this .numFaces)
|
|
82
83
|
{
|
|
83
84
|
const color = scene .createNode ("Color");
|
|
84
85
|
|
|
@@ -117,32 +118,6 @@ class OffParser extends X3D .X3DParser
|
|
|
117
118
|
return false;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
comments ()
|
|
121
|
-
{
|
|
122
|
-
while (this .comment ())
|
|
123
|
-
;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
comment ()
|
|
127
|
-
{
|
|
128
|
-
this .whitespaces ();
|
|
129
|
-
|
|
130
|
-
if (Grammar .comment .parse (this))
|
|
131
|
-
return true;
|
|
132
|
-
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
whitespaces ()
|
|
137
|
-
{
|
|
138
|
-
Grammar .whitespaces .parse (this);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
whitespacesNoLineTerminator ()
|
|
142
|
-
{
|
|
143
|
-
Grammar .whitespacesNoLineTerminator .parse (this);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
121
|
header ()
|
|
147
122
|
{
|
|
148
123
|
return Grammar .header .parse (this);
|
|
@@ -193,7 +168,8 @@ class OffParser extends X3D .X3DParser
|
|
|
193
168
|
if (this .double ())
|
|
194
169
|
{
|
|
195
170
|
points .push (this .value);
|
|
196
|
-
|
|
171
|
+
|
|
172
|
+
this .untilEndOfLine ();
|
|
197
173
|
continue;
|
|
198
174
|
}
|
|
199
175
|
}
|
|
@@ -235,18 +211,18 @@ class OffParser extends X3D .X3DParser
|
|
|
235
211
|
|
|
236
212
|
if (this .int32 ())
|
|
237
213
|
{
|
|
238
|
-
|
|
214
|
+
colors .push (this .value / 255);
|
|
239
215
|
|
|
240
216
|
if (this .int32 ())
|
|
241
217
|
{
|
|
242
|
-
|
|
218
|
+
colors .push (this .value / 255);
|
|
243
219
|
|
|
244
220
|
if (this .int32 ())
|
|
245
|
-
colors .push (
|
|
221
|
+
colors .push (this .value / 255);
|
|
246
222
|
}
|
|
247
223
|
}
|
|
248
224
|
|
|
249
|
-
|
|
225
|
+
this .untilEndOfLine ();
|
|
250
226
|
continue;
|
|
251
227
|
}
|
|
252
228
|
|
|
@@ -256,6 +232,46 @@ class OffParser extends X3D .X3DParser
|
|
|
256
232
|
return true;
|
|
257
233
|
}
|
|
258
234
|
|
|
235
|
+
comments ()
|
|
236
|
+
{
|
|
237
|
+
while (this .comment ())
|
|
238
|
+
;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
comment ()
|
|
242
|
+
{
|
|
243
|
+
this .whitespaces ();
|
|
244
|
+
|
|
245
|
+
if (Grammar .comment .parse (this))
|
|
246
|
+
return true;
|
|
247
|
+
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
whitespaces ()
|
|
252
|
+
{
|
|
253
|
+
if (Grammar .whitespaces .parse (this))
|
|
254
|
+
this .lines (this .result [0]);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
whitespacesNoLineTerminator ()
|
|
258
|
+
{
|
|
259
|
+
Grammar .whitespacesNoLineTerminator .parse (this);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
untilEndOfLine ()
|
|
263
|
+
{
|
|
264
|
+
Grammar .untilEndOfLine .parse (this);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
lines (string)
|
|
268
|
+
{
|
|
269
|
+
const match = string .match (Grammar .LineFeed);
|
|
270
|
+
|
|
271
|
+
if (match)
|
|
272
|
+
this .lineNumber += match .length;
|
|
273
|
+
}
|
|
274
|
+
|
|
259
275
|
int32 ()
|
|
260
276
|
{
|
|
261
277
|
this .whitespacesNoLineTerminator ();
|