x_ite-off-parser 1.0.2 → 1.0.4
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 +7 -2
- package/dist/x_ite-off-parser.js +7 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# x_ite-off-parser
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/x_ite-off-parser)
|
|
4
|
+
[](https://bundlephobia.com/package/x_ite-off-parser)
|
|
5
|
+
[](https://create3000.github.io/jsdelivr-download-stats/?username=create3000&repository=x_ite)
|
|
6
|
+
[](https://npmtrends.com/x_ite-off-parser)
|
|
7
|
+
|
|
3
8
|
OFF 3D File Format Parser for [X_ITE](https://create3000.github.io/x_ite/)
|
|
4
9
|
|
|
5
10
|
## Usage
|
|
@@ -8,10 +13,10 @@ Include the script after X_ITE:
|
|
|
8
13
|
|
|
9
14
|
```html
|
|
10
15
|
<script defer src="https://cdn.jsdelivr.net/npm/x_ite@15.0.3/dist/x_ite.min.js"></script>
|
|
11
|
-
<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.4/dist/x_ite-off-parser.min.js"></script>
|
|
12
17
|
<!-- or as ES module -->
|
|
13
18
|
<script type="module" src="https://cdn.jsdelivr.net/npm/x_ite@15.0.3/dist/x_ite.min.mjs"></script>
|
|
14
|
-
<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.4/dist/x_ite-off-parser.min.js"></script>
|
|
15
20
|
```
|
|
16
21
|
|
|
17
22
|
Now you can load OFF files:
|
package/dist/x_ite-off-parser.js
CHANGED
|
@@ -9,6 +9,7 @@ const Grammar = X3D .Expressions ({
|
|
|
9
9
|
// General
|
|
10
10
|
whitespaces: /[\x20\n\t\r,]+/y,
|
|
11
11
|
whitespacesNoLineTerminator: /[\x20\t]+/y,
|
|
12
|
+
untilEndOfLine: /[^\r\n]+/y,
|
|
12
13
|
comment: /#[^\r\n]*(?=[\r\n]|$)/y,
|
|
13
14
|
header: /OFF/y,
|
|
14
15
|
|
|
@@ -44,7 +45,7 @@ class OffParser extends X3D .X3DParser
|
|
|
44
45
|
|
|
45
46
|
isValid ()
|
|
46
47
|
{
|
|
47
|
-
return this .input .match (
|
|
48
|
+
return this .input .match (/^OFF/);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
parseIntoScene (resolve, reject)
|
|
@@ -192,6 +193,7 @@ class OffParser extends X3D .X3DParser
|
|
|
192
193
|
if (this .double ())
|
|
193
194
|
{
|
|
194
195
|
points .push (this .value);
|
|
196
|
+
Grammar .untilEndOfLine .parse (this);
|
|
195
197
|
continue;
|
|
196
198
|
}
|
|
197
199
|
}
|
|
@@ -233,17 +235,18 @@ class OffParser extends X3D .X3DParser
|
|
|
233
235
|
|
|
234
236
|
if (this .int32 ())
|
|
235
237
|
{
|
|
236
|
-
|
|
238
|
+
const r = this .value / 255;
|
|
237
239
|
|
|
238
240
|
if (this .int32 ())
|
|
239
241
|
{
|
|
240
|
-
|
|
242
|
+
const g = this .value / 255;
|
|
241
243
|
|
|
242
244
|
if (this .int32 ())
|
|
243
|
-
colors .push (this .value / 255);
|
|
245
|
+
colors .push (r, g, this .value / 255);
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
248
|
|
|
249
|
+
Grammar .untilEndOfLine .parse (this);
|
|
247
250
|
continue;
|
|
248
251
|
}
|
|
249
252
|
|