x3d deserializer board #1241
Replies: 3 comments 1 reply
-
The first three in the list seem to possible. You seem to be well versed with both X3D and JSCAD now. :) Please feel free to make a few fixes, but keep the change compact to simplify the reviews. I noticed inline nodes in the specifications but those just seemed too difficult to handle. Nothing in XML is easy, and all the X3D extensions are really difficult to handle. If there's another library that can "assemble' the X3D model from the different files then there may be a solution. |
Beta Was this translation helpful? Give feedback.
-
comma as separatorexample of comma use: https://github.com/create3000/Library/blob/main/Tests/Components/CADGeometry/CADGeometry.x3d spec. language: https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#Description
rel. code: https://github.com/jscad/OpenJSCAD.org/blob/master/packages/io/x3d-deserializer/src/objects.js Hm. no dedicated parsing function for MFFields. But consistent use of But it would be better to do some refactoring to include a small helper function function _parseNumbers( attribute )
{
return attribute.trim().replaceAll(","," ").split(/ +/).map((v) => parseFloat(v))
}
...
const values = _parseNumbers( element.color ) Add test: The parse patterns is also used for the '-1' index delimiter: Probably makes sense to centralize those in another helper |
Beta Was this translation helpful? Give feedback.
-
see #1287 |
Beta Was this translation helpful? Give feedback.
-
A place to collect ideas for the deserializer:
currently seems to only accept spaces as separator for MFfields,, but a comma surrounded by space is common as well for tuple separation
"1 2 ,3 4 5 , 6".replaceAll(","," ").split(/ +/)
could be a small helper
splitMF
deserialize Material fields into object.material.fields attributes
Box to Cuboid, not Cube ?
The deserializer nicely supports primitives such as Box, Cone, or Disk2d to corresponding JSCAD primitives. If full roundtrips are a goal, the serializer would also support primitives as output. This would allow 3d printing services to optimize their own triangulation but it is not clear how well support richer X3D support would be. Might be worth some trials with imaterialize or shapeways. But it would be a large job for uncertain benefits.
Inline node ? Inline nodes are used to organize larger scenes across multiple files. They would require networking and handling embedded namescopes, potentially also EXPORT/IMPORT pairs. x3dom can embed inline doms into the main dom, so perhaps it is not unreasonable to expect embedded input. Inline then becomes essentially a group.
Beta Was this translation helpful? Give feedback.
All reactions