This project includes a Blender add-on (server) and a JavaScript library (client).
The server sends its state to the clients, and can receive a few commands to edit Blender remotely.
- Download WebSocket-for-Python
- Copy the directory
ws4py
into<Blender root>/2.xx/python/lib
- Download
websocket_server.py
- in Blender, go to
File
>User Preferences...
>Add-ons
>Install from file...
and select the file - Enable the add-on by ticking the corresponding box
Preferences are shown by expanding the add-on box. In particular, you can choose which data to send to the clients, in order to lower communication for unused data.
Include the library as usual in your HTML.
<script src="blender-websocket.js"></script>
blender = new BlenderWebSocket();
Alias: on
Default options:
url
:ws://localhost:8137
Alias: off
Specifies client-side axis permutation.
In Blender, the coordinate system is right-handed and Z is vertical, but you may want another axis depending on your rendering engine. Only applies on objects' location and scale, not rotation.
The axes
parameter is a string (up to 3 characters) containing the mapping for each axis. The first character is the mapping for the resulting X axis, and so on. The character could either be x
, y
, z
(positive) or X
, Y
, Z
(negative).
Example: if you want a right-handed coordinate system and Y as vertical axis, call
blender.setAxes("xzY")
Copyright (c) 2015 Bloutiouf aka Jonathan Giroux