[x3d-public] [x3dom-users] Nodes for V4

Andreas Plesch andreasplesch at gmail.com
Sun Aug 28 11:59:35 PDT 2016


Leonard,

thanks Leonard, this looks great. I put the test scenes on github pages for
> easy viewing here:
>
> http://andreasplesch.github.io/x3dv4/
>
>
> Thanks.
>
> Is there an automatic process to update these if I update (or add) a test
> file?
>
>
You could create a PR after an update. This lets me simply update my fork
and the served pages.
It may be best if you could create your own github pages site. I left an
issue in this regard. It is quite straightforward. Take a look at my fork.
The tests could live in the gh-pages branch only to avoid a need for
duplication. (If you want to keep all in the master branch, github now lets
use a doc/ folder in the master branch as the ghpages source which is
served).

> Concerning the Macro node, what do you think about having a way to define
> defaults for the %parameters% in the Macro template for the case when not
> all or no parameters are provided with the Macro node ?
>
>
> Providing defaults is a good idea. I like it.
>
>
> A possible syntax would be perhaps to just add the default after an equal
> sign to where the parameter is used: %myparam=10% ?
>
>
> Right now I am using JavaScript's RegExp parser on '\%'+name+'\%'.  I can
> see problems with backslashes or other RegEx control structures in name.
> Perhaps name should be limited to A-Za-z0-9\-_
>
The loop is over the list of supplied name/value pairs where the name is
> the hash of the value in the array. Once all of the array values have been
> processed, another pass would need to be done to handle the defaults.
> Anything left as %<string>% would need to be processed for an '=' and
> replaced with the default value.
>
> Is that what you had in mind?
>
>
Yes, something like this. Let's see:
All params in the Macro template need a value in the Macro instance. The
order of precedence would be instance value > template default value > x3d
default value.

So looping over the supplied names first and replacing with the supplied
value would take care of those. The regexp would need to ignore  =.* after
the name until the second %, if there is a equal sign. Would
 '(\%'+name+'\%) || '(\%'+name+'=.*\%)' work as regexp ? Perhaps ignore
white space in front of the = as well ? With some testing it should be
possible to figure out a good regexp.

Then what is left are param names which are not supplied. They may have a
default value or not.
Not sure how to best look for those but let's try.

string.match(),
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match
could give you all the remaining param names between %, and their locations
[though this does not quite work in case of multiple %par%s on one line].
Those which have an equal sign could be split at the equal sign, and
replaced with the value after the equal sign. Those without an equal sign
would have no value. This means probably a warning message, and replacement
with an empty string (?) or removal of the whole field including the field
name, so it can be assigned its x3d default during subsequent parsing.

There may be other, cleaner ways for a default value syntax although this
seems intuitive and compact.

In any case, the node spec. probably needs to clarify what happens if there
is a param in the template without a default value or supplied value in the
instance. Undefined ? Fall back to x3d default values ?

I somewhat fear that in the end it may be necessary to deal with a parsed
xml (html) tree for the macro expansion rather than simple string
substitution.

Andreas


> Leonard Daly
>
>
>
>
>
> -Andreas
>
>
> On Fri, Aug 26, 2016 at 10:39 PM, Leonard Daly <web3d at realism.com> wrote:
>
>> For the last year I have been working on advancing X3D to be standardized
>> in HTML5/DOM environment and support mobile and VR. I have just completed
>> alpha work on the Macro node. This node provides the static definition
>> capabilities of PROTO in an HTML5 environment. It can perform string
>> substitution (name/value pairs) on X3D code stored externally. The node
>> documentation is at http://tools.realism.com/speci
>> fication/x3d-v40/abstract-specification/changes-additions-x3d-v33/macro.
>>
>> I will continue to get to at least alpha stage (basic functional
>> implemented and working) for all nodes I discussed during my presentations
>> at Web3D2016 & SIGGRAPH. The presentation is online at
>> http://realism.com/presentations/188?title=Extending-X3DOM-to-Mobile.
>>
>> All of the code is up on Github at https://github.com/DrX3D/x3dv4 with
>> testing code.
>>
>> I am interested in any bugs that are found or new/revised direction for
>> the nodes. I am completely open to anyone who would like to help code.
>>
>> --
>> *Leonard Daly*
>> 3D Systems Architect
>> Cloud Consultant
>> President, Daly Realism - *Creating the Future*
>>
>> ------------------------------------------------------------
>> ------------------
>>
>> _______________________________________________
>> X3dom-users mailing list
>> X3dom-users at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/x3dom-users
>>
>>
>
>
> --
> Andreas Plesch
> 39 Barbara Rd.
> Waltham, MA 02453
>
>
>
> --
> *Leonard Daly*
> X3D Co-Chair
> Cloud Consultant
> President, Daly Realism - *Creating the Future*
>



-- 
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160828/5f45b364/attachment.html>


More information about the x3d-public mailing list