Hi everyone! ![]()
I built a small Chrome extension with Babylon.js
- a cute 3D shark that swims across whatever page youโre viewing,
in a transparent overlay that stays click-through everywhere except the character itself.
Chrome Web Store: https://chromewebstore.google.com/detail/units-cfc-โ-cute-floating/fcodbljmmbhhkofinngcephgjjfpfcfl
Video: https://www.youtube.com/watch?v=ZELAYtwPhKM
Blog post: UNIT's Page

What it does
- Swims freely around the viewport; drag and toss it, and wall hits spawn rising bubbles
- Double-click empty space โ a procedural flag pops up and the shark swims to it
- Every so often it lunges at the camera to startle you (can be turned off)
- Continues seamlessly when you switch tabs
A few Babylon.js bits that might be useful to others
- Tree-shaken bundle for MV3:
@babylonjs/core+ glTF loader bundled with esbuild as an IIFE exposing aBABYLONglobal. No dynamicimport(), so it runs as an extension content script. - Transparent canvas over a live page:
alpha: truewithpremultipliedAlpha: trueandclearColor (0,0,0,0). Withfalse, translucent meshes looked grey and washed out because the compositor multiplied alpha twice. - Pixel-space camera: an orthographic camera where 1 unit = 1 CSS px (X from the viewport center, Y from the bottom). All movement and edge bouncing becomes plain 2D math, and resize just refits the ortho bounds.
- Selective click-through: the overlay is
pointer-events: none. Capture-phase window listeners runscene.pick()against an invisible proxy box and switch toautoonly while hovering or dragging. - One engine at a time: the engine is created only in the visible tab and
engine.dispose()d shortly after the tab is hidden, so background tabs hold no WebGL context. - Cheap effects: the goal flag is a
CreateRibbonupdated in place viainstancefor the waving cloth, plus thin tori as pulse rings. Bubbles are a fixed pool of cloned planes sharing oneDynamicTexture, with per-bubble alpha throughmesh.visibility, so nothing is allocated at runtime.
Feedback is very welcome, especially ideas for keeping the overlay even lighter. Thanks for making Babylon.js such a joy to build with! ![]()