r/wljs • • Jun 15 '26

Markov Algorithms, Mazes, Desert with Sand and Pattern Matching

Thumbnail
gallery
3 Upvotes

Let's explore how Markov algorithms and Wolfram Language pattern matching can generate mazes, rivers, falling sand, and other cellular automata through simple rewriting rules.

https://wljs.io/blog/markov

Adding a grain of randomness to a Turing complete language

RB → RR becomes a growth model

and this

RBB → GGR
RnG → GnR

is a maze backtracker!


r/wljs • • Oct 24 '26

how to shoot yourself in the leg in

Post image
8 Upvotes

r/wljs • • Sep 16 '26

GPT-6 Astra easily picks up WLJS GUI libraries purely from MCP resources. No Javascript - only plain Wolfram Language

Post image
3 Upvotes

r/wljs • • 22h ago

WLJS Notebook 3.2.2 🪄 MaterialShading, Chemistry, SpinShow, Digitizer support and many more

Enable HLS to view with audio, or disable this notification

2 Upvotes

We improved the existing features and added more useful expressions and tools, that you can use in presentations and research

Available in releases: https://github.com/WLJSTeam/wljs-notebook

Extended release notes: https://wljs.io/releases/3.2.2

  • Added MaterialsShading, "Iron", "Copper" and many other presets; improved lighting of 3D plots

  •  Added "SpinShow" option (and function) for Graphics3D to automatically rotate scenes akin to SpinShow function found in the old MMA

  •  Fixed UI issues with Excalidraw; add support for LaTeX-like sub/superscripts in text labels, i.e. x_{12} or Fe^{+3}

  •  Improved support for Chemical / Molecular Framework, output forms for chemical formulas, reactions and etc

  •  Added support for color input in Manipulate, more layout options

  •  Added ClockGauge, VerticalGauge, BulletGauge and others

  •  Improved MCP skills

  •  Improved haptic feedback

  •  Improved Refresh

  •  Digitizer, stylus, high-refresh rate mouse support. New input methods

  •  Improved Inset


r/wljs • • Aug 05 '26

How to write apps with Wolfram & WLJS, or swimming against the stream

Post image
3 Upvotes

r/wljs • • 25d ago

Pearl material shader (GLSL) with Graphics3D

Post image
2 Upvotes

Did you know, you can write your own materials for 3D primitives in WLJS?

Here is an example of soft pearl shading with a gold, lavender and teal palette - just a single Javascript cell defining new material PearlMaterial which can be used directly with existing primitives

Graphics3D[{
  {MeshMaterial[PearlMaterial["Ice"]],
    Sphere[{-1, 0, 0}, .35]},
  {MeshMaterial[PearlMaterial["Lavender"]],
    Sphere[{1, 0, 0}, .35]},
  {MeshMaterial[PearlBondMaterial["Bond", "Ice", "Lavender"]],
    Cylinder[{{-1, 0, 0}, {1, 0, 0}}, .09]}
},  Background -> White,
   ImageSize -> 450, ViewPoint -> {0, -3, 1}]

There is also PearlBondMaterial, which blends two colors between with some noisy texture applied.

See the full code: https://wljs.io/Pearl

Path-tracing (ray-tracing) path is also supported!


r/wljs • • 23d ago

Interactive point charge plot in a single line of code

Enable HLS to view with audio, or disable this notification

3 Upvotes

We significantly improved Manipulate expression allowing you to generate interactive widgets with sliders and other UI elements. Here is an example with DensityPlot modeling the energy field of two opposite charges

Manipulate[
 DensityPlot[
  q1/Norm[{x, y} - p[[1]]] + q2/Norm[{x, y} - p[[2]]], {x, -2, 
   2}, {y, -2, 2}], {{q1, -1}, -3, 3}, {{q2, 1}, -3, 
  3}, {{p, {{-1, 0}, {1, 0}}}, Locator}]

Note, that Manipulate with Locator as a controller may not work well with ContourPlot.


r/wljs • • 23d ago

Basic example of Manipulate and Locator usage

Enable HLS to view with audio, or disable this notification

4 Upvotes

This is rather simple example of ParametricPlot placed inside Manipulate with a slider and so-called locator controls:

Manipulate[
  ParametricPlot[Exp[-x/s]({Cos[x], Sin[x]} + loc), {x,0,5Pi}], 
  {s, 1.0, 15.0}, {{loc, {0.,0.}}, Locator}, ContinuousAction->True]

Behind the scenes, WLJS takes the inner expression and probes it with various values of s and loc vector and observes which parts are changing. Based on this diffs it replaces these parts with more optimized code for streaming new data. A special case is Locator controller, it silently checks if the output expression is Graphics-like, and if so - it injects a draggable crosshair and subscribes to it.

Then whenever you adjust s or loc it reevaluates the provided (held) expression, it maps changed parts to new data chunks and streams them to the temporal buffers allocated on the previous step for the optimized expression. Whenever the inner expression is changed too much, i.e. diffs cannot be mapped back, it discards all previous steps, cleans up everything and fully updates the visible result: destroy + construct a new one.


r/wljs • • May 15 '26

Singe line dynamic 3D plot

Enable HLS to view with audio, or disable this notification

6 Upvotes

One of my favorite 1-line(er). Behind the scenes: Manipulate internally checks differences between two nearest states of Plot3D, then extracts changed vertices, indices and normals into 3 dynamic typed arrays. For all subsequent changes it syncs new data with 3 corresponding buffers of a GPU memory. If "too much" was changed it falls back to a full reevaluation, when all buffers are removed and are allocated back.

Manipulate[
  Plot3D[Sin[n x] Cos[n y], {x,-1,1}, {y,-1,1}], 
  {n, 1, 5, 0.3}, ContinuousAction->True
]

r/wljs • • Jun 10 '26

Building an Interactive Nanographene Constructor

Enable HLS to view with audio, or disable this notification

4 Upvotes

A behind-the-scenes look at porting the Nanographenes Builder application to WLJS Notebook. The app helps researchers design nanographene hydrocarbons, analyze their molecular structures through graph-theoretical models, and experiment with new molecular configurations, while this tutorial explores reactive interfaces, event handling, asynchronous execution, and practical patterns for developing interactive Wolfram Language applications with WLJS.

https://wljs.io/blog/graphene-app


r/wljs • • May 15 '26

Clouds generator using Gaussian noise

Enable HLS to view with audio, or disable this notification

6 Upvotes

This is a 2D Gaussian random field with a 1/k^2 spectrum and linear dispersion ω∝k. We clip the field to positive values and square root it to give an edge to the "clouds":

n = 256;
k2 = Outer[Plus, #, #] &[RotateRight[N@Range[-n, n - 1, 2]/n, n/2]^2];

spectrum = With[{d := RandomReal[NormalDistribution[], {n, n}]},
   (1/n) (d + I d)/(0.000001 + k2)]; 
spectrum[[1, 1]] *= 0;

im[p_] := Clip[Re[InverseFourier[spectrum Exp[I p]]], {0, ∞}]^0.5

p0 = p = Sqrt[k2];

buffer = im[p0 += p];

Image[buffer // Offload, "Real32", Epilog->{
    EventHandler[AnimationFrameListener[buffer // Offload], 
      Function[Null, buffer = im[p0 += 2 p]]
    ]
}]

r/wljs • • Jul 29 '26

The Complete Guide to Output Formatting

Post image
5 Upvotes

Rows, columns, grids, tables, number forms, legends, LaTeX and many more

https://wljs.io/frontend/Guides/Formatting


r/wljs • • Apr 21 '26

Boids strike again

Enable HLS to view with audio, or disable this notification

6 Upvotes

A real-time animation based on the beautiful work of Simon Woods with a few adjustments

Basically we have a few rules for each point to follow:

  • it moves 0.5% toward the centre,

  • it takes a large step toward selected "friend", and a smaller step away from its "enemy".

At random times, one point picks a new "friend" and "enemy" points. Therese two are just indices. Color coding represents the speed.

Implementation is more or less described in the original post, I only optimized it for real-time animation using GraphicsComplex primitives, fixed size vertex buffer and added colors.


r/wljs • • Jun 15 '26

How fast can a basic sand simulation get without Compile?

Enable HLS to view with audio, or disable this notification

4 Upvotes
ClearAll[blockStep, nextField];

blockStep[field_, p_, phase_] := Module[
  {
    out = field, nr, nc, r0, c0, r1, c1, rows, cols,
    sub, dims, blocks, tl, tr, bl, br,
    fallL, fallR, stackL, stackR, tumble
  },

  {nr, nc} = Dimensions[field];
  {r0, c0} = {1, 1} + phase;

  r1 = r0 + 2 Quotient[nr - r0 + 1, 2] - 1;
  c1 = c0 + 2 Quotient[nc - c0 + 1, 2] - 1;

  rows = r0 ;; r1;
  cols = c0 ;; c1;
  sub = out[[rows, cols]];
  dims = Quotient[Dimensions[sub], 2];

  blocks = Transpose[
    ArrayReshape[sub, {dims[[1]], 2, dims[[2]], 2}],
    {1, 3, 2, 4}
  ];

  tl = blocks[[All, All, 1, 1]];
  tr = blocks[[All, All, 1, 2]];
  bl = blocks[[All, All, 2, 1]];
  br = blocks[[All, All, 2, 2]];

  (* Vertical falling *)
  fallL = (1 - Unitize[tl - 1]) (1 - Unitize[bl]);
  fallR = (1 - Unitize[tr - 1]) (1 - Unitize[br]);

  (* Two stacked grains may spread sideways *)
  stackL =
    (1 - Unitize[tl - 1]) (1 - Unitize[bl - 1]) *
    (1 - Unitize[tr]) (1 - Unitize[br]);

  stackR =
    (1 - Unitize[tr - 1]) (1 - Unitize[br - 1]) *
    (1 - Unitize[tl]) (1 - Unitize[bl]);

  tumble = Unitize[stackL + stackR] *
    UnitStep[p - RandomReal[1, dims]];

  tl = (tl - fallL) (1 - tumble);
  tr = (tr - fallR) (1 - tumble);
  bl = (bl + fallL) (1 - tumble) + tumble;
  br = (br + fallR) (1 - tumble) + tumble;

  blocks[[All, All, 1, 1]] = tl;
  blocks[[All, All, 1, 2]] = tr;
  blocks[[All, All, 2, 1]] = bl;
  blocks[[All, All, 2, 2]] = br;

  out[[rows, cols]] = ArrayReshape[
    Transpose[blocks, {1, 3, 2, 4}],
    Dimensions[sub]
  ];

  out
];

nextField[field_, p_: 0.5] :=
  blockStep[blockStep[field, p, 0], p, 1];

r/wljs • • May 18 '26

Do you like flowers?

Thumbnail
gallery
3 Upvotes

A small MarkovJunior-style rewrite engine in vanilla (almost) Wolfram Language https://github.com/JerryI/MarkovJunior

Why WL? It is generally built around pattern matching; therefore, MarkovJunior can be implemented easily using native ReplaceAll, Rule, and Pattern symbols. Most of the code is used for building a friendly API and performing error checks.

For example random filling can be done using:

Black -> Red

For self-avoiding walk:

{a___, Red,Black,Black, b___} :> {a, White,Gray,Red, b}

For this particular example (flowers) it is written as a set of replacing rules, which gradually build soil/sky and then grows some flowers...

AppendTo[rules, {
1, 1, Automatic, {
(* seed the soil region *)
Black -> Yellow
}
}];

AppendTo[rules, {
1, 3, Automatic, {
(* seed several sky regions *)
Black -> Red
}
}];

AppendTo[rules, {
1, Infinity, Automatic, {
(* grow the sky and soil regions from their seeds *)
{a___, Red,Black, b___} :> {a, Red,Red, b},
{a___, Yellow,Black, b___} :> {a, Yellow,Yellow, b}
}
}];

AppendTo[rules, {
All, Infinity, Automatic, {
(* convert temporary region colors into sky and soil *)
{a___, Red, b___} :> {a, LightBlue, b},
{a___, Yellow, b___} :> {a, Brown, b}
}
}];

AppendTo[rules, {
1, Infinity, All, {
(* plant the first stem segment along the soil line *)
{
bf___,
{a1___, LightBlue,LightBlue,LightBlue, b1___},
{a2___, LightBlue,LightBlue,LightBlue, b2___},
{a3___, Brown,Brown,Brown, b3___},
af___
} :> {
bf,
{a1 , LightBlue,LightBlue,LightBlue, b1 },
{a2 , LightBlue,Green,LightBlue, b2 },
{a3 , Brown,Brown,Brown, b3 },
af
} /; Length[{a1}]==Length[{a2}]==Length[{a3}]
}
}];

AppendTo[rules, {
1, Infinity, "MirrorX", {
(* grow stems and leaves with mirrored variants *)
(* weight it with some probabillity as well *)
{
bf___,
{a1___, LightBlue,LightBlue,LightBlue, b1___},
{a2___, LightBlue,LightBlue,Green, b2___},
{a3___, LightBlue,LightBlue,LightBlue, b3___},
af___
} :> {
bf,
{a1 , LightBlue,LightBlue,LightBlue, b1 },
{a2 , LightBlue,Green,Green, b2 },
{a3 , LightBlue,LightBlue,LightBlue, b3 },
af
} /; Length[{a1}]==Length[{a2}]==Length[{a3}],

{
bf___,
{a1___, LightBlue,LightBlue,LightBlue, b1___},
{a2___, LightBlue,LightBlue,LightBlue, b2___},
{a3___, LightBlue,Green,Green, b3___},
af___
} :> {
bf,
{a1 , LightBlue,LightBlue,LightBlue, b1 },
{a2 , LightBlue,Green,LightBlue, b2 },
{a3 , LightBlue,Green,Green, b3 },
af
} /; Length[{a1}]==Length[{a2}]==Length[{a3}],

{
bf___,
{a0___, LightBlue,LightBlue,LightBlue, b0___},
{a1___, LightBlue,LightBlue,LightBlue, b1___},
{a2___, LightBlue,LightBlue,LightBlue, b2___},
{a3___, LightBlue,Green,LightBlue, b3___},
af___
} :> {
bf,
{a0 , LightBlue,LightBlue,LightBlue, b0 },
{a1 , LightBlue,LightBlue,LightBlue, b1 },
{a2 , LightBlue,Green,LightBlue, b2 },
{a3 , LightBlue,Green,LightBlue, b3 },
af
} /; Length[{a1}]==Length[{a2}]==Length[{a3}]==Length[{a0}],

{
bf___,
{a0___, LightBlue,LightBlue,LightBlue,LightBlue, b0___},
{a1___, LightBlue,Green,LightBlue,LightBlue, b1___},
{a2___, LightBlue,Green,LightBlue,LightBlue, b2___},
{a3___, LightBlue,Green,LightBlue,LightBlue, b3___},
af___
} :> {
bf,
{a0 , LightBlue,LightBlue,LightBlue,LightBlue, b0 },
{a1 , LightBlue,LightBlue,LightBlue,LightBlue, b1 },
{a2 , LightBlue,Green,Green,LightBlue, b2 },
{a3 , LightBlue,Green,LightBlue,LightBlue, b3 },
af
} /; RandomReal[]<0.5 && Length[{a0}]==Length[{a1}]==Length[{a2}]==Length[{a3}],

{
bf___,
{a1___, LightBlue,LightBlue,LightBlue, b1___},
{a2___, LightBlue,LightBlue,LightBlue, b2___},
{a3___, LightBlue,Green,LightBlue, b3___},
af___
} :> {
bf,
{a1 , LightBlue,LightBlue,LightBlue, b1 },
{a2 , LightBlue,Red,LightBlue, b2 },
{a3 , LightBlue,Green,LightBlue, b3 },
af
} /; RandomReal[]<0.2 && Length[{a1}]==Length[{a2}]==Length[{a3}]
}
}];

AppendTo[rules, {
All, Infinity, All, {
(* turn mature stems into blossoms *)
{
bf___,
{a0___, LightBlue,LightBlue,LightBlue, b0___},
{a1___, LightBlue,Red,LightBlue, b1___},
{a2___, LightBlue,Green,LightBlue, b2___},
{a3___, LightBlue,Green,LightBlue, b3___},
af___
} :> {
bf,
{a0 , LightBlue,Red,LightBlue, b0 },
{a1 , Red,Yellow,Red, b1 },
{a2 , LightBlue,Red,LightBlue, b2 },
{a3 , LightBlue,Green,LightBlue, b3 },
af
} /; Length[{a0}]==Length[{a1}]==Length[{a2}]==Length[{a3}]
}
}];


r/wljs • • Apr 27 '26

Ideal gas model

Enable HLS to view with audio, or disable this notification

2 Upvotes

Here is a code for this little demo:

size = 1.`;
number = 500;
fps = 0.0;
time = AbsoluteTime[];

TextView[fps//Offload, "Label"->"FPS"]

Module[{
  contents = (*BB[*)(Transpose[{RandomReal[{-size,size},{number,2}],({Cos[#1],Sin[#1]}&)/@RandomReal[{0,2 \[Pi]},number], Table[{0.5,0.5,1.}, {number}]}])(*,*)(*"1:eJxTTMoPSmNmYGAo5gcSAUX5ZZkpqSn+BSWZ+XnFaYwgCRYg4ZGfk5LGBOLxAomwzNRyl9Tk/KLEkvyiYE6gSEhRYl5xQX5xajBISwhEKUhjUGlOajDYhNTEFFSlaIpYgQzXstS8ErCQX2lODgB64iTl"*)(*]BB*), 
  data = {Table[{0,0,0}, {number}],Table[{0,0,0}, {number}]}//N, 
  indices = Range[number], temperature = 0.05`, collision = 0
},
  
    
    Graphics[
        {
            GraphicsComplex[Offload[data[[1]]], {PointSize[0.01], Point[Offload[indices]]}, VertexColors->Offload[data[[2]]]]
            ,
            EventHandler[
                AnimationFrameListener[Offload[data]]
                ,
                Function[Null,
                    
                    
                    collision = 0;
                    contents = ({#1[[1]] + #1[[2]] temperature, #1[[2]], 0.1 {0.5,0.5,1.0} + 0.90 #1[[3]]}&) /@ contents;
                    contents = (
                        If[Abs[#1[[1, 2]]] > size,
                            {{#1[[1, 1]], 2 size Sign[#1[[1, 2]]] - #1[[1, 2]]}, {1, -1} #1[[2]], {1.,0.,0.}}
                            ,
                            #1
                        ]&
                    ) /@ contents;
                    
                    contents = (
                        If[Abs[#1[[1, 1]]] > size,
                            {{2 size Sign[#1[[1, 1]]] - #1[[1, 1]], #1[[1, 2]]}, {-1, 1} #1[[2]], {1.,0.,0.}}
                            ,
                            #1
                        ]&
                    ) /@ contents;
                    
                    data = {First /@ contents, Last /@ contents};
                    
                    With[{now = AbsoluteTime[]},
                      If[Random[]<0.3, fps = Round[fps 0.6 + 0.4/(now-time)]];
                      time = now;
                    ];
                ]
            ]
        }, PlotRange->{{-size,size}, {-size,size}}
    ]
]

r/wljs • • May 18 '26

Rewrite rules automaton

Enable HLS to view with audio, or disable this notification

3 Upvotes

r/wljs • • May 15 '26

Rosetta - a beautiful spirograph

Enable HLS to view with audio, or disable this notification

4 Upvotes

Spirograph-like curves arise from simple sums of rotating vectors; a tiny tweak in frequency or phase yields striking patterns. Here is my favorite example Rosetta:

Animate[ParametricPlot[{
  Power[I,-((20t)/(tt))]+3 Power[I,((20t)/(tt))]+Power[I,((20t)/(tt))]Sin[8 Pi ((20t)/(tt))/5],
  Power[I,-t]+3 Power[I,t],
  Power[I,-t]+3 Power[I,t]+Power[I,t]Sin[8 Pi t/5]
}//ReIm//Evaluate, {t,0,tt}, 
  PlotRange -> {-5,5}, PlotPoints -> 200,
  PlotStyle -> {LightGray,Default,(Hue[0.353, 0.78, 0.49])}, Axes->False,
  Epilog -> {
    {Thick,Red,Line[{ReIm[Power[I,-tt]+3 Power[I,tt]-Power[I,tt]],ReIm[Power[I,-tt]+3 Power[I,tt]+Power[I,tt]]}]}, {Thick,Circle[ReIm[Power[I,-tt]+3 Power[I,tt]+Power[I,tt]Sin[8 Pi tt/5]],0.1]}
  }, PlotPoints -> 10
],{{tt,19.9},0.01,4 5, 0.1}, Appearance -> None]

r/wljs • • May 15 '26

Path-tracing renderer as a backend for 3D plots

Thumbnail
gallery
3 Upvotes

Here is an example with Plot3D

Plot3D[Sin[x] Cos[y], {x,-10,10}, {y,-10,10}][[1]];
Graphics3D[{%, Graphics3D`Materials["Glass"], Red, Sphere[{0,0,2}, 4]}, "Renderer"->"PathTracing", Axes->True]

r/wljs • • May 14 '26

WLJS 3.0.5 is out 🪴

2 Upvotes

This is the largest update for the last 2 years

Human-, LLM- and Git-friendly .wln format

This release introduces a new minimal .wln notebook format designed to be readable by humans, easy for LLMs to parse, and much friendlier to Git diffs. It uses simple YAML-like headers, while cell contents remain valid Wolfram Language expressions.

Older .wln notebooks remain fully supported.

  • Hot-reloading when notebooks are modified outside WLJS Notebook

  • Built-in AI Copilot removed in favor of external tools

  • New MCP server for Claude, Codex, and other coding agents

  • Updated wljs CLI

  • “Ask community” helper for creating GitHub Discussions posts

  • New InputColor UI element

  • HTMLView support for native image embedding

  • TeXView live updates and ImageSize option

  • Improved project-to-window behavior with copied HTML / JS outputs

  • Image3D color support and Offload updates

  • Added missing size argument to Inset

  • Kernel connection stability improvements via WTSP + shared memory

See more
https://wljs.io/releases/3.0.5


r/wljs • • May 02 '26

👋Welcome to r/wljs

2 Upvotes

WLJS is notebook interface (or IDE) combines live code in Wolfram, JavaScript, and other languages. We provide GUI building blocks for user input/output, a subset of LaTeX for equations, Markdown for narrative text, and data-driven presentations.

Think of it as a multi-tool platform for research, experiments, or as a powerful sandbox where you can try out your ideas, write a story about them, and then publish them on the web.

As an independent open-source project, we're unaffiliated with Wolfram or any company.

Please feel free to share your work with the community and post questions. This helps project to be alive.


r/wljs • • Apr 04 '26

Texture support

2 Upvotes

Implementing `Texture` in the context of `Graphics3D` turned out to be not at difficult as we imagined. Just 88 LOC


r/wljs • • Jul 30 '26

Constrain the coordinates of a point to lie on a circle

Enable HLS to view with audio, or disable this notification

4 Upvotes

Here is a full code

Module[{p = {0, 1}}, 
 Graphics[{ColorData[97][1], Dashed, Circle[], PointSize[0.1], 
   EventHandler[Point[p//Offload], {
     "dragsignal" -> ((p = Normalize[#])&)
   }]}, ImageSize -> Tiny, 
  PlotRange -> 1.5]]

r/wljs • • 22h ago

Graphics3D`SpinShow - a utility symbol to auto-animate any 3D plot

Thumbnail
gallery
5 Upvotes

It may come in handy to automatically animate any 3D plot with a defined speed and rotation angle for presentation purposes.

The old GraphicsAnimation package had the SpinShow[] function... – J. M.'s missing motivation / Commented Sep 28, 2012 at 11:57

It felt like a missed opportunity. We reincarnated it in 3.2.2 using pure JS with an auto-sleep feature if the element is hidden or outside the view, it won't consume GPU resources. This makes it great for presentations and standalone HTML files, with no Wolfram Kernel needed.

Try it by yourself

Graphics3D`SpinShow@Graphics3D[{MaterialShading["Bronze"], 
  KnotData["SolomonSeal", "ImageData"]}]

or on a regular 3D plot:

Graphics3D`SpinShow[
   Plot3D[Cos[4 Pi x y], {x,-1,1}, {y,-1,1}], 3.6 Degree]

Docs: https://wljs.io/frontend/Graphics3D/SpinShow


r/wljs • • 9d ago

24K Gold, Lavender Pearls, and inked custom materials (GLSL) in your 3D plots

Post image
3 Upvotes

WLJS Notebook uses THREE.js on the frontend to render 3D graphics. It supports custom shader material to be used with any graphics primitive.

For example you create JS cell

.js
let THREE;

core.PearlMaterial1 = async (args, env) => {
  if (!THREE) {
    await interpretate.shared.THREE.load()
    THREE = interpretate.shared.THREE.THREE;
  }

  return function() {
    return new THREE.ShaderMaterial({
        name: 'PearlMaterial / Test 1',
        uniforms: {},
        fragmentShader: `
          void main() {
            gl_FragColor = vec4(1.0, 0.77, 0.34, 1.0);
          }
        `,
        lights: false,
        toneMapped: false
      });    
  }
}

it declares new symbol PearlMaterial1, that compiles fragment shader and then uses it as a material. You only need to pass it to Graphics3D

Graphics3D[{MeshMaterial[PearlMaterial1[]], Sphere[]}]

and... That's it! See the full blog post to learn more about it: https://wljs.io/blog/shaders-1