Resource icon

Visual Utils 3D Renderer 1.0.0

Basic 3d render shapes
Example usage:
JavaScript:
const render = require('./libs/3DRenderer');

// World anchor
const BX = 8.5, BY = 64.0, BZ = 8.5;

// Draw on every renderTick. ctx is the native JsRenderContext.
events.on('renderTick', (ctx) => {
    if (!enabled) return;
    const t = Date.now() / 1000;

    // Filled semi-transparent red box, through walls
    render.box(ctx, BX, BY, BZ, 1, 2, 1, 1.0, 0.0, 0.0, 0.4, true);

    // Outlined opaque green box, through walls
    render.outlinedBox(ctx, BX - 3, BY, BZ, 2, 2, 2, 0.0, 1.0, 0.0, 0.5, 2, true);

    // Blue line with pulsing alpha, through walls
    render.line(ctx,
        BX, BY + 2, BZ,
        BX + 4, BY + 2, BZ + 4,
        0.0, 0.5, 1.0, 0.5 + 0.5 * Math.sin(t * 2), 3, true);

    // Yellow flat quad (floor marker), through walls
    render.flatQuad(ctx, BX + 4, BY, BZ, 2, 2, 1.0, 1.0, 0.0, 0.5, true);

    // Orange ring around the box, through walls
    render.circle(ctx, BX, BY + 0.5, BZ, 2.5, 1.0, 0.5, 0.0, 1.0, 2, true, 48);

    // Cyan filled disk on the ground, through walls
    render.filledCircle(ctx, BX - 5, BY, BZ, 1.5, 0.0, 1.0, 1.0, 0.6, true, 48);

    // Magenta tracer ray from camera toward the box anchor, through walls
    render.tracer(ctx, BX, BY + 1, BZ, 1.0, 0.0, 1.0, 0.8, 2, true);
});

// Toggle rendering with F3 (keyCode 292 for F3)
let enabled = true;
events.on('keyEvent', (event) => {
    if (event.getKey() === 292 && event.getAction().name() === 'Press') {
        enabled = !enabled;
    }
    return true;
});
Author
Neki_play
Downloads
6
Views
17
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Neki_play

Back
Top