create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.
https://create3000.github.io/x_ite/
Other
67 stars 15 forks source link

Feature Request: Torus Component #127

Closed jamesleesaunders closed 1 year ago

jamesleesaunders commented 1 year ago

Please could you add a Torus shape component to X_ITE? https://doc.x3dom.org/author/Geometry3D/Torus.html

I have a 'donut chart' component in d3-x3d which works in x3dom: https://raw.githack.com/jamesleesaunders/d3-x3d/master/examples/X3DOM/chart/DonutChart.html

But at the moment it looks like Torus is not supported by X_ITE: https://raw.githack.com/jamesleesaunders/d3-x3d/master/examples/X_ITE/chart/DonutChart.html

Error:

x_ite.js:42679 XML Parser Error: Unknown node type 'TORUS', you probably have insufficient component/profile statements.

I have tried reverting back to Full profile also.

I would be willing to contribute myself and have has a look at the code around here https://github.com/create3000/x_ite/tree/main/src/standard/Math/Geometry but would not have a clue where to start!

create3000 commented 1 year ago

Have you considered to use a prototype to get a torus?

Here is an example of a Torus, which can be modified to get what you want, for instance to implement a angle property.

https://github.com/create3000/Library/blob/main/Prototypes/Geometry3D/Torus.x3d

create3000 commented 1 year ago

You would define the proto within the Scene element before you use it, then add a ProtoInstance element:

<ProtoInstance name='Torus' containerField='geometry'>
  <fieldValue name='minorRadius' value='2'/> 
  <fieldValue name='majorRadius' value='3'/>
</ProtoInstance>

Note: X3DOM does not support protos as far as I know.

create3000 commented 1 year ago

Here are some proto examples form We3d3d.org https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/.

andreasplesch commented 1 year ago

Yes, a torus proto would be possible and could mimic the x3dom torus. x3dom does now support protos but has the important restriction that the <script> node is not implemented:

https://github.com/x3dom/x3dom/wiki/Prototypes

(It would be very cool if x_ite would support the vrml style 'short' xml syntax <Torus majorRadius='5' /> for instances which is non-standard.)

create3000 commented 1 year ago

Nop, will not implement this 'short' syntax. The ProtoInstance element is well specified and compatible to other browsers. To implement this will lead to a parser change, which is not desired. The parser is cleaner without this syntax.

jamesleesaunders commented 1 year ago

Thanks Guys, Although I am not sure how I would integrate prototypes into d3-x3d (as the while point of the library is we use D3 and JS to generate the X3D - it would be difficult and a little incestuous for D3/JS to generate the Githubissues.

  • Githubissues is a development platform for aggregating issues.