@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,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CardBending.js - 3D Card Effect with 6D Rotation
|
|
3
|
+
*
|
|
4
|
+
* Creates a holographic trading card effect by:
|
|
5
|
+
* - Applying CSS 3D transforms for physical card bend
|
|
6
|
+
* - Mapping card tilt to 4D rotation planes
|
|
7
|
+
* - Adding holographic shimmer based on viewing angle
|
|
8
|
+
* - Creating parallax depth layers
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { EventEmitter } from 'events';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Bend presets for different card effects
|
|
15
|
+
*/
|
|
16
|
+
export const BendPreset = {
|
|
17
|
+
NONE: 'none',
|
|
18
|
+
SUBTLE: 'subtle',
|
|
19
|
+
STANDARD: 'standard',
|
|
20
|
+
DRAMATIC: 'dramatic',
|
|
21
|
+
HOLOGRAPHIC: 'holographic'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Preset configurations
|
|
26
|
+
*/
|
|
27
|
+
const BEND_CONFIGS = {
|
|
28
|
+
[BendPreset.NONE]: {
|
|
29
|
+
maxBend: 0,
|
|
30
|
+
perspective: 1000,
|
|
31
|
+
shimmerIntensity: 0,
|
|
32
|
+
parallaxDepth: 0
|
|
33
|
+
},
|
|
34
|
+
[BendPreset.SUBTLE]: {
|
|
35
|
+
maxBend: 5,
|
|
36
|
+
perspective: 1500,
|
|
37
|
+
shimmerIntensity: 0.3,
|
|
38
|
+
parallaxDepth: 10
|
|
39
|
+
},
|
|
40
|
+
[BendPreset.STANDARD]: {
|
|
41
|
+
maxBend: 15,
|
|
42
|
+
perspective: 1000,
|
|
43
|
+
shimmerIntensity: 0.5,
|
|
44
|
+
parallaxDepth: 20
|
|
45
|
+
},
|
|
46
|
+
[BendPreset.DRAMATIC]: {
|
|
47
|
+
maxBend: 30,
|
|
48
|
+
perspective: 800,
|
|
49
|
+
shimmerIntensity: 0.7,
|
|
50
|
+
parallaxDepth: 40
|
|
51
|
+
},
|
|
52
|
+
[BendPreset.HOLOGRAPHIC]: {
|
|
53
|
+
maxBend: 20,
|
|
54
|
+
perspective: 1000,
|
|
55
|
+
shimmerIntensity: 1.0,
|
|
56
|
+
parallaxDepth: 30
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* CardBending - 3D Card Effect Controller
|
|
62
|
+
*/
|
|
63
|
+
export class CardBending extends EventEmitter {
|
|
64
|
+
constructor(options = {}) {
|
|
65
|
+
super();
|
|
66
|
+
|
|
67
|
+
this.element = null;
|
|
68
|
+
this.shimmerOverlay = null;
|
|
69
|
+
this.parallaxLayers = [];
|
|
70
|
+
|
|
71
|
+
// Bend state
|
|
72
|
+
this.bendX = 0; // Horizontal bend (-1 to 1)
|
|
73
|
+
this.bendY = 0; // Vertical bend (-1 to 1)
|
|
74
|
+
this.bendZ = 0; // Twist/rotation
|
|
75
|
+
|
|
76
|
+
// Configuration
|
|
77
|
+
this.preset = options.preset || BendPreset.STANDARD;
|
|
78
|
+
this.config = { ...BEND_CONFIGS[this.preset], ...options };
|
|
79
|
+
|
|
80
|
+
// 6D rotation mapping coefficients
|
|
81
|
+
this.rotationMapping = {
|
|
82
|
+
xy: options.xyCoeff || 0.2,
|
|
83
|
+
xz: options.xzCoeff || 0.3,
|
|
84
|
+
yz: options.yzCoeff || 0.3,
|
|
85
|
+
xw: options.xwCoeff || 0.5,
|
|
86
|
+
yw: options.ywCoeff || 0.5,
|
|
87
|
+
zw: options.zwCoeff || 0.1
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Shimmer colors for holographic effect
|
|
91
|
+
this.shimmerColors = options.shimmerColors || [
|
|
92
|
+
'rgba(255, 0, 128, 0.3)',
|
|
93
|
+
'rgba(128, 0, 255, 0.3)',
|
|
94
|
+
'rgba(0, 255, 255, 0.3)',
|
|
95
|
+
'rgba(255, 255, 0, 0.3)'
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
// Animation state
|
|
99
|
+
this.isAnimating = false;
|
|
100
|
+
this._animationFrame = null;
|
|
101
|
+
this._targetBend = { x: 0, y: 0, z: 0 };
|
|
102
|
+
this._smoothing = options.smoothing || 0.1;
|
|
103
|
+
|
|
104
|
+
// Bind methods
|
|
105
|
+
this._animate = this._animate.bind(this);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Initialize card bending on an element
|
|
110
|
+
*/
|
|
111
|
+
initialize(element) {
|
|
112
|
+
this.element = element;
|
|
113
|
+
|
|
114
|
+
// Set up perspective container
|
|
115
|
+
if (element.parentElement) {
|
|
116
|
+
element.parentElement.style.perspective = `${this.config.perspective}px`;
|
|
117
|
+
element.parentElement.style.perspectiveOrigin = '50% 50%';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Apply base styles
|
|
121
|
+
Object.assign(element.style, {
|
|
122
|
+
transformStyle: 'preserve-3d',
|
|
123
|
+
transition: 'none',
|
|
124
|
+
willChange: 'transform'
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Create shimmer overlay
|
|
128
|
+
this._createShimmerOverlay();
|
|
129
|
+
|
|
130
|
+
// Start animation loop
|
|
131
|
+
this._startAnimation();
|
|
132
|
+
|
|
133
|
+
this.emit('initialized');
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Dispose and cleanup
|
|
139
|
+
*/
|
|
140
|
+
dispose() {
|
|
141
|
+
this._stopAnimation();
|
|
142
|
+
|
|
143
|
+
if (this.shimmerOverlay && this.shimmerOverlay.parentElement) {
|
|
144
|
+
this.shimmerOverlay.parentElement.removeChild(this.shimmerOverlay);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.parallaxLayers.forEach(layer => {
|
|
148
|
+
if (layer.parentElement) {
|
|
149
|
+
layer.parentElement.removeChild(layer);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
this.element = null;
|
|
154
|
+
this.shimmerOverlay = null;
|
|
155
|
+
this.parallaxLayers = [];
|
|
156
|
+
|
|
157
|
+
this.emit('disposed');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Set bend preset
|
|
162
|
+
*/
|
|
163
|
+
setPreset(preset) {
|
|
164
|
+
if (BEND_CONFIGS[preset]) {
|
|
165
|
+
this.preset = preset;
|
|
166
|
+
this.config = { ...BEND_CONFIGS[preset] };
|
|
167
|
+
this._updateShimmer();
|
|
168
|
+
this.emit('presetChanged', preset);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Set bend values directly
|
|
174
|
+
*/
|
|
175
|
+
setBend(x, y, z = 0) {
|
|
176
|
+
this._targetBend.x = Math.max(-1, Math.min(1, x));
|
|
177
|
+
this._targetBend.y = Math.max(-1, Math.min(1, y));
|
|
178
|
+
this._targetBend.z = Math.max(-1, Math.min(1, z));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Set bend from mouse/touch position relative to element
|
|
183
|
+
*/
|
|
184
|
+
setBendFromPosition(clientX, clientY, rect = null) {
|
|
185
|
+
if (!this.element) return;
|
|
186
|
+
|
|
187
|
+
rect = rect || this.element.getBoundingClientRect();
|
|
188
|
+
|
|
189
|
+
// Normalize position to -1 to 1
|
|
190
|
+
const x = ((clientX - rect.left) / rect.width) * 2 - 1;
|
|
191
|
+
const y = ((clientY - rect.top) / rect.height) * 2 - 1;
|
|
192
|
+
|
|
193
|
+
this.setBend(-y * 0.8, x * 0.8, 0);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Set bend from device orientation
|
|
198
|
+
*/
|
|
199
|
+
setBendFromOrientation(beta, gamma) {
|
|
200
|
+
// Beta: front-to-back tilt (-180 to 180), Gamma: left-to-right (-90 to 90)
|
|
201
|
+
const normalizedBeta = Math.max(-1, Math.min(1, beta / 45));
|
|
202
|
+
const normalizedGamma = Math.max(-1, Math.min(1, gamma / 45));
|
|
203
|
+
|
|
204
|
+
this.setBend(normalizedBeta, normalizedGamma, 0);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get current 6D rotation values based on card bend
|
|
209
|
+
*/
|
|
210
|
+
get6DRotation() {
|
|
211
|
+
const { xy, xz, yz, xw, yw, zw } = this.rotationMapping;
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
xy: this.bendZ * xy * Math.PI,
|
|
215
|
+
xz: this.bendY * xz * Math.PI,
|
|
216
|
+
yz: this.bendX * yz * Math.PI,
|
|
217
|
+
xw: this.bendY * xw * Math.PI,
|
|
218
|
+
yw: this.bendX * yw * Math.PI,
|
|
219
|
+
zw: (this.bendX * this.bendY) * zw * Math.PI
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Create the shimmer overlay element
|
|
225
|
+
*/
|
|
226
|
+
_createShimmerOverlay() {
|
|
227
|
+
if (!this.element) return;
|
|
228
|
+
|
|
229
|
+
this.shimmerOverlay = document.createElement('div');
|
|
230
|
+
Object.assign(this.shimmerOverlay.style, {
|
|
231
|
+
position: 'absolute',
|
|
232
|
+
top: '0',
|
|
233
|
+
left: '0',
|
|
234
|
+
width: '100%',
|
|
235
|
+
height: '100%',
|
|
236
|
+
pointerEvents: 'none',
|
|
237
|
+
mixBlendMode: 'overlay',
|
|
238
|
+
opacity: '0',
|
|
239
|
+
background: 'linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.3) 50%, transparent 70%)',
|
|
240
|
+
backgroundSize: '200% 200%',
|
|
241
|
+
zIndex: '10'
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
this.element.style.position = 'relative';
|
|
245
|
+
this.element.appendChild(this.shimmerOverlay);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Create parallax depth layers
|
|
250
|
+
*/
|
|
251
|
+
createParallaxLayers(count = 3) {
|
|
252
|
+
if (!this.element) return;
|
|
253
|
+
|
|
254
|
+
this.parallaxLayers = [];
|
|
255
|
+
|
|
256
|
+
for (let i = 0; i < count; i++) {
|
|
257
|
+
const layer = document.createElement('div');
|
|
258
|
+
Object.assign(layer.style, {
|
|
259
|
+
position: 'absolute',
|
|
260
|
+
top: '0',
|
|
261
|
+
left: '0',
|
|
262
|
+
width: '100%',
|
|
263
|
+
height: '100%',
|
|
264
|
+
pointerEvents: 'none',
|
|
265
|
+
transformStyle: 'preserve-3d',
|
|
266
|
+
zIndex: String(i)
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
this.parallaxLayers.push(layer);
|
|
270
|
+
this.element.appendChild(layer);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return this.parallaxLayers;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Start animation loop
|
|
278
|
+
*/
|
|
279
|
+
_startAnimation() {
|
|
280
|
+
if (this.isAnimating) return;
|
|
281
|
+
this.isAnimating = true;
|
|
282
|
+
this._animate();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Stop animation loop
|
|
287
|
+
*/
|
|
288
|
+
_stopAnimation() {
|
|
289
|
+
this.isAnimating = false;
|
|
290
|
+
if (this._animationFrame) {
|
|
291
|
+
cancelAnimationFrame(this._animationFrame);
|
|
292
|
+
this._animationFrame = null;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Animation loop
|
|
298
|
+
*/
|
|
299
|
+
_animate() {
|
|
300
|
+
if (!this.isAnimating) return;
|
|
301
|
+
|
|
302
|
+
// Smooth interpolation
|
|
303
|
+
this.bendX += (this._targetBend.x - this.bendX) * this._smoothing;
|
|
304
|
+
this.bendY += (this._targetBend.y - this.bendY) * this._smoothing;
|
|
305
|
+
this.bendZ += (this._targetBend.z - this.bendZ) * this._smoothing;
|
|
306
|
+
|
|
307
|
+
// Apply transforms
|
|
308
|
+
this._applyTransform();
|
|
309
|
+
this._updateShimmer();
|
|
310
|
+
this._updateParallax();
|
|
311
|
+
|
|
312
|
+
// Emit update
|
|
313
|
+
this.emit('update', {
|
|
314
|
+
bendX: this.bendX,
|
|
315
|
+
bendY: this.bendY,
|
|
316
|
+
bendZ: this.bendZ,
|
|
317
|
+
rotation6D: this.get6DRotation()
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
this._animationFrame = requestAnimationFrame(this._animate);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Apply CSS transform to element
|
|
325
|
+
*/
|
|
326
|
+
_applyTransform() {
|
|
327
|
+
if (!this.element) return;
|
|
328
|
+
|
|
329
|
+
const { maxBend } = this.config;
|
|
330
|
+
|
|
331
|
+
const rotateX = this.bendX * maxBend;
|
|
332
|
+
const rotateY = this.bendY * maxBend;
|
|
333
|
+
const rotateZ = this.bendZ * maxBend * 0.5;
|
|
334
|
+
|
|
335
|
+
// Calculate subtle scale based on tilt (cards appear closer when tilted toward viewer)
|
|
336
|
+
const tiltMagnitude = Math.sqrt(this.bendX ** 2 + this.bendY ** 2);
|
|
337
|
+
const scale = 1 + tiltMagnitude * 0.02;
|
|
338
|
+
|
|
339
|
+
this.element.style.transform = `
|
|
340
|
+
rotateX(${rotateX}deg)
|
|
341
|
+
rotateY(${rotateY}deg)
|
|
342
|
+
rotateZ(${rotateZ}deg)
|
|
343
|
+
scale(${scale})
|
|
344
|
+
`;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Update shimmer effect
|
|
349
|
+
*/
|
|
350
|
+
_updateShimmer() {
|
|
351
|
+
if (!this.shimmerOverlay) return;
|
|
352
|
+
|
|
353
|
+
const { shimmerIntensity } = this.config;
|
|
354
|
+
|
|
355
|
+
// Calculate shimmer position based on bend
|
|
356
|
+
const shimmerX = 50 + this.bendY * 50;
|
|
357
|
+
const shimmerY = 50 + this.bendX * 50;
|
|
358
|
+
|
|
359
|
+
// Calculate shimmer hue based on angle
|
|
360
|
+
const angle = Math.atan2(this.bendY, this.bendX);
|
|
361
|
+
const hue = ((angle + Math.PI) / (2 * Math.PI)) * 360;
|
|
362
|
+
|
|
363
|
+
// Create holographic gradient
|
|
364
|
+
const gradient = `
|
|
365
|
+
linear-gradient(
|
|
366
|
+
${45 + this.bendY * 30}deg,
|
|
367
|
+
transparent 20%,
|
|
368
|
+
hsla(${hue}, 100%, 70%, ${shimmerIntensity * 0.3}) 40%,
|
|
369
|
+
hsla(${(hue + 60) % 360}, 100%, 70%, ${shimmerIntensity * 0.5}) 50%,
|
|
370
|
+
hsla(${(hue + 120) % 360}, 100%, 70%, ${shimmerIntensity * 0.3}) 60%,
|
|
371
|
+
transparent 80%
|
|
372
|
+
)
|
|
373
|
+
`;
|
|
374
|
+
|
|
375
|
+
this.shimmerOverlay.style.background = gradient;
|
|
376
|
+
this.shimmerOverlay.style.backgroundPosition = `${shimmerX}% ${shimmerY}%`;
|
|
377
|
+
this.shimmerOverlay.style.opacity = String(shimmerIntensity * Math.min(1, Math.sqrt(this.bendX ** 2 + this.bendY ** 2) * 2));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Update parallax layers
|
|
382
|
+
*/
|
|
383
|
+
_updateParallax() {
|
|
384
|
+
if (this.parallaxLayers.length === 0) return;
|
|
385
|
+
|
|
386
|
+
const { parallaxDepth } = this.config;
|
|
387
|
+
|
|
388
|
+
this.parallaxLayers.forEach((layer, index) => {
|
|
389
|
+
const depth = (index + 1) / this.parallaxLayers.length;
|
|
390
|
+
const offsetX = this.bendY * parallaxDepth * depth;
|
|
391
|
+
const offsetY = this.bendX * parallaxDepth * depth;
|
|
392
|
+
const offsetZ = depth * 10;
|
|
393
|
+
|
|
394
|
+
layer.style.transform = `translate3d(${offsetX}px, ${offsetY}px, ${offsetZ}px)`;
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Apply a bend animation sequence
|
|
400
|
+
*/
|
|
401
|
+
async animateBend(keyframes, duration = 1000) {
|
|
402
|
+
const startTime = performance.now();
|
|
403
|
+
const startBend = { x: this.bendX, y: this.bendY, z: this.bendZ };
|
|
404
|
+
|
|
405
|
+
return new Promise(resolve => {
|
|
406
|
+
const animate = (time) => {
|
|
407
|
+
const progress = Math.min(1, (time - startTime) / duration);
|
|
408
|
+
|
|
409
|
+
// Find current keyframe
|
|
410
|
+
let frame = keyframes[0];
|
|
411
|
+
for (let i = 0; i < keyframes.length - 1; i++) {
|
|
412
|
+
const nextFrame = keyframes[i + 1];
|
|
413
|
+
if (progress >= keyframes[i].time && progress <= nextFrame.time) {
|
|
414
|
+
const localProgress = (progress - keyframes[i].time) / (nextFrame.time - keyframes[i].time);
|
|
415
|
+
frame = {
|
|
416
|
+
x: keyframes[i].x + (nextFrame.x - keyframes[i].x) * localProgress,
|
|
417
|
+
y: keyframes[i].y + (nextFrame.y - keyframes[i].y) * localProgress,
|
|
418
|
+
z: (keyframes[i].z || 0) + ((nextFrame.z || 0) - (keyframes[i].z || 0)) * localProgress
|
|
419
|
+
};
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
this._targetBend.x = frame.x;
|
|
425
|
+
this._targetBend.y = frame.y;
|
|
426
|
+
this._targetBend.z = frame.z || 0;
|
|
427
|
+
|
|
428
|
+
if (progress < 1) {
|
|
429
|
+
requestAnimationFrame(animate);
|
|
430
|
+
} else {
|
|
431
|
+
resolve();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
requestAnimationFrame(animate);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Play a holographic showcase animation
|
|
441
|
+
*/
|
|
442
|
+
async playShowcaseAnimation(duration = 3000) {
|
|
443
|
+
const keyframes = [
|
|
444
|
+
{ time: 0, x: 0, y: 0, z: 0 },
|
|
445
|
+
{ time: 0.2, x: 0.5, y: -0.3, z: 0 },
|
|
446
|
+
{ time: 0.4, x: -0.3, y: 0.5, z: 0.1 },
|
|
447
|
+
{ time: 0.6, x: -0.5, y: -0.4, z: -0.1 },
|
|
448
|
+
{ time: 0.8, x: 0.4, y: 0.3, z: 0 },
|
|
449
|
+
{ time: 1, x: 0, y: 0, z: 0 }
|
|
450
|
+
];
|
|
451
|
+
|
|
452
|
+
return this.animateBend(keyframes, duration);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Serialize current state
|
|
457
|
+
*/
|
|
458
|
+
toJSON() {
|
|
459
|
+
return {
|
|
460
|
+
bendX: this.bendX,
|
|
461
|
+
bendY: this.bendY,
|
|
462
|
+
bendZ: this.bendZ,
|
|
463
|
+
preset: this.preset,
|
|
464
|
+
config: this.config,
|
|
465
|
+
rotationMapping: this.rotationMapping,
|
|
466
|
+
rotation6D: this.get6DRotation()
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Restore from serialized state
|
|
472
|
+
*/
|
|
473
|
+
fromJSON(data) {
|
|
474
|
+
if (data.preset) this.setPreset(data.preset);
|
|
475
|
+
if (data.config) this.config = { ...this.config, ...data.config };
|
|
476
|
+
if (data.rotationMapping) this.rotationMapping = { ...data.rotationMapping };
|
|
477
|
+
if (typeof data.bendX === 'number') this.setBend(data.bendX, data.bendY, data.bendZ);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export default CardBending;
|