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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ultrx

v1.1.1

Published

Lightweight WebGL 2.0 3D engine with scene graph, PBR-style lighting, UBO-optimized rendering, raycasting, instanced meshes, and built-in geometry primitives.

Readme

UltrX

Lightweight WebGL 2.0 3D engine with scene graph, PBR-style lighting, UBO-optimized rendering, raycasting, instanced meshes, and built-in geometry primitives.

UltrX

WebGL 2.0

License

ESM


Features

  • 🎯 Scene Graph - Hierarchical object management with dirty flag optimization
  • 💡 Multiple Light Types - Ambient, Directional, Point, Hemisphere, Spot lights
  • 📐 Geometry Primitives - Box, Sphere, Plane, Cylinder
  • 🎨 Material System - Color, texture mapping, blend modes, transparency
  • UBO Optimized - Uniform Buffer Objects for high-performance rendering
  • 🔦 Raycasting - Object picking and intersection tests
  • 🏗️ Instanced Rendering - Efficient rendering of thousands of objects
  • 📷 Cameras - Perspective and Orthographic
  • 🔄 Quaternion & Euler - Full rotation support
  • 🖼️ Texture Support - Load and apply textures

Installation

npm install ultrx

API Reference

Vector3

3D vector class with common mathematical operations.

Constructor

new Vector3(x = 0, y = 0, z = 0)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | x | number | 0 | X component | | y | number | 0 | Y component | | z | number | 0 | Z component |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | set(x, y, z) | x: number, y: number, z: number | this | Set all components | | copy(v) | v: Vector3 | this | Copy values from another vector | | clone() | None | Vector3 | Create a copy | | add(v) | v: Vector3 | this | Add another vector | | sub(v) | v: Vector3 | this | Subtract another vector | | multiplyScalar(scalar) | scalar: number | this | Multiply by scalar | | length() | None | number | Calculate magnitude | | normalize() | None | this | Normalize to unit vector | | cross(v) | v: Vector3 | this | Cross product | | dot(v) | v: Vector3 | number | Dot product | | distanceTo(v) | v: Vector3 | number | Distance to another vector |


Vector2

2D vector class.

Constructor

new Vector2(x = 0, y = 0)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | x | number | 0 | X component | | y | number | 0 | Y component |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | set(x, y) | x: number, y: number | this | Set components | | copy(v) | v: Vector2 | this | Copy from another vector | | clone() | None | Vector2 | Create a copy | | add(v) | v: Vector2 | this | Add another vector | | sub(v) | v: Vector2 | this | Subtract another vector | | multiplyScalar(scalar) | scalar: number | this | Multiply by scalar | | length() | None | number | Calculate magnitude | | normalize() | None | this | Normalize to unit vector | | dot(v) | v: Vector2 | number | Dot product | | distanceTo(v) | v: Vector2 | number | Distance to another vector |


Euler

Euler angle representation with rotation order support.

Constructor

new Euler(x = 0, y = 0, z = 0, order = 'XYZ')

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | x | number | 0 | Pitch (rotation around X) | | y | number | 0 | Yaw (rotation around Y) | | z | number | 0 | Roll (rotation around Z) | | order | string | 'XYZ' | Rotation order: 'XYZ', 'YXZ', 'ZXY', 'ZYX', 'YZX', 'XZY' |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | set(x, y, z, order) | x: number, y: number, z: number, order: string | this | Set all values | | copy(e) | e: Euler | this | Copy from another Euler | | clone() | None | Euler | Create a copy | | setOrder(order) | order: string | this | Set rotation order | | toMatrix(target) | target: Float32Array (optional) | Float32Array | Convert to 4x4 rotation matrix |


Quaternion

Quaternion for smooth rotation interpolation.

Constructor

new Quaternion(x = 0, y = 0, z = 0, w = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | x | number | 0 | X component | | y | number | 0 | Y component | | z | number | 0 | Z component | | w | number | 1 | W component (scalar) |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | set(x, y, z, w) | x: number, y: number, z: number, w: number | this | Set components | | copy(q) | q: Quaternion | this | Copy from another quaternion | | clone() | None | Quaternion | Create a copy | | setFromEuler(euler) | euler: Euler | this | Convert from Euler angles | | setFromAxisAngle(axis, angle) | axis: Vector3, angle: number | this | Set from axis-angle representation | | multiply(q) | q: Quaternion | this | Multiply by another quaternion | | multiplyQuaternions(a, b) | a: Quaternion, b: Quaternion | this | Multiply two quaternions | | inverse() | None | this | Calculate inverse | | conjugate() | None | this | Calculate conjugate | | normalize() | None | this | Normalize to unit quaternion | | length() | None | number | Calculate magnitude | | dot(q) | q: Quaternion | number | Dot product | | slerp(q, t) | q: Quaternion, t: number (0-1) | this | Spherical linear interpolation | | toMatrix(target) | target: Float32Array (optional) | Float32Array | Convert to 4x4 rotation matrix | | toEuler(target) | target: Euler (optional) | Euler | Convert to Euler angles | | equals(q) | q: Quaternion | boolean | Check equality | | rotateTowards(q, maxStep) | q: Quaternion, maxStep: number | this | Rotate towards target quaternion |


Object3D

Base class for all 3D objects in the scene graph.

Constructor

new Object3D()

Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | position | Vector3 | (0,0,0) | Local position | | rotation | Euler | (0,0,0,'XYZ') | Local rotation | | scale | Vector3 | (1,1,1) | Local scale | | matrix | Float32Array | Identity | Local transformation matrix | | matrixWorld | Float32Array | Identity | World transformation matrix | | parent | Object3D | null | Parent object | | children | Array | [] | Child objects | | up | Vector3 | (0,1,0) | Up direction |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | markDirty() | None | void | Mark matrix as needing update | | add(...objects) | objects: Object3D[] | this | Add child objects | | remove(...objects) | objects: Object3D[] | this | Remove child objects | | removeFromParent() | None | this | Remove from parent | | clear() | None | this | Remove all children | | getChildByIndex(index) | index: number | Object3D | Get child by index | | getDescendants() | None | Object3D[] | Get all descendants | | contains(object) | object: Object3D | boolean | Check if contains object | | getWorldPosition(target) | target: Vector3 (optional) | Vector3 | Get world position | | getWorldScale(target) | target: Vector3 (optional) | Vector3 | Get world scale | | localToWorld(vector) | vector: Vector3 | Vector3 | Transform local to world coordinates | | worldToLocal(vector) | vector: Vector3 | Vector3 | Transform world to local coordinates | | updateMatrix() | None | void | Update local matrix | | updateWorldMatrix(updateParents) | updateParents: boolean | void | Update world matrix |


Scene

Root container for the scene graph.

Constructor

new Scene()

Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | background | any | null | Scene background (future: color or texture) |

Methods Inherits all methods from Object3D.


Group

Container for grouping objects without transformation.

Constructor

new Group()

Methods Inherits all methods from Object3D.


Camera

Base camera class.

Constructor

new Camera()

Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | projectionMatrix | Float32Array | Identity | Projection matrix | | projectionMatrixInverse | Float32Array | Identity | Inverse projection matrix | | viewMatrix | Float32Array | Identity | View matrix | | matrixWorldInverse | Float32Array | Identity | Inverse world matrix | | isCamera | boolean | true | Camera flag |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | updateViewMatrix() | None | void | Update view matrix | | invertMatrix4(m) | m: Float32Array | Float32Array | Invert 4x4 matrix | | lookAt(target) | target: Vector3 | this | Point camera at target |


PerspectiveCamera

Perspective projection camera.

Constructor

new PerspectiveCamera(fov = 60, aspect = 1, near = 0.1, far = 10)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | fov | number | 60 | Field of view in degrees | | aspect | number | 1 | Width/height ratio | | near | number | 0.1 | Near clipping plane | | far | number | 10 | Far clipping plane |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | updateProjectionMatrix() | None | Float32Array | Update projection matrix | | updateAspect(aspect) | aspect: number | this | Update aspect ratio | | setFov(fov) | fov: number | this | Set field of view | | setNearFar(near, far) | near: number, far: number | this | Set clipping planes |

Properties Inherits all properties from Camera.


OrthographicCamera

Orthographic projection camera.

Constructor

new OrthographicCamera(left = -1, right = 1, bottom = -1, top = 1, near = 0.1, far = 10)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | left | number | -1 | Left clipping plane | | right | number | 1 | Right clipping plane | | bottom | number | -1 | Bottom clipping plane | | top | number | 1 | Top clipping plane | | near | number | 0.1 | Near clipping plane | | far | number | 10 | Far clipping plane |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | updateProjectionMatrix() | None | Float32Array | Update projection matrix | | set(left, right, bottom, top, near, far) | All numbers | this | Set all clipping planes |


Geometry

Base geometry class for mesh data.

Constructor

new Geometry(data = null)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | data | Geometry[] | null | Array of geometries to merge |

Properties

| Property | Type | Description | |----------|------|-------------| | position | Float32Array | Vertex positions [x,y,z,...] | | index | Uint16Array | Index buffer | | color | Float32Array | Vertex colors [r,g,b,...] | | uv | Float32Array | UV coordinates [u,v,...] | | normal | Float32Array | Vertex normals [x,y,z,...] | | vertexCount | number | Number of vertices |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | computeVertexCount() | None | number | Calculate vertex count | | computeNormals() | None | this | Compute vertex normals | | upload(gl) | gl: WebGL2RenderingContext | void | Upload to GPU | | setupVAO(gl, program) | gl, program: WebGLProgram | WebGLVertexArrayObject | Setup vertex array object | | update() | None | void | Mark as needing update | | setUV(uvData) | uvData: Float32Array | this | Set UV data | | mergeGeometries(geometries) | geometries: Geometry[] | this | Merge multiple geometries | | addGeometry(geometry) | geometry: Geometry | this | Add a geometry | | clone() | None | Geometry | Create a copy | | transform(matrix) | matrix: Float32Array | this | Transform vertices | | translate(x, y, z) | x: number, y: number, z: number | this | Translate vertices | | scale(x, y, z) | x: number, y: number, z: number | this | Scale vertices | | dispose(gl) | gl: WebGL2RenderingContext | void | Clean up GPU resources |


BoxGeometry

Box/cube geometry.

Constructor

new BoxGeometry(width = 1, height = 1, depth = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | width | number | 1 | Width (X axis) | | height | number | 1 | Height (Y axis) | | depth | number | 1 | Depth (Z axis) |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | buildGeometry() | None | void | Build the geometry | | setBoxUV(uvData) | uvData: Float32Array | this | Set custom UV data | | setUniformUV(uvMap) | uvMap: {uMin, vMin, uMax, vMax} | this | Set uniform UV mapping | | setSize(width, height, depth) | All numbers | this | Resize the box |


SphereGeometry

Sphere geometry.

Constructor

new SphereGeometry(radius = 1, widthSegments = 16, heightSegments = 12)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | radius | number | 1 | Sphere radius | | widthSegments | number | 16 | Segments around equator | | heightSegments | number | 12 | Segments from pole to pole |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | buildGeometry() | None | void | Build the geometry | | setRadius(radius) | radius: number | this | Change radius | | setSegments(widthSegments, heightSegments) | Both numbers | this | Change segment count |


PlaneGeometry

Plane geometry.

Constructor

new PlaneGeometry(width = 1, height = 1, widthSegments = 1, heightSegments = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | width | number | 1 | Plane width | | height | number | 1 | Plane height | | widthSegments | number | 1 | Segments along width | | heightSegments | number | 1 | Segments along height |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | buildGeometry() | None | void | Build the geometry |


CylinderGeometry

Cylinder geometry.

Constructor

new CylinderGeometry(radiusTop = 1, radiusBottom = 1, height = 1, radialSegments = 16, heightSegments = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | radiusTop | number | 1 | Top radius | | radiusBottom | number | 1 | Bottom radius | | height | number | 1 | Cylinder height | | radialSegments | number | 16 | Segments around circumference | | heightSegments | number | 1 | Segments along height |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | buildGeometry() | None | void | Build the geometry |


Texture

Texture loader and manager.

Constructor

new Texture(url)

| Parameter | Type | Description | |-----------|------|-------------| | url | string | Image URL |

Properties

| Property | Type | Description | |----------|------|-------------| | url | string | Image URL | | image | HTMLImageElement | Loaded image | | texture | WebGLTexture | GPU texture handle | | loaded | boolean | Load status |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | load() | None | void | Load the texture | | upload(gl) | gl: WebGL2RenderingContext | WebGLTexture | Upload to GPU | | dispose(gl) | gl: WebGL2RenderingContext | void | Clean up GPU resources |


Material

Material properties for rendering.

Constructor

new Material(options = {})

| Option | Type | Default | Description | |--------|------|---------|-------------| | color | object | {r:1,g:1,b:1} | Diffuse color | | map | Texture | null | Texture map | | side | string | 'FRONT' | Render side: 'FRONT', 'BACK', 'DOUBLE' | | blendMode | string | 'MULTIPLY' | Blend mode: 'MULTIPLY', 'ADD', 'SUBTRACT', 'REPLACE' | | transparent | boolean | false | Enable transparency | | opacity | number | 1.0 | Opacity (0-1) | | receiveLight | boolean | true | Receive lighting |

Properties

| Property | Type | Description | |----------|------|-------------| | color | Vector3 | Diffuse color | | map | Texture | Texture map | | side | string | Render side | | blendMode | string | Blend mode | | transparent | boolean | Transparency flag | | opacity | number | Opacity value | | receiveLight | boolean | Light reception flag |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setColor(r, g, b) | r: number, g: number, b: number | this | Set diffuse color | | setMap(texture) | texture: Texture | this | Set texture map | | setSide(side) | side: string | this | Set render side | | setBlendMode(mode) | mode: string | this | Set blend mode | | setTransparent(transparent) | transparent: boolean | this | Set transparency | | setOpacity(opacity) | opacity: number | this | Set opacity | | setReceiveLight(receive) | receive: boolean | this | Set light reception | | getGLFaceMode(gl) | gl: WebGL2RenderingContext | number | Get GL face mode |


Mesh

Renderable mesh object.

Constructor

new Mesh(geometry, material)

| Parameter | Type | Description | |-----------|------|-------------| | geometry | Geometry | Mesh geometry | | material | Material | Mesh material |

Properties

| Property | Type | Description | |----------|------|-------------| | geometry | Geometry | Mesh geometry | | material | Material | Mesh material | | isMesh | boolean | true |

Methods Inherits all methods from Object3D.


InstancedMesh

High-performance instanced mesh.

Constructor

new InstancedMesh(geometry, material, count)

| Parameter | Type | Description | |-----------|------|-------------| | geometry | Geometry | Shared geometry | | material | Material | Shared material | | count | number | Instance count |

Properties

| Property | Type | Description | |----------|------|-------------| | instanceMatrix | Float32Array | Instance transformation matrices | | instanceColors | Float32Array | Instance colors | | count | number | Number of instances |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setMatrixAt(index, matrix) | index: number, matrix: Float32Array | this | Set instance matrix | | getMatrixAt(index, target) | index: number, target: Float32Array | Float32Array | Get instance matrix | | setColorAt(index, color) | index: number, color: Vector3/number | this | Set instance color | | getColorAt(index, target) | index: number, target: Vector3 | Vector3 | Get instance color | | setPositionAt(index, position) | index: number, position: Vector3 | this | Set instance position | | setRotationAt(index, rotation) | index: number, rotation: Euler/Quaternion | this | Set instance rotation | | setScaleAt(index, scale) | index: number, scale: Vector3/number | this | Set instance scale | | setTransformAt(index, position, rotation, scale) | All parameters | this | Set full transform | | dispose(gl) | gl: WebGL2RenderingContext | void | Clean up GPU resources |


Light

Base light class.

Constructor

new Light(color = 0xffffff, intensity = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | color | number | 0xffffff | Light color (hex) | | intensity | number | 1 | Light intensity |

Properties

| Property | Type | Description | |----------|------|-------------| | color | Vector3 | Light color | | intensity | number | Light intensity | | isLight | boolean | true |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setColor(r, g, b) | r: number, g: number, b: number | this | Set color | | setIntensity(intensity) | intensity: number | this | Set intensity |


AmbientLight

Ambient lighting.

Constructor

new AmbientLight(color = 0xffffff, intensity = 0.5)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | color | number | 0xffffff | Light color (hex) | | intensity | number | 0.5 | Light intensity |

Properties

| Property | Type | Description | |----------|------|-------------| | isAmbientLight | boolean | true | | type | string | 'AmbientLight' |

Methods Inherits from Light.


DirectionalLight

Directional light (simulates sunlight).

Constructor

new DirectionalLight(color = 0xffffff, intensity = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | color | number | 0xffffff | Light color (hex) | | intensity | number | 1 | Light intensity |

Properties

| Property | Type | Description | |----------|------|-------------| | target | Object3D | Target object for direction | | isDirectionalLight | boolean | true | | type | string | 'DirectionalLight' |

Methods Inherits from Light.


PointLight

Point light source.

Constructor

new PointLight(color = 0xffffff, intensity = 1, distance = 0, decay = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | color | number | 0xffffff | Light color (hex) | | intensity | number | 1 | Light intensity | | distance | number | 0 | Maximum distance (0 = infinite) | | decay | number | 1 | Light decay factor |

Properties

| Property | Type | Description | |----------|------|-------------| | distance | number | Maximum distance | | decay | number | Decay factor | | isPointLight | boolean | true | | type | string | 'PointLight' |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setDistance(distance) | distance: number | this | Set maximum distance | | setDecay(decay) | decay: number | this | Set decay factor | | getAttenuation(distance) | distance: number | number | Calculate attenuation at distance |


HemisphereLight

Sky/ground gradient light.

Constructor

new HemisphereLight(skyColor = 0xffffff, groundColor = 0x444444, intensity = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | skyColor | number | 0xffffff | Sky color (hex) | | groundColor | number | 0x444444 | Ground color (hex) | | intensity | number | 1 | Light intensity |

Properties

| Property | Type | Description | |----------|------|-------------| | groundColor | Vector3 | Ground color | | isHemisphereLight | boolean | true | | type | string | 'HemisphereLight' |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setSkyColor(r, g, b) | r: number, g: number, b: number | this | Set sky color | | setGroundColor(r, g, b) | r: number, g: number, b: number | this | Set ground color |


SpotLight

Spotlight with cone angle.

Constructor

new SpotLight(color = 0xffffff, intensity = 1, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | color | number | 0xffffff | Light color (hex) | | intensity | number | 1 | Light intensity | | distance | number | 0 | Maximum distance | | angle | number | PI/3 | Cone angle in radians | | penumbra | number | 0 | Penumbra factor (0-1) | | decay | number | 1 | Decay factor |

Properties

| Property | Type | Description | |----------|------|-------------| | angle | number | Cone angle | | penumbra | number | Penumbra factor | | target | Object3D | Target object | | isSpotLight | boolean | true | | type | string | 'SpotLight' |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setAngle(angle) | angle: number | this | Set cone angle | | setPenumbra(penumbra) | penumbra: number | this | Set penumbra factor |


WebGLRenderer

WebGL 2.0 renderer.

Constructor

new WebGLRenderer()

Properties

| Property | Type | Description | |----------|------|-------------| | domElement | HTMLCanvasElement | Render target canvas | | gl | WebGL2RenderingContext | WebGL context | | width | number | Canvas width | | height | number | Canvas height |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | setSize(width, height) | width: number, height: number | void | Resize canvas and viewport | | createShader(type, source) | type: number, source: string | WebGLShader | Create shader | | createProgram() | None | WebGLProgram | Create shader program | | render(scene, camera) | scene: Scene, camera: Camera | void | Render the scene | | dispose() | None | void | Clean up GPU resources |


Raycaster

Raycasting for object picking and intersection.

Constructor

new Raycaster(origin = new Vector3(), direction = new Vector3(0, 0, -1), near = 0, far = Infinity)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | origin | Vector3 | (0,0,0) | Ray origin | | direction | Vector3 | (0,0,-1) | Ray direction | | near | number | 0 | Near clipping distance | | far | number | Infinity | Far clipping distance |

Properties

| Property | Type | Description | |----------|------|-------------| | ray.origin | Vector3 | Ray origin | | ray.direction | Vector3 | Ray direction | | near | number | Near clipping | | far | number | Far clipping |

Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | set(origin, direction) | origin: Vector3, direction: Vector3 | this | Set ray | | setFromCamera(pos, camera) | pos: Vector2, camera: Camera | this | Set from camera | | intersectObject(object, recursive, intersects) | object: Object3D, recursive: boolean, intersects: Array | Array | Intersect object | | intersectObjects(objects, recursive) | objects: Object3D[], recursive: boolean | Array | Intersect multiple objects |


Quick Start

import { 
    Scene, 
    PerspectiveCamera, 
    WebGLRenderer, 
    BoxGeometry, 
    Mesh, 
    Material,
    AmbientLight,
    DirectionalLight,
    Vector3 
} from 'ultrx';

// Create scene
const scene = new Scene();

// Add lights
const ambient = new AmbientLight(0x404060, 0.5);
scene.add(ambient);

const directional = new DirectionalLight(0xffffff, 1);
directional.position.set(5, 10, 5);
scene.add(directional);

// Create a cube
const geometry = new BoxGeometry(1, 1, 1);
const material = new Material({ 
    color: { r: 1, g: 0.3, b: 0.3 },
    receiveLight: true 
});
const cube = new Mesh(geometry, material);
cube.position.y = 0.5;
scene.add(cube);

// Create camera
const camera = new PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 100);
camera.position.set(3, 3, 5);
camera.lookAt(new Vector3(0, 0, 0));

// Create renderer
const renderer = new WebGLRenderer();
document.body.appendChild(renderer.domElement);

// Animation loop
function animate() {
    requestAnimationFrame(animate);
    cube.rotation.x += 0.01;
    cube.rotation.y += 0.02;
    renderer.render(scene, camera);
}
animate();

Building from Source

git clone https://github.com/yourusername/ultrx.git
cd ultrx
npm install
npm run build

License

Apache-2.0 © Wang Xiaoyu