本日はApple枠です。
今回はAppleVisionProでBlenderとリアルタイムに同期するプロトタイププロジェクトGeometryLinkを動かしていきます。
〇環境
・Apple VisionPro
・VisionOS2.0
・Windows11PC
・Blender4.1
〇GeometryLinkとは?
GeometryLinkはDanilo氏がGitHub上でリリースしているプロジェクトです。
BlenderとVisionPro間でWebSocketを使用した通信を行いBlenderのデータをUSDZ形式に変換して送信し、VisionPro側でリアルタイムにメッシュが表示できるというツールです。
まずはBlenderのアドオンに相当するBlender Plugin.zipをダウンロードします。
このアドオンは通常のアドオン同様にBlender側でアドオンとしてインストールすることができますが、この時点では実行時にnetworkモジュールがないとエラーが発生します。

Blender Addonのinit.pyを開きます。
通常のパスはC:\Users\(ユーザー名)\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Blender Pluginなどのようになります。
init.pyを開きます。

次のコードを冒頭部に追加します。
import sys
current_dir = os.path.dirname(__file__)
network_module_path = os.path.join(current_dir, "Geometry Link") # "Geometry Link"フォルダを指定
if network_module_path not in sys.path:
sys.path.append(network_module_path)
修正後のコードは次のようになります。
import os
import sys
current_dir = os.path.dirname(__file__)
network_module_path = os.path.join(current_dir, "Geometry Link") # "Geometry Link"フォルダを指定
if network_module_path not in sys.path:
sys.path.append(network_module_path)
bl_info = {
"name": "Geometry Link",
"blender": (2, 80, 0),
"category": "Object",
"version": (1, 0, 0),
"author": "Danilo Campos",
"description": "Monitors geometry changes and serializes them to JSON",
}
import bpy
from bpy.app.handlers import depsgraph_update_post
import network
・・・

以上でBlender側でアドオンとしてnetworkモジュールを登録して実行することができました。
次回はBlender側の調整とXCodeを使用したSwiftコードを見ていきます。
本日は以上です。