npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

threejs-blendertools

v0.0.1

Published

A Javasript library to hook Blender into Threejs

Downloads

10

Readme

What is this??

When working in ThreeJs, you will need to animate your objects and cameras and sometimes is may feel like a bit of a hassle to do so, sometimes having to create custom editors or installing libraries to control the camera, maybe a bit overkill. This is a blender plugin / Threejs library combo that simply connects / sync an object from blender to your threejs scene using WebSockets.

In baby terms, please...

You will move stuff in blender, as you already know how to do, and the position, rotation and so on will be sent to your threejs scene in real time, allowing you to preview how things will look in threejs. You will have both, blender and your threejs app opened at the same time, side by side.

Blender Sync Module

This module provides utilities to synchronize Three.js scenes with Blender via a WebSocket connection. It allows for real-time updates of object positions, camera properties, and animation frames from Blender to your web application.

Instalation in Blender

Install the python script in blender: Edit > Preferences > Addons > Install from disk and pick the .py file in /blender-plugin folder.

Download the python script

Plugin's side panel

It will look like this once installed (Side panel window)

Plugin's side panel

Installation in ThreeJs

npm install threejs-blendertools
# or
pnpm add threejs-blendertools
# or
yarn add threejs-blendertools

Usage

The module exports three main functions for different synchronization needs.

syncWithBlender

The generic callback. It takes a function that receives data updates from Blender.

Example:

import { syncWithBlender } from 'threejs-blendertools';

const cleanup = syncWithBlender((data) => {
  console.log('Received data from Blender:', data);
  // Update your objects here
});

// Later, when you want to stop syncing:
// cleanup();

syncCameraWithBlender

Quick helper function specifically designed to synchronize a Three.js PerspectiveCamera with a camera in Blender. It updates the camera's position, rotation (quaternion), and field of view (FOV).

Example:

import { syncCameraWithBlender } from 'threejs-blendertools';
/**
 * the camera posittion, rottion and fov will be updated everytime the blender server sends updates.
 */
const cleanup = syncCameraWithBlender(camera);

syncFrameWithBlender

A helper function for subscribing to frame and FPS updates from Blender. This is useful for using the Blender's timeline to scrub animations on the threejs side.

Example:

import { syncFrameWithBlender } from 'threejs-blendertools';

const cleanup = syncFrameWithBlender((frame, fps) => {
  console.log(`Current Frame: ${frame}, FPS: ${fps}`);
});

Shots Manager - Utility / Helper

Utility class to handle playing a combination of shots as one single thing. A cutscene is composed of several shots, you can play them easily using this class like this:

import { ShotsManager } from 'threejs-blendertools';

/**
 * Normally, you will load the cameras and clips from a glb file that was animated in Blender. You will collect the cameras from the scene and the animation clips of each camera. To make things easy, each camera is expected to have the same name as the animation clip it is using. Example: camera.name = "shot1" will use animation clip.name == "shot1"
 */
const cameras = [camera1, camera2, camera3];
const clips = [clip1, clip2, clip3];
const shotsManager = new ShotsManager(cameras, clips);
shotsManager.config(shotsNames);
shotsManager.play();

// and then in your animation loop....

shotsManager.update(delta);

When designing the shots, or when you have the shots and you want to start designing the post processing effects or so, you will want to let the sequence play in a loop as to let you touch things...

shotsManager.loop = true; // will restart the sequence when it is done playing.

SCRUB SHOTS

So let's say you have all your shots done, and you want to start working on the sounds or postprocessing, etc.. you will use this hook and instead of playing the shots you will scrub them in blender and threejs will update respecting the timeline:

Example:

import { syncFrameWithBlender, ShotsManager } from 'threejs-blendertools';

const shots = new ShotsManager( cameras as PerspectiveCamera[], animationClips );

shots.config([
	"shot1", // stairs intro
	"shot2", // hope closeup
	"shot3", // behind hope - wide shot
	"shot4" // red monk face closeup
	,"shot5" // top down descend wide shot from the side.
	,"shot-face"
	,"shot6" // ceiling shot
	,"shot7" // behind red monk / hope confrontation
]); 

// instead of calling .play we call .scrub ( blender will update this )
const cleanup = syncFrameWithBlender((frame, fps) => {
  shots.scrub( frame/fps, myMainCameraRef )
});

Data Types

BlenderObjectData

The data structure received from Blender:

interface BlenderObjectData {
  position: { x: number; y: number; z: number };
  quaternion: { x: number; y: number; z: number; w: number };
  rotation: { x: number; y: number; z: number };
  fov: number | null;
  frame: number;
  fps: number;
  objectName: string;
  objectType: string;
  scrubFrame?: number;
}

Connection Details

The module attempts to connect to a WebSocket server at ws://localhost:8765.

  • It automatically handles reconnection attempts if the connection is lost or cannot be established initially (retrying every 2 seconds).
  • The connection is properly closed when the returned cleanup function is called.