[x3d-public] SFRotation constructor axis argument by reference or value ?

John Carlson yottzumm at gmail.com
Tue Mar 3 08:29:16 PST 2020


I think there’s more going on.   Primitives are passed by value, not by
reference.

The question becomes, does the axis reference get stored internally, such
that rot.axis.y is the value you are talking about, or does it get copied
to rot.y?

On Tue, Mar 3, 2020 at 9:08 AM Andreas Plesch <andreasplesch at gmail.com>
wrote:

> In the ecmascript SAI, SFRotation has a constructor which has the
> rotation axis as a SFVec3f argument:
>
> new SFRotation ( SFVec3f axis, numeric  angle )
>
>
> https://www.web3d.org/documents/specifications/19777-1/V3.3/Part1/functions.html#SFRotation
> (Table 7.18, -url in the first sentence is off-)
>
> The question is when I make a new SFRotation and later change the
> SFVec3f which was used for the axis, does the previously constructed
> SFRotation also change ?
>
> axis = new SFVec3f ( 0, 0, 1 );
> rot = new SFRotation( axis, 3.14 );
> axis.y = 1.0
> axis.z = 0.0
> // rot.y is ?
> // constructed by value: rot.y = 0.0
> // constructed by reference: rot.y = 1.0
>
> I did not check the abstract SAI spec. for guidance so it is very
> possible I missed something.
>
> This is just an example. There are of course other constructors which
> use objects as parameters. It is also probably rare that a script
> would want to do this.
>
> It may depend on the scripting language. In ecmascript objects are
> passed by reference, you have to explicitly make a copy if you need
> it. This is for performance. So I would guess for ecmascript it should
> be rot.y = 1.0 .
>
> -Andreas
>
>
> --
> Andreas Plesch
> Waltham, MA 02453
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200303/51ef6d77/attachment.html>


More information about the x3d-public mailing list