@vib3code/sdk 2.0.3-canary.590fbae → 2.0.3-canary.69d53b3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DOCS/AGENT_HARNESS_ARCHITECTURE.md +2 -0
- package/DOCS/ANDROID_DEPLOYMENT.md +59 -0
- package/DOCS/ARCHITECTURE.md +1 -0
- package/DOCS/CI_TESTING.md +2 -0
- package/DOCS/CLI_ONBOARDING.md +2 -0
- package/DOCS/CONTROL_REFERENCE.md +2 -0
- package/DOCS/CROSS_SITE_DESIGN_PATTERNS.md +2 -0
- package/DOCS/ENV_SETUP.md +2 -0
- package/DOCS/EPIC_SCROLL_EVENTS.md +2 -0
- package/DOCS/EXPANSION_DESIGN.md +979 -0
- package/DOCS/EXPANSION_DESIGN_ULTRA.md +389 -0
- package/DOCS/EXPORT_FORMATS.md +2 -0
- package/DOCS/GPU_DISPOSAL_GUIDE.md +2 -0
- package/DOCS/HANDOFF_LANDING_PAGE.md +2 -0
- package/DOCS/HANDOFF_SDK_DEVELOPMENT.md +2 -0
- package/DOCS/LICENSING_TIERS.md +2 -0
- package/DOCS/MASTER_PLAN_2026-01-31.md +2 -0
- package/DOCS/MULTIVIZ_CHOREOGRAPHY_PATTERNS.md +3 -1
- package/DOCS/OBS_SETUP_GUIDE.md +2 -0
- package/DOCS/OPTIMIZATION_PLAN_MATH.md +119 -0
- package/DOCS/PRODUCT_STRATEGY.md +2 -0
- package/DOCS/PROJECT_SETUP.md +2 -0
- package/DOCS/README.md +5 -3
- package/DOCS/REFERENCE_SCROLL_ANALYSIS.md +2 -0
- package/DOCS/RENDERER_LIFECYCLE.md +2 -0
- package/DOCS/REPO_MANIFEST.md +2 -0
- package/DOCS/ROADMAP.md +2 -0
- package/DOCS/SCROLL_TIMELINE_v3.md +2 -0
- package/DOCS/SITE_REFACTOR_PLAN.md +2 -0
- package/DOCS/STATUS.md +2 -0
- package/DOCS/SYSTEM_INVENTORY.md +2 -0
- package/DOCS/TELEMETRY_EXPORTS.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_CLICKERSS.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_FACETAD.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_SIMONE.md +2 -0
- package/DOCS/VISUAL_ANALYSIS_TABLESIDE.md +2 -0
- package/DOCS/WEBGPU_STATUS.md +2 -0
- package/DOCS/XR_BENCHMARKS.md +2 -0
- package/DOCS/archive/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +1 -34
- package/DOCS/archive/DEV_TRACK_ANALYSIS.md +1 -80
- package/DOCS/archive/DEV_TRACK_PLAN_2026-01-07.md +1 -42
- package/DOCS/archive/SESSION_014_PLAN.md +1 -195
- package/DOCS/archive/SESSION_LOG_2026-01-07.md +1 -56
- package/DOCS/archive/STRATEGIC_BLUEPRINT_2026-01-07.md +1 -72
- package/DOCS/archive/SYSTEM_AUDIT_2026-01-30.md +1 -741
- package/DOCS/archive/WEBGPU_STATUS_2026-02-15_STALE.md +1 -38
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-01-31.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-06.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-13.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-15.md +2 -0
- package/DOCS/dev-tracks/DEV_TRACK_SESSION_2026-02-16.md +2 -0
- package/DOCS/dev-tracks/PERF_UPGRADE_2026-02-16.md +2 -0
- package/DOCS/dev-tracks/README.md +2 -0
- package/package.json +1 -1
- package/src/experimental/GameLoop.js +72 -0
- package/src/experimental/LatticePhysics.js +100 -0
- package/src/experimental/LiveDirector.js +143 -0
- package/src/experimental/PlayerController4D.js +154 -0
- package/src/experimental/VIB3Actor.js +138 -0
- package/src/experimental/VIB3Compositor.js +117 -0
- package/src/experimental/VIB3Link.js +122 -0
- package/src/experimental/VIB3Orchestrator.js +146 -0
- package/src/experimental/VIB3Universe.js +109 -0
- package/src/experimental/demos/CrystalLabyrinth.js +202 -0
- package/src/geometry/generators/Crystal.js +2 -2
- package/src/math/Mat4x4.js +238 -92
- package/src/math/Rotor4D.js +69 -46
- package/src/math/Vec4.js +200 -103
- package/src/scene/Node4D.js +74 -24
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIB3Actor - A VIB3+ Entity with Personality
|
|
3
|
+
*
|
|
4
|
+
* Wraps a VIB3Engine instance with emotional state and expression logic.
|
|
5
|
+
* Actors can "emote" (transition parameters based on mood) and "speak"
|
|
6
|
+
* (modulate geometry).
|
|
7
|
+
*
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
import { TransitionAnimator } from '../creative/TransitionAnimator.js';
|
|
11
|
+
|
|
12
|
+
export class VIB3Actor {
|
|
13
|
+
/**
|
|
14
|
+
* @param {VIB3Engine} engine - The VIB3 engine instance
|
|
15
|
+
* @param {string|object} profile - Personality profile name or object
|
|
16
|
+
*/
|
|
17
|
+
constructor(engine, profile = 'neutral') {
|
|
18
|
+
this.engine = engine;
|
|
19
|
+
this.id = `actor_${Math.random().toString(36).substr(2, 9)}`;
|
|
20
|
+
this.active = true;
|
|
21
|
+
|
|
22
|
+
// Emotional State (-1.0 to 1.0)
|
|
23
|
+
this.emotion = {
|
|
24
|
+
valence: 0, // Positive/Negative
|
|
25
|
+
arousal: 0 // High/Low Energy
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Animation system
|
|
29
|
+
this.animator = new TransitionAnimator(
|
|
30
|
+
(k, v) => this.engine.setParameter(k, v),
|
|
31
|
+
(k) => this.engine.getParameter(k)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Load profile
|
|
35
|
+
this.profile = typeof profile === 'string' ? this._getProfile(profile) : profile;
|
|
36
|
+
|
|
37
|
+
// Apply base state
|
|
38
|
+
this.reset();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Update loop called by Orchestrator.
|
|
43
|
+
* @param {number} time - Total elapsed simulation time
|
|
44
|
+
* @param {number} dt - Delta time in seconds
|
|
45
|
+
*/
|
|
46
|
+
update(time, dt) {
|
|
47
|
+
if (!this.active) return;
|
|
48
|
+
|
|
49
|
+
// Idle behavior (breathing)
|
|
50
|
+
// Sync morphFactor to universe time
|
|
51
|
+
const breath = Math.sin(time * 2.0) * 0.1; // 2.0 rad/s
|
|
52
|
+
|
|
53
|
+
// Apply breath modulation on top of base profile
|
|
54
|
+
// Note: This is a simple additive modulation.
|
|
55
|
+
// A real system would blend this with active transitions.
|
|
56
|
+
const currentMorph = this.engine.getParameter('morphFactor') || 1.0;
|
|
57
|
+
// Only modulate if not transitioning heavily
|
|
58
|
+
if (!this.animator.isAnimating()) {
|
|
59
|
+
// Gentle idle sway
|
|
60
|
+
this.engine.setParameter('morphFactor', 1.0 + breath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Express an emotion.
|
|
66
|
+
* @param {string} emotionName - e.g., 'joy', 'anger', 'fear', 'sadness'
|
|
67
|
+
* @param {number} intensity - 0.0 to 1.0
|
|
68
|
+
* @param {number} duration - Transition duration in ms
|
|
69
|
+
*/
|
|
70
|
+
emote(emotionName, intensity = 1.0, duration = 1000) {
|
|
71
|
+
const mapping = this.profile.emotions[emotionName];
|
|
72
|
+
if (!mapping) {
|
|
73
|
+
console.warn(`VIB3Actor: Unknown emotion '${emotionName}' for profile '${this.profile.name}'`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const targetParams = {};
|
|
78
|
+
for (const [param, baseVal] of Object.entries(mapping)) {
|
|
79
|
+
// Lerp between current/neutral and target based on intensity
|
|
80
|
+
// Simplified: just setting target value scaled by intensity logic could go here
|
|
81
|
+
// For now, we just use the mapped value directly as the "100% intensity" target
|
|
82
|
+
targetParams[param] = baseVal;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Apply global intensity modifiers
|
|
86
|
+
if (targetParams.intensity) targetParams.intensity *= intensity;
|
|
87
|
+
if (targetParams.speed) targetParams.speed *= intensity;
|
|
88
|
+
|
|
89
|
+
this.animator.transition(targetParams, duration, 'easeOut');
|
|
90
|
+
|
|
91
|
+
// Update internal state (simplified)
|
|
92
|
+
this.emotion.lastEmote = emotionName;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Reset to neutral state.
|
|
97
|
+
*/
|
|
98
|
+
reset(duration = 1000) {
|
|
99
|
+
this.animator.transition(this.profile.base, duration, 'easeInOut');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Get a predefined personality profile.
|
|
104
|
+
* @param {string} name
|
|
105
|
+
*/
|
|
106
|
+
_getProfile(name) {
|
|
107
|
+
const profiles = {
|
|
108
|
+
neutral: {
|
|
109
|
+
name: 'neutral',
|
|
110
|
+
base: { hue: 200, saturation: 0.5, intensity: 0.5, chaos: 0, speed: 1.0, gridDensity: 20 },
|
|
111
|
+
emotions: {
|
|
112
|
+
joy: { hue: 50, saturation: 1.0, intensity: 0.8, speed: 2.0, chaos: 0.2 },
|
|
113
|
+
anger: { hue: 0, saturation: 1.0, intensity: 0.9, speed: 3.0, chaos: 0.8 },
|
|
114
|
+
sadness: { hue: 240, saturation: 0.2, intensity: 0.3, speed: 0.2, chaos: 0 },
|
|
115
|
+
fear: { hue: 280, saturation: 0.8, intensity: 0.6, speed: 2.5, chaos: 0.9, gridDensity: 50 }
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
heroic: {
|
|
119
|
+
name: 'heroic',
|
|
120
|
+
base: { hue: 210, saturation: 0.8, intensity: 0.7, chaos: 0.1, speed: 1.0, gridDensity: 15 },
|
|
121
|
+
emotions: {
|
|
122
|
+
joy: { hue: 50, saturation: 1.0, intensity: 1.0, speed: 1.5, morphFactor: 1.2 },
|
|
123
|
+
anger: { hue: 20, saturation: 1.0, intensity: 1.0, speed: 2.5, chaos: 0.5 },
|
|
124
|
+
determination: { hue: 220, saturation: 0.9, intensity: 0.9, speed: 1.2, gridDensity: 10 }
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
glitch: {
|
|
128
|
+
name: 'glitch',
|
|
129
|
+
base: { hue: 120, saturation: 0.0, intensity: 0.4, chaos: 0.5, speed: 2.0, gridDensity: 40 },
|
|
130
|
+
emotions: {
|
|
131
|
+
panic: { hue: 0, saturation: 0, intensity: 0.9, speed: 5.0, chaos: 1.0, rot4dXW: 1.5 },
|
|
132
|
+
calm: { hue: 120, saturation: 0.5, intensity: 0.4, speed: 0.5, chaos: 0.2 }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return profiles[name] || profiles.neutral;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIB3Compositor - Visual Layering and Scene Management
|
|
3
|
+
*
|
|
4
|
+
* Handles the complexity of rendering multiple VIB3+ instances into a cohesive visual.
|
|
5
|
+
* Manages DOM structure, Z-indexing, masking, and blend modes for "Universe" rendering.
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*/
|
|
9
|
+
export class VIB3Compositor {
|
|
10
|
+
constructor(containerId = 'vib3-universe') {
|
|
11
|
+
this.containerId = containerId;
|
|
12
|
+
this.layers = []; // Ordered list of layer configs
|
|
13
|
+
this.activeInstances = new Map(); // instanceId -> DOM element
|
|
14
|
+
|
|
15
|
+
// Ensure container exists
|
|
16
|
+
if (typeof document !== 'undefined') {
|
|
17
|
+
this.container = document.getElementById(containerId);
|
|
18
|
+
if (!this.container) {
|
|
19
|
+
this.container = document.createElement('div');
|
|
20
|
+
this.container.id = containerId;
|
|
21
|
+
this.container.style.position = 'relative';
|
|
22
|
+
this.container.style.width = '100vw';
|
|
23
|
+
this.container.style.height = '100vh';
|
|
24
|
+
this.container.style.overflow = 'hidden';
|
|
25
|
+
document.body.appendChild(this.container);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Register a VIB3 instance to be composited.
|
|
32
|
+
* @param {string} instanceId - Unique ID for the VIB3 instance
|
|
33
|
+
* @param {HTMLElement} canvasElement - The canvas element of the VIB3 instance
|
|
34
|
+
* @param {object} options - Layer configuration (zIndex, blendMode, opacity)
|
|
35
|
+
*/
|
|
36
|
+
addInstance(instanceId, canvasElement, options = {}) {
|
|
37
|
+
if (this.activeInstances.has(instanceId)) {
|
|
38
|
+
console.warn(`VIB3Compositor: Instance ${instanceId} already registered.`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Apply default styles for compositing
|
|
43
|
+
canvasElement.style.position = 'absolute';
|
|
44
|
+
canvasElement.style.top = '0';
|
|
45
|
+
canvasElement.style.left = '0';
|
|
46
|
+
canvasElement.style.width = '100%';
|
|
47
|
+
canvasElement.style.height = '100%';
|
|
48
|
+
|
|
49
|
+
// Apply options
|
|
50
|
+
this.updateLayer(instanceId, options);
|
|
51
|
+
|
|
52
|
+
this.container.appendChild(canvasElement);
|
|
53
|
+
this.activeInstances.set(instanceId, canvasElement);
|
|
54
|
+
this.layers.push(instanceId);
|
|
55
|
+
|
|
56
|
+
console.log(`VIB3Compositor: Added instance ${instanceId}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Remove a VIB3 instance from the compositor.
|
|
61
|
+
* @param {string} instanceId
|
|
62
|
+
*/
|
|
63
|
+
removeInstance(instanceId) {
|
|
64
|
+
if (this.activeInstances.has(instanceId)) {
|
|
65
|
+
const canvasElement = this.activeInstances.get(instanceId);
|
|
66
|
+
if (canvasElement.parentNode) {
|
|
67
|
+
canvasElement.parentNode.removeChild(canvasElement);
|
|
68
|
+
}
|
|
69
|
+
this.activeInstances.delete(instanceId);
|
|
70
|
+
this.layers = this.layers.filter(id => id !== instanceId);
|
|
71
|
+
console.log(`VIB3Compositor: Removed instance ${instanceId}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Update visual properties of a layer.
|
|
77
|
+
* @param {string} instanceId
|
|
78
|
+
* @param {object} options - { zIndex, blendMode, opacity, visible }
|
|
79
|
+
*/
|
|
80
|
+
updateLayer(instanceId, options) {
|
|
81
|
+
const canvasElement = this.activeInstances.get(instanceId);
|
|
82
|
+
if (!canvasElement) return;
|
|
83
|
+
|
|
84
|
+
if (options.zIndex !== undefined) canvasElement.style.zIndex = options.zIndex;
|
|
85
|
+
if (options.blendMode !== undefined) canvasElement.style.mixBlendMode = options.blendMode;
|
|
86
|
+
if (options.opacity !== undefined) canvasElement.style.opacity = options.opacity;
|
|
87
|
+
if (options.visible !== undefined) canvasElement.style.display = options.visible ? 'block' : 'none';
|
|
88
|
+
|
|
89
|
+
// Handle masking if provided (experimental CSS mask)
|
|
90
|
+
if (options.maskImage) {
|
|
91
|
+
canvasElement.style.webkitMaskImage = `url(${options.maskImage})`;
|
|
92
|
+
canvasElement.style.maskImage = `url(${options.maskImage})`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Reorder layers based on a list of IDs.
|
|
98
|
+
* @param {string[]} order - Array of instance IDs, from bottom to top
|
|
99
|
+
*/
|
|
100
|
+
setLayerOrder(order) {
|
|
101
|
+
order.forEach((id, index) => {
|
|
102
|
+
this.updateLayer(id, { zIndex: index });
|
|
103
|
+
});
|
|
104
|
+
this.layers = order;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Clear all instances.
|
|
109
|
+
*/
|
|
110
|
+
clear() {
|
|
111
|
+
this.activeInstances.forEach((el, id) => {
|
|
112
|
+
if (el.parentNode) el.parentNode.removeChild(el);
|
|
113
|
+
});
|
|
114
|
+
this.activeInstances.clear();
|
|
115
|
+
this.layers = [];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIB3Link - Multi-User Synchronization
|
|
3
|
+
*
|
|
4
|
+
* Provides a networking layer (mocked for now) to sync VIB3Universe state
|
|
5
|
+
* between multiple clients. Handles entity updates, parameter deltas, and events.
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*/
|
|
9
|
+
export class VIB3Link {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.connected = false;
|
|
12
|
+
this.roomId = null;
|
|
13
|
+
this.isHost = false;
|
|
14
|
+
this.peers = new Set();
|
|
15
|
+
this.eventBus = new EventTarget();
|
|
16
|
+
|
|
17
|
+
// Bind methods
|
|
18
|
+
this.handleMessage = this.handleMessage.bind(this);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Connect to a shared room.
|
|
23
|
+
* @param {string} roomId
|
|
24
|
+
*/
|
|
25
|
+
async connect(roomId) {
|
|
26
|
+
this.roomId = roomId;
|
|
27
|
+
this.connected = true;
|
|
28
|
+
|
|
29
|
+
// Mock connection logic
|
|
30
|
+
console.log(`VIB3Link: Connected to room ${roomId}`);
|
|
31
|
+
|
|
32
|
+
// In a real implementation, we would establish WebRTC/WebSocket here
|
|
33
|
+
// and negotiate host status. For now, assume single-player or host.
|
|
34
|
+
this.isHost = true;
|
|
35
|
+
|
|
36
|
+
this.emit('connected', { roomId, isHost: this.isHost });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Disconnect from the room.
|
|
41
|
+
*/
|
|
42
|
+
disconnect() {
|
|
43
|
+
this.connected = false;
|
|
44
|
+
this.peers.clear();
|
|
45
|
+
console.log(`VIB3Link: Disconnected.`);
|
|
46
|
+
this.emit('disconnected', {});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Broadcast an event to all peers.
|
|
51
|
+
* @param {string} type - Message type (upd, prm, evt)
|
|
52
|
+
* @param {object} payload
|
|
53
|
+
*/
|
|
54
|
+
broadcast(type, payload) {
|
|
55
|
+
if (!this.connected) return;
|
|
56
|
+
|
|
57
|
+
const message = {
|
|
58
|
+
t: type,
|
|
59
|
+
s: Date.now(), // simple sequence
|
|
60
|
+
p: payload
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// In real impl: webrtcChannel.send(JSON.stringify(message));
|
|
64
|
+
|
|
65
|
+
// Mock loopback for local testing (optional)
|
|
66
|
+
// this.handleMessage(message);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Handle an incoming message from the network.
|
|
71
|
+
* @param {object} message
|
|
72
|
+
*/
|
|
73
|
+
handleMessage(message) {
|
|
74
|
+
const { t, p } = message;
|
|
75
|
+
|
|
76
|
+
switch (t) {
|
|
77
|
+
case 'upd':
|
|
78
|
+
this.emit('entityUpdate', p);
|
|
79
|
+
break;
|
|
80
|
+
case 'prm':
|
|
81
|
+
this.emit('parameterDelta', p);
|
|
82
|
+
break;
|
|
83
|
+
case 'evt':
|
|
84
|
+
this.emit('universeEvent', p);
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
console.warn(`VIB3Link: Unknown message type ${t}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Sync the state of all entities. Called by Orchestrator tick.
|
|
93
|
+
* @param {Map<string, object>} entities
|
|
94
|
+
*/
|
|
95
|
+
sync(entities) {
|
|
96
|
+
if (!this.connected || !this.isHost) return;
|
|
97
|
+
|
|
98
|
+
// Collect dirty state
|
|
99
|
+
// In a real optimized system, we'd diff state or only send moved entities
|
|
100
|
+
// For now, let's just log that we would sync
|
|
101
|
+
// console.log(`VIB3Link: Syncing ${entities.size} entities`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Emit a local event for system consumption.
|
|
106
|
+
* @param {string} name
|
|
107
|
+
* @param {object} detail
|
|
108
|
+
*/
|
|
109
|
+
emit(name, detail) {
|
|
110
|
+
const event = new CustomEvent(name, { detail });
|
|
111
|
+
this.eventBus.dispatchEvent(event);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Listen for network events.
|
|
116
|
+
* @param {string} name
|
|
117
|
+
* @param {function} callback
|
|
118
|
+
*/
|
|
119
|
+
on(name, callback) {
|
|
120
|
+
this.eventBus.addEventListener(name, (e) => callback(e.detail));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIB3Orchestrator - The Core of the VIB3 Universe
|
|
3
|
+
*
|
|
4
|
+
* Manages the lifecycle and coordination of multiple VIB3+ entities (visualizers).
|
|
5
|
+
* Implements the "Universe" concept where multiple instances share a clock,
|
|
6
|
+
* physics, and event bus.
|
|
7
|
+
*
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
export class VIB3Orchestrator {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.entities = new Map(); // id -> Entity
|
|
13
|
+
this.nextEntityId = 1;
|
|
14
|
+
|
|
15
|
+
// Master Clock
|
|
16
|
+
this.time = 0;
|
|
17
|
+
this.lastFrameTime = 0;
|
|
18
|
+
this.paused = false;
|
|
19
|
+
|
|
20
|
+
// Systems
|
|
21
|
+
this.eventBus = new EventTarget();
|
|
22
|
+
|
|
23
|
+
// Bind loop
|
|
24
|
+
this.tick = this.tick.bind(this);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Start the universe simulation loop.
|
|
29
|
+
*/
|
|
30
|
+
start() {
|
|
31
|
+
if (this.running) return;
|
|
32
|
+
this.running = true;
|
|
33
|
+
this.lastFrameTime = performance.now();
|
|
34
|
+
requestAnimationFrame(this.tick);
|
|
35
|
+
console.log('VIB3Orchestrator: Universe started.');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stop the universe simulation loop.
|
|
40
|
+
*/
|
|
41
|
+
stop() {
|
|
42
|
+
this.running = false;
|
|
43
|
+
console.log('VIB3Orchestrator: Universe stopped.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Spawn a new VIB3 entity.
|
|
48
|
+
* @param {string} type - 'actor', 'prop', 'environment'
|
|
49
|
+
* @param {object} config - Configuration for the entity
|
|
50
|
+
* @returns {string} Entity ID
|
|
51
|
+
*/
|
|
52
|
+
spawn(type, config = {}) {
|
|
53
|
+
const id = `vib3_entity_${this.nextEntityId++}`;
|
|
54
|
+
|
|
55
|
+
// In a real implementation, this would instantiate VIB3Actor or VIB3Prop
|
|
56
|
+
// For now, we store a mock object representing the entity state
|
|
57
|
+
const entity = {
|
|
58
|
+
id,
|
|
59
|
+
type,
|
|
60
|
+
config,
|
|
61
|
+
position: config.position || { x: 0, y: 0, z: 0 },
|
|
62
|
+
rotation: config.rotation || { x: 0, y: 0, z: 0, w: 0 }, // 4D rotation
|
|
63
|
+
active: true,
|
|
64
|
+
|
|
65
|
+
// Mock VIB3Engine interface
|
|
66
|
+
engine: {
|
|
67
|
+
setParameter: (k, v) => console.log(`[${id}] set ${k}=${v}`),
|
|
68
|
+
getParameter: (k) => 0
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
update: (dt) => {
|
|
72
|
+
// Default update logic
|
|
73
|
+
// e.g., apply basic physics or script behavior
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
this.entities.set(id, entity);
|
|
78
|
+
this.emit('entitySpawned', { id, type });
|
|
79
|
+
console.log(`VIB3Orchestrator: Spawned ${type} (${id})`);
|
|
80
|
+
|
|
81
|
+
return id;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Remove an entity from the universe.
|
|
86
|
+
* @param {string} id
|
|
87
|
+
*/
|
|
88
|
+
kill(id) {
|
|
89
|
+
if (this.entities.has(id)) {
|
|
90
|
+
const entity = this.entities.get(id);
|
|
91
|
+
// Cleanup logic (e.g., destroy VIB3Engine instance)
|
|
92
|
+
if (entity.destroy) entity.destroy();
|
|
93
|
+
|
|
94
|
+
this.entities.delete(id);
|
|
95
|
+
this.emit('entityDespawned', { id });
|
|
96
|
+
console.log(`VIB3Orchestrator: Killed entity ${id}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The main simulation loop.
|
|
102
|
+
* Prioritizes Physics -> Narrative -> Visuals.
|
|
103
|
+
* @param {number} timestamp
|
|
104
|
+
*/
|
|
105
|
+
tick(timestamp) {
|
|
106
|
+
if (!this.running) return;
|
|
107
|
+
|
|
108
|
+
const dt = (timestamp - this.lastFrameTime) / 1000;
|
|
109
|
+
this.lastFrameTime = timestamp;
|
|
110
|
+
this.time += dt;
|
|
111
|
+
|
|
112
|
+
// 1. Physics / Logic Update
|
|
113
|
+
this.entities.forEach(entity => {
|
|
114
|
+
if (entity.active && entity.update) {
|
|
115
|
+
entity.update(this.time, dt);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// 2. Event Processing (Mock)
|
|
120
|
+
// Check for collisions, triggers, etc.
|
|
121
|
+
|
|
122
|
+
// 3. Visual Sync (Mock)
|
|
123
|
+
// Ensure all entities are rendering the current frame
|
|
124
|
+
|
|
125
|
+
requestAnimationFrame(this.tick);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Emit a global universe event.
|
|
130
|
+
* @param {string} name
|
|
131
|
+
* @param {object} detail
|
|
132
|
+
*/
|
|
133
|
+
emit(name, detail) {
|
|
134
|
+
const event = new CustomEvent(name, { detail });
|
|
135
|
+
this.eventBus.dispatchEvent(event);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Listen for global universe events.
|
|
140
|
+
* @param {string} name
|
|
141
|
+
* @param {function} callback
|
|
142
|
+
*/
|
|
143
|
+
on(name, callback) {
|
|
144
|
+
this.eventBus.addEventListener(name, (e) => callback(e.detail));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VIB3Universe - High-Level Entry Point for VIB3+ Ultra
|
|
3
|
+
*
|
|
4
|
+
* Combines Orchestrator (Logic) and Compositor (Visuals) into a single API.
|
|
5
|
+
* Manages the "World" where multiple VIB3+ instances coexist.
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*/
|
|
9
|
+
import { VIB3Orchestrator } from './VIB3Orchestrator.js';
|
|
10
|
+
import { VIB3Compositor } from './VIB3Compositor.js';
|
|
11
|
+
import { VIB3Actor } from './VIB3Actor.js';
|
|
12
|
+
import { VIB3Engine } from '../core/VIB3Engine.js';
|
|
13
|
+
|
|
14
|
+
export class VIB3Universe {
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} containerId - DOM ID for the universe container
|
|
17
|
+
*/
|
|
18
|
+
constructor(containerId = 'vib3-universe') {
|
|
19
|
+
this.orchestrator = new VIB3Orchestrator();
|
|
20
|
+
this.compositor = new VIB3Compositor(containerId);
|
|
21
|
+
this.actors = new Map(); // id -> VIB3Actor
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Start the universe simulation.
|
|
26
|
+
*/
|
|
27
|
+
start() {
|
|
28
|
+
this.orchestrator.start();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Stop the universe simulation.
|
|
33
|
+
*/
|
|
34
|
+
stop() {
|
|
35
|
+
this.orchestrator.stop();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Spawn a new actor into the universe.
|
|
40
|
+
* @param {object} config
|
|
41
|
+
* @param {string} config.personality - Actor personality profile
|
|
42
|
+
* @param {string} config.system - Visualization system ('quantum', 'faceted', 'holographic')
|
|
43
|
+
* @param {number} config.geometry - Initial geometry index
|
|
44
|
+
* @param {object} config.layer - Layer options { zIndex, blendMode, opacity, position }
|
|
45
|
+
* @returns {Promise<VIB3Actor>} The spawned actor
|
|
46
|
+
*/
|
|
47
|
+
async spawnActor(config = {}) {
|
|
48
|
+
const actorId = `actor_${Date.now()}_${Math.floor(Math.random() * 1000)}`;
|
|
49
|
+
|
|
50
|
+
// 1. Create a container for this actor's engine
|
|
51
|
+
const container = document.createElement('div');
|
|
52
|
+
container.id = `container_${actorId}`;
|
|
53
|
+
container.style.width = '100%';
|
|
54
|
+
container.style.height = '100%';
|
|
55
|
+
container.style.pointerEvents = 'none'; // Default to pass-through events
|
|
56
|
+
|
|
57
|
+
// 2. Add to compositor (visual layer)
|
|
58
|
+
this.compositor.addInstance(actorId, container, config.layer || {});
|
|
59
|
+
|
|
60
|
+
// 3. Initialize VIB3 Engine
|
|
61
|
+
const engine = new VIB3Engine({
|
|
62
|
+
system: config.system || 'holographic',
|
|
63
|
+
preferWebGPU: true // Ultra tier defaults to high perf
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Initialize engine within the container
|
|
67
|
+
// Note: VIB3Engine.initialize expects a container ID
|
|
68
|
+
await engine.initialize(container.id);
|
|
69
|
+
|
|
70
|
+
// Set initial state
|
|
71
|
+
if (config.geometry !== undefined) {
|
|
72
|
+
engine.setParameter('geometry', config.geometry);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 4. Wrap in Actor (logic layer)
|
|
76
|
+
const actor = new VIB3Actor(engine, config.personality || 'neutral');
|
|
77
|
+
actor.id = actorId;
|
|
78
|
+
|
|
79
|
+
// 5. Register with Orchestrator (simulation loop)
|
|
80
|
+
this.orchestrator.entities.set(actorId, actor);
|
|
81
|
+
this.actors.set(actorId, actor);
|
|
82
|
+
|
|
83
|
+
console.log(`VIB3Universe: Spawned actor ${actorId}`);
|
|
84
|
+
return actor;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Remove an actor from the universe.
|
|
89
|
+
* @param {string} actorId
|
|
90
|
+
*/
|
|
91
|
+
despawnActor(actorId) {
|
|
92
|
+
const actor = this.actors.get(actorId);
|
|
93
|
+
if (actor) {
|
|
94
|
+
// Remove from logic
|
|
95
|
+
this.orchestrator.kill(actorId);
|
|
96
|
+
|
|
97
|
+
// Cleanup engine
|
|
98
|
+
if (actor.engine && actor.engine.destroy) {
|
|
99
|
+
actor.engine.destroy();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Remove from visuals
|
|
103
|
+
this.compositor.removeInstance(actorId);
|
|
104
|
+
this.actors.delete(actorId);
|
|
105
|
+
|
|
106
|
+
console.log(`VIB3Universe: Despawned actor ${actorId}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|