@vib3code/sdk 2.0.1
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/CHANGELOG.md +118 -0
- package/DOCS/BLUEPRINT_EXECUTION_PLAN_2026-01-07.md +34 -0
- package/DOCS/CI_TESTING.md +38 -0
- package/DOCS/CLI_ONBOARDING.md +75 -0
- package/DOCS/CONTROL_REFERENCE.md +64 -0
- package/DOCS/DEV_TRACK_ANALYSIS.md +77 -0
- package/DOCS/DEV_TRACK_PLAN_2026-01-07.md +42 -0
- package/DOCS/DEV_TRACK_SESSION_2026-01-31.md +220 -0
- package/DOCS/ENV_SETUP.md +189 -0
- package/DOCS/EXPORT_FORMATS.md +417 -0
- package/DOCS/GPU_DISPOSAL_GUIDE.md +21 -0
- package/DOCS/LICENSING_TIERS.md +275 -0
- package/DOCS/MASTER_PLAN_2026-01-31.md +570 -0
- package/DOCS/OBS_SETUP_GUIDE.md +98 -0
- package/DOCS/PROJECT_SETUP.md +66 -0
- package/DOCS/RENDERER_LIFECYCLE.md +40 -0
- package/DOCS/REPO_MANIFEST.md +121 -0
- package/DOCS/SESSION_014_PLAN.md +195 -0
- package/DOCS/SESSION_LOG_2026-01-07.md +56 -0
- package/DOCS/STRATEGIC_BLUEPRINT_2026-01-07.md +72 -0
- package/DOCS/SYSTEM_AUDIT_2026-01-30.md +738 -0
- package/DOCS/SYSTEM_INVENTORY.md +520 -0
- package/DOCS/TELEMETRY_EXPORTS.md +34 -0
- package/DOCS/WEBGPU_STATUS.md +38 -0
- package/DOCS/XR_BENCHMARKS.md +608 -0
- package/LICENSE +21 -0
- package/README.md +426 -0
- package/docs/.nojekyll +0 -0
- package/docs/01-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/02-hyperspatial_ego_death.html +346 -0
- package/docs/03-post_cartesian_sublime.html +346 -0
- package/docs/04-crystalline_void_meditation.html +346 -0
- package/docs/05-quantum_decoherence_ballet.html +346 -0
- package/docs/06-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/07-hyperspatial_ego_death.html +346 -0
- package/docs/08-post_cartesian_sublime.html +346 -0
- package/docs/09-crystalline_void_meditation.html +346 -0
- package/docs/10-quantum_decoherence_ballet.html +346 -0
- package/docs/11-dissolution_of_euclidean_hegemony.html +346 -0
- package/docs/12-hyperspatial_ego_death.html +346 -0
- package/docs/13-post_cartesian_sublime.html +346 -0
- package/docs/index.html +794 -0
- package/docs/test-hub.html +441 -0
- package/docs/url-state.js +102 -0
- package/docs/vib3-exports/01-quantum-quantum-tetrahedron-lattice.html +489 -0
- package/docs/vib3-exports/02-quantum-quantum-hypersphere-matrix.html +489 -0
- package/docs/vib3-exports/03-quantum-quantum-hypertetra-fractal.html +489 -0
- package/docs/vib3-exports/04-faceted-faceted-crystal-structure.html +407 -0
- package/docs/vib3-exports/05-faceted-faceted-klein-bottle.html +407 -0
- package/docs/vib3-exports/06-faceted-faceted-hypertetra-torus.html +407 -0
- package/docs/vib3-exports/07-holographic-holographic-wave-field.html +457 -0
- package/docs/vib3-exports/08-holographic-holographic-hypersphere-sphere.html +457 -0
- package/docs/vib3-exports/09-holographic-holographic-hypertetra-crystal.html +457 -0
- package/docs/vib3-exports/index.html +238 -0
- package/docs/webgpu-live.html +702 -0
- package/package.json +367 -0
- package/src/advanced/AIPresetGenerator.js +777 -0
- package/src/advanced/MIDIController.js +703 -0
- package/src/advanced/OffscreenWorker.js +1051 -0
- package/src/advanced/WebGPUCompute.js +1051 -0
- package/src/advanced/WebXRRenderer.js +680 -0
- package/src/agent/cli/AgentCLI.js +615 -0
- package/src/agent/cli/index.js +14 -0
- package/src/agent/index.js +73 -0
- package/src/agent/mcp/MCPServer.js +950 -0
- package/src/agent/mcp/index.js +9 -0
- package/src/agent/mcp/tools.js +548 -0
- package/src/agent/telemetry/EventStream.js +669 -0
- package/src/agent/telemetry/Instrumentation.js +618 -0
- package/src/agent/telemetry/TelemetryExporters.js +427 -0
- package/src/agent/telemetry/TelemetryService.js +464 -0
- package/src/agent/telemetry/index.js +52 -0
- package/src/benchmarks/BenchmarkRunner.js +381 -0
- package/src/benchmarks/MetricsCollector.js +299 -0
- package/src/benchmarks/index.js +9 -0
- package/src/benchmarks/scenes.js +259 -0
- package/src/cli/index.js +675 -0
- package/src/config/ApiConfig.js +88 -0
- package/src/core/CanvasManager.js +217 -0
- package/src/core/ErrorReporter.js +117 -0
- package/src/core/ParameterMapper.js +333 -0
- package/src/core/Parameters.js +396 -0
- package/src/core/RendererContracts.js +200 -0
- package/src/core/UnifiedResourceManager.js +370 -0
- package/src/core/VIB3Engine.js +636 -0
- package/src/core/renderers/FacetedRendererAdapter.js +32 -0
- package/src/core/renderers/HolographicRendererAdapter.js +29 -0
- package/src/core/renderers/QuantumRendererAdapter.js +29 -0
- package/src/core/renderers/RendererLifecycleManager.js +63 -0
- package/src/creative/ColorPresetsSystem.js +980 -0
- package/src/creative/ParameterTimeline.js +1061 -0
- package/src/creative/PostProcessingPipeline.js +1113 -0
- package/src/creative/TransitionAnimator.js +683 -0
- package/src/export/CSSExporter.js +226 -0
- package/src/export/CardGeneratorBase.js +279 -0
- package/src/export/ExportManager.js +580 -0
- package/src/export/FacetedCardGenerator.js +279 -0
- package/src/export/HolographicCardGenerator.js +543 -0
- package/src/export/LottieExporter.js +552 -0
- package/src/export/QuantumCardGenerator.js +315 -0
- package/src/export/SVGExporter.js +519 -0
- package/src/export/ShaderExporter.js +903 -0
- package/src/export/TradingCardGenerator.js +3055 -0
- package/src/export/TradingCardManager.js +181 -0
- package/src/export/VIB3PackageExporter.js +559 -0
- package/src/export/index.js +14 -0
- package/src/export/systems/TradingCardSystemFaceted.js +494 -0
- package/src/export/systems/TradingCardSystemHolographic.js +452 -0
- package/src/export/systems/TradingCardSystemQuantum.js +411 -0
- package/src/faceted/FacetedSystem.js +963 -0
- package/src/features/CollectionManager.js +433 -0
- package/src/gallery/CollectionManager.js +240 -0
- package/src/gallery/GallerySystem.js +485 -0
- package/src/geometry/GeometryFactory.js +314 -0
- package/src/geometry/GeometryLibrary.js +72 -0
- package/src/geometry/buffers/BufferBuilder.js +338 -0
- package/src/geometry/buffers/index.js +18 -0
- package/src/geometry/generators/Crystal.js +420 -0
- package/src/geometry/generators/Fractal.js +298 -0
- package/src/geometry/generators/KleinBottle.js +197 -0
- package/src/geometry/generators/Sphere.js +192 -0
- package/src/geometry/generators/Tesseract.js +160 -0
- package/src/geometry/generators/Tetrahedron.js +225 -0
- package/src/geometry/generators/Torus.js +304 -0
- package/src/geometry/generators/Wave.js +341 -0
- package/src/geometry/index.js +142 -0
- package/src/geometry/warp/HypersphereCore.js +211 -0
- package/src/geometry/warp/HypertetraCore.js +386 -0
- package/src/geometry/warp/index.js +57 -0
- package/src/holograms/HolographicVisualizer.js +1073 -0
- package/src/holograms/RealHolographicSystem.js +966 -0
- package/src/holograms/variantRegistry.js +69 -0
- package/src/integrations/FigmaPlugin.js +854 -0
- package/src/integrations/OBSMode.js +754 -0
- package/src/integrations/ThreeJsPackage.js +660 -0
- package/src/integrations/TouchDesignerExport.js +552 -0
- package/src/integrations/frameworks/Vib3React.js +591 -0
- package/src/integrations/frameworks/Vib3Svelte.js +654 -0
- package/src/integrations/frameworks/Vib3Vue.js +628 -0
- package/src/llm/LLMParameterInterface.js +240 -0
- package/src/llm/LLMParameterUI.js +577 -0
- package/src/math/Mat4x4.js +708 -0
- package/src/math/Projection.js +341 -0
- package/src/math/Rotor4D.js +637 -0
- package/src/math/Vec4.js +476 -0
- package/src/math/constants.js +164 -0
- package/src/math/index.js +68 -0
- package/src/math/projections.js +54 -0
- package/src/math/rotations.js +196 -0
- package/src/quantum/QuantumEngine.js +906 -0
- package/src/quantum/QuantumVisualizer.js +1103 -0
- package/src/reactivity/ReactivityConfig.js +499 -0
- package/src/reactivity/ReactivityManager.js +586 -0
- package/src/reactivity/SpatialInputSystem.js +1783 -0
- package/src/reactivity/index.js +93 -0
- package/src/render/CommandBuffer.js +465 -0
- package/src/render/MultiCanvasBridge.js +340 -0
- package/src/render/RenderCommand.js +514 -0
- package/src/render/RenderResourceRegistry.js +523 -0
- package/src/render/RenderState.js +552 -0
- package/src/render/RenderTarget.js +512 -0
- package/src/render/ShaderLoader.js +253 -0
- package/src/render/ShaderProgram.js +599 -0
- package/src/render/UnifiedRenderBridge.js +496 -0
- package/src/render/backends/WebGLBackend.js +1108 -0
- package/src/render/backends/WebGPUBackend.js +1409 -0
- package/src/render/commands/CommandBufferExecutor.js +607 -0
- package/src/render/commands/RenderCommandBuffer.js +661 -0
- package/src/render/commands/index.js +17 -0
- package/src/render/index.js +367 -0
- package/src/scene/Disposable.js +498 -0
- package/src/scene/MemoryPool.js +618 -0
- package/src/scene/Node4D.js +697 -0
- package/src/scene/ResourceManager.js +599 -0
- package/src/scene/Scene4D.js +540 -0
- package/src/scene/index.js +98 -0
- package/src/schemas/error.schema.json +84 -0
- package/src/schemas/extension.schema.json +88 -0
- package/src/schemas/index.js +214 -0
- package/src/schemas/parameters.schema.json +142 -0
- package/src/schemas/tool-pack.schema.json +44 -0
- package/src/schemas/tool-response.schema.json +127 -0
- package/src/shaders/common/fullscreen.vert.glsl +5 -0
- package/src/shaders/common/fullscreen.vert.wgsl +17 -0
- package/src/shaders/common/geometry24.glsl +65 -0
- package/src/shaders/common/geometry24.wgsl +54 -0
- package/src/shaders/common/rotation4d.glsl +85 -0
- package/src/shaders/common/rotation4d.wgsl +86 -0
- package/src/shaders/common/uniforms.glsl +44 -0
- package/src/shaders/common/uniforms.wgsl +48 -0
- package/src/shaders/faceted/faceted.frag.glsl +129 -0
- package/src/shaders/faceted/faceted.frag.wgsl +164 -0
- package/src/shaders/holographic/holographic.frag.glsl +406 -0
- package/src/shaders/holographic/holographic.frag.wgsl +185 -0
- package/src/shaders/quantum/quantum.frag.glsl +513 -0
- package/src/shaders/quantum/quantum.frag.wgsl +361 -0
- package/src/testing/ParallelTestFramework.js +519 -0
- package/src/testing/__snapshots__/exportFormats.test.js.snap +24 -0
- package/src/testing/exportFormats.test.js +8 -0
- package/src/testing/projections.test.js +14 -0
- package/src/testing/rotations.test.js +37 -0
- package/src/ui/InteractivityMenu.js +516 -0
- package/src/ui/StatusManager.js +96 -0
- package/src/ui/adaptive/renderers/webgpu/BufferLayout.ts +252 -0
- package/src/ui/adaptive/renderers/webgpu/PolytopeInstanceBuffer.ts +144 -0
- package/src/ui/adaptive/renderers/webgpu/TripleBufferedUniform.ts +170 -0
- package/src/ui/adaptive/renderers/webgpu/WebGPURenderer.ts +735 -0
- package/src/ui/adaptive/renderers/webgpu/index.ts +112 -0
- package/src/variations/VariationManager.js +431 -0
- package/src/viewer/AudioReactivity.js +505 -0
- package/src/viewer/CardBending.js +481 -0
- package/src/viewer/GalleryUI.js +832 -0
- package/src/viewer/ReactivityManager.js +590 -0
- package/src/viewer/TradingCardExporter.js +600 -0
- package/src/viewer/ViewerPortal.js +374 -0
- package/src/viewer/index.js +12 -0
- package/src/wasm/WasmLoader.js +296 -0
- package/src/wasm/index.js +132 -0
- package/tools/agentic/mcpTools.js +88 -0
- package/tools/cli/agent-cli.js +92 -0
- package/tools/export/formats.js +24 -0
- package/tools/math/rotation-baseline.mjs +64 -0
- package/tools/shader-sync-verify.js +937 -0
- package/tools/telemetry/manifestPipeline.js +141 -0
- package/tools/telemetry/telemetryEvents.js +35 -0
- package/types/adaptive-sdk.d.ts +185 -0
- package/types/advanced/AIPresetGenerator.d.ts +81 -0
- package/types/advanced/MIDIController.d.ts +100 -0
- package/types/advanced/OffscreenWorker.d.ts +82 -0
- package/types/advanced/WebGPUCompute.d.ts +52 -0
- package/types/advanced/WebXRRenderer.d.ts +77 -0
- package/types/advanced/index.d.ts +46 -0
- package/types/core/ErrorReporter.d.ts +50 -0
- package/types/core/VIB3Engine.d.ts +204 -0
- package/types/creative/ColorPresetsSystem.d.ts +91 -0
- package/types/creative/ParameterTimeline.d.ts +74 -0
- package/types/creative/PostProcessingPipeline.d.ts +109 -0
- package/types/creative/TransitionAnimator.d.ts +71 -0
- package/types/creative/index.d.ts +35 -0
- package/types/integrations/FigmaPlugin.d.ts +46 -0
- package/types/integrations/OBSMode.d.ts +74 -0
- package/types/integrations/ThreeJsPackage.d.ts +62 -0
- package/types/integrations/TouchDesignerExport.d.ts +36 -0
- package/types/integrations/Vib3React.d.ts +74 -0
- package/types/integrations/Vib3Svelte.d.ts +63 -0
- package/types/integrations/Vib3Vue.d.ts +55 -0
- package/types/integrations/index.d.ts +52 -0
- package/types/reactivity/SpatialInputSystem.d.ts +173 -0
- package/types/reactivity/index.d.ts +394 -0
- package/types/render/CommandBuffer.d.ts +169 -0
- package/types/render/RenderCommand.d.ts +312 -0
- package/types/render/RenderState.d.ts +279 -0
- package/types/render/RenderTarget.d.ts +254 -0
- package/types/render/ShaderProgram.d.ts +277 -0
- package/types/render/UnifiedRenderBridge.d.ts +143 -0
- package/types/render/WebGLBackend.d.ts +168 -0
- package/types/render/WebGPUBackend.d.ts +186 -0
- package/types/render/index.d.ts +141 -0
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RenderCommand - Base class for all render commands
|
|
3
|
+
*
|
|
4
|
+
* Commands are recorded into a CommandBuffer and executed by a backend.
|
|
5
|
+
* This allows for sorting, batching, and deferred execution.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { RenderState } from './RenderState.js';
|
|
9
|
+
|
|
10
|
+
let commandIdCounter = 0;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Command types enum
|
|
14
|
+
*/
|
|
15
|
+
export const CommandType = {
|
|
16
|
+
// State commands
|
|
17
|
+
SET_STATE: 'set_state',
|
|
18
|
+
SET_VIEWPORT: 'set_viewport',
|
|
19
|
+
SET_SCISSOR: 'set_scissor',
|
|
20
|
+
|
|
21
|
+
// Clear commands
|
|
22
|
+
CLEAR: 'clear',
|
|
23
|
+
CLEAR_COLOR: 'clear_color',
|
|
24
|
+
CLEAR_DEPTH: 'clear_depth',
|
|
25
|
+
CLEAR_STENCIL: 'clear_stencil',
|
|
26
|
+
|
|
27
|
+
// Bind commands
|
|
28
|
+
BIND_SHADER: 'bind_shader',
|
|
29
|
+
BIND_TEXTURE: 'bind_texture',
|
|
30
|
+
BIND_BUFFER: 'bind_buffer',
|
|
31
|
+
BIND_VERTEX_ARRAY: 'bind_vertex_array',
|
|
32
|
+
BIND_RENDER_TARGET: 'bind_render_target',
|
|
33
|
+
|
|
34
|
+
// Uniform commands
|
|
35
|
+
SET_UNIFORM: 'set_uniform',
|
|
36
|
+
SET_UNIFORM_BLOCK: 'set_uniform_block',
|
|
37
|
+
|
|
38
|
+
// Draw commands
|
|
39
|
+
DRAW: 'draw',
|
|
40
|
+
DRAW_INDEXED: 'draw_indexed',
|
|
41
|
+
DRAW_INSTANCED: 'draw_instanced',
|
|
42
|
+
DRAW_INDEXED_INSTANCED: 'draw_indexed_instanced',
|
|
43
|
+
|
|
44
|
+
// Compute commands
|
|
45
|
+
DISPATCH: 'dispatch',
|
|
46
|
+
|
|
47
|
+
// Transfer commands
|
|
48
|
+
COPY_BUFFER: 'copy_buffer',
|
|
49
|
+
COPY_TEXTURE: 'copy_texture',
|
|
50
|
+
READ_PIXELS: 'read_pixels',
|
|
51
|
+
|
|
52
|
+
// Barrier/sync
|
|
53
|
+
MEMORY_BARRIER: 'memory_barrier',
|
|
54
|
+
|
|
55
|
+
// Custom
|
|
56
|
+
CUSTOM: 'custom'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Primitive types for drawing
|
|
61
|
+
*/
|
|
62
|
+
export const PrimitiveType = {
|
|
63
|
+
POINTS: 'points',
|
|
64
|
+
LINES: 'lines',
|
|
65
|
+
LINE_STRIP: 'line_strip',
|
|
66
|
+
LINE_LOOP: 'line_loop',
|
|
67
|
+
TRIANGLES: 'triangles',
|
|
68
|
+
TRIANGLE_STRIP: 'triangle_strip',
|
|
69
|
+
TRIANGLE_FAN: 'triangle_fan'
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Base render command
|
|
74
|
+
*/
|
|
75
|
+
export class RenderCommand {
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} type - Command type from CommandType enum
|
|
78
|
+
*/
|
|
79
|
+
constructor(type) {
|
|
80
|
+
/** @type {number} Unique command ID */
|
|
81
|
+
this.id = ++commandIdCounter;
|
|
82
|
+
|
|
83
|
+
/** @type {string} Command type */
|
|
84
|
+
this.type = type;
|
|
85
|
+
|
|
86
|
+
/** @type {number} Sort key for ordering */
|
|
87
|
+
this.sortKey = 0;
|
|
88
|
+
|
|
89
|
+
/** @type {number} Priority (higher = earlier) */
|
|
90
|
+
this.priority = 0;
|
|
91
|
+
|
|
92
|
+
/** @type {string|null} Debug label */
|
|
93
|
+
this.label = null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Execute the command (implemented by subclasses)
|
|
98
|
+
* @param {object} backend - Rendering backend
|
|
99
|
+
*/
|
|
100
|
+
execute(backend) {
|
|
101
|
+
throw new Error('RenderCommand.execute() must be implemented');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Set debug label
|
|
106
|
+
* @param {string} label
|
|
107
|
+
* @returns {this}
|
|
108
|
+
*/
|
|
109
|
+
setLabel(label) {
|
|
110
|
+
this.label = label;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Clear command - clears framebuffer attachments
|
|
117
|
+
*/
|
|
118
|
+
export class ClearCommand extends RenderCommand {
|
|
119
|
+
/**
|
|
120
|
+
* @param {object} options
|
|
121
|
+
*/
|
|
122
|
+
constructor(options = {}) {
|
|
123
|
+
super(CommandType.CLEAR);
|
|
124
|
+
|
|
125
|
+
/** @type {boolean} */
|
|
126
|
+
this.clearColor = options.color !== false;
|
|
127
|
+
|
|
128
|
+
/** @type {boolean} */
|
|
129
|
+
this.clearDepth = options.depth !== false;
|
|
130
|
+
|
|
131
|
+
/** @type {boolean} */
|
|
132
|
+
this.clearStencil = options.stencil === true;
|
|
133
|
+
|
|
134
|
+
/** @type {number[]} RGBA clear color */
|
|
135
|
+
this.colorValue = options.colorValue || [0, 0, 0, 1];
|
|
136
|
+
|
|
137
|
+
/** @type {number} */
|
|
138
|
+
this.depthValue = options.depthValue ?? 1;
|
|
139
|
+
|
|
140
|
+
/** @type {number} */
|
|
141
|
+
this.stencilValue = options.stencilValue ?? 0;
|
|
142
|
+
|
|
143
|
+
// Clear commands should execute first
|
|
144
|
+
this.priority = 1000;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
execute(backend) {
|
|
148
|
+
backend.clear(this);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Create color-only clear
|
|
153
|
+
* @param {number[]} color
|
|
154
|
+
* @returns {ClearCommand}
|
|
155
|
+
*/
|
|
156
|
+
static color(color) {
|
|
157
|
+
return new ClearCommand({
|
|
158
|
+
color: true,
|
|
159
|
+
depth: false,
|
|
160
|
+
stencil: false,
|
|
161
|
+
colorValue: color
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Create depth-only clear
|
|
167
|
+
* @param {number} depth
|
|
168
|
+
* @returns {ClearCommand}
|
|
169
|
+
*/
|
|
170
|
+
static depth(depth = 1) {
|
|
171
|
+
return new ClearCommand({
|
|
172
|
+
color: false,
|
|
173
|
+
depth: true,
|
|
174
|
+
stencil: false,
|
|
175
|
+
depthValue: depth
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* SetState command - changes GPU state
|
|
182
|
+
*/
|
|
183
|
+
export class SetStateCommand extends RenderCommand {
|
|
184
|
+
/**
|
|
185
|
+
* @param {RenderState} state
|
|
186
|
+
*/
|
|
187
|
+
constructor(state) {
|
|
188
|
+
super(CommandType.SET_STATE);
|
|
189
|
+
|
|
190
|
+
/** @type {RenderState} */
|
|
191
|
+
this.state = state;
|
|
192
|
+
|
|
193
|
+
// State commands should execute early
|
|
194
|
+
this.priority = 900;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
execute(backend) {
|
|
198
|
+
backend.setState(this.state);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* BindShader command - binds a shader program
|
|
204
|
+
*/
|
|
205
|
+
export class BindShaderCommand extends RenderCommand {
|
|
206
|
+
/**
|
|
207
|
+
* @param {object} shader - Shader program reference
|
|
208
|
+
*/
|
|
209
|
+
constructor(shader) {
|
|
210
|
+
super(CommandType.BIND_SHADER);
|
|
211
|
+
|
|
212
|
+
/** @type {object} */
|
|
213
|
+
this.shader = shader;
|
|
214
|
+
|
|
215
|
+
this.priority = 800;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
execute(backend) {
|
|
219
|
+
backend.bindShader(this.shader);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* BindTexture command - binds a texture to a slot
|
|
225
|
+
*/
|
|
226
|
+
export class BindTextureCommand extends RenderCommand {
|
|
227
|
+
/**
|
|
228
|
+
* @param {object} texture - Texture reference
|
|
229
|
+
* @param {number} slot - Texture unit slot
|
|
230
|
+
*/
|
|
231
|
+
constructor(texture, slot = 0) {
|
|
232
|
+
super(CommandType.BIND_TEXTURE);
|
|
233
|
+
|
|
234
|
+
/** @type {object} */
|
|
235
|
+
this.texture = texture;
|
|
236
|
+
|
|
237
|
+
/** @type {number} */
|
|
238
|
+
this.slot = slot;
|
|
239
|
+
|
|
240
|
+
this.priority = 700;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
execute(backend) {
|
|
244
|
+
backend.bindTexture(this.texture, this.slot);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* BindVertexArray command - binds vertex array object
|
|
250
|
+
*/
|
|
251
|
+
export class BindVertexArrayCommand extends RenderCommand {
|
|
252
|
+
/**
|
|
253
|
+
* @param {object} vao - Vertex array object reference
|
|
254
|
+
*/
|
|
255
|
+
constructor(vao) {
|
|
256
|
+
super(CommandType.BIND_VERTEX_ARRAY);
|
|
257
|
+
|
|
258
|
+
/** @type {object} */
|
|
259
|
+
this.vao = vao;
|
|
260
|
+
|
|
261
|
+
this.priority = 600;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
execute(backend) {
|
|
265
|
+
backend.bindVertexArray(this.vao);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* BindRenderTarget command - sets render target
|
|
271
|
+
*/
|
|
272
|
+
export class BindRenderTargetCommand extends RenderCommand {
|
|
273
|
+
/**
|
|
274
|
+
* @param {object|null} target - Render target or null for default framebuffer
|
|
275
|
+
*/
|
|
276
|
+
constructor(target) {
|
|
277
|
+
super(CommandType.BIND_RENDER_TARGET);
|
|
278
|
+
|
|
279
|
+
/** @type {object|null} */
|
|
280
|
+
this.target = target;
|
|
281
|
+
|
|
282
|
+
this.priority = 950;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
execute(backend) {
|
|
286
|
+
backend.bindRenderTarget(this.target);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* SetUniform command - sets shader uniform value
|
|
292
|
+
*/
|
|
293
|
+
export class SetUniformCommand extends RenderCommand {
|
|
294
|
+
/**
|
|
295
|
+
* @param {string} name - Uniform name
|
|
296
|
+
* @param {any} value - Uniform value
|
|
297
|
+
* @param {string} [type] - Uniform type hint
|
|
298
|
+
*/
|
|
299
|
+
constructor(name, value, type = null) {
|
|
300
|
+
super(CommandType.SET_UNIFORM);
|
|
301
|
+
|
|
302
|
+
/** @type {string} */
|
|
303
|
+
this.name = name;
|
|
304
|
+
|
|
305
|
+
/** @type {any} */
|
|
306
|
+
this.value = value;
|
|
307
|
+
|
|
308
|
+
/** @type {string|null} */
|
|
309
|
+
this.uniformType = type;
|
|
310
|
+
|
|
311
|
+
this.priority = 500;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
execute(backend) {
|
|
315
|
+
backend.setUniform(this.name, this.value, this.uniformType);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Draw command - draws primitives
|
|
321
|
+
*/
|
|
322
|
+
export class DrawCommand extends RenderCommand {
|
|
323
|
+
/**
|
|
324
|
+
* @param {object} options
|
|
325
|
+
*/
|
|
326
|
+
constructor(options = {}) {
|
|
327
|
+
super(CommandType.DRAW);
|
|
328
|
+
|
|
329
|
+
/** @type {string} */
|
|
330
|
+
this.primitive = options.primitive || PrimitiveType.TRIANGLES;
|
|
331
|
+
|
|
332
|
+
/** @type {number} */
|
|
333
|
+
this.vertexCount = options.vertexCount || 0;
|
|
334
|
+
|
|
335
|
+
/** @type {number} */
|
|
336
|
+
this.firstVertex = options.firstVertex || 0;
|
|
337
|
+
|
|
338
|
+
/** @type {number} Sort key based on state/material */
|
|
339
|
+
this.sortKey = options.sortKey || 0;
|
|
340
|
+
|
|
341
|
+
/** @type {number} Depth for depth sorting */
|
|
342
|
+
this.depth = options.depth || 0;
|
|
343
|
+
|
|
344
|
+
this.priority = 0; // Draw commands execute last
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
execute(backend) {
|
|
348
|
+
backend.draw(this);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* DrawIndexed command - draws indexed primitives
|
|
354
|
+
*/
|
|
355
|
+
export class DrawIndexedCommand extends RenderCommand {
|
|
356
|
+
/**
|
|
357
|
+
* @param {object} options
|
|
358
|
+
*/
|
|
359
|
+
constructor(options = {}) {
|
|
360
|
+
super(CommandType.DRAW_INDEXED);
|
|
361
|
+
|
|
362
|
+
/** @type {string} */
|
|
363
|
+
this.primitive = options.primitive || PrimitiveType.TRIANGLES;
|
|
364
|
+
|
|
365
|
+
/** @type {number} */
|
|
366
|
+
this.indexCount = options.indexCount || 0;
|
|
367
|
+
|
|
368
|
+
/** @type {number} */
|
|
369
|
+
this.firstIndex = options.firstIndex || 0;
|
|
370
|
+
|
|
371
|
+
/** @type {number} */
|
|
372
|
+
this.baseVertex = options.baseVertex || 0;
|
|
373
|
+
|
|
374
|
+
/** @type {string} Index type ('uint16' or 'uint32') */
|
|
375
|
+
this.indexType = options.indexType || 'uint16';
|
|
376
|
+
|
|
377
|
+
/** @type {number} */
|
|
378
|
+
this.sortKey = options.sortKey || 0;
|
|
379
|
+
|
|
380
|
+
/** @type {number} */
|
|
381
|
+
this.depth = options.depth || 0;
|
|
382
|
+
|
|
383
|
+
this.priority = 0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
execute(backend) {
|
|
387
|
+
backend.drawIndexed(this);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* DrawInstanced command - draws instanced primitives
|
|
393
|
+
*/
|
|
394
|
+
export class DrawInstancedCommand extends RenderCommand {
|
|
395
|
+
/**
|
|
396
|
+
* @param {object} options
|
|
397
|
+
*/
|
|
398
|
+
constructor(options = {}) {
|
|
399
|
+
super(CommandType.DRAW_INSTANCED);
|
|
400
|
+
|
|
401
|
+
/** @type {string} */
|
|
402
|
+
this.primitive = options.primitive || PrimitiveType.TRIANGLES;
|
|
403
|
+
|
|
404
|
+
/** @type {number} */
|
|
405
|
+
this.vertexCount = options.vertexCount || 0;
|
|
406
|
+
|
|
407
|
+
/** @type {number} */
|
|
408
|
+
this.firstVertex = options.firstVertex || 0;
|
|
409
|
+
|
|
410
|
+
/** @type {number} */
|
|
411
|
+
this.instanceCount = options.instanceCount || 1;
|
|
412
|
+
|
|
413
|
+
/** @type {number} */
|
|
414
|
+
this.firstInstance = options.firstInstance || 0;
|
|
415
|
+
|
|
416
|
+
/** @type {number} */
|
|
417
|
+
this.sortKey = options.sortKey || 0;
|
|
418
|
+
|
|
419
|
+
this.priority = 0;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
execute(backend) {
|
|
423
|
+
backend.drawInstanced(this);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* DrawIndexedInstanced command - draws indexed instanced primitives
|
|
429
|
+
*/
|
|
430
|
+
export class DrawIndexedInstancedCommand extends RenderCommand {
|
|
431
|
+
/**
|
|
432
|
+
* @param {object} options
|
|
433
|
+
*/
|
|
434
|
+
constructor(options = {}) {
|
|
435
|
+
super(CommandType.DRAW_INDEXED_INSTANCED);
|
|
436
|
+
|
|
437
|
+
/** @type {string} */
|
|
438
|
+
this.primitive = options.primitive || PrimitiveType.TRIANGLES;
|
|
439
|
+
|
|
440
|
+
/** @type {number} */
|
|
441
|
+
this.indexCount = options.indexCount || 0;
|
|
442
|
+
|
|
443
|
+
/** @type {number} */
|
|
444
|
+
this.firstIndex = options.firstIndex || 0;
|
|
445
|
+
|
|
446
|
+
/** @type {number} */
|
|
447
|
+
this.baseVertex = options.baseVertex || 0;
|
|
448
|
+
|
|
449
|
+
/** @type {number} */
|
|
450
|
+
this.instanceCount = options.instanceCount || 1;
|
|
451
|
+
|
|
452
|
+
/** @type {number} */
|
|
453
|
+
this.firstInstance = options.firstInstance || 0;
|
|
454
|
+
|
|
455
|
+
/** @type {string} */
|
|
456
|
+
this.indexType = options.indexType || 'uint16';
|
|
457
|
+
|
|
458
|
+
/** @type {number} */
|
|
459
|
+
this.sortKey = options.sortKey || 0;
|
|
460
|
+
|
|
461
|
+
this.priority = 0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
execute(backend) {
|
|
465
|
+
backend.drawIndexedInstanced(this);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* SetViewport command - sets viewport dimensions
|
|
471
|
+
*/
|
|
472
|
+
export class SetViewportCommand extends RenderCommand {
|
|
473
|
+
/**
|
|
474
|
+
* @param {number} x
|
|
475
|
+
* @param {number} y
|
|
476
|
+
* @param {number} width
|
|
477
|
+
* @param {number} height
|
|
478
|
+
*/
|
|
479
|
+
constructor(x, y, width, height) {
|
|
480
|
+
super(CommandType.SET_VIEWPORT);
|
|
481
|
+
|
|
482
|
+
this.x = x;
|
|
483
|
+
this.y = y;
|
|
484
|
+
this.width = width;
|
|
485
|
+
this.height = height;
|
|
486
|
+
|
|
487
|
+
this.priority = 900;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
execute(backend) {
|
|
491
|
+
backend.setViewport(this.x, this.y, this.width, this.height);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Custom command - executes arbitrary function
|
|
497
|
+
*/
|
|
498
|
+
export class CustomCommand extends RenderCommand {
|
|
499
|
+
/**
|
|
500
|
+
* @param {function(object): void} callback
|
|
501
|
+
*/
|
|
502
|
+
constructor(callback) {
|
|
503
|
+
super(CommandType.CUSTOM);
|
|
504
|
+
|
|
505
|
+
/** @type {function} */
|
|
506
|
+
this.callback = callback;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
execute(backend) {
|
|
510
|
+
this.callback(backend);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export default RenderCommand;
|