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

add x_ite-dom tests #126

Closed andreasplesch closed 1 year ago

andreasplesch commented 1 year ago

It would be good to add these tests, in some way:

https://github.com/andreasplesch/x_ite_dom/tree/master/tests

probably to

https://github.com/create3000/Library/tree/main/Tests

create3000 commented 1 year ago

Yes, good idea, and Library is a good place, because I cannot make the repro larger than ca. 40MB, because of jsdelivr restrictions.

andreasplesch commented 1 year ago

I submitted a pull request with the existing tests to Library. Some tests still work with the alpha version, quite a few do not. See https://github.com/create3000/Library/pull/2

andreasplesch commented 1 year ago

Here are a few direct links: https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/addAndRemoveNode.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/cycle.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/fanOutRoute.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/gears_proto.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/importDocument.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/importDoc.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inline_dom.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inline_in_inline.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inline_Mushrooms.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inline_proto.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inline_route.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inlinev2.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/interactiveTransformations.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/jqueryui_adopt.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/noDOM_multiview.html https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/output_events.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/removeAddMaterial.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/rosetta_xite.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/test_alphax_ite.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_d3.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_integration2.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_multiview.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_script2.xhtml https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_script.xhtml

create3000 commented 1 year ago

I have remove the "x3d_" from the events so .addEventListener('x3d_touchTime', myToggleSizeFunction) has become just .addEventListener('touchTime', myToggleSizeFunction). This should work well because it is a CustomEvent.

create3000 commented 1 year ago

Ahh, and including the CSS is not needed anymore.

andreasplesch commented 1 year ago

ok, I can work on fixing the examples that way.

andreasplesch commented 1 year ago

I have fixed the event names, and https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/fanOutRoute.xhtml works now, for example.

https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_d3.xhtml works better as well. The detail.fields event property is not available anymore. Perhaps because node.getFields() does not seem be there anymore. Event values are important to web programmers so it would be great to have access to all fields.

Only the 'new color' button still works in that example. Something to track down.

create3000 commented 1 year ago

Have removed the CSS and removed "x3d_".

There is a "node" property in the detail, which is a SFNode. A SFNode is essentially only a collection of fields, thus fields can be accessed by node.fieldName.

andreasplesch commented 1 year ago

node.fieldName is fine (I thought I had tried that before). Listing all available fields in a fields property would make it much friendlier to discover fields for web programmers who are not that familiar with x3d.

Perhaps via node.getFieldDefinitions()

fields[node.getFieldDefinitions()[i].name] = node.getFieldDefinitions()[i].value

Seems a bit convoluted. Perhaps there is a better way.

I updated the d3_x3d example and it works now: https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/x3d_d3.xhtml

Looking at other examples.

andreasplesch commented 1 year ago

https://raw.githack.com/andreasplesch/Library/dom_integration/Tests/Browser/DOMIntegration/inline_proto.xhtml

has problems. Investigating.

andreasplesch commented 1 year ago

Updated inline_proto.xhtml to use less restrictive selector to access inline transform.

Since now the complete X3D element is appended: https://github.com/create3000/x_ite/blob/main/src/x_ite/Browser/DOMIntegration.js#L305

It used to be just the Scene element. x3dom appends the children of the Scene element.

create3000 commented 1 year ago

I think It is better to add the complete X3D element to an Inline, it is the loaded world with all properties (meta, components and so on), which are then accessible.

andreasplesch commented 1 year ago

That's ok. Small fixes to cycle, noDom_multiview, rosetta_xite.

andreasplesch commented 1 year ago

all fixes in https://github.com/create3000/Library/pull/3

create3000 commented 1 year ago

HTML Script elements should work now better. Added processing of these element directly in XMLParser, thus the childNodes are immediately available during parsing, and routes to Script node fields will work now.

HTML Test: https://raw.githack.com/create3000/Library/main/Tests/Browser/DOMIntegration/html5/x3d_script.html https://raw.githack.com/create3000/Library/main/Tests/Browser/DOMIntegration/html5/x3d_script2.html

create3000 commented 1 year ago

Also added documentation.

https://create3000.github.io/x_ite/dom-integration#script-element

andreasplesch commented 1 year ago

node.fieldName for accessing node fields does not seem work anymore. See hitPoint_changed field = undefined after isOver here:

https://raw.githack.com/andreasplesch/Library/master/Tests/Browser/DOMIntegration/x3d_d3.xhtml

node._fieldName works.

create3000 commented 1 year ago

Should work again now.

andreasplesch commented 1 year ago

Yes, thanks ! It looks like node.valueOf() already tried to use the node cache ?

But the debugger indicates that instead of SFNode.valueOf function the native JS Object.prototype.valueOf function was called.

create3000 commented 1 year ago

Yes that's true for SFNode.valueOf, but in DOMIntegration at the neuralgic points a X3DBaseNode occurs, for which SFNodeCache is fine.

And that was the bug before.