Global

Members

(constant) DATA_VERSION :number

The version of the JSON data format of the scene, which matches the major version number of the app starting from version 5.0.

Type:
  • number
Source:

(constant) FN1

One-argument functions: LaTeX command → math.js name

Source:

(constant) FORMULA_MODULE_TOOLTIP_MAX_LINES

Max tooltip lines when listing distinct expanded values across instances/rows. When exceeded, shows first (this − 2) value rows, an ellipsis line, then the last row.

Source:

(constant) FOR_IF_DEFAULTS

Get a value from an object by a dot-separated key path. Numeric segments are treated as array indices.

Source:

(constant) GREEK_SYMBOL

LaTeX math-mode command (no leading ) → math.js symbol name

Source:

(constant) JSON_INNER_COLLAPSE_THRESHOLD

Inner length (between { and }) above which we collapse the segment in the UI.

Source:

(constant) LITERAL_NUMERIC_TOKEN

Single JS-style numeric token (no thousands separators).

Source:

(constant) MODULE_EDITOR_LIST

One sidebar list may have selection at a time; add keys when adding new lists (see clearOtherModuleSidebarLists).

Source:

(constant) usePreferencesStore

Create a Vue store for application preferences that persist to localStorage

Source:

(constant) useSceneStore

Create a Vue store for the scene, which is a wrapper around the Ray Optics Simulation core library Scene class. /** Create a Vue store for the scene, which is a wrapper around the Ray Optics Simulation core library Scene class.

Source:

(constant) useStatusStore

Create a Vue store for application status

Source:

(constant) useThemeStore

Create a Vue store for theme properties, which manages the nested theme structure from Scene.

Source:

(constant) vTooltipPopover

Vue directive for handling Bootstrap tooltips and popovers Usage:

  • For tooltips: v-tooltip-popover="{ title: 'Tooltip text' }"
  • For popovers: v-tooltip-popover:popover="{ title: 'Title', content: 'Content', popoverImage: 'image.svg' }"
Source:

Methods

CircleObjMixin(Base) → {T}

The mixin for the scene objects that are defined by a circle.

Parameters:
Name Type Description
Base T
Source:
Returns:
Type
T

LineObjMixin(Base) → {T}

The mixin for the scene objects that are defined by a line segment.

Parameters:
Name Type Description
Base T
Source:
Returns:
Type
T

ParamCurveObjMixin(Base) → {T}

The mixin for the scene objects that are defined by a line segment.

Parameters:
Name Type Description
Base T
Source:
Returns:
Type
T

applyTextareaAutoResize()

Sets textarea height from content. Returns false if skipped (hidden / not measurable); does not write a zero height in that case.

Source:

buildModuleInstanceTooltipHtml(allRows) → {string}

Build Bootstrap tooltip title HTML from rows of cell tuples (same shape as FormulaInput).

Parameters:
Name Type Description
allRows Array.<Array.<*>>
Source:
Returns:
Type
string

checkRayIntersectsShape(ray) → {Point}

Check if a ray intersects the circle. In the child class, this can be called from the checkRayIntersects method.

Parameters:
Name Type Description
ray Ray

The ray.

Source:
Returns:

The intersection point, or null if there is no intersection.

Type
Point

checkRayIntersectsShape(ray) → {Point}

Check if a ray intersects the line segment. In the child class, this can be called from the checkRayIntersects method.

Parameters:
Name Type Description
ray Ray

The ray.

Source:
Returns:

The intersection point, or null if there is no intersection.

Type
Point

collapseRedundantNestedParentheses(node) → {*}

Collapse AST chains ParenthesisNode(ParenthesisNode(x)) to a single ParenthesisNode so e.g. ((a+b)) does not become redundant nesting in output. Does not unwrap a single outer pair around a product like ((a+b)*(c+d)).

Parameters:
Name Type Description
node *

math.js expression AST node

Source:
Returns:

math.js expression AST node

Type
*

collectPointPaths(objData, schema, basePathopt) → {Array.<string>}

Recursively collect all point-type property paths from schema and objData. Handles arrays with itemSchema by expanding to concrete indices from objData.

Parameters:
Name Type Attributes Default Description
objData Object

Template object data.

schema Array

Property schema descriptors.

basePath string <optional>
''

Base path for nested contexts.

Source:
Returns:

List of full dot-separated paths to point values.

Type
Array.<string>

controlPointIndexAfterReorder()

Index s after moving one item from from to to.

Source:

countIntersections(point) → {number}

Count intersections between a horizontal ray from the point and the parametric curve. Uses a more robust crossing number algorithm that handles dense/repeated points. Lazy-generates the path if needed.

Parameters:
Name Type Description
point Point

The point from which to cast the horizontal ray

Source:
Returns:

Number of intersections with the curve boundary

Type
number

deepEqual(obj1, obj2) → {boolean}

Recursively compare two objects for equality.

Parameters:
Name Type Description
obj1 *

First object

obj2 *

Second object

Source:
Returns:

True if objects are equal

Type
boolean

distancePointToSegment(point, segment) → {number}

Calculate distance from a point to a line segment.

Parameters:
Name Type Description
point Point

The point

segment Line

The line segment

Source:
Returns:

Distance from point to segment

Type
number

draftsToCommittedValue()

Same shape as passed to applyUpdate in commitForDrafts (for equality checks).

Source:

drawPath(canvasRenderer, offset)

Draw the parametric curve path on the canvas. This method sets up the canvas path but does not stroke or fill it.

Parameters:
Name Type Default Description
canvasRenderer CanvasRenderer

The canvas renderer

offset number 0

Optional offset distance perpendicular to the curve (positive = left side)

Source:

equationDisplayToValue(text, isTemplate) → {string|undefined}

Convert a display string (user-entered math.js text) back to a stored equation value.

In template mode the value is wrapped in double backticks. In non-template mode the value is converted to LaTeX, then validated by parsing that LaTeX back to math.js so stored values remain editable.

Parameters:
Name Type Description
text string

The user-entered math.js expression.

isTemplate boolean

Whether the current context is a template.

Source:
Throws:

If non-template conversion to LaTeX fails or the LaTeX cannot be read back.

Returns:

The stored value, or undefined for empty input.

Type
string | undefined

equationValueForListDisplay(value) → {string}

Plain-text equation for object list descriptions (matches EquationPropertyControl / equationValueToDisplay): LaTeX → math.js string; expr → inner expr; unsupported → raw stored value.

Parameters:
Name Type Description
value *

The stored equation value.

Source:
Returns:
Type
string

equationValueToDisplay(value) → {Object|Object}

Check whether a stored equation value is supported by the visual editor and extract the math.js display string.

Supported formats:

  • A string without backticks: interpreted as LaTeX, converted to math.js.
  • A string that is a single double-backtick block (expr): the inner part is already math.js.
Parameters:
Name Type Description
value *

The stored equation value.

Source:
Returns:
Type
Object | Object

extractNonDefaults(obj, defaults) → {Object|null}

Recursively extract only non-default values from a nested object.

Parameters:
Name Type Description
obj Object

The object to extract from

defaults Object

The default values

Source:
Returns:

Object containing only non-default values, or null if all values are default

Type
Object | null

findMatchingBraceEnd(s, openIdx) → {number}

Index of the matching } for { at openIdx, or -1. Ignores { / } inside JSON strings.

Parameters:
Name Type Description
s string
openIdx number
Source:
Returns:
Type
number

findValidJsonObjectSpans(line) → {Array.<{start: number, end: number, json: string}>}

Non-overlapping { ... } spans that parse as JSON.

Parameters:
Name Type Description
line string
Source:
Returns:
Type
Array.<{start: number, end: number, json: string}>

formatKeyPath(path) → {string}

Format a dot-separated key path into a more familiar bracket notation. Numeric segments become array indices: path.1.x → path[1].x Reserved JS keywords (for, if) use bracket notation: obj.if → obj["if"]

Parameters:
Name Type Description
path string

Dot-separated key path.

Source:
Returns:

The formatted path.

Type
string

formatStatusLineHtml(line, options) → {string}

HTML for one status line with long JSON segments collapsed to { [icon] }.

Parameters:
Name Type Description
line string
options object
Properties
Name Type Attributes Description
expanded Record.<string, boolean>
keyPrefix string

e.g. 'w' or 'e'

lineIdx number
labels Object
threshold number <optional>
Source:
Returns:
Type
string

formatTooltipNumber()

If the value shows 4+ digits after the decimal point, round for display to 3 places.

Source:

formulaDisplayToValue(text, typeopt) → {number|boolean|string|undefined}

Convert a display string (user-entered text) back to a stored value. For numbers: numeric text becomes a number; anything else is wrapped in backticks. For booleans: "true"/"false" become boolean literals; anything else is wrapped in backticks. Empty string always returns undefined.

Parameters:
Name Type Attributes Default Description
text string
type 'number' | 'boolean' <optional>
'number'
Source:
Returns:
Type
number | boolean | string | undefined

getAllByKeyPath(obj, path) → {Array}

Read values along a dot-separated key path, returning an array of results (one per branch). Like getByKeyPath, but when a numeric segment follows an array that isSourceIndexArray marks as source-indexed, the segment selects every element whose _sourceIndex equals that number (not the array index). Remaining segments are applied to each branch; the final return is the list of leaf values (possibly empty).

Parameters:
Name Type Description
obj Object

Root object.

path string

Dot-separated path (e.g. expanded.2.x). Empty string returns [obj].

Source:
Returns:

All values at the path; [] if no branches match or all branches hit null.

Type
Array

getNextModuleIdentifierName()

Next unused single-letter az, then n0, n1, … — existingNames should include both module parameters and variables.

Source:

getRayIntersections(ray) → {Array}

Get all ray intersections with the parametric curve. Returns an array of intersection data with normal vectors and incident types consistent with CustomArcSurface conventions for counterclockwise arcs.

Parameters:
Name Type Description
ray Ray

The ray to check intersections with

Source:
Returns:

Array of intersection objects with properties:

  • s_point: intersection point
  • normal: {x, y} normal vector
  • incidentType: 1 (inside to outside), -1 (outside to inside), or NaN
  • incidentPiece: piece index (0-based)
  • incidentPos: parameter t value of the intersection
Type
Array

initPath() → {boolean}

Initialize the path points based on the parametric curve pieces. This method generates points for each piece from tMin to tMax with the given step.

Source:
Returns:

Whether the initialization was successful.

Type
boolean

isClosed() → {boolean}

Check if the parametric curve is closed (first point matches last point within floating point error). Lazy-generates the path if needed.

Source:
Returns:

True if the curve is closed, false otherwise

Type
boolean

isFormula(text, typeopt) → {boolean}

Check whether a display string represents a formula (not a literal of the given type).

Parameters:
Name Type Attributes Default Description
text string
type 'number' | 'boolean' <optional>
'number'
Source:
Returns:
Type
boolean

isFormulaValueSupported(value, typeopt) → {boolean}

Check whether a stored value can be displayed/edited by the visual formula editor for the given property type. Supported: undefined, null, backtick-wrapped formula strings, and the native JS type matching type (number for 'number', boolean for 'boolean').

Parameters:
Name Type Attributes Default Description
value *
type 'number' | 'boolean' <optional>
'number'
Source:
Returns:
Type
boolean

isInside(point) → {boolean}

Check if a point is inside the parametric curve (using crossing number algorithm). Lazy-generates the path if needed.

Parameters:
Name Type Description
point Point

The point to test

Source:
Returns:

True if the point is inside the curve, false otherwise

Type
boolean

isLiteralBooleanFieldValue()

True when the field is the boolean literals true or false only (after trim).

Source:

isLiteralNumericFieldValue()

True when the field is a plain number or comma-separated list of numbers (literal user input). In that case we skip the expanded-instance tooltip.

Source:

isNonBasicProperty(descriptor) → {boolean}

Check whether a property is "non-basic" (always shown in partial view). Non-basic: points, equations, and arrays of objects (arrays whose itemSchema is not just a single number or string). Styles are basic.

Parameters:
Name Type Description
descriptor Object

PropertyDescriptor.

Source:
Returns:

True if the property is non-basic.

Type
boolean

isNonDefault(objData, descriptor, serializableDefaults, basePathopt) → {boolean}

Check whether the value at the given descriptor key path differs from the default. Non-basic properties (points, equations, arrays of objects) are always treated as non-default. Basic properties use serializableDefaults for comparison.

Parameters:
Name Type Attributes Default Description
objData Object

Raw/serialized object data (plain object with type and properties; never a class instance).

descriptor Object

PropertyDescriptor with a key property (dot-separated path).

serializableDefaults Object

The default values structure (e.g. from constructor.serializableDefaults).

basePath string <optional>
''

Optional base path when used in nested contexts (e.g. array items).

Source:
Returns:

True if the value is different from the default (or if non-basic, always true).

Type
boolean

isOnBoundary(point) → {boolean}

Check if a point is on the boundary of the parametric curve. Uses distance-based approach similar to checkMouseOver for robustness. Lazy-generates the path if needed.

Parameters:
Name Type Description
point Point

The point to test

Source:
Returns:

True if the point is on the boundary, false otherwise

Type
boolean

isOutside(point) → {boolean}

Check if a point is outside the parametric curve (using crossing number algorithm). Lazy-generates the path if needed.

Parameters:
Name Type Description
point Point

The point to test

Source:
Returns:

True if the point is outside the curve, false otherwise

Type
boolean

isPointHardcoded(value) → {boolean}

Check whether a point value has hardcoded coordinates. Hardcoded means both x and y are numbers (not formula strings). The special coordinates (0, 0) are NOT considered hardcoded.

Parameters:
Name Type Description
value Object | undefined

Point value from template (may have x/y as number or string).

Source:
Returns:

True if the point is hardcoded (numeric x, y, and not (0,0)).

Type
boolean

isPositivelyOriented() → {boolean}

Check if the parametric curve is positively oriented (clockwise in the computer graphics coordinate system). Uses the shoelace formula to calculate signed area. Lazy-generates the path if needed.

Source:
Returns:

True if the curve is positively oriented false otherwise

Type
boolean

isSourceIndexArray(arr) → {boolean}

Returns true when arr looks like a module-expanded list: at least one element is a non-null object with a numeric _sourceIndex (see ModuleObj.expandArray).

Parameters:
Name Type Description
arr Array
Source:
Returns:
Type
boolean

isTextareaAutoResizeMeasurable()

Whether the element participates in layout in a way that yields a real scrollHeight (not e.g. display: none under a hidden sidebar tab).

Source:

latexToMathJS(latex) → {string}

Convert a LaTeX equation string to a math.js expression string.

Parameters:
Name Type Description
latex string

A LaTeX equation string.

Source:
Throws:

If the LaTeX cannot be parsed.

Returns:

The equivalent math.js expression string.

Type
string

mathJSToLatex(mathJSStr) → {string}

Convert a math.js expression string to a LaTeX equation string. Uses the same toTex handler as ModuleObj.expandEquation().

Parameters:
Name Type Description
mathJSStr string

A math.js expression string.

Source:
Throws:

If the expression cannot be parsed or converted.

Returns:

The equivalent LaTeX equation string.

Type
string

mergeWithDefaults(target, source, defaults, path) → {Object}

Recursively merge a nested object with its defaults.

Parameters:
Name Type Description
target Object

The target object to merge into

source Object

The source object to merge from

defaults Object

The default values

path string

The current path for error reporting

Source:
Returns:

The merged object

Type
Object

newlinesToBr(html) → {string}

HTML ignores newline characters in text; convert them to line breaks for status display.

Parameters:
Name Type Description
html string
Source:
Returns:
Type
string

nextDuplicateIdentifier()

Next unused identifier when duplicating a parameter or variable row (the symbol name used in math.js expressions).

  • Increments a trailing integer (a1a2), instead of appending (a1a11).
  • For function-style LHS f(...), only the function symbol before ( changes (f(x)f1(x)).
Source:

normalizeParsedEquationAST(node) → {*}

Parameters:
Name Type Description
node *

math.js expression AST node

Source:
Returns:

math.js expression AST node

Type
*

observeTextareasResizeWhenVisible(getElements, resizeAll) → {Object}

When a textarea lives under tabs / v-show / sidebar chrome, it can become visible after sidebarWidth updates while hidden. Observe intersection and re-measure when shown.

Parameters:
Name Type Description
getElements function

Returns textareas to observe (may include null/undefined entries).

resizeAll function

Re-measure all linked textareas.

Source:
Returns:

{ disconnect } — call disconnect() to stop observing.

Type
Object

populateObjBarShape(objBar)

Populate the object bar with parametric curve controls. This method should be called from populateObjBar in subclasses.

Parameters:
Name Type Description
objBar ObjBar

The object bar instance

Source:

promptNewModuleName(moduleNames) → {string|null}

Prompts for a new module name. Shows alerts on invalid input.

Parameters:
Name Type Description
moduleNames Array.<string>

Existing module names.

Source:
Returns:

The chosen name, or null if cancelled / invalid.

Type
string | null

promptNewModuleNameForHandle(scene) → {string|null}

Prompt for a new module name using the same rules as the module editor (for handle → module conversion).

Parameters:
Name Type Description
scene Object
Source:
Returns:
Type
string | null

sanitizePastedJson(text) → {string}

Prepare clipboard text for the scene JSON editor (fences + comments).

Parameters:
Name Type Description
text string
Source:
Returns:
Type
string

setByKeyPath(obj, path, value, defaultsopt)

Set a value in an object by a dot-separated key path. Creates intermediate objects/arrays as needed. When a parent is undefined (using default), materializes it from defaults before modifying.

Parameters:
Name Type Attributes Description
obj Object

The object to mutate (root).

path string

Dot-separated path (e.g. 'focalLength', 'path.0', 'params.r1'). Empty string is not valid for set (would replace root).

value *

The value to set.

defaults Object <optional>

Optional defaults. When an intermediate is null/undefined, materializes from defaults first. When the value being set matches the default (from defaults or the built-in for/if defaults), the property is deleted instead of set.

Source:

setViewportSize(width, height)

Set the size (in CSS pixels) for the viewport of the scene.

Parameters:
Name Type Description
width number
height number
Source:

splitTexCommaArgs(inner) → {Array.<string>}

Split a TeX fragment on commas that separate arguments at the current fence level: {…} / () / \left…\right nesting increments/decrements; commas only split when all depths are 0.

Parameters:
Name Type Description
inner string
Source:
Returns:
Type
Array.<string>

splitTopLevelCommas(str) → {Array.<string>}

Split a string by commas that are not inside (), [], or {}.

Parameters:
Name Type Description
str string
Source:
Returns:

The parts, each trimmed.

Type
Array.<string>

stripJsonComments(text) → {string}

Strip // and /* */ comments from pasted text while respecting string literals. :// is not treated as a line comment (e.g. http://).

Parameters:
Name Type Description
text string
Source:
Returns:
Type
string

stripMarkdownCodeFence(text) → {string}

Remove leading markdown fence (e.g. json) and trailing from AI-style pastes.

Parameters:
Name Type Description
text string
Source:
Returns:
Type
string

stripParenChain(node) → {*}

Remove a chain of ParenthesisNode wrappers (used after nested collapse).

Parameters:
Name Type Description
node *

math.js expression AST node

Source:
Returns:

math.js expression AST node

Type
*

suggestNewModuleName(names) → {string}

Parameters:
Name Type Description
names Array.<string>

Existing module names in the scene.

Source:
Returns:
Type
string

templatePointLockState(objData, schema, basePathopt) → {Object}

Check whether all point-type properties in a module template have hardcoded coordinates. Used to determine if a template object will be movable in the canvas when placed in a module.

Parameters:
Name Type Attributes Default Description
objData Object

Template object data (raw JSON from module objs).

schema Array

Property schema from getPropertySchema.

basePath string <optional>
''

Base path for nested contexts.

Source:
Returns:
Type
Object

toJSON() → {string}

Convert the scene to JSON.

Source:
Returns:

The JSON string representing the scene.

Type
string

tooltipAllTupleRowsConstant()

True if every collected tuple row equals row 0 (raw values).

Source:

tooltipMantissaDecimalPlaces()

Mantissa decimal places as shown by Number#toString (handles scientific notation).

Source:

tooltipPointTupleEqual()

One expansion row as a tuple (e.g. point x,y); whole tuple must match to collapse.

Source:

tooltipValueEqualForCollapse()

Equality for tooltip collapse; uses raw values (not rounded / not display-truncated).

Source:

unwrapParenInCallableArgs(node) → {*}

Strip gratuitous ParenthesisNode wrappers from function and unary +/- arguments (e.g. sin(((x))) → sin(x)). Top-level expressions such as ((a+b)*(c+d)) are unchanged.

Parameters:
Name Type Description
node *

math.js expression AST node

Source:
Returns:

math.js expression AST node

Type
*

useStatus() → {Object}

Composable for handling application status including mouse position, simulator metrics, and system status (errors/warnings)

Source:
Returns:

Reactive status state and computed properties

Type
Object

validateNestedKeys(obj, defaults, path) → {string|null}

Recursively validate that an object only contains known keys.

Parameters:
Name Type Description
obj Object

The object to validate

defaults Object

The default structure defining known keys

path string

The current path for error reporting

Source:
Returns:

The path of unknown key if found, null otherwise

Type
string | null

valueToFormulaDisplay(value) → {string}

Convert a stored value (number or backtick-wrapped formula string) to a display string with backticks stripped.

Parameters:
Name Type Description
value *
Source:
Returns:
Type
string

versionUpdate(jsonData) → {Object}

Update the scene JSON data to the latest version.

Parameters:
Name Type Description
jsonData Object
Source:
Returns:

The updated JSON data.

Type
Object

viewportCenterSceneCoords()

Scene-space point at the viewport center (same formula as observer init when switching to observer mode).

Source:
See:
  • app/store/scene.js — mode callback

Type Definitions

BodyMergingObj

Every ray has a temporary bodyMerging object ("bodyMergingObj") as a property (this property exists only while the ray is inside a region of one or several overlapping grin objects - e.g. CircleGrinGlass and GrinGlass), which gets updated as the ray enters/exits into/from grin objects, using the "multRefIndex"/"devRefIndex" function, respectively.

Type:
  • Object
Properties:
Name Type Description
fn_p function

The refractive index function for the equivalent region of the simulation.

fn_p_der_x function

The x derivative of fn_p for the equivalent region of the simulation.

fn_p_der_y function

The y derivative of fn_p for the equivalent region of the simulation.

Source:

Circle

Type:
  • Object
Properties:
Name Type Description
c Point
r number | Line
Source:

ConstructReturn

Type:
  • Object
Properties:
Name Type Attributes Description
isDone boolean <optional>

Whether the construction is done.

requiresObjBarUpdate boolean <optional>

Whether the object bar should be updated.

isCancelled boolean <optional>

Whether the construction is cancelled.

Source:

ControlPoint

Type:
  • Object
Properties:
Name Type Description
dragContext DragContext

The drag context of the virtual mouse that is dragging the control point.

newPoint Point

The new position of the control point.

Source:

DragContext

Type:
  • Object
Properties:
Name Type Attributes Description
part number

The index of the part within the object being dragged. 0 for the whole object.

targetPoint Point <optional>

The target point where the user is dragging. This is recognized by the editor so that it can be used for popping up the coordinate box (when the user double-clicks or right-clicks such a point), or binding to a handle (when the user holds Ctrl and clicks such a point).

targetPoint_ Point <optional>

If this property is set instead of setting targetPoint, then the point will not be used for the coordinate box or handle, but is still recognized by the editor when deciding which part of which object the user want to interact with.

requiresObjBarUpdate boolean <optional>

Whether the object bar should be updated during the dragging.

cursor string <optional>

The cursor to be used during hovering and dragging.

snapContext SnapContext <optional>

The snap context.

hasDuplicated boolean <optional>

Whether the object is duplicated during the dragging. This is true when the user holds the Ctrl key and drags the whole object. Only set by the editor.

originalObj BaseSceneObj <optional>

The original object when the dragging starts. Only set by the editor.

isByHandle boolean <optional>

Whether the dragging is initiated by dragging a handle. Only set by the editor.

Source:

Line

Type:
  • Object
Properties:
Name Type Description
p1 Point
p2 Point
Source:

ModuleDef

Type:
  • Object
Properties:
Name Type Description
numPoints number

The number of control points of the module.

params Array.<string>

The parameters of the module.

vars Array.<string>

Mathematical variable definitions that can be used in the objects.

objs Array.<Object>

The objects in the module in the form of JSON objects with template syntax.

maxLoopLength number

The maximum length of the list in for loops to prevent infinite loops.

Source:

OutRay

Variables that can be used in the angle and brightness functions:

  • (\theta_0): The angle of the incident ray.
  • (\lambda): The wavelength of the incident ray.
  • (t): The position of the incident ray on the surface.
  • (p): The polarization of the incident ray. 0 for s-polarized, 1 for p-polarized.
  • (n_0): The refractive index of the source medium (glass merged at the same side as the incident ray).
  • (n_1): The refractive index of the destination medium (glass merged at the opposite side as the incident ray).
  • (\theta_1), (\theta_2), ..., (\theta_{j-1}): The angles of the previous outgoing rays. For (P_j), (\theta_j) can also be used.
  • (P_1), (P_2), ..., (P_{j-1}): The brightnesses of the previous outgoing rays.
Type:
  • Object
Properties:
Name Type Description
eqnTheta string

The LaTeX expression of the angle (\theta_j) of the jth outgoing ray.

eqnP string

The LaTeX expression of the brightness (P_j) of the jth outgoing ray.

Source:

Point

Type:
  • Object
Properties:
Name Type Description
x number
y number
Source:

PropertyDescriptor

Type:
  • Object
Properties:
Name Type Attributes Description
key string

Dot-separated property path (e.g. 'focalLength', 'p1', 'path.0', 'params.r1'). Numeric segments are array indices. Empty string '' means the root object itself (e.g. PointSource x/y).

type 'point' | 'number' | 'boolean' | 'dropdown' | 'equation' | 'text' | 'style' | 'array'

The type of the property.

styleKind 'stroke' | 'fill' <optional>

For 'style' type: 'stroke' = line/stroke style (color, width, dash); 'fill' = fill style (color only). Required when type is 'style'.

label string

Pre-rendered HTML label string (i18n already expanded).

info string | null <optional>

Optional pre-rendered HTML for an info popover (i18n already expanded).

options Object.<string, string> | null <optional>

For 'dropdown' type: value -> display label map (already translated).

variables Array.<(string|RegExp)> | null <optional>

For 'equation' type: valid variable names (literal strings or RegExp patterns).

differentiable boolean <optional>

For 'equation' type: if true, only the differentiable function subset is allowed (for symbolic derivative). Default false.

readOnly boolean <optional>

If true, the property is display-only (e.g. module name in ModuleObj).

updatesSchema boolean <optional>

If true, changing this property invalidates the schema (reserved for future use).

itemSchema Array.<PropertyDescriptor> | null <optional>

For 'array' type: schema for each array item. Keys within itemSchema are relative to each array element.

Source:

Ray

Type:
  • Object
Properties:
Name Type Attributes Description
p1 Point

The starting point of the ray.

p2 Point

Another point on the ray.

brightness_s number

he intensity of the s-polarization component of the ray.

brightness_p number

The intensity of the p-polarization component of the ray. In this simulator the two polarization components are assumed to be of no phase coherence.

wavelength number <optional>

The wavelength of the ray in nanometers. Only has effect when "Simulate Colors" is on.

gap boolean

Whether the ray is the first ray in a bunch of "continuous" rays. This is for the detection of images to work correctly. The intersection of two rays is considered as a candidate of an image only if the second ray has gap === false.

isNew boolean

Whether the ray is just emitted by a source. This is to avoid drawing trivial initial extensions in the "Extended rays" mode.

Source:

SelectionSearchResult

Type:
  • Object
Properties:
Name Type Description
dragContext DragContext

The drag context.

targetObjIndex number

The index of the target object.

Source:

SimulationReturn

Type:
  • Object
Properties:
Name Type Attributes Description
isAbsorbed boolean <optional>

Whether the object absorbs the ray.

newRays Array.<Ray> <optional>

The new rays to be added.

truncation number <optional>

The brightness of truncated rays due to numerical cutoff (e.g. after a large number of partial internal reflections within a glass). This is used to estimate the error of the simulation.

brightnessScale number <optional>

The actual brightness of the ray divided by the brightness inferred from the properties of the object. This should be 1 when "ray density" is high enough. When "ray density" is low, the calculated brightness of the individual rays will be too high (alpha value for rendering will be larger than 1). In this case, the object should rescale all the brightness of the rays by a factor to keep the maximum alpha value to be 1. This factor should be returned here and is used to generate warnings.

isUndefinedBehavior boolean <optional>

Whether the behavior of the ray is undefined. For example, when the ray is incident on a corner of a glass.

Source:

SnapContext

Type:
  • Object
Properties:
Name Type Attributes Description
locked boolean <optional>

Whether the snapping direction is locked.

i0 number <optional>

The index of the locked direction.

Source:

loadJSONCallback(needFullUpdate, completed)

The callback function when the entire scene or a resource (e.g. image) is loaded.

Parameters:
Name Type Description
needFullUpdate boolean

Whether the scene needs a full update.

completed boolean

Whether the scene is completely loaded.

Source:

objBarValueChangeCallback(obj, value)

The callback function for when a value changes. If "Apply to all" is checked, this function will be called for each scene object of the same type.

Parameters:
Name Type Description
obj Object

The scene object whose value changed.

value any

The new value.

Source:

Events

deviceChange

The event when the device type (touch/mouse) changes.

Properties:
Name Type Description
lastDeviceIsTouch boolean

Whether the last interaction is done by a touch device.

Source:

requestUpdateErrorAndWarning

The event when the error and warning messages in the UI should be updated.

Source:

requestUpdateErrorAndWarning

The event when the error and warning messages in the UI should be updated.

Source:

webglContextLost

The event when the WebGL context is lost.

Source: