Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rays should look like they're passing through things. #125

Closed
sarchang opened this issue Jul 20, 2021 · 27 comments
Closed

Rays should look like they're passing through things. #125

sarchang opened this issue Jul 20, 2021 · 27 comments

Comments

@sarchang
Copy link
Contributor

sarchang commented Jul 20, 2021

(This comment was edited by @pixelzoom.)

The optical axis should appear to poke through the object and the image (real and virtual).

The optical axis should also appear to poke through the projection screen, to prevent a 3D optical illusion effect.

Ditto for rays.

This should not apply to light sources.

@veillette veillette added the dev:enhancement New feature or request label Jul 22, 2021
@kathy-phet kathy-phet added this to the Feature Complete Milestone milestone Sep 2, 2021
@pixelzoom pixelzoom changed the title Optical axis should pass through object and image Optical axis should pass through object, image, and projection screen. Oct 21, 2021
@pixelzoom
Copy link
Contributor

In #109 (comment), @veillette said:

In order to give 3D perspective, it was suggested that the object and images be split in half vertically, where each half would be on a different z layer. The optical axis and rays could then be allow to fit within the two z-layers to give a sense of depth.

The flash simulation uses a similar approach with the projector screen (but not the images).
image

@pixelzoom pixelzoom changed the title Optical axis should pass through object, image, and projection screen. Optical axis and rays should pass through object, image, and projection screen. Oct 21, 2021
@phetsims phetsims deleted a comment from veillette Oct 21, 2021
@pixelzoom
Copy link
Contributor

pixelzoom commented Oct 21, 2021

10/21/2021 design meeting: @arouinfar @kathy-phet @ariel-phet

Splitting each object, image, and projection screen into 2 Nodes is going to be quite a mess. I'm speaking from experience, since I did this in Faraday's Electromagnetic Lab.

I'm going to investigate another approach, where the optical axis and rays are split into multiple Nodes. The optical axis seems straightforward, the rays wil be tricky.

@pixelzoom
Copy link
Contributor

Moving the optical axis part of this to #283, since it's going to be a separate chunk of work.

@pixelzoom pixelzoom changed the title Optical axis and rays should pass through object, image, and projection screen. Rays should pass through object, image, and projection screen. Dec 22, 2021
@pixelzoom pixelzoom changed the title Rays should pass through object, image, and projection screen. Rays should look like they're passing through things. Dec 22, 2021
@pixelzoom
Copy link
Contributor

From #283 (comment):

@pixelzoom
Copy link
Contributor

pixelzoom commented Jan 5, 2022

Similar to what I did in #283 with OpticalAxisForegroundNode extends OpticalAxisNode ....

Create class LightRaysForegroundNode extends LightRaysNode. Use clipArea: null for virtual image and projection screen. For real image, set clipArea to everything to the left of the image's position.

Then in GOScreenView.js:

const lightRays1Node = new LightRaysNode( ... );
const lightRays2Node = new LightRaysNode( ... );
const lightRays1ForegroundNode = new LightRaysForegroundNode( ... );
const lightRays2ForegroundNode = new LightRaysForegroundNode( ... );

... and adjust the rendering order.

pixelzoom added a commit that referenced this issue Jan 5, 2022
@pixelzoom
Copy link
Contributor

pixelzoom commented Jan 5, 2022

In the above commit, I did what I described in #125 (comment). ?debugRays renders the foreground rays with 'red' stroke.

This is looking pretty nice imo:

screenshot_1490

@pixelzoom
Copy link
Contributor

@arouinfar This is ready for review in master. The current opacity of the image mask is 0.8. Let me know if you'd like to see more or less of the occluded rays. Note that this opacity will also affect how much of the occluded optical axis is seen.

@pixelzoom
Copy link
Contributor

pixelzoom commented Jan 19, 2022

The problem noted in #125 (comment) is due to the clipArea not being properly transformed (translated and scaled). In the above commit, I added rendering of the clipArea with ?debugRays, and this is what it looks like (red rectangle). Rays in red are the foreground rays, inside the clipArea.

screenshot_319

This was indeed a problem in 1.1.0-dev.14 and earlier, but only noticeable when you zoomed out. Here's ?debugRays in 1.1.0-dev.14, when zoomed out. clipArea rendering had not been added in this version, but the red rays are the ones the are inside the clipArea.

screenshot_318

So it's not worth reverting a9b9e6a for #277 to address this. It was broken before that change was made, just less obvious.

@pixelzoom
Copy link
Contributor

The problem noted in #125 (comment) is fixed in the above commits, published in 1.1.0-dev.17.

Assigned to @arouinfar for guidance on the cases where a ray appears to pass in front of the Object, as shown in #125 (comment). What would make the most sense to me is to have the rays stop at the Object. But that would require significant changes to the ray-tracing code - which I have so far managed not to touch much.

@pixelzoom pixelzoom removed their assignment Jan 20, 2022
@ariel-phet
Copy link

@pixelzoom for the problems noted in #125 (comment) I think only the 2nd and 3rd case are egregious. However, in those case I do think the most correct thing would be to have the rays stop at the object, despite the unfortunate nature of modifications to the ray-tracing code.

@pixelzoom
Copy link
Contributor

1/20/22 design meeting:

We all agreed that it would be preferable to not have rays going through the Object. But this could be costly, and would also involve adding information about the height (bisector line) of the framed objects. I'll do 1-2 hours of exploration and report back.

@pixelzoom
Copy link
Contributor

In LightRay.js, here's the code that handles termination of a ray on the projection screen. Terminating a ray on the Object would probably involve something similar.

    // If we have a projection screen, check whether the last ray intersects the projection screen,
    // and therefore terminates at the projection screen.
    if ( projectionScreen ) {
      setFinalPointOnProjectionScreen( this.realRays, projectionScreen.getBisectorLineTranslated() );
    }

@pixelzoom
Copy link
Contributor

pixelzoom commented Jan 21, 2022

We all agreed that it would be preferable to not have rays going through the Object. But this could be costly, and would also involve adding information about the height (bisector line) of the framed objects. I'll do 1-2 hours of exploration and report back.

It wasn't too difficult to locate the relevant ray-tracing code, and clean it up so that it could be used to terminate rays at the Projection Screen or the Object.

There are 2 additional changes that would need to be made in order to terminate rays that intersect the Object:

  • add a bisection line for "framed objects" to the model (non-trivial)
  • modify the ray clipArea used for mirrors (relatively easy)

Before making any big changes, I added a hard-coded bisection line, just so I could see what it looks like. And what I saw concerned me. The representation for rays has no directionality, and you only see directionality when rays animate (when changing Rays radio buttons, or pressing Show/Hide button). So when looking at the static "picture", reflected rays that stop at the Object might be misinterpreted as rays that originate from the Object.

Below are screenshot for 2 scenarios, comparing "Object blocks reflected rays" vs "Reflected rays pass in front of Object".

I discussed this with @arouinfar. She doesn't want to add directional indicators (e.g. arrows) to the rays, and I agree. While both approaches have problems, "reflected rays pass in front of Object" seems to be the less-problematic approach, and could be noted in Teacher Tips. So we're inclined to allow reflected arrays to pass in front of Objects.

@ariel-phet @kathy-phet do you agree?


SCENARIO 1: Concave Mirror

Object blocks reflected rays:
screenshot_327

Reflected rays pass in front of Object:
screenshot_328


SCENARIO 2: Convex Mirror

Object blocks reflected rays:
screenshot_329

Reflected rays pass in front of Object:
screenshot_330

@pixelzoom
Copy link
Contributor

pixelzoom commented Jan 21, 2022

If you'd like to test-drive the "Object blocks reflected rays" approach, see 1.1.0-dev.18.

I reverted 75cf430 after publishing 1.1.0-dev.18.

@pixelzoom
Copy link
Contributor

@arouinfar if you're confident about our decisions in #125 (comment), then there is nothing left to do, and you can close this issue. Or we can leave it open until @ariel-phet and @kathy-phet weigh in. Your call.

@arouinfar
Copy link
Contributor

@pixelzoom I am confident in our decision to allow reflected rays to pass over the object. I've made a note to document this behavior in the Teacher Tips, so I'll go ahead and close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants