Ray Optics Simulation: 2D optical scenes in the browser
A web app for creating and simulating 2D geometric optical scenes, with a gallery of (interactive) demos.
At a glance
- What is it?
- Ray Optics Simulation is a browser-based JavaScript application for constructing 2D geometric optics models, tracing rays, and exporting diagrams or irradiance data. It suits educators, students, and engineers who need interactive optical layouts, but its 2D scope and beta WebGPU engine narrow its use for physically complete system analysis.
- Who is it for?
- Ray Optics Simulation is appropriate for teaching geometric optics, prototyping 2D arrangements, and inspecting ray and image behavior through a graphical interface. It is less suitable for users who require a 3D layout, full-wave analysis, or production simulation without reviewing the optical assumptions behind each component.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 19 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Ray Optics Simulation's geometric optics workspace
Ray Optics Simulation solves the problem of arranging optical elements in a two-dimensional plane and seeing how rays interact with them. It is aimed at people who need an interactive way to explain or inspect a geometric optics arrangement: students learning reflection and refraction, educators preparing demonstrations, and engineers sketching a conceptual optical system. The web application provides a simulator, a gallery of interactive examples, and documentation rather than presenting ray optics as a command-line-only calculation package.
The supported scene vocabulary is broad for a 2D simulator. Sources include individual rays, parallel beams, divergent beams, and point sources. Optical elements include linear and curved mirrors, refraction interfaces, ideal lenses and mirrors, spherical lenses defined by front and back focal distances, beam splitters, dichroic mirrors, diffraction gratings, and gradient-index materials. A custom equation can define a surface, a refractive index function, or custom ray interaction. That combination makes the application useful when a stock lens or mirror description does not match the geometry a user needs to represent.
The application also treats color as part of the model rather than as a purely decorative display setting. Scenes can include mixtures of colors, color filtering, and chromatic dispersion. Measurements cover distance, angle, energy flow, and momentum flow. The README further describes direct views of real images, virtual images, virtual objects, and images observed from a chosen position. These features point to an educational and exploratory tool, not a general replacement for optical design software with a prescribed 3D coordinate system and vendor-specific analysis reports.
Ray tracing from source to optical element
The simulator is organized around constructing a scene from optical objects and then tracing rays through those objects. A ray begins at a source such as a point source or a beam and encounters defined elements in the two-dimensional layout. The documented elements then alter ray paths according to their type. Mirrors reflect rays, interfaces refract them, lenses and ideal optical components follow their stated optical equations, and gratings produce diffraction behavior. The exact implementation of each interaction is defined by the component model, so a scene that mixes several elements requires users to understand which assumptions apply at each boundary.
The visible architecture is also modular. The README says that users can create modularized combinations of optical elements with custom parameters. This is more than a list of isolated widgets: the simulator can represent repeated or grouped optical arrangements, while modules can be imported through the import module interface when the full project is built. The project is written in ES6 JavaScript and bundled with Webpack. The repository contains separate build configuration, tests, source code, data, integrations, and optional node-related tooling. That layout indicates a browser application first, with a node module path intended for integration into other projects and programming languages.
The feature list includes extensions of rays, which helps determine whether lines converge toward a virtual image. This distinction matters because simply seeing a drawn ray extension can lead to an incorrect interpretation of where an image is observable. The simulator can also display real images, virtual images, and virtual objects directly, and can calculate what can be observed from a specified position. The documentation does not claim that these outputs reproduce every effect of a physical laboratory measurement, so results should be read within the model's geometric-optics assumptions.
WebGPU tracing and export paths in Ray Optics Simulation
The README identifies a high-performance ray tracing engine based on WebGPU, but labels it Beta. That distinction changes how an evaluator should interpret the performance feature. The normal simulator is available through the web application, while the WebGPU path is presented as a beta capability. The README does not document browser compatibility, fallback behavior, numerical tolerances, or a performance comparison, so none of those can be assumed. A team considering WebGPU should verify the browser and operating system requirements separately before depending on that path.
For analysis outside the visual canvas, Ray Optics Simulation supports an irradiance map that can be exported as CSV data. It can also export a scene as an SVG diagram. These formats serve different purposes. SVG preserves a vector representation of the optical layout, which is useful for diagrams and documentation. CSV is intended for numerical irradiance data, which is more suitable for downstream inspection in a spreadsheet or data-processing environment. The README does not state the CSV schema or specify whether irradiance values are normalized, so users should inspect the export header and units before combining results with other data.
Import and export also affect how scenes enter a workflow. SVG files can be imported as optical components, and modules can combine elements with custom parameters. The documentation does not claim round-trip preservation of every scene property through SVG export and import. It should therefore be treated as a diagram or component interchange path, not as an assumed backup format for every simulation setting.
Running Ray Optics Simulation locally for a first scene
The README separates ordinary web-app use from local development. If the goal is simply to use the simulator, the documented entry point is the hosted simulator. For development, Node.js is required, and the README identifies version 18 or later as a troubleshooting requirement. The following commands clone the repository, install the developer dependency set, and start the simulator:
git clone https://github.com/ricktu288/ray-optics.git
cd ray-optics
npm install --no-optional
npm run startAfter the start command completes successfully, the README says the simulator should be available at `http://localhost:8080/simulator/`. In this developer installation, some links and the import module window will not work because the rest of the project has not been built. That limitation matters for a first use involving imported modules. For a complete build, including the home pages, gallery, modules, documentation, and node version of the simulator, use:
npm install
npm run build
npm run startThe README states that the complete website content is placed in the `dist` folder. It also warns that the full build can take about half an hour because the gallery requires generation of a large number of images. The first practical use is therefore either opening the hosted simulator without a local build, or starting the developer server and accepting that module-related features may be unavailable until the complete build has been produced.
Maintenance, releases, and the limits of the 2D model
The repository is not archived, and its last push was on 2026-10-05. The release list includes v5.4.0 dated 2026-08-22, v5.3.2 dated 2026-05-08, and v5.3.1 dated 2026-04-23. The package metadata identifies the current package version as 5.5.0, while the README's listed release history does not show a corresponding v5.5.0 entry. That mismatch is worth checking before citing or packaging a particular version. The README says that users should cite the Zenodo record for the version they use, and it provides separate guidance for online use, beta features, local releases, and repository clones.
The clearest limitation is the model's two-dimensional scope. The repository description and README explicitly describe 2D geometric optical scenes. A scene can contain many mirrors, interfaces, lenses, sources, and custom equations, but the documentation does not present this as a 3D ray-tracing package. It also does not claim to perform full electromagnetic or wave-based analysis. Diffraction gratings and gradient-index materials are listed as supported scene elements, but their presence does not by itself establish that the application models every relevant physical phenomenon. Users who need validated 3D layout, polarization, wave propagation, coating behavior, or manufacturing tolerances should verify the specific component implementation before adopting it.
A real alternative approach is to implement a dedicated optical calculation system or use a general numerical ray tracer with an explicit 3D scene model. That approach can offer a different geometry system and a more formal numerical API, but it requires users to assemble source definitions, intersections, material properties, and visualization themselves. Ray Optics Simulation instead supplies an interactive scene editor, examples, image visualization, measurements, and export features in one application. Its trade-off is that browser-oriented flexibility does not remove the need to inspect the equations and limitations of the selected optical component.
Apache-2.0 licensing and contribution boundaries
Ray Optics Simulation is distributed under the Apache-2.0 license. That license identifier is stated both in the repository description and in `package.json`. This is relevant to teams considering redistribution, modification, or embedding the simulator, although the license text should be reviewed for the obligations that apply to a particular distribution. The README does not provide legal advice or a project-specific interpretation of the license, so the safest approach is to read `LICENSE` and preserve required notices when handling the code.
The contribution documentation identifies several routes for involvement. Adding gallery items, translations, and modules may require little or no programming knowledge. Code contributions require JavaScript and module-bundling knowledge, consistent with the repository's ES6 and Webpack architecture. Translations use Weblate, while the README points contributors to `CONTRIBUTING.md` for the process and `ROADMAP.md` to avoid duplicate work. This separation is useful because it tells adopters which parts of the project are intended to remain stable interfaces and which parts require more specialized development knowledge. It does not, however, provide a compatibility guarantee for scenes created with one version and reopened in another.
Editorial conclusion
Ray Optics Simulation is appropriate for teaching geometric optics, prototyping 2D arrangements, and inspecting ray and image behavior through a graphical interface. It is less suitable for users who require a 3D layout, full-wave analysis, or production simulation without reviewing the optical assumptions behind each component. Before adoption, verify that Node.js 18 or later is available in your environment, inspect the behavior of the specific optical elements and equations you need, and decide whether the beta WebGPU trace path is acceptable for the intended environment. The project is licensed under Apache-2.0, so review the repository license and release metadata before distributing modifications.
Frequently asked questions
How do I install and run Ray Optics Simulation locally?
The README says to install Node.js, clone the repository, run `npm install --no-optional`, and then run `npm run start`. The simulator should then be available at `http://localhost:8080/simulator/`, although some links and the import module window require a complete build.
Does Ray Optics Simulation support 3D optical scenes?
No. The repository describes Ray Optics Simulation as a web app for 2D geometric optical scenes. The documented features concern planar layouts, 2D ray behavior, SVG diagrams, and related visualization, not a 3D optical design system.
Can Ray Optics Simulation export simulation data?
Yes. The README documents export of an irradiance map as CSV data and export of scenes as SVG diagrams. It does not specify the CSV column schema or guarantee that every scene setting survives an SVG round trip.
What optical components can be added to a Ray Optics Simulation scene?
The documented components include linear and curved mirrors, beam splitters, dichroic mirrors, refraction interfaces, ideal lenses and mirrors, spherical lenses, gradient-index materials, diffraction gratings, and custom surfaces. Rays can originate from ray, beam, or point-source configurations.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/ricktu288-ray-optics)Was this useful?