three-sync
v1.3.0
Published
A TypeScript library for synchronizing 3D scenes in Three.js
Maintainers
Readme
Three-Sync
A TypeScript library for synchronizing 3D scenes in Three.js applications with real-time collaboration capabilities.
Features
- Real-time 3D object synchronization
- Support for Three.js 0.160.0
- Version history and rollback capabilities
- Conflict resolution strategies
- Adapter system for different storage backends
- Event-based architecture
Installation
npm install three-syncBasic Usage
import * as THREE from 'three';
import { SceneSyncController, SyncManager } from 'three-sync';
import { YourCustomAdapter } from './your-adapter';
// Create a Three.js scene
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
// Initialize your adapter
const adapter = new YourCustomAdapter();
// Create a sync controller
const controller = new SceneSyncController({
scene,
camera,
renderer,
adapter,
userId: 'user-123'
});
// Listen for sync events
controller.on('syncStatusChanged', (status) => {
console.log('Sync status:', status);
});
controller.on('objectAdded', (object) => {
console.log('Object added:', object);
});
// Add an object to the scene and sync it
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
// Sync the object
controller.syncObject(cube);
// Save a version
controller.saveVersion('Initial version');
// Clean up when done
function cleanup() {
controller.removeAllListeners();
}API Documentation
For detailed API documentation, please refer to the documentation.md file.
Version History
For a complete list of changes and version history, see the CHANGELOG.md file.
License
MIT
