Nordic Skating to LittleJS Migration Summary
Overview
This document summarizes the planned conversion from Three.js to LittleJS for the Nordic Skating project.
Completed Work
1. Research and Planning ✅
- Analyzed LittleJS framework capabilities
- Reviewed current Three.js implementation
- Created comprehensive migration plan (CONVERSION_PLAN.md)
2. Infrastructure Setup ✅
- Created adapter utilities for Three.js to LittleJS conversion
- Established testing framework for migration components
- Set up prototype structure
3. Component Migration Progress ✅
Adapter Layer (Complete)
// src/adapters/three-to-littlejs.ts
class ThreeToLittleJSAdapter {
static convertColor() - Converts THREE.Color to LittleJS format
static convertVector3() - Converts THREE.Vector3 to array
static convertVector4() - Converts THREE.Vector4 to array
static createBasicMaterial() - Creates LittleJS material equivalent
static adaptUniforms() - Adapts shader uniforms for LittleJS
}
Sky Component (In Progress)
- Created
sky-littlejs.tswith adapted shader - Vertex and fragment shaders converted to GLSL ES
- Uniform adaptation system implemented
- Material creation with back-side rendering
4. Testing ✅
- Unit tests for adapter utilities (10/10 passing)
- Test coverage for color, vector, material conversions
- Uniform adaptation tests
Files Created
CONVERSION_PLAN.md - Comprehensive migration plan
MIGRATION_SUMMARY.md - This summary document
src/
├── adapters/
│ └── three-to-littlejs.ts - Conversion utilities
├── render/
│ └── sky-littlejs.ts - LittleJS sky implementation
└── prototype/
└── littlejs-prototype.ts - Test prototype
test/
└── littlejs-migration.test.ts - Migration tests (10/10 passing)
Key Technical Decisions
1. Shader Adaptation Strategy
- Converted Three.js shader to GLSL ES format
- Maintained same visual appearance and functionality
- Adjusted uniform naming for LittleJS compatibility
2. Material System
- Created adapter utilities for material properties
- Handled color, transparency, emissive properties
- Preserved rendering order with
renderOrder: -1
3. Geometry Conversion
- Used LittleJS's built-in geometry creators
- Sphere geometry for sky dome (radius 1000)
- Double-sided rendering for proper sky appearance
Testing Results
✓ Color Conversion Tests (2/2 passing)
✓ Vector Conversion Tests (2/2 passing)
✓ Material Creation Tests (3/3 passing)
✓ Uniform Adaptation Tests (3/3 passing)
Total: 10/10 tests passing
Next Steps
Immediate Tasks:
- Complete Sky Component - Finalize shader adaptation and testing
- Integrate with Main Render Loop - Connect LittleJS to existing game loop
- Migrate Ice Surface - Convert plane geometry and materials
- Particle System Conversion - Adapt snow effects to LittleJS particles
Mid-Term Tasks:
- Camera System Migration - Convert Three.js camera to LittleJS
- Input Handling Integration - Ensure touch/keyboard controls work
- Performance Optimization - Benchmark and optimize rendering
- Mobile Testing - Verify on various mobile devices
Long-Term Tasks:
- Full Component Migration - Complete all render components
- Three.js Cleanup - Remove deprecated Three.js code
- Final Testing - Comprehensive QA and bug fixing
- Deployment Preparation - Update build configurations
Risk Assessment
High Priority Risks:
-
Shader Compatibility: Complex shaders may need adjustments Mitigation: Test each shader individually, create fallback options
-
Performance Characteristics: Different rendering pipeline Mitigation: Benchmark early and often, optimize hot spots
-
Coordinate System Differences: Potential transformation issues Mitigation: Create comprehensive conversion utilities
Medium Priority Risks:
-
Material Property Mismatches: Different material capabilities Mitigation: Feature detection and fallback materials
-
Particle System Behavior: Different particle API Mitigation: Test with existing snow effects first
Success Metrics
- Functional Completeness - All features working as before
- Visual Fidelity - No perceptible differences in rendering
- Performance - Equal or better frame rates
- Bundle Size - Target < 50KB gzipped (current ~80KB)
- Mobile Compatibility - Works on iOS/Android without issues
- Code Quality - Clean, maintainable migration code
Resources
- LittleJS Documentation: https://github.com/KilledByAPixel/LittleJS
- Migration Plan: CONVERSION_PLAN.md
- Test Results: npm test -- test/littlejs-migration.test.ts
- Prototype: src/prototype/littlejs-prototype.ts
Timeline Estimate
Current Status: Week 1-2 of migration (Research & Infrastructure)
Projected Timeline: - Weeks 3-4: Core components (sky, ice, particles) - Weeks 5-6: Secondary components and integration - Weeks 7-8: Testing, optimization, and cleanup
Total Estimated Duration: 8 weeks from start
Notes
The migration is proceeding according to plan. The adapter layer provides a solid foundation for converting Three.js concepts to LittleJS equivalents. Unit tests confirm that basic conversions work correctly.
The sky component migration demonstrates the approach: adapt shaders, convert materials, and create equivalent geometries while maintaining visual fidelity.