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

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