question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Arguments are passed to Ray by reference in constructor but by value in .set

See original GitHub issue
Description 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:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Neptilocommented, Oct 28, 2019

Thanks. I will do when I find some time

1reaction
Neptilocommented, Oct 15, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found