-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Torus Component #127
Comments
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 |
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. |
Here are some proto examples form We3d3d.org https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/. |
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 https://github.com/x3dom/x3dom/wiki/Prototypes (It would be very cool if x_ite would support the vrml style 'short' xml syntax |
Nop, will not implement this 'short' syntax. The |
Thanks Guys, I have however as a learning exercise had a go at using the prototype and after a lot of head banging I finally got it working: The issues I was having I tracked down to the self closing tags in the Torus prototype - after eventually swapping all the self closing for separate closing tags it started to work. This is far from my expertise but would either of you be able to advise how I could implement an angle (start angle/end angle) so I can start to build up donut slices? Second (possible dumb) question... will/can this prototype be integrated into X_ITE as standard? i.e Adding support for Torus into X_ITE as a standard shape? I would guess from the above this is not an option? Thanks again, |
Added angle and beginCap, endCap. |
Thank you soooo much! You have been a massive help! I have tweaked your example a little to align with the x3dom interface attributes: x3dom:
x_ite proto:
I nearly have it but I have one small issue with the start and end angles on the sectors - there is a small gap and the end caps seem to be at a slight different angle. I have tried tweaking the script angles, radius etc in the forEach loops but cant seem to figure out how to 'straighten' the ends? I also need to figure out default orientation and angles going anti-clockwise (again to match the x3dom behaviour). Here is my version with Prototype + X_ITE: And here is a version with Torus + X3DOM: |
It's more a hack, but it works, to get the Extrusion closer to a circle. I also added a |
Because this is a test page, I also added a |
Have now seen this with the orientation in you post. Played around with it, think the values you can use are now equal to X3DOM. |
You are a star! This was an interesting thought exercise for me and I learnt more about Prototypes. I think it is looking good with both versions fairly equivalent. Hopefully this modified prototype may be of use to you also? I understand you are not looking to implement Torus into X_ITE and therefore will close this issue. All that is left for me to do is work out how to weave Prototypes into my d3-x3d library. Or worse case lift and shift the JavaScript you have kindly modified to generate the extrusions. |
Yes, the ProtoInstance xml element was invented for that reason, to make it easier and cleaner for a parser (and to make validation for correctness possible with xslt). I understand that parsing would be more fragile and require a lot of work. On the other hand, the existing vrml parser already needs to be able to recognize such new node names (from Protos), showing that this is quite possible, and that it was the original intention. [For x3dom it turned out that the 'short' syntax was actually the 'natural' syntax and easier to parse. It converts internally all ProtoInstance elements to that short form first.] |
Think you know how to include the proto into D3X3D. But there are also the possibility to use an ExternPrototype. Maybe this is an option. |
In the meanwhile I have seen examples of the short syntax and it is now quite clearly to me how to implement this, and this is what I have already done now. @jamesleesaunders you can use the short syntax, as you would do it with every other node: <Torus containerField='geometry'
angle='1.984163781214606'
innerRadius='0.25'
outerRadius='1'
subdivision='48,48'
solid='true'>
</Torus> |
That was quick ! I think that will be a powerful feature. Is the containerField attribute needed ? |
The |
Makes sense. |
Additionally the root node of the ProtoypeInstance itself can again be a ExternProto which makes automatic determination impossible. |
Amazingly quick - the 'short syntax' works a charm. This is a much simpler syntax and I should I could see this been very powerful / versatile when prototyping new nodes. |
It's like xmas, loads of presents. 🎅 🎁 |
Just a quick update before I close this ticket... Thanks to your great help I have now implemented a Donut chart in X_ITE: Which now works almost identically to X3DOM: With your help using Prototypes + the short Syntax this has meant that the scene nodes etc used to generate both these are identical Although this was a great learning exercise, I am not sure having to load a prototype from external URL is future proof, as it means I have to bake in the URL of the torus prototype into d3-x3d dist code and it means that I have to find a more permanent location to host the prototype file(s) and should this break / move this will break d3-x3d. This is how it currently works: https://github.com/jamesleesaunders/d3-x3d/blob/master/src/base.js#L47 My other alternative is to not load the prototype from a remote external URL and bring generate the prototype in JavaScript. My third option would be skip the idea of the Prototype and Torus node and move to generate the Extrusion directly and move the Prototype <Script> JavaScript into being core code. Thanks again @create3000 and @andreasplesch Have a fantastic Christmas and New Year! |
Cool, looks good! There is also the possibility to use the ExternPrototype with a
|
Brilliant idea! I have swapped the external URL out for a base64 encoded And then created a little facility to read a x3d prototype file and convert it into a data url. I hope you has a great Christmas! |
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:
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!
The text was updated successfully, but these errors were encountered: