From bb0ef18903295e958894f0c2a3b0bffd6f092630 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 18 Sep 2023 21:28:23 -0700 Subject: [PATCH] feat: Handle IndexedLineSet Also turns on PointSet but I don't have a good test case for that so not sure it is working. Resolves #16. --- package.json5 | 4 ++-- pnpm-lock.yaml | 8 ++++---- src/index.civet | 13 ++++++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package.json5 b/package.json5 index 2c74980..47bc539 100644 --- a/package.json5 +++ b/package.json5 @@ -1,6 +1,6 @@ { name: 'vrml1to97', - version: '0.2.1', + version: '0.2.2', description: 'JavaScript converter from VRML 1 to VRML97', scripts: { test: 'echo "Error: no test specified" && exit 1', @@ -40,7 +40,7 @@ }, type: 'module', devDependencies: { - '@danielx/civet': '^0.6.35', + '@danielx/civet': '^0.6.38', '@types/moo': '^0.5.6', 'http-server': '^14.1.1', json5: '^2.2.3', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0f81dc1..0ae457f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,8 +11,8 @@ dependencies: devDependencies: '@danielx/civet': - specifier: ^0.6.35 - version: 0.6.35(typescript@5.2.2) + specifier: ^0.6.38 + version: 0.6.38(typescript@5.2.2) '@types/moo': specifier: ^0.5.6 version: 0.5.6 @@ -35,8 +35,8 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: true - /@danielx/civet@0.6.35(typescript@5.2.2): - resolution: {integrity: sha512-C6Yf7sQBUAnkPWRMirUT0wrQ2BtQtgc/Iz1ymPyyt+Ayo3gWlAi/wotWeCtt6Z2+WEoG8XNmmJI80B4QkCiwAQ==} + /@danielx/civet@0.6.38(typescript@5.2.2): + resolution: {integrity: sha512-R63YGIfvV4DQianNPUfMfBX60ozlv5htnRXI1wK3Pg6+d4NZ2V3RifFRH0NkmXXoFkRcULzJ+9BzVeI2/yX+yA==} engines: {node: '>=19 || ^18.6.0 || ^16.17.0'} hasBin: true peerDependencies: diff --git a/src/index.civet b/src/index.civet index 9b81221..6848624 100644 --- a/src/index.civet +++ b/src/index.civet @@ -138,9 +138,8 @@ function parse(stream: Lexer, tree: Tree = {}): Tree dims := radius: '' findNumbersAtTopLevel stream, dims addShape 'Sphere', [`radius ${dims.radius}`], tree - /IndexedLineSet|PointSet/ // ignored, but why? They are in VRML97 - findNumbersAtTopLevel stream, {} - 'IndexedFaceSet' + /IndexedFaceSet|IndexedLineSet|PointSet/ + isFaces := held.value is 'IndexedFaceSet' contents := translatedToksUntilClose stream params := [] if 'Coordinate' in tree @@ -149,15 +148,15 @@ function parse(stream: Lexer, tree: Tree = {}): Tree if 'Normal' in tree params.push "normal Normal {\n", ...tree.Normal, " }\n" - if 'TextureCoordinate' in tree + if isFaces and 'TextureCoordinate' in tree params.push "texCoord TextureCoordinate {\n", ...tree.TextureCoordinate, " }\n" - if 'creaseAngle' in tree + if isFaces and 'creaseAngle' in tree params.push `creaseAngle ${tree.creaseAngle[0]}` - if 'ccw' in tree + if isFaces and 'ccw' in tree params.push `ccw true` params.push ...contents - addShape 'IndexedFaceSet', params, tree + addShape held.value, params, tree /Light$/ contents := toksUntilClose stream addChild {[held.value]: contents}, tree