[x3d-public] Proposal: expressions

Yves Piguet yves.piguet at gmail.com
Fri Sep 16 01:14:06 PDT 2016


Thanks for your reactions, Don!

On 16 sept. 2016, at 05:02, Don Brutzman wrote:

> Some reactions:
> 
> - likely difficult to get existing base of players to adopt this kind of change, affects a player's scene parsing and scripting capabilities simultaneously.

Yes, I agree. Mostly parsing/evaluating and maybe the execution model, depending on the player architecture.

> - taking care to avoid over-mixing of presentation and content/computation.
> - potential security considerations, dangers inherent in running dynamic code.

That's why I limit the "language" to simple expressions, not a general-purpose programming language: no loop, no recursion, no arbitrary storage to variables, no file or internet access... In an authoring environment, you should be able to enter an expression in the same kind of input field as an IS reference.

The goal is to simplify X3D files, not to extend their capabilities and the associated potential security risks. But that's relevant mainly in cases where files are created by hand, not generated programmatically from a higher-level format. I don't know how X3D is usually authored; because of the emphasis on the XML encoding and the current work on JSON, I suspect hand-written files are less common.

> + consider similarities to PHP, macros, other hybrid-programming constructs.
> + comparing compatible approaches with X3D Script node as well as HTML script code is helpful - in some sense you are simply moving the locations of expressions around, from page to scripts to scene (and perhaps from client to server).

In terms of capabilities, yes. But the syntax aims at convenience. Our implementation is pure JavaScript/WebGL in the web browser.

> + might be considered a variant/superset of X3D, where a preprocessor takes your version and "expands macros" to create compliant X3D.
> + a Script node (or Prototype with embedded Script node) could take your expressions as an SFString field input and run javascript eval() function at run time.

Different implementations are possible with different consequences in terms of security, convenience and speed.

Thanks for the reference to Alexei Sourin's book. I'd seen the web page about fVRML. If I understand it correctly, expressions are used for a different purpose, more flexible and powerful nodes for geometries, textures and transforms.

Best,

Yves




More information about the x3d-public mailing list