feat: Implement Translations (#19)
Also fixes bug: Translations and Rotations should not be inherited into inner grouping nodes. Reviewed-on: #19 Co-authored-by: Glen Whitney <glen@studioinfinity.org> Co-committed-by: Glen Whitney <glen@studioinfinity.org>
This commit is contained in:
parent
1409d39665
commit
a6a6e60894
@ -15,7 +15,7 @@ VRML 1.0. Overall, it recognizes and converts
|
||||
* All Light nodes
|
||||
* Grouping nodes including Transform, Separator, Group, Switch, and WWWAnchor
|
||||
* ShapeHints
|
||||
* Rotations
|
||||
* Rotations and Translations
|
||||
* All shape nodes including Cube, Cone, Cylinder, Sphere, IndexedFaceSet,
|
||||
IndexedLineSet, PointSet, Coordinate3, and Normal
|
||||
* All material nodes including Material, TextureCoordinate2, and Texture2
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
name: 'vrml1to97',
|
||||
version: '0.3.0',
|
||||
version: '0.3.1',
|
||||
description: 'JavaScript converter from VRML 1 to VRML97',
|
||||
scripts: {
|
||||
test: 'echo "Error: no test specified" && exit 1',
|
||||
|
@ -205,13 +205,16 @@ function parse(stream: Lexer, tree: DefTree = {}): DefTree
|
||||
matches GroupNode
|
||||
parent :=
|
||||
held.value.endsWith('Separator') ? 'Transform' : 'Group'
|
||||
{children, ...context} := tree
|
||||
{children, Translation, Rotation, ...context} := tree
|
||||
subTree := parse stream, context
|
||||
if newKids := subTree.children
|
||||
newChild .= `${parent} {\n `
|
||||
if 'Rotation' in subTree
|
||||
newChild += renderList subTree.Rotation
|
||||
newChild += "\n "
|
||||
if 'Translation' in subTree
|
||||
newChild += renderList subTree.Translation
|
||||
newChild += "\n "
|
||||
newChild += `children [\n ${renderList newKids} ] }\n`
|
||||
addChild newChild, tree
|
||||
'ShapeHints'
|
||||
@ -227,6 +230,8 @@ function parse(stream: Lexer, tree: DefTree = {}): DefTree
|
||||
tree._definitions[lastDefinition] = [hints]
|
||||
'Rotation'
|
||||
tree.Rotation = toksUntilClose stream
|
||||
'Translation'
|
||||
tree.Translation = toksUntilClose stream
|
||||
'Coordinate3'
|
||||
tree.Coordinate = toksUntilClose stream
|
||||
'Normal'
|
||||
|
Loading…
Reference in New Issue
Block a user