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.
This commit is contained in:
Glen Whitney 2023-09-18 21:28:23 -07:00
parent d0da8ced68
commit bb0ef18903
3 changed files with 12 additions and 13 deletions

View File

@ -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',

View File

@ -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:

View File

@ -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