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', name: 'vrml1to97',
version: '0.2.1', version: '0.2.2',
description: 'JavaScript converter from VRML 1 to VRML97', description: 'JavaScript converter from VRML 1 to VRML97',
scripts: { scripts: {
test: 'echo "Error: no test specified" && exit 1', test: 'echo "Error: no test specified" && exit 1',
@ -40,7 +40,7 @@
}, },
type: 'module', type: 'module',
devDependencies: { devDependencies: {
'@danielx/civet': '^0.6.35', '@danielx/civet': '^0.6.38',
'@types/moo': '^0.5.6', '@types/moo': '^0.5.6',
'http-server': '^14.1.1', 'http-server': '^14.1.1',
json5: '^2.2.3', json5: '^2.2.3',

View File

@ -11,8 +11,8 @@ dependencies:
devDependencies: devDependencies:
'@danielx/civet': '@danielx/civet':
specifier: ^0.6.35 specifier: ^0.6.38
version: 0.6.35(typescript@5.2.2) version: 0.6.38(typescript@5.2.2)
'@types/moo': '@types/moo':
specifier: ^0.5.6 specifier: ^0.5.6
version: 0.5.6 version: 0.5.6
@ -35,8 +35,8 @@ packages:
'@jridgewell/trace-mapping': 0.3.9 '@jridgewell/trace-mapping': 0.3.9
dev: true dev: true
/@danielx/civet@0.6.35(typescript@5.2.2): /@danielx/civet@0.6.38(typescript@5.2.2):
resolution: {integrity: sha512-C6Yf7sQBUAnkPWRMirUT0wrQ2BtQtgc/Iz1ymPyyt+Ayo3gWlAi/wotWeCtt6Z2+WEoG8XNmmJI80B4QkCiwAQ==} resolution: {integrity: sha512-R63YGIfvV4DQianNPUfMfBX60ozlv5htnRXI1wK3Pg6+d4NZ2V3RifFRH0NkmXXoFkRcULzJ+9BzVeI2/yX+yA==}
engines: {node: '>=19 || ^18.6.0 || ^16.17.0'} engines: {node: '>=19 || ^18.6.0 || ^16.17.0'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:

View File

@ -138,9 +138,8 @@ function parse(stream: Lexer, tree: Tree = {}): Tree
dims := radius: '' dims := radius: ''
findNumbersAtTopLevel stream, dims findNumbersAtTopLevel stream, dims
addShape 'Sphere', [`radius ${dims.radius}`], tree addShape 'Sphere', [`radius ${dims.radius}`], tree
/IndexedLineSet|PointSet/ // ignored, but why? They are in VRML97 /IndexedFaceSet|IndexedLineSet|PointSet/
findNumbersAtTopLevel stream, {} isFaces := held.value is 'IndexedFaceSet'
'IndexedFaceSet'
contents := translatedToksUntilClose stream contents := translatedToksUntilClose stream
params := [] params := []
if 'Coordinate' in tree if 'Coordinate' in tree
@ -149,15 +148,15 @@ function parse(stream: Lexer, tree: Tree = {}): Tree
if 'Normal' in tree if 'Normal' in tree
params.push "normal Normal {\n", params.push "normal Normal {\n",
...tree.Normal, " }\n" ...tree.Normal, " }\n"
if 'TextureCoordinate' in tree if isFaces and 'TextureCoordinate' in tree
params.push "texCoord TextureCoordinate {\n", params.push "texCoord TextureCoordinate {\n",
...tree.TextureCoordinate, " }\n" ...tree.TextureCoordinate, " }\n"
if 'creaseAngle' in tree if isFaces and 'creaseAngle' in tree
params.push `creaseAngle ${tree.creaseAngle[0]}` params.push `creaseAngle ${tree.creaseAngle[0]}`
if 'ccw' in tree if isFaces and 'ccw' in tree
params.push `ccw true` params.push `ccw true`
params.push ...contents params.push ...contents
addShape 'IndexedFaceSet', params, tree addShape held.value, params, tree
/Light$/ /Light$/
contents := toksUntilClose stream contents := toksUntilClose stream
addChild {[held.value]: contents}, tree addChild {[held.value]: contents}, tree