Skip to content
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

Discussion about declaratively modifying routes. #1

Open
coderextreme opened this issue Sep 11, 2023 · 15 comments
Open

Discussion about declaratively modifying routes. #1

coderextreme opened this issue Sep 11, 2023 · 15 comments
Labels
question Further information is requested solved Question is solved

Comments

@coderextreme
Copy link

coderextreme commented Sep 11, 2023

Tag yourself in this issue to get emails. Add a comment.

Note that this is enough of a modification that forking may be considered. Or at least, development off the main branch.

@coderextreme
Copy link
Author

coderextreme commented Sep 11, 2023

@create3000 says:

It is not all official SAI but X_ITE has internally and official these route functions:

  1. X3DExecutionContext.addRoute (sourceNode, sourceField, destinationNode, destinationField) : X3DRoute

  2. X3DExecutionContext.deleteRoute (route)

  3. X3DExecutionContext.getRoute (sourceNode, sourceField, destinationNode, destinationField) : X3DRoute

  4. X3DExecutionContext.getRoutes () : RouteArray

  5. X3DBrowser.addRoute (sourceNode, sourceField, destinationNode, destinationField)

  6. X3DBrowser.deleteRoute (sourceNode, sourceField, destinationNode, destinationField)

1 and 2 are standard.
3 is non-standard, but could be useful.
4 is the same as ‚routes‘ property.
5 and 6 are legacy functions from VRML ages, but I like them too.

Discussing declarative syntax can also be done in an issue(s), this has a lot of advantages. Think you all know GitHub issues.

@coderextreme
Copy link
Author

So my thought is that an editor or authoring system already provides ways to update route fields. Can we take the route features of an authoring system, and make them available in XML or VRML syntax?

@create3000
Copy link
Owner

With DOM integration you can find routes like you would do find any HTMLElement, with native DOM methods or maybe jQuery:

https://github.com/create3000/Library/blob/ba2a1e79276923e2c0b15933a5c6995256cdc5b6/Tests/Browser/DOMIntegration/inline_route.xhtml

@coderextreme
Copy link
Author

coderextreme commented Sep 11, 2023

We’re also hoping to make this feature available in castle-engine and view3dscene. So portability of scripts is an issue. This is not really an SAI/DOM discussion, but yes, SAI or DOM will implement the features we do to the scene, so SAI modications are probably first

@coderextreme
Copy link
Author

From my original post, I suggested that a fraction from [0,1] would map to integers which would map to a position in an MFString. The MFString would potentially update a ROUTE.

@coderextreme
Copy link
Author

coderextreme commented Sep 11, 2023

Say I want to take a [0,1] fraction key and map it to an MFString keyValue. How do I do that in X3D?

This might be used for alternating Text nodes, or ROUTEs, see below.

Also, can I take a similar key fraction and map to keyValue MFNodes?

I realize that Switch plus and ScalarInterpolator would satisfy the latter.

I’m not clear on how to do the former. This would be key to sending events to ROUTEs, changing the from/to node names and fields.

This seems like a very powerful feature! I just don’t know how to route SFString events to route statements. Is there an alternative?

Maybe I should create an Uber X3D? Can we add DEF and name to ROUTEs, and make them first class nodes?

I’m not sure how performant this would be, or even how implementable it is.

@coderextreme
Copy link
Author

I’m also thinking of a TextInterpolator where one one SFString morphs into another …

@coderextreme coderextreme changed the title Discussion about modifying routes. Discussion about declaratively modifying routes. Sep 11, 2023
@coderextreme
Copy link
Author

So there’s some discussion about using an id attribute (CSS) to update a route. So one would use CSS instead of a sequencer or interpolator to change values instead of SAI or DOM. Hmm!

@coderextreme
Copy link
Author

coderextreme commented Sep 12, 2023

For reference, here’s the code bloat I’m trying to reduce. I’ve got 4 files of this. https://github.com/coderextreme/jaminate/blob/main/Jaminate/app/src/main/javascript/takes.John.txt

the timings in each file are slightly different.

@coderextreme
Copy link
Author

Here’s what I generate the 4 files with:

https://github.com/coderextreme/jaminate/blob/main/Jaminate/app/src/main/javascript/takes.js

(I know, lots of commented out code)

@coderextreme
Copy link
Author

coderextreme commented Sep 12, 2023

I only need the characters, moves per character, and times per character arrays to generate the code bloat. I’m looking for a quicker load time. https://github.com/coderextreme/jaminate/blob/main/Jaminate/app/src/main/javascript/John.json

@coderextreme
Copy link
Author

If there’s an easier way to do this, I’m all ears

@coderextreme
Copy link
Author

One solution may be to write 2 scripts, one like takes.js and the other in castle script

@create3000
Copy link
Owner

create3000 commented Dec 13, 2024

What about this prototype? Set names of nodes and field names, then toggle enabled:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "https://www.web3d.org/specifications/x3d-4.0.dtd">
<X3D profile='Interchange' version='4.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.0.xsd'>
  <head>
    <component name='Scripting' level='1'/>
  </head>
  <Scene>
    <ProtoDeclare name='Route'>
      <ProtoInterface>
        <field accessType='inputOutput' type='SFBool' name='connected'/>
        <field accessType='inputOutput' type='SFNode' name='sourceNode'/>
        <field accessType='inputOutput' type='SFString' name='sourceField'/>
        <field accessType='inputOutput' type='SFNode' name='destinationNode'/>
        <field accessType='inputOutput' type='SFString' name='destinationField'/>
      </ProtoInterface>
      <ProtoBody>
        <Script DEF='RouteScript'>
          <field accessType='inputOutput' type='SFBool' name='connected'/>
          <field accessType='inputOutput' type='SFNode' name='sourceNode'/>
          <field accessType='inputOutput' type='SFString' name='sourceField'/>
          <field accessType='inputOutput' type='SFNode' name='destinationNode'/>
          <field accessType='inputOutput' type='SFString' name='destinationField'/>
          <IS>
            <connect nodeField='connected' protoField='connected'/>
            <connect nodeField='sourceNode' protoField='sourceNode'/>
            <connect nodeField='sourceField' protoField='sourceField'/>
            <connect nodeField='destinationNode' protoField='destinationNode'/>
            <connect nodeField='destinationField' protoField='destinationField'/>
          </IS>
<![CDATA[ecmascript:

let route;

function initialize ()
{
   set_connected ();
}

function set_connected ()
{
   const scene = Browser .currentScene;

   if (connected)
   {
      if (!sourceNode || !sourceField)
         return;

      if (!destinationNode || !destinationField)
         return;
      
      route = scene .addRoute (sourceNode, sourceField, destinationNode, destinationField);
   }
   else if (route)
   {
      scene .deleteRoute (route);
   }
}
]]>
        </Script>
      </ProtoBody>
    </ProtoDeclare>
  </Scene>
</X3D>

@create3000 create3000 added the question Further information is requested label Dec 13, 2024
@coderextreme
Copy link
Author

coderextreme commented Dec 13, 2024 via email

@create3000 create3000 added the solved Question is solved label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested solved Question is solved
Projects
None yet
Development

No branches or pull requests

2 participants