Arguments are passed to Ray by reference in constructor but by value in .set
See original GitHub issueDescription of the problem
The origin
and direction
vector arguments are inconsistently passed by reference in THREE.Ray
’s constructor and passed by value in its .set
method.
This has the effect that the vectors initially passed in the constructor are unexpectedly modified when calling .set
.
Example:
let o0 = new THREE.Vector3(1, 2, 3);
let d0 = new THREE.Vector3(4, 5, 6);
let ray = new THREE.Ray(o0, d0);
let o1 = new THREE.Vector3(3, 2, 1);
let d1 = new THREE.Vector3(6, 5, 4);
ray.set(o1, d1);
o0
and d0
now contain the values of o1
and d1
.
Three.js version
- Dev
- r109
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
What kinds of constructor will be invoked when an object ...
In Java, objects are only passed by value when they are serialised and deserialised. Java only uses object references, but remote method call...
Read more >Passing by reference to a constructor - c++ - Stack Overflow
I take take a const string& in the constructor and assign it to the public member variable.
Read more >Passing Information to a Method or a Constructor
Arguments are the actual values that are passed in when the method is invoked. ... used only within constructors and methods that set...
Read more >Default Constructor - an overview | ScienceDirect Topics
Our Person class has two constructors: a default constructor that takes no parameters and a non-default constructor that takes a std::string name.
Read more >11: References & the Copy-Constructor
Look at the point inside f( ), which occurs after the argument is passed by value. This means the original object h exists...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks. I will do when I find some time
Thanks for the info. I guess I never came across such objects. Can you give some examples? This behavior seemed very unintuitive to me and I was certain it was a bug. If it is a convention, then I think it should at least be mentioned somewhere in the doc.