summaryrefslogtreecommitdiff
path: root/web-timeplot/src/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'web-timeplot/src/main.js')
-rw-r--r--web-timeplot/src/main.js152
1 files changed, 1 insertions, 151 deletions
diff --git a/web-timeplot/src/main.js b/web-timeplot/src/main.js
index e435193..d2b348e 100644
--- a/web-timeplot/src/main.js
+++ b/web-timeplot/src/main.js
@@ -1,151 +1 @@
-import { Application } from 'pixi.js';
-import * as PIXI from 'pixi.js';
-import { StateManager } from './state.js';
-
-// ============================================================================
-// GLOBAL STATE
-// ============================================================================
-
-// Centralized reactive state
-const state = new StateManager();
-
-// DOM references
-let dom = {
- container: null,
-};
-
-// Application instances
-let app = null; // PixiJS Application
-
-// ============================================================================
-// APPLICATION ENTRY POINT
-// ============================================================================
-
-document.addEventListener('DOMContentLoaded', async function() {
- log('Framework starting...');
-
- log('init DOM');
- await initDOM();
-
- log('init PixiJS renderer');
- await initRenderer();
-
- log('init services');
- await initServices();
-
- log('Framework ready - start prototyping!');
-});
-
-// ============================================================================
-// INITIALIZATION FUNCTIONS
-// ============================================================================
-
-async function initDOM() {
- dom.container = document.getElementById('canvas-container');
-
- if (!dom.container) {
- throw new Error('Canvas container not found');
- }
-}
-
-async function initRenderer() {
- // Check WebGPU availability
- let preference = 'webgpu';
- if (!navigator.gpu) {
- log('WebGPU not available, using WebGL');
- preference = 'webgl';
- }
-
- try {
- app = new Application();
-
- await app.init({
- preference: preference,
- width: window.innerWidth,
- height: window.innerHeight,
- backgroundColor: 0x1a1a26,
- antialias: true,
- autoDensity: true,
- resolution: window.devicePixelRatio || 1,
- });
-
- dom.container.appendChild(app.canvas);
-
- // Store renderer info in state
- const rendererType = app.renderer.type;
- state.state.rendering.rendererType = rendererType;
- log(`Using renderer: ${rendererType}`);
-
- // Store canvas dimensions in state
- state.state.uiConfig.canvasWidth = app.screen.width;
- state.state.uiConfig.canvasHeight = app.screen.height;
-
- // Handle window resize
- window.addEventListener('resize', handleResize);
-
- } catch (error) {
- log(`Failed to initialize renderer: ${error}`);
- throw error;
- }
-}
-
-async function initServices() {
- // Start animation loop
- app.ticker.add(update);
-
- log('Services initialized');
-}
-
-// ============================================================================
-// EVENT HANDLERS
-// ============================================================================
-
-function handleResize() {
- const width = window.innerWidth;
- const height = window.innerHeight;
-
- app.renderer.resize(width, height);
-
- // Update state
- state.state.uiConfig.canvasWidth = width;
- state.state.uiConfig.canvasHeight = height;
-}
-
-// ============================================================================
-// MAIN UPDATE LOOP
-// ============================================================================
-
-function update() {
- // Update time using state manager
- state.incrementTime(0.016); // ~60fps increment
- state.updateRealElapsed();
-
- state.state.rendering.frameCounter++;
-
- // YOUR PROTOTYPE CODE GOES HERE
- // Example:
- // yourSprite.x += 1;
- // yourGraphics.rotation += 0.01;
-}
-
-// ============================================================================
-// UTILITIES
-// ============================================================================
-
-function log(msg) {
- console.log(`[Framework] ${msg}`);
-}
-
-// ============================================================================
-// EXPORTS FOR PROTOTYPING
-// ============================================================================
-
-// Export immediately available objects
-window.PIXI = PIXI;
-window.state = state;
-window.log = log;
-
-// Export app after initialization (using a getter)
-Object.defineProperty(window, 'pixiApp', {
- get() { return app; }
-});
+import './bootstrap.js';