entangled-worlds-orbiters-shared
v1.0.7
Published
Shared library for entangled worlds orbiters - contains core world rendering, moons system, and UI components
Maintainers
Readme
Entangled Worlds Orbiters Shared Library
A shared library containing core components for 3D world rendering, moons system, and UI components used across Entangled Worlds applications.
Features
- World System: Core world rendering with textured spheres, normal materials, GLB models, and cloud shells
- Moons System: Orbital moon generation and management
- Arrow UI: Reusable UI component system based on lil-gui
- Loaders: Texture, GLB, and cubemap loading utilities
- Core Rendering: Lighting, Fresnel effects, and material utilities
- Configuration: Texture and configuration management system
Installation
npm install entangled-worlds-orbiters-sharedTest locally
In /entangled-worlds-orbiters-shared: npm install npm link
In /entangled-worlds-preview or /orbiters:
npm link entangled-worlds-orbiters-shared
Usage
// Import specific modules
import { WorldManager } from 'entangled-worlds-orbiters-shared/world';
import { MoonsManager } from 'entangled-worlds-orbiters-shared/moons';
import { GUI } from 'entangled-worlds-orbiters-shared/arrow-ui';
// Or import everything
import * as EntangledWorlds from 'entangled-worlds-orbiters-shared';Modules
World System
WorldManager- Main world orchestrationworldTexture- Textured sphere generationworldNormal- Normal material spheresworldGLB- GLB model loadingcloudShell- Cloud rendering system
Moons System
MoonsManager- Moons orchestrationmoonsGeneration- Moon generation logic
Arrow UI
- Complete UI component system based on lil-gui
- Controllers for boolean, color, function, number, option, and string inputs
Loaders
cubeMapLoader- Skybox loadingglbLoader- GLB loading utilitiesbodyTextureLoader- Texture loading
Core
lights- Lighting setuplightFresnel- Fresnel glow effects
Utils
materials- Material utilitiesdispose- Memory management
Configuration
textureConfig- Texture configuration system
Runtime base configuration (env)
This package is built statically. At runtime, it can use a public base URL to turn relative asset paths into absolute URLs. If you don’t provide a base, it will use same-origin root-relative paths (e.g., /default/...).
You have two ways to provide it:
- Environment variables (no code needed):
If your bundler/framework defines import.meta.env.VITE_PUBLIC_HERBARIUM_BASE (Vite) or you set window.VITE_PUBLIC_HERBARIUM_BASE (before the library runs), the library will pick it up automatically.
- Programmatic override (recommended for portability):
import { setPublicBase, loadTextureConfig } from 'entangled-worlds-orbiters-shared/config';
// Call this early at app startup (optional if you use envs/window)
setPublicBase(
(typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.VITE_PUBLIC_HERBARIUM_BASE) ||
(typeof process !== 'undefined' && process.env && process.env.NEXT_PUBLIC_HERBARIUM_BASE)
);
// Optionally preload a remote config file
// await loadTextureConfig('https://your-cdn/config/textures.json');Is setPublicBase required?
- Not required. If you don’t provide any base (via env/window/programmatic), the library will use same-origin root-relative URLs.
- Also not required if you provide
VITE_PUBLIC_HERBARIUM_BASEvia env (Vite) or setwindow.VITE_PUBLIC_HERBARIUM_BASEbefore using the library. - Use
setPublicBasewhen you want to:- Override the base at runtime (e.g., switch between staging/production dynamically)
- Avoid build-time coupling to a specific bundler env key
- Ensure the base is set in environments where env injection isn’t available
Defaults:
- If nothing is provided, it falls back to same-origin root-relative paths.
Effects:
- All URLs returned by
config/textureConfighelpers are absolute. - Skybox loader and moons generation resolve relative paths against the configured base.
- Cloud shell textures passed to
world.makeSphereare resolved to absolute URLs.
Peer Dependencies
This library requires Three.js and three-stdlib as peer dependencies:
npm install three three-stdlibLicense
MIT
