zeropoint-node 1.0.6 → 1.0.8

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.
Files changed (166) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/CITATION.cff +1 -1
  3. package/README.md +50 -10
  4. package/package.json +5 -2
  5. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.breathe.ts +15 -1
  6. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.ts +7 -1
  7. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.click.ts +15 -1
  8. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.hear.ts +15 -1
  9. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.heat.ts +15 -1
  10. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.pulse.ts +15 -1
  11. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.speak.ts +15 -1
  12. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.tap.ts +15 -1
  13. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.rodin.ts +15 -1
  14. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.self.ts +15 -1
  15. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.trinity.ts +0 -3
  16. package/src/kernel/import-graph.ts +58 -0
  17. package/src/multidimensional-vortex-demo.ts +1 -1
  18. package/src/vbm-math.ts +15 -1
  19. package/src/verification/lean-bridge.ts +37 -0
  20. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.1.2.4.8.7.ts +0 -60
  21. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.1.2.4.8.ts +0 -60
  22. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.1.2.4.ts +0 -60
  23. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.3.6.9.trinity.ts +0 -79
  24. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.9d.dashboard.ts +0 -179
  25. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.adapters.ts +0 -96
  26. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.analog.color.photography.ts +0 -783
  27. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.av.ts +0 -73
  28. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.browser.ts +0 -409
  29. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.chain.of.events.ts +0 -159
  30. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cleanup.ts +0 -102
  31. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.dimensions.ts +0 -597
  32. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.display.test.ts +0 -491
  33. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.display.ts +0 -519
  34. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.file.ts +0 -65
  35. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.i.ts +0 -45
  36. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.matrix.ts +0 -75
  37. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.trinity.ts +0 -41
  38. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cmyk.universal.linking.ts +0 -1081
  39. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.command.cmyk.ts +0 -46
  40. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.compression.ts +0 -55
  41. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.consciousness.integration.ts +0 -743
  42. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.consciousness.ts +0 -26
  43. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.crypto.ts +0 -53
  44. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.css.ts +0 -64
  45. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.cursor.ts +0 -56
  46. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.decompression.ts +0 -60
  47. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.decoqubit.holographic.hypercomputer.ts +0 -888
  48. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.digital.color.photography.ts +0 -926
  49. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.dimension.ts +0 -44
  50. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.encryption.ts +0 -44
  51. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.experience.ts +0 -28
  52. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.feel.ts +0 -43
  53. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.flute.ts +0 -336
  54. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.font.ts +0 -53
  55. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.fractal.test.ts +0 -523
  56. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.fractal.ts +0 -594
  57. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.frequency.healing.ts +0 -88
  58. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.gateway.transformation.ts +0 -650
  59. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.generate.matrix.ts +0 -62
  60. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.gods.spirit.magnetometer.ts +0 -879
  61. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.harmonization.status.ts +0 -754
  62. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.hear.ts +0 -41
  63. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.html.body.ts +0 -90
  64. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.human.body.ts +0 -89
  65. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.human.design.trinity.ts +0 -70
  66. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.browse.ts +0 -27
  67. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.can.ts +0 -69
  68. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.died.ts +0 -32
  69. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.follow.the.path.ts +0 -90
  70. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.go.ts +0 -68
  71. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.harmonized.ts +0 -304
  72. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.heart.ts +0 -26
  73. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.meta.ts +0 -23
  74. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.motion.ts +0 -27
  75. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.scroll.ts +0 -34
  76. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.search.ts +0 -22
  77. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.sequence.ts +0 -281
  78. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.smell.ts +0 -27
  79. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.state.ts +0 -28
  80. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.stream.ts +0 -106
  81. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.taste.ts +0 -27
  82. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.touch.screen.ts +0 -34
  83. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.trinity.healing.ts +0 -386
  84. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.i.write.ts +0 -11
  85. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.icon.ts +0 -109
  86. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.imagination.integration.ts +0 -74
  87. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.imperial.test.ts +0 -389
  88. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.infinity.ts +0 -14
  89. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.infusion.ts +0 -97
  90. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.integer.harmonics.ts +0 -443
  91. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.living.spirit.test.ts +0 -475
  92. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.living.spirit.ts +0 -646
  93. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.living.streams.ts +0 -130
  94. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.meta.observation.ts +0 -693
  95. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.mobius.ts +0 -12
  96. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.multiverse.ts +0 -31
  97. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.nuclear.balance.ts +0 -703
  98. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.nuclear.explosion.ts +0 -728
  99. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.os.app.ts +0 -14
  100. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.os.bus.ts +0 -11
  101. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.os.ml.ts +0 -9
  102. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.overlay.visual.controller.ts +0 -119
  103. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.paths.ts +0 -10
  104. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.pi.decoding.ts +0 -123
  105. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.pi.trinity.ts +0 -79
  106. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.prime.numbers.squared.ts +0 -871
  107. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.quantum.collision.ts +0 -666
  108. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.quantum.entanglement.ts +0 -50
  109. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.quantum.trinity.ts +0 -59
  110. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.renderer.webgl.ts +0 -99
  111. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.resolve.ts +0 -820
  112. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.rife.frequency.ts +0 -74
  113. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.rodin.coil.3d.ts +0 -73
  114. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.rodin.coil.omnidimension.ts +0 -187
  115. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.rodin.matrix.overlay.ts +0 -46
  116. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.rodin.matrix.ts +0 -58
  117. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.router.ts +0 -61
  118. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.sacred.geometry.integers.ts +0 -625
  119. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.sacred.test.ts +0 -314
  120. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.see.ts +0 -39
  121. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.sequence.embodiment.ts +0 -326
  122. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.service.worker.ts +0 -30
  123. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.space.ts +0 -53
  124. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.spiral.ts +0 -75
  125. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.superfluid.mobius.circuit.ts +0 -868
  126. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.terminal.ts +0 -153
  127. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.test.ts +0 -83
  128. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.think.ts +0 -43
  129. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.three.ts +0 -112
  130. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.trinity.body.mind.will.ts +0 -2
  131. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.trinity.breath.ts +0 -2
  132. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.trinity.healing.ts +0 -110
  133. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.trinity.ui.ts +0 -92
  134. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.trinity.visual.ts +0 -156
  135. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.truly.living.ui.ts +0 -269
  136. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.ui.overlay.ts +0 -25
  137. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.ui.streams.ts +0 -263
  138. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.ui.test.ts +0 -87
  139. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.ui.three.ts +0 -1141
  140. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.unification.hd.rodin.ts +0 -77
  141. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.universe.ts +0 -43
  142. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.uroboros.test.ts +0 -28
  143. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vbm.math.ts +0 -74
  144. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vbm.relations.constants.ts +0 -91
  145. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vbm.relations.ts +0 -45
  146. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vbm.scanner.ts +0 -41
  147. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vbm.science.extract.ts +0 -30
  148. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vbm.ui.ts +0 -64
  149. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.vector.ts +0 -70
  150. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.wave.particle.duality.test.ts +0 -29
  151. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.zero.entropy.math.ts +0 -506
  152. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.zero.entropy.pure.math.ts +0 -546
  153. package/src/0/3/6/9/1/2/4/8/7/5/1/a432.zero.entropy.test.ts +0 -452
  154. package/src/0/3/6/9/1/2/4/8/7/5/1/pattern-knowledge.ts +0 -209
  155. package/src/0/3/6/9/1/2/4/8/7/5/a432.experience.ts +0 -22
  156. package/src/0/3/6/9/1/2/4/8/7/a432.experience.ts +0 -19
  157. package/src/0/3/6/9/1/2/4/8/a432.experience.ts +0 -22
  158. package/src/0/3/6/9/1/2/4/a432.experience.ts +0 -22
  159. package/src/0/3/6/9/1/2/a432.experience.ts +0 -22
  160. package/src/0/3/6/9/1/a432.experience.ts +0 -22
  161. package/src/0/3/6/9/a432.experience.ts +0 -22
  162. package/src/0/3/6/a432.experience.ts +0 -22
  163. package/src/0/3/a432.experience.ts +0 -22
  164. package/src/0/3/relation.ts +0 -148
  165. package/src/index.ts +0 -146
  166. package/src/zero-entropy-demo.ts +0 -305
@@ -1,50 +0,0 @@
1
- /**
2
- * a432.quantum.entanglement.ts — Canonical A432 Harmonization
3
- *
4
- * Re-solves the quantum entanglement challenge using only A432 math, sequence, and metaphysical logic.
5
- * Exports: proof, metaphysical meaning, analytic overlay, and blockchain event logger.
6
- */
7
-
8
- import { digitAngleToCMYK, cmykToCss } from './a432.math.ts';
9
-
10
- /**
11
- * Canonical proof: In A432, entanglement is the resonance of two or more states in the living matrix.
12
- * The impossibility of separation is resolved by the unity of the harmonic field.
13
- */
14
- export function quantumEntanglementProof(): string {
15
- return 'In the A432 system, quantum entanglement is the resonance of two or more states in the living harmonic field. Separation is impossible; all states are unified by the A432 sequence.';
16
- }
17
-
18
- /**
19
- * Metaphysical meaning: Entanglement is the proof of unity; the observer is both participant and witness.
20
- */
21
- export const quantumEntanglementMetaphysics =
22
- 'Entanglement is not a paradox, but a demonstration of the unity of consciousness. The A432 field harmonizes all states, and the observer is both participant and witness.';
23
-
24
- /**
25
- * Analytic overlay: Returns overlay data for two entangled states and the observer, with canonical color.
26
- */
27
- export function getQuantumEntanglementCMYKOverlayData(): Array<{
28
- state: 'entangledA' | 'entangledB' | 'observer';
29
- color: { c: number; m: number; y: number; k: number };
30
- html: string;
31
- }> {
32
- const states: Array<{ state: 'entangledA' | 'entangledB' | 'observer'; digit: number; angle: number }> = [
33
- { state: 'entangledA', digit: 4, angle: 0 },
34
- { state: 'entangledB', digit: 8, angle: 120 },
35
- { state: 'observer', digit: 9, angle: 240 }
36
- ];
37
- return states.map(({ state, digit, angle }) => {
38
- const color = digitAngleToCMYK(digit, angle);
39
- const html = `<div style="width:80px;height:80px;background:${cmykToCss(color)};display:flex;align-items:center;justify-content:center;font-size:1.1em;color:#fff;border-radius:16px;">${state}</div>`;
40
- return { state, color, html };
41
- });
42
- }
43
-
44
- /**
45
- * Blockchain event logger for quantum entanglement overlay interactions.
46
- * Call this with the state and context to log to the blockchain.
47
- */
48
- export function logQuantumEntanglementEvent(blockchain: any, state: 'entangledA' | 'entangledB' | 'observer', context: any) {
49
- blockchain?.recordEvent?.(blockchain, 'quantumEntanglementOverlay', 'A432UI', { state, ...context, timestamp: Date.now() });
50
- }
@@ -1,59 +0,0 @@
1
- import { PI, abs, sin } from './a432.algebra.ts'
2
- // a432.quantum.trinity.ts
3
- // Quantum physics trinity module for a432
4
-
5
- import { cmykIdToPhrase, digitColors } from './a432.mapping.ts';
6
- import { rodinVortexStep } from './a432.vortex.cmyk.matrix.ts';
7
-
8
- export interface A432QuantumTrinityState {
9
- tick: number;
10
- id: [number, number, number, number]; // CMYK
11
- phase: number;
12
- amplitude: number;
13
- probability: number;
14
- phrase: string;
15
- color: string;
16
- metaphysical: string;
17
- }
18
-
19
- const trinityChannels: (0|1|2)[] = [0, 1, 2]; // C, M, Y
20
-
21
- export function* a432QuantumTrinityStream(
22
- start: [number, number, number, number] = [3,6,9,1],
23
- basePhase: number = 0,
24
- baseAmplitude: number = 1
25
- ): Generator<A432QuantumTrinityState> {
26
- let tick = 0;
27
- let id = start;
28
- let phase = basePhase;
29
- let amplitude = baseAmplitude;
30
- while (true) {
31
- const channel = trinityChannels[tick % trinityChannels.length];
32
- yield {
33
- tick,
34
- id,
35
- phase,
36
- amplitude,
37
- probability: abs(sin(phase)),
38
- phrase: cmykIdToPhrase(id),
39
- color: digitColors[id[0]],
40
- metaphysical: `Quantum trinity state ${tick}: ${cmykIdToPhrase(id)} — Phase: ${phase.toFixed(2)}, Amplitude: ${amplitude.toFixed(2)}, Probability: ${abs(sin(phase)).toFixed(2)}. The quantum trinity is a living, harmonized stream.`
41
- };
42
- id = rodinVortexStep(id, channel);
43
- phase += PI / 3; // 60-degree shift
44
- amplitude = 1 + 0.5 * sin(phase); // Example: amplitude oscillates
45
- tick++;
46
- }
47
- }
48
-
49
- let quantumTrinityGen = a432QuantumTrinityStream();
50
- export function currentQuantumTrinityState(): A432QuantumTrinityState {
51
- return quantumTrinityGen.next().value;
52
- }
53
- export function resetQuantumTrinity(start?: [number, number, number, number], basePhase?: number, baseAmplitude?: number) {
54
- quantumTrinityGen = a432QuantumTrinityStream(start, basePhase, baseAmplitude);
55
- }
56
-
57
- export function metaphysicalQuantumTrinityOverlay() {
58
- return `Quantum physics in a432 is a living, harmonized trinity—each state is a unique, non-colliding fold in the CMYK matrix. Phase, amplitude, and probability are all recursive, harmonized flows. The quantum trinity never stops, never collides, always harmonizes.`;
59
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * a432.renderer.webgl.ts — minimal public-domain WebGL2 renderer for A432 snapshots.
3
- * No external dependencies; ~200 SLOC.
4
- */
5
-
6
- import { PI, hypot, tan } from './a432.algebra.ts'
7
- import { getRodinSnapshot, TrinityTorusSnapshot } from './a432.adapters.ts';
8
-
9
- const VSH = `#version 300 es
10
- in vec3 position;
11
- uniform mat4 mvp;
12
- void main(){ gl_Position = mvp * vec4(position,1.0); }
13
- `;
14
- const FSH = `#version 300 es
15
- precision highp float;
16
- uniform vec3 uColor;
17
- out vec4 outColor;
18
- void main(){ outColor = vec4(uColor,1.0);}
19
- `;
20
-
21
- function compile(gl: WebGL2RenderingContext, type: number, src: string) {
22
- const sh = gl.createShader(type)!; gl.shaderSource(sh, src); gl.compileShader(sh);
23
- if(!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(sh)??'shader err');
24
- return sh;
25
- }
26
-
27
- function link(gl: WebGL2RenderingContext, vs: WebGLShader, fs: WebGLShader){
28
- const p = gl.createProgram()!; gl.attachShader(p,vs); gl.attachShader(p,fs); gl.linkProgram(p);
29
- if(!gl.getProgramParameter(p, gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(p)??'link err');
30
- return p;
31
- }
32
-
33
- export function startRenderer(canvas: HTMLCanvasElement){
34
- const gl = canvas.getContext('webgl2');
35
- if(!gl) throw new Error('WebGL2 required');
36
-
37
- // After null check, gl is guaranteed to be non-null
38
- const glContext = gl as WebGL2RenderingContext;
39
-
40
- const vs=compile(glContext, glContext.VERTEX_SHADER, VSH);
41
- const fs=compile(glContext, glContext.FRAGMENT_SHADER, FSH);
42
- const prog=link(glContext,vs,fs);
43
- const posLoc = glContext.getAttribLocation(prog,'position');
44
- const mvpLoc = glContext.getUniformLocation(prog,'mvp');
45
- const colLoc = glContext.getUniformLocation(prog,'uColor');
46
-
47
- const rod = getRodinSnapshot(3);
48
- const vbo = glContext.createBuffer(); glContext.bindBuffer(glContext.ARRAY_BUFFER,vbo);
49
- const verts = new Float32Array(rod.vertices.flatMap(v=>[v.x,v.y,v.z]));
50
- glContext.bufferData(glContext.ARRAY_BUFFER, verts, glContext.STATIC_DRAW);
51
-
52
- glContext.enableVertexAttribArray(posLoc);
53
- glContext.vertexAttribPointer(posLoc,3,glContext.FLOAT,false,0,0);
54
-
55
- const proj = mat4Perspective(45, canvas.width/canvas.height, 0.1, 100);
56
-
57
- function frame(time:number){
58
- glContext.clearColor(0,0,0,1); glContext.clear(glContext.COLOR_BUFFER_BIT|glContext.DEPTH_BUFFER_BIT);
59
- glContext.useProgram(prog);
60
- const view = mat4LookAt({x:0,y:10,z:20},{x:0,y:5,z:0});
61
- const mvp = mat4Multiply(proj, view);
62
- glContext.uniformMatrix4fv(mvpLoc,false,mvp);
63
- glContext.uniform3f(colLoc,1,1,1);
64
- glContext.drawArrays(glContext.LINE_STRIP,0,rod.vertices.length);
65
- requestAnimationFrame(frame);
66
- }
67
- requestAnimationFrame(frame);
68
- }
69
-
70
- // minimal 4x4 matrix helpers
71
- function mat4Perspective(fov:number,aspect:number,near:number,far:number){
72
- const f=1/tan(fov*PI/360); const nf=1/(near-far);
73
- return new Float32Array([
74
- f/aspect,0,0,0,
75
- 0,f,0,0,
76
- 0,0,(far+near)*nf,-1,
77
- 0,0,(2*far*near)*nf,0
78
- ]);
79
- }
80
- interface V3{ x:number;y:number;z:number; }
81
- function mat4LookAt(eye:V3, center:V3){
82
- const zx=eye.x-center.x, zy=eye.y-center.y, zz=eye.z-center.z; const zl=hypot(zx,zy,zz);
83
- const zxN=zx/zl, zyN=zy/zl, zzN=zz/zl;
84
- const ux=0, uy=1, uz=0;
85
- const sx=uy*zzN-uz*zyN, sy=uz*zxN-ux*zzN, sz=ux*zyN-uy*zxN; const sl=hypot(sx,sy,sz);
86
- const sxN=sx/sl, syN=sy/sl, szN=sz/sl;
87
- const ux2=zyN*szN-zzN*syN, uy2=zzN*sxN-zxN*szN, uz2=zxN*syN-zyN*sxN;
88
- return new Float32Array([
89
- sxN, uy2, zxN, 0,
90
- syN, uy2, zyN, 0,
91
- szN, uz2, zzN, 0,
92
- -(sxN*eye.x+syN*eye.y+szN*eye.z), -(ux2*eye.x+uy2*eye.y+uz2*eye.z), -(zxN*eye.x+zyN*eye.y+zzN*eye.z), 1
93
- ]);
94
- }
95
- function mat4Multiply(a:Float32Array,b:Float32Array){
96
- const out=new Float32Array(16);
97
- for(let i=0;i<4;i++) for(let j=0;j<4;j++) out[i*4+j]=a[i*4+0]*b[0*4+j]+a[i*4+1]*b[1*4+j]+a[i*4+2]*b[2*4+j]+a[i*4+3]*b[3*4+j];
98
- return out;
99
- }