@bvdmitri/gyroview 0.0.0-stage → 0.9.0-cutaway.2

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 (302) hide show
  1. package/CHANGELOG.md +402 -0
  2. package/LICENSE +21 -0
  3. package/README.md +313 -2
  4. package/dist/define.d.ts +3 -0
  5. package/dist/define.js +4 -0
  6. package/dist/index.d.ts +1204 -0
  7. package/dist/index.js +12 -0
  8. package/dist/packages/adapters/blob/src/BlobRandomAccessSource.js +36 -0
  9. package/dist/packages/adapters/fetch/src/HttpByteStream.js +173 -0
  10. package/dist/packages/adapters/fetch/src/HttpRangeSource.js +37 -0
  11. package/dist/packages/adapters/fetch/src/HttpResource.js +227 -0
  12. package/dist/packages/adapters/fetch/src/HttpResourceLocator.js +35 -0
  13. package/dist/packages/adapters/fetch/src/contentRange.js +15 -0
  14. package/dist/packages/adapters/fetch/src/httpRequest.js +136 -0
  15. package/dist/packages/adapters/fetch/src/passingFailures.js +23 -0
  16. package/dist/packages/adapters/fetch/src/rangeFailures.js +16 -0
  17. package/dist/packages/adapters/fetch/src/recordingVersion.js +37 -0
  18. package/dist/packages/adapters/mediabunny/src/MediabunnyAudioPackager.js +162 -0
  19. package/dist/packages/adapters/mediabunny/src/MediabunnyCodecReader.js +93 -0
  20. package/dist/packages/adapters/mediabunny/src/SegmentChannel.js +135 -0
  21. package/dist/packages/adapters/mediabunny/src/bufferSources.js +12 -0
  22. package/dist/packages/adapters/mediabunny/src/decoderConfigurations.js +43 -0
  23. package/dist/packages/adapters/mediabunny/src/trackColour.js +20 -0
  24. package/dist/packages/adapters/mse-audio/src/MediaSourceAudioClock.js +138 -0
  25. package/dist/packages/adapters/mse-audio/src/SourceBufferFeeder.js +263 -0
  26. package/dist/packages/adapters/mse-audio/src/events.js +26 -0
  27. package/dist/packages/adapters/mse-audio/src/mediaSourceSupport.js +81 -0
  28. package/dist/packages/adapters/three/src/ThreeFrameRenderer.js +215 -0
  29. package/dist/packages/adapters/three/src/compileAndProve.js +14 -0
  30. package/dist/packages/adapters/three/src/conversionUniforms.js +60 -0
  31. package/dist/packages/adapters/three/src/drawSchedules.js +13 -0
  32. package/dist/packages/adapters/three/src/fullscreenPass.js +52 -0
  33. package/dist/packages/adapters/three/src/glslLiterals.js +10 -0
  34. package/dist/packages/adapters/three/src/lensTextures.js +34 -0
  35. package/dist/packages/adapters/three/src/matrixCorrections.js +34 -0
  36. package/dist/packages/adapters/three/src/pictureMaterials.js +44 -0
  37. package/dist/packages/adapters/three/src/renderInto.js +15 -0
  38. package/dist/packages/adapters/three/src/rendererParts.js +108 -0
  39. package/dist/packages/adapters/three/src/rendererUniforms.js +176 -0
  40. package/dist/packages/adapters/three/src/samplingStrategies.js +26 -0
  41. package/dist/packages/adapters/three/src/scissorBox.js +20 -0
  42. package/dist/packages/adapters/three/src/seamMeter/SeamMeterPass.js +85 -0
  43. package/dist/packages/adapters/three/src/seamMeter/rowMeans.js +42 -0
  44. package/dist/packages/adapters/three/src/shaderPrograms.js +68 -0
  45. package/dist/packages/adapters/three/src/shaders/analysis.frag.js +4 -0
  46. package/dist/packages/adapters/three/src/shaders/displayConversion.js +4 -0
  47. package/dist/packages/adapters/three/src/shaders/equirectangularRays.js +4 -0
  48. package/dist/packages/adapters/three/src/shaders/fixedJoin.js +4 -0
  49. package/dist/packages/adapters/three/src/shaders/fullscreen.vert.js +4 -0
  50. package/dist/packages/adapters/three/src/shaders/header.js +4 -0
  51. package/dist/packages/adapters/three/src/shaders/lensModels.js +4 -0
  52. package/dist/packages/adapters/three/src/shaders/lensSampling.js +4 -0
  53. package/dist/packages/adapters/three/src/shaders/lensTextures.js +4 -0
  54. package/dist/packages/adapters/three/src/shaders/rawLenses.frag.js +4 -0
  55. package/dist/packages/adapters/three/src/shaders/rectilinearRays.js +4 -0
  56. package/dist/packages/adapters/three/src/shaders/screenAreas.js +4 -0
  57. package/dist/packages/adapters/three/src/shaders/stitch.frag.js +4 -0
  58. package/dist/packages/adapters/three/src/threeMatrix.js +10 -0
  59. package/dist/packages/adapters/three/src/webglRenderer.js +37 -0
  60. package/dist/packages/adapters/webcodecs/src/WebCodecsVideoDecoderPort.js +152 -0
  61. package/dist/packages/adapters/webcodecs/src/colorSpaceOf.js +32 -0
  62. package/dist/packages/core/src/application/download/BlockStore.js +97 -0
  63. package/dist/packages/core/src/application/download/DownloadedAudioSamples.js +50 -0
  64. package/dist/packages/core/src/application/download/DownloadedVideoTrack.js +122 -0
  65. package/dist/packages/core/src/application/download/FileDownload.js +208 -0
  66. package/dist/packages/core/src/application/download/RecordingBuffer.js +22 -0
  67. package/dist/packages/core/src/application/download/SampleCursor.js +89 -0
  68. package/dist/packages/core/src/application/download/SourceByteStream.js +46 -0
  69. package/dist/packages/core/src/application/download/Transfers.js +82 -0
  70. package/dist/packages/core/src/application/download/startFileDownload.js +37 -0
  71. package/dist/packages/core/src/application/gainMatching/GainMatching.js +76 -0
  72. package/dist/packages/core/src/application/gainMatching/GainMatchingFrameSink.js +80 -0
  73. package/dist/packages/core/src/application/gainMatching/referenceLensOf.js +18 -0
  74. package/dist/packages/core/src/application/playback/Buffering.js +54 -0
  75. package/dist/packages/core/src/application/playback/ClockStart.js +55 -0
  76. package/dist/packages/core/src/application/playback/ClockWatch.js +76 -0
  77. package/dist/packages/core/src/application/playback/DecodePipeline.js +234 -0
  78. package/dist/packages/core/src/application/playback/DecodeRun.js +108 -0
  79. package/dist/packages/core/src/application/playback/FramePairQueue.js +93 -0
  80. package/dist/packages/core/src/application/playback/FramePairer.js +77 -0
  81. package/dist/packages/core/src/application/playback/PictureOnScreen.js +56 -0
  82. package/dist/packages/core/src/application/playback/PlaybackSession.js +410 -0
  83. package/dist/packages/core/src/application/playback/SeekOrder.js +35 -0
  84. package/dist/packages/core/src/application/playback/SessionLifecycle.js +42 -0
  85. package/dist/packages/core/src/application/playback/StartGate.js +69 -0
  86. package/dist/packages/core/src/application/playback/TimeUpdates.js +31 -0
  87. package/dist/packages/core/src/application/playback/WallClock.js +46 -0
  88. package/dist/packages/core/src/application/playback/keyframeTimeAt.js +15 -0
  89. package/dist/packages/core/src/application/playback/probeDecoding.js +182 -0
  90. package/dist/packages/core/src/application/recording/frameTimesOf.js +21 -0
  91. package/dist/packages/core/src/application/recording/inspectLayout.js +21 -0
  92. package/dist/packages/core/src/application/recording/inspectRecording.js +125 -0
  93. package/dist/packages/core/src/application/recording/locateOtherLensFile.js +18 -0
  94. package/dist/packages/core/src/application/recording/motionOf.js +43 -0
  95. package/dist/packages/core/src/application/recording/readRecording.js +31 -0
  96. package/dist/packages/core/src/application/recording/readRecordingFiles.js +130 -0
  97. package/dist/packages/core/src/application/recording/readSampleTable.js +27 -0
  98. package/dist/packages/core/src/application/recording/timeRecording.js +57 -0
  99. package/dist/packages/core/src/application/stabilization/StabilizingFrameSink.js +33 -0
  100. package/dist/packages/core/src/domain/colour/DisplayConversion.js +137 -0
  101. package/dist/packages/core/src/domain/colour/TrackColour.js +38 -0
  102. package/dist/packages/core/src/domain/colour/gainMatch.js +64 -0
  103. package/dist/packages/core/src/domain/colour/matrixCorrection.js +76 -0
  104. package/dist/packages/core/src/domain/container/KeyframeRule.js +7 -0
  105. package/dist/packages/core/src/domain/container/SampleTable.js +29 -0
  106. package/dist/packages/core/src/domain/container/TrackSampleTable.js +96 -0
  107. package/dist/packages/core/src/domain/container/presentationOrder.js +10 -0
  108. package/dist/packages/core/src/domain/download/DownloadPolicy.js +84 -0
  109. package/dist/packages/core/src/domain/download/isReadyToResume.js +27 -0
  110. package/dist/packages/core/src/domain/download/planDownloads.js +175 -0
  111. package/dist/packages/core/src/domain/download/trackNeeds.js +32 -0
  112. package/dist/packages/core/src/domain/format/boxes/BoxLayout.js +7 -0
  113. package/dist/packages/core/src/domain/format/boxes/boxConstants.js +16 -0
  114. package/dist/packages/core/src/domain/format/boxes/boxHeader.js +44 -0
  115. package/dist/packages/core/src/domain/format/boxes/scanBoxes.js +32 -0
  116. package/dist/packages/core/src/domain/format/calibration/CalibrationVersion.js +16 -0
  117. package/dist/packages/core/src/domain/format/calibration/layouts/CalibrationStringLayout.js +34 -0
  118. package/dist/packages/core/src/domain/format/calibration/layouts/LegacyCalibrationLayout.js +46 -0
  119. package/dist/packages/core/src/domain/format/calibration/layouts/MeiCalibrationLayout.js +121 -0
  120. package/dist/packages/core/src/domain/format/calibration/layouts/PolynomialCalibrationLayout.js +46 -0
  121. package/dist/packages/core/src/domain/format/calibration/offsetTokens.js +94 -0
  122. package/dist/packages/core/src/domain/format/calibration/parseOffsetString.js +77 -0
  123. package/dist/packages/core/src/domain/format/calibration/selectCalibration.js +59 -0
  124. package/dist/packages/core/src/domain/format/calibration/v6TermReading.js +20 -0
  125. package/dist/packages/core/src/domain/format/captureOrigin.js +34 -0
  126. package/dist/packages/core/src/domain/format/constants.js +35 -0
  127. package/dist/packages/core/src/domain/format/info/calibrationSources.js +27 -0
  128. package/dist/packages/core/src/domain/format/info/infoFields.js +116 -0
  129. package/dist/packages/core/src/domain/format/info/parseInfoRecord.js +107 -0
  130. package/dist/packages/core/src/domain/format/info/readInfoRecord.js +14 -0
  131. package/dist/packages/core/src/domain/format/layout/detectLensLayout.js +133 -0
  132. package/dist/packages/core/src/domain/format/mp4/hevcCodecString.js +161 -0
  133. package/dist/packages/core/src/domain/format/mp4/keyframeRules.js +81 -0
  134. package/dist/packages/core/src/domain/format/mp4/movieBoxes.js +52 -0
  135. package/dist/packages/core/src/domain/format/mp4/mp4BoxTypes.js +46 -0
  136. package/dist/packages/core/src/domain/format/mp4/mp4Layouts.js +183 -0
  137. package/dist/packages/core/src/domain/format/mp4/parseMovie.js +72 -0
  138. package/dist/packages/core/src/domain/format/mp4/readTable.js +31 -0
  139. package/dist/packages/core/src/domain/format/mp4/sampleLocations.js +76 -0
  140. package/dist/packages/core/src/domain/format/mp4/sampleTiming.js +120 -0
  141. package/dist/packages/core/src/domain/format/mp4/trackHeaders.js +88 -0
  142. package/dist/packages/core/src/domain/format/naming/RecordingFileName.js +70 -0
  143. package/dist/packages/core/src/domain/format/records/TrailerRecords.js +100 -0
  144. package/dist/packages/core/src/domain/format/records/exposure/parseExposureRecord.js +48 -0
  145. package/dist/packages/core/src/domain/format/records/gyro/FloatGyroSampleLayout.js +38 -0
  146. package/dist/packages/core/src/domain/format/records/gyro/RawGyroSampleLayout.js +55 -0
  147. package/dist/packages/core/src/domain/format/records/gyro/SampleColumns.js +89 -0
  148. package/dist/packages/core/src/domain/format/records/gyro/gyroLayouts.js +12 -0
  149. package/dist/packages/core/src/domain/format/records/gyro/parseGyroRecord.js +138 -0
  150. package/dist/packages/core/src/domain/format/records/trim/parseTrimRecord.js +24 -0
  151. package/dist/packages/core/src/domain/format/trailer/RecordHeader.js +23 -0
  152. package/dist/packages/core/src/domain/format/trailer/Trailer.js +23 -0
  153. package/dist/packages/core/src/domain/format/trailer/TrailerFooter.js +27 -0
  154. package/dist/packages/core/src/domain/format/trailer/locateRecords.js +80 -0
  155. package/dist/packages/core/src/domain/format/trailer/parseRecordIndex.js +28 -0
  156. package/dist/packages/core/src/domain/format/trailer/readTrailer.js +60 -0
  157. package/dist/packages/core/src/domain/motion/exposure/ExposureRecord.js +48 -0
  158. package/dist/packages/core/src/domain/motion/gyro/GyroTrack.js +70 -0
  159. package/dist/packages/core/src/domain/motion/gyro/medianStep.js +11 -0
  160. package/dist/packages/core/src/domain/motion/gyro/repairedTimeline.js +101 -0
  161. package/dist/packages/core/src/domain/motion/imu/ImuFrame.js +178 -0
  162. package/dist/packages/core/src/domain/motion/mounting/Mounting.js +131 -0
  163. package/dist/packages/core/src/domain/motion/orientation/OrientationTrack.js +142 -0
  164. package/dist/packages/core/src/domain/motion/orientation/estimateGyroBias.js +72 -0
  165. package/dist/packages/core/src/domain/motion/orientation/gravity.js +97 -0
  166. package/dist/packages/core/src/domain/motion/stabilization/Stabilizer.js +13 -0
  167. package/dist/packages/core/src/domain/motion/stabilization/stabilizers.js +86 -0
  168. package/dist/packages/core/src/domain/motion/timing/CaptureClock.js +41 -0
  169. package/dist/packages/core/src/domain/motion/timing/FrameTimes.js +85 -0
  170. package/dist/packages/core/src/domain/motion/timing/frameTimeSources.js +58 -0
  171. package/dist/packages/core/src/domain/motion/timing/resolveFrameTimes.js +68 -0
  172. package/dist/packages/core/src/domain/optics/EquidistantModel.js +34 -0
  173. package/dist/packages/core/src/domain/optics/MeiDistortion.js +27 -0
  174. package/dist/packages/core/src/domain/optics/MeiModel.js +27 -0
  175. package/dist/packages/core/src/domain/optics/PolynomialModel.js +39 -0
  176. package/dist/packages/core/src/domain/optics/lensPose.js +49 -0
  177. package/dist/packages/core/src/domain/optics/opticsConstants.js +5 -0
  178. package/dist/packages/core/src/domain/optics/scaledProjection.js +30 -0
  179. package/dist/packages/core/src/domain/playback/PlayerState.js +83 -0
  180. package/dist/packages/core/src/domain/rendition/RenditionSpan.js +70 -0
  181. package/dist/packages/core/src/domain/stitching/LensLayout.js +21 -0
  182. package/dist/packages/core/src/domain/stitching/StitchingSetup.js +87 -0
  183. package/dist/packages/core/src/domain/stitching/seamRing.js +4 -0
  184. package/dist/packages/core/src/domain/view/Framing.js +37 -0
  185. package/dist/packages/core/src/domain/view/Picture.js +12 -0
  186. package/dist/packages/core/src/domain/view/PictureQuality.js +26 -0
  187. package/dist/packages/core/src/domain/view/ViewMode.js +9 -0
  188. package/dist/packages/core/src/domain/view/ViewState.js +54 -0
  189. package/dist/packages/core/src/domain/view/lensTilesView.js +64 -0
  190. package/dist/packages/core/src/domain/view/magnification.js +103 -0
  191. package/dist/packages/core/src/domain/view/motionLookView.js +100 -0
  192. package/dist/packages/core/src/domain/view/normalView.js +37 -0
  193. package/dist/packages/core/src/domain/view/panoramaView.js +95 -0
  194. package/dist/packages/core/src/domain/view/rectilinear.js +53 -0
  195. package/dist/packages/core/src/domain/view/screenLayout.js +129 -0
  196. package/dist/packages/core/src/domain/view/screenLook.js +74 -0
  197. package/dist/packages/core/src/domain/view/viewGestures.js +104 -0
  198. package/dist/packages/core/src/domain/view/viewModes.js +31 -0
  199. package/dist/packages/core/src/ports/FramePair.js +6 -0
  200. package/dist/packages/core/src/shared/async/Deferred.js +42 -0
  201. package/dist/packages/core/src/shared/async/RunStop.js +40 -0
  202. package/dist/packages/core/src/shared/async/iteration.js +24 -0
  203. package/dist/packages/core/src/shared/binary/ByteRange.js +50 -0
  204. package/dist/packages/core/src/shared/binary/ByteRangeSet.js +85 -0
  205. package/dist/packages/core/src/shared/binary/ByteReader.js +104 -0
  206. package/dist/packages/core/src/shared/binary/concatenated.js +15 -0
  207. package/dist/packages/core/src/shared/errors/GyroViewError.js +140 -0
  208. package/dist/packages/core/src/shared/errors/reportLater.js +11 -0
  209. package/dist/packages/core/src/shared/events/Outbox.js +68 -0
  210. package/dist/packages/core/src/shared/events/TypedEmitter.js +55 -0
  211. package/dist/packages/core/src/shared/keysOf.js +10 -0
  212. package/dist/packages/core/src/shared/lazy.js +11 -0
  213. package/dist/packages/core/src/shared/mapRecord.js +11 -0
  214. package/dist/packages/core/src/shared/math/Matrix3.js +121 -0
  215. package/dist/packages/core/src/shared/math/Quaternion.js +133 -0
  216. package/dist/packages/core/src/shared/math/Vector3.js +58 -0
  217. package/dist/packages/core/src/shared/math/clamp.js +9 -0
  218. package/dist/packages/core/src/shared/math/countAtOrBelow.js +31 -0
  219. package/dist/packages/core/src/shared/math/minimum.js +17 -0
  220. package/dist/packages/core/src/shared/protobuf/ProtobufMessage.js +143 -0
  221. package/dist/packages/core/src/shared/protobuf/wireFormat.js +16 -0
  222. package/dist/packages/core/src/shared/text/urlPath.js +31 -0
  223. package/dist/packages/core/src/shared/text/utf8.js +12 -0
  224. package/dist/packages/core/src/shared/units/angle.js +22 -0
  225. package/dist/packages/core/src/shared/units/time.js +13 -0
  226. package/dist/packages/player/src/PlayerSource.js +14 -0
  227. package/dist/packages/player/src/browserPlayer.js +20 -0
  228. package/dist/packages/player/src/choices.js +24 -0
  229. package/dist/packages/player/src/composition/AnimationFrameDraws.js +38 -0
  230. package/dist/packages/player/src/composition/BrowserAttitudeSensor.js +191 -0
  231. package/dist/packages/player/src/composition/Disposables.js +31 -0
  232. package/dist/packages/player/src/composition/DrawingBufferFit.js +119 -0
  233. package/dist/packages/player/src/composition/animationFrames.js +9 -0
  234. package/dist/packages/player/src/composition/attitudeSensor.js +18 -0
  235. package/dist/packages/player/src/composition/browserPorts.js +80 -0
  236. package/dist/packages/player/src/composition/buildPipeline.js +186 -0
  237. package/dist/packages/player/src/composition/ensureDecodable.js +62 -0
  238. package/dist/packages/player/src/composition/openInputs.js +120 -0
  239. package/dist/packages/player/src/composition/openRecording.js +41 -0
  240. package/dist/packages/player/src/composition/readInputs.js +25 -0
  241. package/dist/packages/player/src/composition/renditionFrames.js +160 -0
  242. package/dist/packages/player/src/controls/ChoiceMenu.js +125 -0
  243. package/dist/packages/player/src/controls/FullscreenButton.js +29 -0
  244. package/dist/packages/player/src/controls/MotionLookButton.js +34 -0
  245. package/dist/packages/player/src/controls/PictureMenus.js +60 -0
  246. package/dist/packages/player/src/controls/SeekBar.js +126 -0
  247. package/dist/packages/player/src/controls/SoundControls.js +43 -0
  248. package/dist/packages/player/src/controls/TransportButtons.js +28 -0
  249. package/dist/packages/player/src/controls/ViewGestures.js +135 -0
  250. package/dist/packages/player/src/controls/Wording.js +79 -0
  251. package/dist/packages/player/src/controls/controlParts.js +38 -0
  252. package/dist/packages/player/src/controls/controls.js +4 -0
  253. package/dist/packages/player/src/controls/controlsBar.js +33 -0
  254. package/dist/packages/player/src/controls/controlsMarkup.js +100 -0
  255. package/dist/packages/player/src/controls/customControls.js +43 -0
  256. package/dist/packages/player/src/controls/formatTime.js +19 -0
  257. package/dist/packages/player/src/controls/icons.js +66 -0
  258. package/dist/packages/player/src/controls/keyboard.js +120 -0
  259. package/dist/packages/player/src/controls/messages.js +130 -0
  260. package/dist/packages/player/src/controls/nativeFullscreen.js +27 -0
  261. package/dist/packages/player/src/controls/parseMarkup.js +30 -0
  262. package/dist/packages/player/src/controls/resetViewButton.js +11 -0
  263. package/dist/packages/player/src/controls/sliderFill.js +15 -0
  264. package/dist/packages/player/src/element/ElementLoads.js +130 -0
  265. package/dist/packages/player/src/element/FullscreenToggle.js +93 -0
  266. package/dist/packages/player/src/element/GyroViewElement.js +358 -0
  267. package/dist/packages/player/src/element/IdleWatcher.js +71 -0
  268. package/dist/packages/player/src/element/PlayerCanvas.js +72 -0
  269. package/dist/packages/player/src/element/TypedEventElement.js +22 -0
  270. package/dist/packages/player/src/element/accessibleRegion.js +19 -0
  271. package/dist/packages/player/src/element/attributeNames.js +62 -0
  272. package/dist/packages/player/src/element/attributes.js +123 -0
  273. package/dist/packages/player/src/element/defineGyroView.js +20 -0
  274. package/dist/packages/player/src/element/earlyProperties.js +35 -0
  275. package/dist/packages/player/src/element/elementProperties.js +34 -0
  276. package/dist/packages/player/src/element/elementSource.js +39 -0
  277. package/dist/packages/player/src/element/fetchProperty.js +48 -0
  278. package/dist/packages/player/src/element/liveSettings.js +137 -0
  279. package/dist/packages/player/src/element/playbackAttributes.js +52 -0
  280. package/dist/packages/player/src/element/playerEventMirror.js +33 -0
  281. package/dist/packages/player/src/element/reflectedProperties.js +96 -0
  282. package/dist/packages/player/src/element/styles.js +4 -0
  283. package/dist/packages/player/src/element/template.js +46 -0
  284. package/dist/packages/player/src/inspectRecording.js +21 -0
  285. package/dist/packages/player/src/player/FrameLoop.js +35 -0
  286. package/dist/packages/player/src/player/MotionLook.js +150 -0
  287. package/dist/packages/player/src/player/PictureSettings.js +59 -0
  288. package/dist/packages/player/src/player/PlaybackStarts.js +38 -0
  289. package/dist/packages/player/src/player/Player.js +379 -0
  290. package/dist/packages/player/src/player/PlayerEvents.js +28 -0
  291. package/dist/packages/player/src/player/PlayerPhase.js +38 -0
  292. package/dist/packages/player/src/player/PlayerSound.js +60 -0
  293. package/dist/packages/player/src/player/PlayerView.js +143 -0
  294. package/dist/packages/player/src/player/SessionRelay.js +74 -0
  295. package/dist/packages/player/src/player/StatusAnnouncer.js +29 -0
  296. package/dist/packages/player/src/player/ensureFinite.js +26 -0
  297. package/dist/packages/player/src/player/loadRecording.js +47 -0
  298. package/dist/packages/player/src/player/transportEvents.js +30 -0
  299. package/dist/packages/player/src/player/viewAngles.js +17 -0
  300. package/dist/packages/player/src/rendition.js +52 -0
  301. package/dist/standalone.js +5633 -0
  302. package/package.json +70 -3
@@ -0,0 +1,68 @@
1
+ import analysis_frag_default from "./shaders/analysis.frag.js";
2
+ import displayConversion_default from "./shaders/displayConversion.js";
3
+ import equirectangularRays_default from "./shaders/equirectangularRays.js";
4
+ import fixedJoin_default from "./shaders/fixedJoin.js";
5
+ import header_default from "./shaders/header.js";
6
+ import lensModels_default from "./shaders/lensModels.js";
7
+ import lensSampling_default from "./shaders/lensSampling.js";
8
+ import lensTextures_default from "./shaders/lensTextures.js";
9
+ import rawLenses_frag_default from "./shaders/rawLenses.frag.js";
10
+ import rectilinearRays_default from "./shaders/rectilinearRays.js";
11
+ import screenAreas_default from "./shaders/screenAreas.js";
12
+ import stitch_frag_default from "./shaders/stitch.frag.js";
13
+ //#region ../../packages/adapters/three/src/shaderPrograms.ts
14
+ /**
15
+ * The fragment programs, each the GLSL chunks it is made of in the order they must appear: a
16
+ * chunk comes after every chunk whose declarations it uses. The only place that order is known.
17
+ */
18
+ var LENS_TEXELS = [lensTextures_default, displayConversion_default];
19
+ var LENS_PROJECTION = [
20
+ ...LENS_TEXELS,
21
+ lensModels_default,
22
+ lensSampling_default
23
+ ];
24
+ /**
25
+ * A program that reads the lenses through their calibration, ending in `fragment`.
26
+ */
27
+ function lensProjectionProgram(fragment) {
28
+ return [
29
+ header_default,
30
+ ...LENS_PROJECTION,
31
+ fragment
32
+ ];
33
+ }
34
+ /**
35
+ * The picture programs with a seam join chunk: `fixedJoin.glsl` for the player, or one that
36
+ * implements its three functions otherwise.
37
+ */
38
+ function pictureProgramsWith(seamJoin) {
39
+ const stitchThrough = (rays) => [
40
+ header_default,
41
+ screenAreas_default,
42
+ rays,
43
+ ...LENS_PROJECTION,
44
+ seamJoin,
45
+ stitch_frag_default
46
+ ];
47
+ return {
48
+ rectilinear: stitchThrough(rectilinearRays_default),
49
+ equirectangular: stitchThrough(equirectangularRays_default),
50
+ "lens-tiles": [
51
+ header_default,
52
+ screenAreas_default,
53
+ ...LENS_TEXELS,
54
+ rawLenses_frag_default
55
+ ]
56
+ };
57
+ }
58
+ var PICTURE_PROGRAMS = pictureProgramsWith(fixedJoin_default);
59
+ var SEAM_ANALYSIS = lensProjectionProgram(analysis_frag_default);
60
+ /**
61
+ * Every chunk of the given programs once, for checking them against the TypeScript side.
62
+ */
63
+ function chunksOf(programs) {
64
+ return [...new Set(programs.flat())];
65
+ }
66
+ chunksOf([...Object.values(PICTURE_PROGRAMS), SEAM_ANALYSIS]);
67
+ //#endregion
68
+ export { PICTURE_PROGRAMS, SEAM_ANALYSIS, chunksOf, lensProjectionProgram, pictureProgramsWith };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/analysis.frag.glsl?raw
2
+ var analysis_frag_default = "in vec2 vNdc;\nout vec4 outColor;\n\n// One row per lens: what that lens sees along the seam ring, the circle of directions halfway\n// through the blend band around lens 0's optical axis, sampled around the ring along x. Rows\n// share their directions, so their means differ by exposure (and parallax), not by content:\n// exposure signals, in which it is a factor (ADR 0033). Alpha marks the texels a lens images.\nvoid main() {\n int lens = int(floor((vNdc.y + 1.0) * 0.5 * float(MAX_LENSES)));\n float phi = (vNdc.x + 1.0) * PI;\n float ring = 0.5 * (uFeather.x + uFeather.y);\n vec3 inLensZero = vec3(sin(ring) * cos(phi), sin(ring) * sin(phi), cos(ring));\n // The lens rotations take body directions into each lens; the transpose goes back.\n vec3 dirBody = transpose(uLensRotation[0]) * inLensZero;\n if (lens >= uLensCount) {\n outColor = vec4(0.0);\n return;\n }\n LensSample seen = sampleLensWith(lens, dirBody, SAMPLING_BILINEAR);\n outColor = seen.isImaged ? vec4(seen.signal, 1.0) : vec4(0.0);\n}\n";
3
+ //#endregion
4
+ export { analysis_frag_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/displayConversion.glsl?raw
2
+ var displayConversion_default = "// How lens i's texels are brought to the SDR BT.709 display, as the core's exposureSignalOf and\n// shownOf (ADR 0033): the browser's upload has applied the track's matrix and range; the\n// transfer and primaries are this chunk's. Shown as recorded, or HLG converted to scene light,\n// into BT.709 and toned; gain matching scales the exposure signal between the two (ADR 0012).\nuniform int uLensConversion[MAX_LENSES];\n// R′G′B′ through the matrix a frame names back to the track's own (matrixCorrectionOf).\nuniform mat3 uLensMatrixCorrection[MAX_LENSES];\nuniform mat3 uLensGamut[MAX_LENSES];\n// Exposure, roll-off start, roll-off ceiling, display encoding power.\nuniform vec4 uLensTone[MAX_LENSES];\n\nstruct ToneCurve {\n float exposure;\n float kneeStart;\n float ceiling;\n float exponent;\n};\n\nToneCurve toneOf(int i) {\n vec4 tone = uLensTone[i];\n return ToneCurve(tone.x, tone.y, tone.z, tone.w);\n}\n\nfloat hlgInverseOetf(float signal) {\n return signal <= HLG_SEGMENT_JOIN\n ? signal * signal / HLG_SQUARE_SEGMENT_DIVISOR\n : (exp((signal - HLG_C) / HLG_A) + HLG_B) / HLG_LOG_SEGMENT_DIVISOR;\n}\n\nconst vec3 BT709_LUMINANCE = vec3(BT709_LUMINANCE_RED, BT709_LUMINANCE_GREEN, BT709_LUMINANCE_BLUE);\n\nfloat rolledOff(float luminance, ToneCurve tone) {\n float over = luminance - tone.kneeStart;\n return over <= 0.0\n ? luminance\n : tone.kneeStart + over / (1.0 + over / (tone.ceiling - tone.kneeStart));\n}\n\n// The signal exposed back to light, its luminance rolled off with every channel scaled alike,\n// and encoded for the display.\nvec3 tonedFrom(vec3 signal, ToneCurve tone) {\n vec3 light = tone.exposure * pow(signal, vec3(tone.exponent));\n float luminance = dot(light, BT709_LUMINANCE);\n float scale = luminance > 0.0 ? rolledOff(luminance, tone) / luminance : 1.0;\n return min(pow(light * scale, vec3(1.0 / tone.exponent)), vec3(1.0));\n}\n\nbool isHlg(int i) {\n return uLensConversion[i] == CONVERSION_HLG_TO_SDR_BT709;\n}\n\n// Lens i's texel where its exposure is a factor; as recorded for any kind but HLG.\nvec3 exposureSignalOf(int i, vec3 texel) {\n vec3 recorded = uLensMatrixCorrection[i] * texel;\n if (!isHlg(i)) return recorded;\n // A corrected texel may fall just outside the signal: below black, which the square segment\n // would make light, or past white, which the log segment would make brighter than HLG encodes.\n recorded = clamp(recorded, 0.0, 1.0);\n vec3 scene = vec3(\n hlgInverseOetf(recorded.r),\n hlgInverseOetf(recorded.g),\n hlgInverseOetf(recorded.b)\n );\n vec3 light = max(uLensGamut[i] * scene, 0.0);\n return pow(light, vec3(1.0 / toneOf(i).exponent));\n}\n\n// An exposure signal of lens i as the display shows it; as recorded for any kind but HLG.\nvec3 shownOf(int i, vec3 signal) {\n if (!isHlg(i)) return signal;\n return tonedFrom(signal, toneOf(i));\n}\n\nvec3 toDisplay(int i, vec3 texel) {\n return shownOf(i, exposureSignalOf(i, texel));\n}\n";
3
+ //#endregion
4
+ export { displayConversion_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/equirectangularRays.glsl?raw
2
+ var equirectangularRays_default = "// An equirectangular picture: a full turn across and a half turn from top to bottom.\n\n// Direction in view space (x right, y down, z forward) seen through a point of the picture, given\n// as fractions of the picture from its top-left corner.\nvec3 rayThroughPicture(vec2 point) {\n vec2 centred = point * 2.0 - 1.0;\n float yaw = centred.x * PI;\n float pitch = -centred.y * HALF_PI;\n return vec3(sin(yaw) * cos(pitch), -sin(pitch), cos(yaw) * cos(pitch));\n}\n";
3
+ //#endregion
4
+ export { equirectangularRays_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/fixedJoin.glsl?raw
2
+ var fixedJoin_default = "// The fixed join: every lens read where the calibration's template reads it, for an infinitely\n// far scene, and blended across the whole feather band. The stitch the player draws; the lab's\n// bent join (ADR 0026) implements the same three functions.\nfloat disparityAt(vec3 dirBody) {\n return 0.0;\n}\n\nvec3 seamReadDirection(int i, vec3 dirBody, float disparity) {\n return dirBody;\n}\n\nvec2 seamFeather(float disparity) {\n return uFeather;\n}\n";
3
+ //#endregion
4
+ export { fixedJoin_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/fullscreen.vert.glsl?raw
2
+ var fullscreen_vert_default = "// One triangle covering the whole viewport; the fragment shader does all the work.\nin vec3 position;\nout vec2 vNdc;\n\nvoid main() {\n vNdc = position.xy;\n gl_Position = vec4(position.xy, 0.0, 1.0);\n}\n";
3
+ //#endregion
4
+ export { fullscreen_vert_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/header.glsl?raw
2
+ var header_default = "// GLSL ES 3.0 needs the default precisions before any float or int is mentioned.\nprecision highp float;\nprecision highp int;\n\nconst float PI = 3.14159265358979;\nconst float HALF_PI = 0.5 * PI;\nconst float TWO_PI = 2.0 * PI;\n";
3
+ //#endregion
4
+ export { header_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/lensModels.glsl?raw
2
+ var lensModels_default = "// The depth is positive for every direction inside a lens's field; directions behind it are\n// projected too, for the footprint's derivatives, and must not divide by zero.\nconst float MIN_DEPTH = 1e-3;\n\nuniform vec2 uLensPrincipalPoint[MAX_LENSES];\nuniform vec2 uLensFocal[MAX_LENSES];\nuniform float uLensXi[MAX_LENSES];\n// Each Mei lens's distortion as the core's MeiDistortion holds it, lens after lens, as many terms\n// per lens as each family holds room for, by increasing order: radial terms k1, k2, ... of r²,\n// Brown's tangential pairs (p1, p2) scaled by r^(2j), and thin-prism shifts scaled by r^(2j + 2).\n// The orders a lens does not fill are zero.\nuniform float uLensRadial[MAX_LENSES * MEI_RADIAL_TERMS];\nuniform vec2 uLensTangential[MAX_LENSES * MEI_TANGENTIAL_ORDERS];\nuniform vec2 uLensThinPrism[MAX_LENSES * MEI_THIN_PRISM_ORDERS];\nuniform vec4 uLensPolynomial[MAX_LENSES];\n\n// c0 + c1 r² + c2 r⁴ + ... of each of lens i's families, by Horner's rule, as the core's seriesIn.\nfloat radialSeries(int i, float r2) {\n float sum = 0.0;\n for (int j = MEI_RADIAL_TERMS - 1; j >= 0; j--) {\n sum = sum * r2 + uLensRadial[i * MEI_RADIAL_TERMS + j];\n }\n return sum;\n}\n\nvec2 tangentialSeries(int i, float r2) {\n vec2 sum = vec2(0.0);\n for (int j = MEI_TANGENTIAL_ORDERS - 1; j >= 0; j--) {\n sum = sum * r2 + uLensTangential[i * MEI_TANGENTIAL_ORDERS + j];\n }\n return sum;\n}\n\nvec2 thinPrismSeries(int i, float r2) {\n vec2 sum = vec2(0.0);\n for (int j = MEI_THIN_PRISM_ORDERS - 1; j >= 0; j--) {\n sum = sum * r2 + uLensThinPrism[i * MEI_THIN_PRISM_ORDERS + j];\n }\n return sum;\n}\n\n// A normalised image-plane point distorted by lens i, as the core's distortMei.\nvec2 distortMei(int i, vec2 m) {\n float r2 = dot(m, m);\n float radialFactor = 1.0 + r2 * radialSeries(i, r2);\n vec2 decentering = tangentialSeries(i, r2);\n vec2 tangentialTerm = vec2(\n 2.0 * decentering.x * m.x * m.y + decentering.y * (r2 + 2.0 * m.x * m.x),\n decentering.x * (r2 + 2.0 * m.y * m.y) + 2.0 * decentering.y * m.x * m.y\n );\n return radialFactor * m + tangentialTerm + r2 * thinPrismSeries(i, r2);\n}\n\n// Canvas pixel of a unit direction in lens i's frame under the unified (Mei) model: project onto\n// the unit sphere, then from xi behind its centre onto the image plane, distort, scale.\nvec2 projectMei(int i, vec3 d) {\n float depth = max(d.z + uLensXi[i], MIN_DEPTH);\n return uLensFocal[i] * distortMei(i, d.xy / depth) + uLensPrincipalPoint[i];\n}\n\n// Canvas pixel of a unit direction under lens i's radial polynomial in the angle from its axis.\nvec2 projectRadialPolynomial(int i, vec3 d, float theta) {\n vec4 c = uLensPolynomial[i];\n float radius = theta * (c.x + theta * (c.y + theta * (c.z + theta * c.w)));\n float lateral = length(d.xy);\n vec2 unit = lateral > 0.0 ? d.xy / lateral : vec2(0.0);\n return uLensPrincipalPoint[i] + radius * unit;\n}\n";
3
+ //#endregion
4
+ export { lensModels_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/lensSampling.glsl?raw
2
+ var lensSampling_default = "// How a body direction becomes a texel of one lens, for the stitch and the seam meters: the\n// pose and field as uniforms, and the sampling through each lens model, the texel as its\n// exposure signal. Needs lensTextures.glsl, displayConversion.glsl and lensModels.glsl.\nuniform vec2 uFeather;\nuniform mat3 uLensRotation[MAX_LENSES];\nuniform int uLensKind[MAX_LENSES];\nuniform float uLensHalfFov[MAX_LENSES];\nuniform vec4 uLensWindow[MAX_LENSES];\n\nstruct LensSample {\n bool isImaged;\n // Angle from the lens's optical axis.\n float theta;\n // The texel where the lens's exposure is a factor (displayConversion.glsl).\n vec3 signal;\n};\n\n// Where lens i images direction d on its calibration canvas; the principal point, and not\n// known, for a kind of lens this shader does not know.\nvec2 canvasPixel(int i, vec3 d, float theta, out bool isKnown) {\n isKnown = true;\n if (uLensKind[i] == LENS_MEI) {\n return projectMei(i, d);\n }\n if (uLensKind[i] == LENS_RADIAL_POLYNOMIAL) {\n return projectRadialPolynomial(i, d, theta);\n }\n isKnown = false;\n return uLensPrincipalPoint[i];\n}\n\n// What lens i shows in a body direction, read as `sampling` says, if it images it at all:\n// outside its field, or beyond the window the frame shows, nothing. The footprint is taken and\n// the texture read in every fragment before the gates: a read inside a branch that some pixels\n// of a 2x2 quad skip took a far too coarse footprint on Apple GPUs (rawLenses.frag.glsl).\nLensSample sampleLensWith(int i, vec3 dirBody, int sampling) {\n vec3 d = uLensRotation[i] * dirBody;\n // atan keeps its precision near the axis where acos loses it.\n float theta = atan(length(d.xy), d.z);\n bool isKnown;\n vec2 pixel = canvasPixel(i, d, theta, isKnown);\n vec2 windowUv = (pixel - uLensWindow[i].xy) / uLensWindow[i].zw;\n Footprint footprint = footprintOf(i, windowUv);\n bool isInWindow =\n all(greaterThanEqual(windowUv, vec2(0.0))) && all(lessThanEqual(windowUv, vec2(1.0)));\n vec3 texel = sampleLens(uLensTexture[i], footprint, sampling).rgb;\n LensSample result;\n result.theta = theta;\n result.isImaged = isKnown && theta < uLensHalfFov[i] && isInWindow;\n result.signal = result.isImaged ? exposureSignalOf(i, texel) : vec3(0.0);\n return result;\n}\n\n// What lens i shows in a body direction, read as the picture is.\nLensSample sampleLensAt(int i, vec3 dirBody) {\n return sampleLensWith(i, dirBody, uSampling);\n}\n";
3
+ //#endregion
4
+ export { lensSampling_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/lensTextures.glsl?raw
2
+ var lensTextures_default = "// Where each lens's image is: the decoded frames as textures, each lens's region of its frame,\n// and how a screen pixel reads them. Every program that reads a lens needs these.\nuniform int uLensCount;\nuniform vec4 uLensRegion[MAX_LENSES];\nuniform int uLensTexture[MAX_LENSES];\nuniform sampler2D uTexture0;\nuniform sampler2D uTexture1;\nuniform int uSampling;\n\n// The patch of a lens image one screen pixel covers: where it is read, and how far the next\n// pixel to the right and the next one down move the read, from the screen derivatives.\nstruct Footprint {\n vec2 uv;\n vec2 dx;\n vec2 dy;\n};\n\nvec2 texelSizeOf(int textureIndex) {\n return 1.0 / vec2(textureIndex == 0 ? textureSize(uTexture0, 0) : textureSize(uTexture1, 0));\n}\n\n// One bilinear tap of the base level, whatever the texture's filters: the seam meters read the\n// frames this way, where the pixel footprint means nothing.\nvec4 fetchBase(int textureIndex, vec2 uv) {\n return textureIndex == 0\n ? textureLod(uTexture0, uv, 0.0)\n : textureLod(uTexture1, uv, 0.0);\n}\n\n// One tap through the mip chain over a footprint.\nvec4 fetchFootprint(int textureIndex, vec2 uv, vec2 dx, vec2 dy) {\n return textureIndex == 0\n ? textureGrad(uTexture0, uv, dx, dy)\n : textureGrad(uTexture1, uv, dx, dy);\n}\n\n// Where a fraction of a lens's region is read. The derivatives are taken here, in every\n// fragment alike, before anything decides whether the pixel shows the lens at all; then the read\n// point is kept half a texel inside the region, so a neighbouring region never bleeds in.\nFootprint footprintOf(int i, vec2 regionUv) {\n vec2 uv = uLensRegion[i].xy + regionUv * uLensRegion[i].zw;\n Footprint footprint;\n footprint.dx = dFdx(uv);\n footprint.dy = dFdy(uv);\n vec2 inset = 0.5 * texelSizeOf(uLensTexture[i]);\n vec2 low = uLensRegion[i].xy + inset;\n vec2 high = uLensRegion[i].xy + uLensRegion[i].zw - inset;\n footprint.uv = clamp(uv, low, high);\n return footprint;\n}\n\n// Four taps on a rotated grid within the footprint, each over a quarter of it (Akenine-Möller\n// et al., Real-Time Rendering, 4th ed., section 5.4.1).\nconst vec2 GRID_OFFSETS[4] = vec2[4](\n vec2(-0.375, 0.125),\n vec2(0.125, 0.375),\n vec2(0.375, -0.125),\n vec2(-0.125, -0.375)\n);\n\nvec4 fetchSupersampled(int textureIndex, Footprint footprint) {\n vec4 sum = vec4(0.0);\n for (int tap = 0; tap < 4; tap++) {\n vec2 uv =\n footprint.uv + GRID_OFFSETS[tap].x * footprint.dx + GRID_OFFSETS[tap].y * footprint.dy;\n sum += fetchFootprint(textureIndex, uv, 0.5 * footprint.dx, 0.5 * footprint.dy);\n }\n return 0.25 * sum;\n}\n\nvec4 sampleLens(int textureIndex, Footprint footprint, int sampling) {\n if (sampling == SAMPLING_TRILINEAR) {\n return fetchFootprint(textureIndex, footprint.uv, footprint.dx, footprint.dy);\n }\n if (sampling == SAMPLING_SUPERSAMPLED) return fetchSupersampled(textureIndex, footprint);\n return fetchBase(textureIndex, footprint.uv);\n}\n";
3
+ //#endregion
4
+ export { lensTextures_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/rawLenses.frag.glsl?raw
2
+ var rawLenses_frag_default = "// The decoded lens images on their own, unstitched: each lens's region of its frame as the\n// decoder delivered it, brought to the display (ADR 0033), in the lens's screen area, with no\n// pose, stabilization or gain. Black around the areas. Every pixel reads every tile, and the area\n// picks one without a branch: a read inside a branch that some pixels of a 2x2 quad skip took a\n// far too coarse footprint on Apple GPUs (Chrome through Metal), a grey line along a tile's edge\n// wherever the edge fell inside a quad.\nin vec2 vNdc;\nout vec4 outColor;\n\nvoid main() {\n vec3 color = vec3(0.0);\n for (int i = 0; i < MAX_LENSES; i++) {\n if (i >= uLensCount) break;\n vec2 point = pointInArea(vNdc, uScreenArea[i]);\n Footprint footprint = footprintOf(i, point);\n vec3 sampled = toDisplay(i, sampleLens(uLensTexture[i], footprint, uSampling).rgb);\n color = mix(color, sampled, float(isInArea(point)));\n }\n outColor = vec4(color, 1.0);\n}\n";
3
+ //#endregion
4
+ export { rawLenses_frag_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/rectilinearRays.glsl?raw
2
+ var rectilinearRays_default = "// A rectilinear picture: the image plane scaled so that the horizontal field of view means what\n// the picture says.\nuniform float uPlaneHalfExtent;\nuniform float uPictureAspect;\n\n// Direction in view space (x right, y down, z forward) seen through a point of the picture, given\n// as fractions of the picture from its top-left corner.\nvec3 rayThroughPicture(vec2 point) {\n vec2 centred = point * 2.0 - 1.0;\n vec2 plane = vec2(centred.x * uPlaneHalfExtent, centred.y * uPlaneHalfExtent / uPictureAspect);\n return normalize(vec3(plane, 1.0));\n}\n";
3
+ //#endregion
4
+ export { rectilinearRays_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/screenAreas.glsl?raw
2
+ var screenAreas_default = "// Where on the viewport the picture goes: per area, x, y, width and height as fractions of the\n// viewport from its top-left corner.\nuniform vec4 uScreenArea[MAX_LENSES];\n\n// Where a pixel lies within an area, as fractions of the area from its top-left corner: outside\n// 0 to 1 when the pixel lies outside the area. Normalised device y points up, screen y down.\nvec2 pointInArea(vec2 ndc, vec4 area) {\n vec2 screen = vec2(ndc.x + 1.0, 1.0 - ndc.y) * 0.5;\n return (screen - area.xy) / area.zw;\n}\n\nbool isInArea(vec2 point) {\n return all(greaterThanEqual(point, vec2(0.0))) && all(lessThanEqual(point, vec2(1.0)));\n}\n";
3
+ //#endregion
4
+ export { screenAreas_default as default };
@@ -0,0 +1,4 @@
1
+ //#region ../../packages/adapters/three/src/shaders/stitch.frag.glsl?raw
2
+ var stitch_frag_default = "// The stitched sphere through the picture's rays: each lens's texel for the ray, read and weighted\n// across the feather band as the seam join says, and matched in exposure. Every pixel drawn\n// samples, even outside the picture's area (the renderer's scissor box holds the area and a\n// pixel around it), so the footprints' derivatives are defined; the area decides what shows.\nuniform mat3 uViewRotation;\nuniform mat3 uStabilization;\nuniform vec3 uLensGain[MAX_LENSES];\n\nin vec2 vNdc;\nout vec4 outColor;\n\nvoid main() {\n vec2 point = pointInArea(vNdc, uScreenArea[0]);\n vec3 dirView = rayThroughPicture(point);\n vec3 dirBody = uStabilization * (uViewRotation * dirView);\n vec3 sum = vec3(0.0);\n float weightSum = 0.0;\n float disparity = disparityAt(dirBody);\n vec2 feather = seamFeather(disparity);\n for (int i = 0; i < MAX_LENSES; i++) {\n if (i >= uLensCount) break;\n // A lens silenced through its gain (ADR 0012) leaves the blend altogether, so the other\n // lens fills the feather band alone and a lens-only render shows that lens as it is.\n if (all(equal(uLensGain[i], vec3(0.0)))) continue;\n LensSample lens = sampleLensAt(i, seamReadDirection(i, dirBody, disparity));\n if (!lens.isImaged) continue;\n // Weighed by the angle from the lens's axis where it is read, which a seam join may move.\n float weight = 1.0 - smoothstep(feather.x, feather.y, lens.theta);\n // Matched in exposure where exposure is a factor, then brought to the display (ADR 0033).\n sum += weight * shownOf(i, uLensGain[i] * lens.signal);\n weightSum += weight;\n }\n bool isShown = isInArea(point) && weightSum > 0.0;\n outColor = isShown ? vec4(sum / weightSum, 1.0) : vec4(0.0, 0.0, 0.0, 1.0);\n}\n";
3
+ //#endregion
4
+ export { stitch_frag_default as default };
@@ -0,0 +1,10 @@
1
+ import { Matrix3 } from "three";
2
+ //#region ../../packages/adapters/three/src/threeMatrix.ts
3
+ /**
4
+ * Row-major core matrix into a three matrix, whose `set` takes rows too.
5
+ */
6
+ function toThreeMatrix(m) {
7
+ return new Matrix3().set(...m);
8
+ }
9
+ //#endregion
10
+ export { toThreeMatrix };
@@ -0,0 +1,37 @@
1
+ import { GyroViewError } from "../../../core/src/shared/errors/GyroViewError.js";
2
+ import { WebGLRenderer } from "three";
3
+ //#region ../../packages/adapters/three/src/webglRenderer.ts
4
+ /**
5
+ * The WebGL 2 context a picture renderer draws on, wrapped by three, with every shader failure
6
+ * made an error.
7
+ */
8
+ function createRenderer(canvas, options) {
9
+ const context = canvas.getContext("webgl2", {
10
+ preserveDrawingBuffer: options.preserveDrawingBuffer ?? false,
11
+ antialias: false,
12
+ alpha: false,
13
+ depth: false,
14
+ stencil: false
15
+ });
16
+ if (!context) throw new GyroViewError("render-unavailable", "this browser has no WebGL2 context");
17
+ if (context.isContextLost()) throw new GyroViewError("render-unavailable", "the canvas's WebGL2 context has been lost");
18
+ const renderer = new WebGLRenderer({
19
+ canvas,
20
+ context
21
+ });
22
+ renderer.setPixelRatio(1);
23
+ renderer.debug.onShaderError = (gl, program, ...shaders) => {
24
+ rejectProgram(gl, program, shaders);
25
+ };
26
+ return renderer;
27
+ }
28
+ /**
29
+ * A shader that does not compile or link is a defect, not something to log and draw black over.
30
+ * A compile failure's reason is in its shader's log, a link failure's in the program's.
31
+ */
32
+ function rejectProgram(gl, program, shaders) {
33
+ const log = [gl.getProgramInfoLog(program), ...shaders.map((shader) => gl.getShaderInfoLog(shader))].filter(Boolean).join("\n");
34
+ throw new GyroViewError("render-unavailable", `a shader did not compile or link: ${log}`);
35
+ }
36
+ //#endregion
37
+ export { createRenderer };
@@ -0,0 +1,152 @@
1
+ import { GyroViewError, asGyroViewError, messageOf } from "../../../core/src/shared/errors/GyroViewError.js";
2
+ import { microseconds, microsecondsToSeconds, secondsToMicroseconds } from "../../../core/src/shared/units/time.js";
3
+ import { colorSpaceOf } from "./colorSpaceOf.js";
4
+ //#region ../../packages/adapters/webcodecs/src/WebCodecsVideoDecoderPort.ts
5
+ /**
6
+ * A hard `prefer-hardware` refuses codecs the browser could decode in software (H.264 recordings
7
+ * on machines without a hardware decoder); with no preference the browser still picks hardware
8
+ * when it has it (ADR 0010).
9
+ */
10
+ var HARDWARE_ACCELERATION = "no-preference";
11
+ /**
12
+ * VideoDecoderPort over the browser's WebCodecs `VideoDecoder`. Frames are exposed as
13
+ * `DecodedFrame<VideoFrame>`; the renderer uploads the handle to the GPU and the pipeline closes
14
+ * it afterwards.
15
+ */
16
+ var WebCodecsVideoDecoderPort = class {
17
+ /**
18
+ * A configuration WebCodecs finds malformed is one it does not support. A browser without
19
+ * WebCodecs refuses to answer, since no configuration would do.
20
+ */
21
+ async isSupported(configuration) {
22
+ if (typeof VideoDecoder === "undefined") throw webCodecsUnavailable();
23
+ try {
24
+ return (await VideoDecoder.isConfigSupported(this.toWebCodecsConfig(configuration))).supported === true;
25
+ } catch {
26
+ return false;
27
+ }
28
+ }
29
+ create(configuration, callbacks) {
30
+ try {
31
+ return Promise.resolve(this.configureDecoder(configuration, callbacks));
32
+ } catch (error) {
33
+ return Promise.reject(asGyroViewError(error, "codec-unsupported", "the decoder rejected its configuration"));
34
+ }
35
+ }
36
+ configureDecoder(configuration, callbacks) {
37
+ if (typeof VideoDecoder === "undefined") throw webCodecsUnavailable();
38
+ return new WebCodecsDecoderHandle(this.toWebCodecsConfig(configuration), callbacks);
39
+ }
40
+ toWebCodecsConfig(configuration) {
41
+ const { description } = configuration;
42
+ const colorSpace = colorSpaceOf(configuration.colour);
43
+ return {
44
+ codec: configuration.codec,
45
+ codedWidth: configuration.codedWidth,
46
+ codedHeight: configuration.codedHeight,
47
+ ...description && { description },
48
+ ...colorSpace && { colorSpace },
49
+ hardwareAcceleration: HARDWARE_ACCELERATION,
50
+ optimizeForLatency: false
51
+ };
52
+ }
53
+ };
54
+ /**
55
+ * One configured `VideoDecoder` for its whole life. The error it reported through its callback
56
+ * is kept, so later calls fail with the real cause instead of a bare "closed" state.
57
+ */
58
+ var WebCodecsDecoderHandle = class {
59
+ decoder;
60
+ failure;
61
+ constructor(config, callbacks) {
62
+ this.decoder = new VideoDecoder({
63
+ output: (frame) => {
64
+ callbacks.onFrame(wrapFrame(frame));
65
+ },
66
+ error: (error) => {
67
+ this.failure ??= new GyroViewError("decode", `video decoder failed: ${error.message}`, { cause: error });
68
+ callbacks.onError(this.failure);
69
+ }
70
+ });
71
+ try {
72
+ this.decoder.configure(config);
73
+ } catch (error) {
74
+ this.decoder.close();
75
+ throw error;
76
+ }
77
+ }
78
+ get pendingCount() {
79
+ return this.decoder.decodeQueueSize;
80
+ }
81
+ /**
82
+ * WebCodecs throws platform exceptions for a packet it refuses (a delta frame first, a closed
83
+ * decoder); they cross the port as `decode` failures, as the fake's do.
84
+ */
85
+ decode(packet) {
86
+ if (this.failure) throw this.failure;
87
+ try {
88
+ this.decoder.decode(chunkOf(packet));
89
+ } catch (error) {
90
+ throw new GyroViewError("decode", `the decoder refused a packet: ${messageOf(error)}`, { cause: error });
91
+ }
92
+ }
93
+ /**
94
+ * Resolves on the decoder's `dequeue` events until fewer than `limit` packets are pending, or
95
+ * at once when the decoder is no longer configured.
96
+ */
97
+ waitForPendingBelow(limit) {
98
+ return this.decoder.decodeQueueSize < limit ? Promise.resolve() : new Promise((resolve) => {
99
+ const check = () => {
100
+ if (this.decoder.decodeQueueSize >= limit && this.decoder.state === "configured") return;
101
+ this.decoder.removeEventListener("dequeue", check);
102
+ resolve();
103
+ };
104
+ this.decoder.addEventListener("dequeue", check);
105
+ });
106
+ }
107
+ async flush() {
108
+ if (this.decoder.state !== "configured") throw this.failure ?? new GyroViewError("decode", "flush on a closed decoder");
109
+ try {
110
+ await this.decoder.flush();
111
+ } catch (error) {
112
+ throw this.failure ?? new GyroViewError("decode", "the decoder could not be flushed", { cause: error });
113
+ }
114
+ }
115
+ close() {
116
+ if (this.decoder.state !== "closed") this.decoder.close();
117
+ }
118
+ };
119
+ /**
120
+ * Browsers expose WebCodecs only in secure contexts, so a page served over plain HTTP is the
121
+ * likelier cause than an old browser, and the one its developer can fix.
122
+ */
123
+ function webCodecsUnavailable() {
124
+ const reason = globalThis.isSecureContext ? "this browser has no WebCodecs VideoDecoder" : "WebCodecs exists only in secure contexts (HTTPS), and this page is not one";
125
+ return new GyroViewError("webcodecs-unavailable", reason);
126
+ }
127
+ function chunkOf(packet) {
128
+ return new EncodedVideoChunk({
129
+ type: packet.isKeyFrame ? "key" : "delta",
130
+ timestamp: wholeMicrosecondsOf(packet.timestamp),
131
+ duration: wholeMicrosecondsOf(packet.duration),
132
+ data: packet.data
133
+ });
134
+ }
135
+ /**
136
+ * The nearest whole microsecond: a chunk's times are integers, which WebIDL would otherwise reach
137
+ * by truncation, a microsecond early for a time like 0.8 s that floating point holds as 0.7999….
138
+ */
139
+ function wholeMicrosecondsOf(time) {
140
+ return Math.round(secondsToMicroseconds(time));
141
+ }
142
+ function wrapFrame(frame) {
143
+ return {
144
+ timestamp: microsecondsToSeconds(microseconds(frame.timestamp)),
145
+ handle: frame,
146
+ close: () => {
147
+ frame.close();
148
+ }
149
+ };
150
+ }
151
+ //#endregion
152
+ export { WebCodecsVideoDecoderPort };
@@ -0,0 +1,32 @@
1
+ //#region ../../packages/adapters/webcodecs/src/colorSpaceOf.ts
2
+ /**
3
+ * A track's colour as a decoder configuration's colour space: every value the track names, none
4
+ * it leaves unspecified. WebCodecs gives the frames the configured colour space whole ("Output
5
+ * VideoFrames"), so it says all the bitstream says, and the frames carry the colour the display
6
+ * conversion was chosen for (ADR 0033). An engine whose WebCodecs does not know one of the values
7
+ * would refuse the whole configuration, so it is told the range alone, as before. Undefined for a
8
+ * track that names nothing.
9
+ */
10
+ function colorSpaceOf(colour) {
11
+ const range = colour.range === "unspecified" ? void 0 : { fullRange: colour.range === "full" };
12
+ const named = {
13
+ ...colour.primaries !== "unspecified" && { primaries: colour.primaries },
14
+ ...colour.transfer !== "unspecified" && { transfer: colour.transfer },
15
+ ...colour.matrix !== "unspecified" && { matrix: colour.matrix },
16
+ ...range
17
+ };
18
+ return Object.keys(named).length === 0 ? void 0 : understoodHere(named) ?? range;
19
+ }
20
+ /**
21
+ * The colour space as this engine reads it, undefined where it names a value the engine does not
22
+ * know.
23
+ */
24
+ function understoodHere(colorSpace) {
25
+ try {
26
+ return new VideoColorSpace(colorSpace).toJSON();
27
+ } catch {
28
+ return;
29
+ }
30
+ }
31
+ //#endregion
32
+ export { colorSpaceOf };
@@ -0,0 +1,97 @@
1
+ import { ensureInvariant } from "../../shared/errors/GyroViewError.js";
2
+ import { ByteRange } from "../../shared/binary/ByteRange.js";
3
+ import { ByteRangeSet } from "../../shared/binary/ByteRangeSet.js";
4
+ //#region ../../packages/core/src/application/download/BlockStore.ts
5
+ var FillingBlock = class {
6
+ range;
7
+ bytes;
8
+ filled = 0;
9
+ /**
10
+ * No more of its bytes will come: all have, or its range was given up.
11
+ */
12
+ isComplete = false;
13
+ constructor(range, bytes) {
14
+ this.range = range;
15
+ this.bytes = bytes;
16
+ }
17
+ get filledRange() {
18
+ return ByteRange.of(this.range.offset, this.filled);
19
+ }
20
+ };
21
+ /**
22
+ * The bytes a download holds, a block for each range it asked for. A range within one block is
23
+ * handed out as a view of it; one across blocks is copied out of them.
24
+ */
25
+ var BlockStore = class {
26
+ blocks = [];
27
+ get held() {
28
+ return ByteRangeSet.of(this.blocks.map((block) => block.filledRange));
29
+ }
30
+ /**
31
+ * The memory the blocks take, whether their bytes have come or not.
32
+ */
33
+ get allocatedBytes() {
34
+ return this.blocks.reduce((total, block) => total + block.bytes.byteLength, 0);
35
+ }
36
+ allocate(range) {
37
+ const block = new FillingBlock(range, new Uint8Array(range.length));
38
+ this.blocks.push(block);
39
+ return block;
40
+ }
41
+ write(block, chunk) {
42
+ const filling = this.fillingOf(block);
43
+ filling.bytes.set(chunk, filling.filled);
44
+ filling.filled += chunk.byteLength;
45
+ }
46
+ /**
47
+ * Every byte of the block has come.
48
+ */
49
+ complete(block) {
50
+ this.fillingOf(block).isComplete = true;
51
+ }
52
+ /**
53
+ * Keeps of a block only what has come, as when its range is given up; a block that got
54
+ * nothing goes.
55
+ */
56
+ trim(block) {
57
+ const filling = this.fillingOf(block);
58
+ filling.isComplete = true;
59
+ filling.bytes = filling.bytes.slice(0, filling.filled);
60
+ this.blocks = this.blocks.filter((held) => held.bytes.byteLength > 0);
61
+ }
62
+ /**
63
+ * The bytes of `range`, if every one of them has come.
64
+ */
65
+ bytesOf(range) {
66
+ const within = this.blocks.find((block) => block.filledRange.contains(range));
67
+ if (within) return viewOf(within, range);
68
+ return this.held.covers(range) ? this.copyOf(range) : void 0;
69
+ }
70
+ /**
71
+ * Lets go of the complete blocks whose every byte `released` holds; a block still filling is
72
+ * its transfer's until it ends.
73
+ */
74
+ release(released) {
75
+ this.blocks = this.blocks.filter((block) => !block.isComplete || !released.covers(block.filledRange));
76
+ }
77
+ fillingOf(block) {
78
+ const filling = this.blocks.find((held) => held === block);
79
+ ensureInvariant(filling !== void 0, "the block is not one this store holds");
80
+ return filling;
81
+ }
82
+ copyOf(range) {
83
+ const copy = new Uint8Array(range.length);
84
+ for (const block of this.blocks) {
85
+ const start = Math.max(block.range.offset, range.offset);
86
+ const end = Math.min(block.filledRange.end, range.end);
87
+ if (start < end) copy.set(block.bytes.subarray(start - block.range.offset, end - block.range.offset), start - range.offset);
88
+ }
89
+ return copy;
90
+ }
91
+ };
92
+ function viewOf(block, range) {
93
+ const start = range.offset - block.range.offset;
94
+ return block.bytes.subarray(start, start + range.length);
95
+ }
96
+ //#endregion
97
+ export { BlockStore };
@@ -0,0 +1,50 @@
1
+ import { Ending, ITERATION_END } from "../../shared/async/iteration.js";
2
+ //#region ../../packages/core/src/application/download/DownloadedAudioSamples.ts
3
+ /**
4
+ * A sound track's samples read through the file's download, within the picture's reach.
5
+ */
6
+ var DownloadedAudioSamples = class {
7
+ parts;
8
+ constructor(parts) {
9
+ this.parts = parts;
10
+ }
11
+ get duration() {
12
+ return this.parts.track.end;
13
+ }
14
+ samplesFrom(time) {
15
+ const { download, track } = this.parts;
16
+ return { [Symbol.asyncIterator]: () => new SampleReading(track, download.openCursor(track, track.sampleShownAt(time) ?? 0, time)) };
17
+ }
18
+ };
19
+ /**
20
+ * One iteration over the samples; each is copied out of what was downloaded, so the samples a
21
+ * media pipeline keeps do not keep the download's blocks alive.
22
+ */
23
+ var SampleReading = class {
24
+ track;
25
+ cursor;
26
+ ending = new Ending();
27
+ constructor(track, cursor) {
28
+ this.track = track;
29
+ this.cursor = cursor;
30
+ }
31
+ async next() {
32
+ const read = await this.cursor.nextSample();
33
+ if (!read || this.ending.hasEnded()) return ITERATION_END;
34
+ return {
35
+ done: false,
36
+ value: {
37
+ timestamp: this.track.timestampOf(read.sample),
38
+ duration: this.track.durationOf(read.sample),
39
+ data: Uint8Array.from(read.bytes)
40
+ }
41
+ };
42
+ }
43
+ return() {
44
+ this.ending.end();
45
+ this.cursor.close();
46
+ return Promise.resolve(ITERATION_END);
47
+ }
48
+ };
49
+ //#endregion
50
+ export { DownloadedAudioSamples };