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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@fred3d/camera-system

v0.0.1

Published

Flexible camera system for Fred Engine

Readme

Camera System

A flexible, extensible camera system for 3D applications and games with support for multiple camera types and smooth transitions.

Features

  • Modular Design: Extensible base camera class with specialized implementations
  • Multiple Camera Types:
    • First Person Camera - FPS-style camera with look controls
    • Third Person Camera - Follow a target with configurable offset and rotation
    • Orbit Camera - Revolve around a target point with zoom capabilities
    • Top Down Camera - Bird's eye view with configurable height and angle
    • Isometric Camera - Fixed-angle orthographic projection
    • Side Scroller Camera - 2D-style camera with parallax support
    • Cinematic Camera - For cutscenes and directed camera movements
  • Smooth Transitions: Seamlessly transition between camera types with customizable easing
  • Advanced Features:
    • Camera shake effects
    • Target following with configurable smoothing
    • Screen space effects
    • Depth of field and cinematic effects
    • Event system for synchronizing camera movements with gameplay
  • Configuration System: Unified configuration for all camera types with serialization support

Installation

npm install @fred/camera-system

Quick Start

import { CameraSystem, FirstPersonCamera, CameraType } from '@fred/camera-system';
import * as THREE from 'three';

// Create a Three.js camera
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);

// Initialize camera system with a First Person Camera
const cameraSystem = new CameraSystem(camera);

// Add a first person camera with configuration
const firstPersonCamera = cameraSystem.createCamera(CameraType.FIRST_PERSON, {
  lookSpeed: 0.1,
  movementSpeed: 1.0,
  constraints: {
    minPolarAngle: 0,
    maxPolarAngle: Math.PI,
  }
});

// Make it the active camera
cameraSystem.setActiveCamera(CameraType.FIRST_PERSON);

// In your animation loop
function animate(time) {
  // Update the camera system (deltaTime in seconds)
  cameraSystem.update(deltaTime);
  
  requestAnimationFrame(animate);
  renderer.render(scene, camera);
}

Camera Types

First Person Camera

First-person perspective camera with mouse/keyboard controls, ideal for FPS games.

cameraSystem.createCamera(CameraType.FIRST_PERSON, {
  lookSpeed: 0.1,
  movementSpeed: 1.0,
  constraints: {
    minPolarAngle: 0,
    maxPolarAngle: Math.PI,
  }
});

Third Person Camera

Camera that follows a target from a configurable offset, ideal for action/adventure games.

cameraSystem.createCamera(CameraType.THIRD_PERSON, {
  target: player, // THREE.Object3D to follow
  offset: new THREE.Vector3(0, 2, -5),
  lookAtOffset: new THREE.Vector3(0, 1, 0),
  damping: 0.5,
  rotationSpeed: 0.1
});

Orbit Camera

Camera that orbits around a target point, good for strategy games or inspection views.

cameraSystem.createCamera(CameraType.ORBIT, {
  target: new THREE.Vector3(0, 0, 0),
  minDistance: 2,
  maxDistance: 20,
  initialDistance: 10,
  damping: 0.2,
  rotationSpeed: 1.0
});

Top Down Camera

Bird's eye view camera, ideal for strategy or management games.

cameraSystem.createCamera(CameraType.TOP_DOWN, {
  height: 10,
  angle: Math.PI / 8, // slight angle from directly above
  target: new THREE.Vector3(0, 0, 0),
  bounds: {
    minX: -100, maxX: 100,
    minZ: -100, maxZ: 100
  }
});

Isometric Camera

Fixed-angle orthographic projection, great for isometric-style games.

cameraSystem.createCamera(CameraType.ISOMETRIC, {
  zoom: 100,
  position: new THREE.Vector3(10, 10, 10),
  target: new THREE.Vector3(0, 0, 0)
});

Side Scroller Camera

2D-style camera with options for parallax, ideal for platformers.

cameraSystem.createCamera(CameraType.SIDE_SCROLLER, {
  target: player,
  deadZone: { x: 0.1, y: 0.2 }, // percentage of screen
  bounds: {
    minX: 0, maxX: 100,
    minY: 0, maxY: 50
  },
  damping: 0.5
});

Cinematic Camera

For cutscenes and scripted camera movements.

cameraSystem.createCamera(CameraType.CINEMATIC, {
  fov: 35, // cinematic narrower FOV
  depthOfField: {
    enabled: true,
    focusDistance: 10,
    bokehStrength: 0.05
  },
  waypoints: [
    {
      position: new THREE.Vector3(0, 2, 5),
      lookAt: player.position,
      duration: 2.0,
      fov: 50
    },
    {
      position: new THREE.Vector3(5, 1, 0),
      lookAt: enemy.position,
      duration: 3.0,
      fov: 35
    }
  ]
});

// Play the sequence
cameraSystem.getCamera(CameraType.CINEMATIC).playSequence();

Camera Transitions

Smoothly transition between different camera types:

// Transition from First Person to Orbit camera over 2 seconds
cameraSystem.transitionTo(CameraType.ORBIT, {
  duration: 2.0,
  easing: 'easeInOutQuad',
  onComplete: () => console.debug('Transition complete')
});

Advanced Usage

Camera Shake

// Add camera shake to the active camera
cameraSystem.getActiveCamera().shake(0.5); // intensity between 0-1

Custom Cameras

Extend the BaseCamera class to create custom camera types:

import { BaseCamera, CameraType } from '@fred/camera-system';

class MyCustomCamera extends BaseCamera {
  constructor(cameraObject, config) {
    // Define a custom camera type
    super(cameraObject, 'CUSTOM', config);
  }
  
  // Override update method for custom behavior
  update(deltaTime) {
    // Custom update logic
  }
}

// Register and use your custom camera
cameraSystem.registerCamera('CUSTOM', MyCustomCamera);
cameraSystem.createCamera('CUSTOM', myConfig);

Documentation

For full API documentation, see the API Reference.

Examples

License

MIT