Skip to main content

Overview

These types define the core data structures for scene objects in G3Engine, including geometry, transforms, materials, and lighting.

SceneObject

Represents a complete 3D object in the scene with all its properties.
export interface SceneObject {
    id: string;
    name: string;
    type: ObjectType;
    position: Vec3;
    rotation: Vec3;
    scale: Vec3;
    material: MaterialProps;
    visible: boolean;
    lightIntensity?: number;
    lightColor?: string;
}

Properties

id
string
required
Unique identifier for the object (UUID v4)
name
string
required
Display name of the object in the scene hierarchy
type
ObjectType
required
Type of 3D object or light. See ObjectType
position
Vec3
required
World position of the object. See Vec3
rotation
Vec3
required
Rotation in radians (Euler angles) around X, Y, Z axes. See Vec3
scale
Vec3
required
Scale multiplier for each axis. See Vec3
material
MaterialProps
required
Material properties defining the object’s appearance. See MaterialProps
visible
boolean
required
Whether the object is visible in the scene
lightIntensity
number
Light intensity for light objects only. Range typically 0-10
lightColor
string
Light color for light objects only (hex format, e.g., “#ffffff”)

ObjectType

Defines the available geometry and light types.
export type ObjectType = 
  | 'box' 
  | 'sphere' 
  | 'cylinder' 
  | 'plane' 
  | 'cone' 
  | 'torus' 
  | 'pointLight' 
  | 'directionalLight' 
  | 'ambientLight' 
  | 'camera';

Geometry Types

  • box - Cube/box mesh
  • sphere - Spherical mesh
  • cylinder - Cylindrical mesh
  • plane - Flat plane mesh
  • cone - Cone mesh
  • torus - Torus/donut mesh

Light Types

  • pointLight - Point light (emits in all directions)
  • directionalLight - Directional light (parallel rays)
  • ambientLight - Ambient light (uniform lighting)

Camera

  • camera - Camera object for viewpoint control

Vec3

Three-component vector used for position, rotation, and scale.
export interface Vec3 {
    x: number;
    y: number;
    z: number;
}

Properties

x
number
required
X-axis component
y
number
required
Y-axis component
z
number
required
Z-axis component

Usage Examples

const position: Vec3 = { x: 0, y: 1.5, z: -3 };

MaterialProps

Defines the visual appearance of an object using PBR (Physically Based Rendering) properties.
export interface MaterialProps {
    color: string;
    roughness: number;
    metalness: number;
    emissive?: string;
    emissiveIntensity?: number;
    opacity?: number;
    transparent?: boolean;
}

Properties

color
string
required
Base color of the material in hex format (e.g., “#6366f1”)
roughness
number
required
Surface roughness from 0 (smooth/reflective) to 1 (rough/diffuse)
metalness
number
required
Metallic property from 0 (dielectric) to 1 (metallic)
emissive
string
Emissive (glow) color in hex format (e.g., “#ffffff”)
emissiveIntensity
number
Intensity of the emissive glow. Range typically 0-10
opacity
number
Opacity level from 0 (fully transparent) to 1 (fully opaque). Requires transparent: true
transparent
boolean
Whether the material supports transparency

Usage Examples

const plastic: MaterialProps = {
  color: '#6366f1',
  roughness: 0.4,
  metalness: 0.1
};

TransformMode

Defines the active transform manipulation mode in the editor.
export type TransformMode = 'translate' | 'rotate' | 'scale';
  • translate - Move objects in 3D space
  • rotate - Rotate objects around their axes
  • scale - Resize objects along their axes

Build docs developers (and LLMs) love