[x3d-public] ECMAScript

Joe D Williams joedwil at earthlink.net
Mon Aug 7 07:47:36 PDT 2023


well, all you have to say is that sorry, I don't support x3d Script node. I've got my own stuff, nana
This is the same as somebody saying we still like the old EAI and don't want to change to SAI. 
Or. I like the old vrmlscript and don't want change to ecmascript. 
Also same as no, I don't want to generate tex stuff for an IFS, even if the spec says i should. 
HAnimDisplacer? 

> So executing scripts within the models is not a commonly needed feature.

How about showing some examples of an external script doing something that could not be done better by internal script, or by internal x3d node? Does this external script operate anything like the x3d SAI?  

A commonly needed feature of x3d is portable between tools. 

Good Luck,
Joe

-----Original Message-----
From: Michalis Kamburelis <michalis.kambi at gmail.com>
Sent: Aug 7, 2023 6:40 AM
To: Joseph D Williams <joedwil at earthlink.net>
Cc: X3D Graphics public mailing list <x3d-public at web3d.org>
Subject: Re: [x3d-public] ECMAScript

Indeed, view3dscene / Castle Game Engine is missing ECMAScript.

It is on the roadmap, and certainly possible to do. We could use
Duktape like FreeWRL; or other JS engines -- whatever is lightweight
to execute and easy to maintain.

But admittedly implementing JS scripting is not high priority in our
case. Reason: most of CGE users do programming "outside" of X3D, using
Castle Game Engine API to manipulate scenes (and X3D nodes too). This
API is available from Pascal, we think about extending to other
languages (Python) in the future too. In most cases, people want to
treat model formats like X3D or glTF (or anything else) as just
carriers of information between 3D authoring tool and CGE. So
executing scripts within the models is not a commonly needed feature.

As a solution for now: We support CastleScript, a really simple (very
simple, much more limited than JS) language for simple things. See
https://castle-engine.io/castle_script.php . It can express the
operation you do in your samples :) And in X3D "Script" node, you can
specify a few alternatives, so you could have both ecmascript and
castlescript versions for cross-browser support. If you want to
pursue this option, the "OrientationData" node would look like this:

-----------
#X3D V3.2 utf8
PROFILE Interchange

DEF OrientationData Script {
outputOnly MFString orientation
inputOnly SFRotation printOrientation
initializeOnly SFString sep ", "
url [
"ecmascript:
function printOrientation (value,ts) {
var x = Math.round(value.x*100)/100;
var y = Math.round(value.y*100)/100;
var z = Math.round(value.z*100)/100;
var angle = Math.round(value.angle*100)/100;
orientation = new MFString ( x + sep + y + sep + z + sep + angle );
}
"
"castlescript:
function foo(value,ts)
{ Note that we have to hardcode sep value (comma) below, due to
CastleScript limitations. }
orientation :=
string(round(vector_get(value, 0) * 100) / 100) + ',' +
string(round(vector_get(value, 1) * 100) / 100) + ',' +
string(round(vector_get(value, 2) * 100) / 100) + ',' +
string(round(vector_get(value, 3) * 100) / 100) + ','
"
]
}
-----------

Regards,
Michalis

niedz., 6 sie 2023 o 22:31 Joseph D Williams napisał(a):
>
>
>
> Hi, view3dscene, missing ECMAScript.
>
> Near implementation?
>
> All I need is some basic stuff. :
>
>
>
> DEF PositionData Script {
>
> outputOnly MFString position
>
> inputOnly SFVec3f printPosition
>
> initializeOnly SFString sep ", "
>
> url "ecmascript:
>
> function printPosition (value,ts) {
>
> var x = Math.round(value.x*100)/100; // simple 2 decimal digits
>
> var y = Math.round(value.y*100)/100;
>
> var z = Math.round(value.z*100)/100;
>
> position = new MFString ( x + sep + y + sep + z );
>
> }
>
> "
>
> }
>
>
>
> DEF OrientationData Script {
>
> outputOnly MFString orientation
>
> inputOnly SFRotation printOrientation
>
> initializeOnly SFString sep ", "
>
> url "ecmascript:
>
> function printOrientation (value,ts) {
>
> var x = Math.round(value.x*100)/100;
>
> var y = Math.round(value.y*100)/100;
>
> var z = Math.round(value.z*100)/100;
>
> var angle = Math.round(value.angle*100)/100;
>
> orientation = new MFString ( x + sep + y + sep + z + sep + angle );
>
> }
>
> "
>
> }
>
>
>
> Thanks,
>
> Joe
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org





More information about the x3d-public mailing list