@lampdotdev/lamp 0.0.0-stage → 0.36.2-nightly.16
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/LICENSE +21 -0
- package/README.md +397 -2
- package/Resources/Devices/roku.json +410 -0
- package/Resources/Devices/xbox-one.json +367 -0
- package/Resources/GameKit/NOTICE.md +63 -0
- package/Resources/GameKit/apple/LampPage.swift +1813 -0
- package/Resources/GameKit/apple/LampPlayer.swift +46 -0
- package/Resources/GameKit/apple/LampWebApp.swift +63 -0
- package/Resources/GameKit/apple/LampWebGame.swift +87 -0
- package/Resources/GameKit/apple/Native.swift +12 -0
- package/Resources/GameKit/build.sh +55 -0
- package/Resources/GameKit/lamp_game.h +116 -0
- package/Resources/GameKit/lamp_host.h +19 -0
- package/Resources/GameKit/lamp_kit.cpp +61 -0
- package/Resources/GameKit/lamp_sound.cpp +455 -0
- package/Resources/GameKit/lamp_xbox.cpp +374 -0
- package/Resources/GameKit/libraries/HandmadeMath.h +3940 -0
- package/Resources/GameKit/libraries/cgltf.h +7240 -0
- package/Resources/GameKit/libraries/dr_mp3.h +5430 -0
- package/Resources/GameKit/libraries/dr_wav.h +9209 -0
- package/Resources/GameKit/libraries/sokol_debugtext.h +4754 -0
- package/Resources/GameKit/libraries/sokol_gfx.h +29558 -0
- package/Resources/GameKit/libraries/sokol_gl.h +4538 -0
- package/Resources/GameKit/libraries/sokol_log.h +335 -0
- package/Resources/GameKit/libraries/sokol_shape.h +1531 -0
- package/Resources/GameKit/libraries/stb_image.h +7988 -0
- package/Resources/GameKit/libraries/stb_vorbis.c +5584 -0
- package/Resources/GameKit/page/lamp-live.js +672 -0
- package/Resources/GameKit/scaffold/Game/game.cpp +142 -0
- package/Resources/GameKit/scaffold/Game/scene.glsl +49 -0
- package/Resources/GameKit/scaffold-web/Web/game.js +31 -0
- package/Resources/GameKit/scaffold-web/Web/index.html +13 -0
- package/Resources/GameKit/scaffold-web/Web/making.js +33 -0
- package/Resources/GameKit/scaffold-web/Web/world.js +33 -0
- package/Resources/GameKit/web/lamp-game.js +3042 -0
- package/Resources/GameKit/web/lamp-phaser.js +128 -0
- package/Resources/WebHost/App.exe +0 -0
- package/Resources/WebHost/Microsoft.Web.WebView2.Core.dll +0 -0
- package/Resources/WebHost/WebView2-LICENSE.txt +27 -0
- package/Resources/WebHost/lamp_controllers.h +1506 -0
- package/Resources/WebHost/lamp_web_host.cpp +1173 -0
- package/Resources/WebLibraries/earlier.txt +318 -0
- package/Resources/WebLibraries/phaser/LICENSE.md +20 -0
- package/Resources/WebLibraries/phaser/NOTICE.md +2 -0
- package/Resources/WebLibraries/phaser/phaser.esm.min.js +1 -0
- package/Resources/WebLibraries/qrcode/LICENSE +21 -0
- package/Resources/WebLibraries/qrcode/NOTICE.md +4 -0
- package/Resources/WebLibraries/qrcode/qrcode.js +2297 -0
- package/Resources/WebLibraries/rapier/LICENSE +201 -0
- package/Resources/WebLibraries/rapier/NOTICE.md +3 -0
- package/Resources/WebLibraries/rapier/rapier.js +2 -0
- package/Resources/WebLibraries/three/LICENSE +21 -0
- package/Resources/WebLibraries/three/NOTICE.md +4 -0
- package/Resources/WebLibraries/three/addons/animation/AnimationClipCreator.js +168 -0
- package/Resources/WebLibraries/three/addons/animation/CCDIKSolver.js +607 -0
- package/Resources/WebLibraries/three/addons/controls/ArcballControls.js +3543 -0
- package/Resources/WebLibraries/three/addons/controls/DragControls.js +452 -0
- package/Resources/WebLibraries/three/addons/controls/FirstPersonControls.js +512 -0
- package/Resources/WebLibraries/three/addons/controls/FlyControls.js +384 -0
- package/Resources/WebLibraries/three/addons/controls/MapControls.js +116 -0
- package/Resources/WebLibraries/three/addons/controls/OrbitControls.js +1985 -0
- package/Resources/WebLibraries/three/addons/controls/PointerLockControls.js +264 -0
- package/Resources/WebLibraries/three/addons/controls/TrackballControls.js +1106 -0
- package/Resources/WebLibraries/three/addons/controls/TransformControls.js +2003 -0
- package/Resources/WebLibraries/three/addons/curves/CurveExtras.js +694 -0
- package/Resources/WebLibraries/three/addons/curves/NURBSCurve.js +169 -0
- package/Resources/WebLibraries/three/addons/curves/NURBSSurface.js +98 -0
- package/Resources/WebLibraries/three/addons/curves/NURBSUtils.js +532 -0
- package/Resources/WebLibraries/three/addons/curves/NURBSVolume.js +82 -0
- package/Resources/WebLibraries/three/addons/effects/AnaglyphEffect.js +274 -0
- package/Resources/WebLibraries/three/addons/effects/AsciiEffect.js +323 -0
- package/Resources/WebLibraries/three/addons/effects/OutlineEffect.js +489 -0
- package/Resources/WebLibraries/three/addons/effects/ParallaxBarrierEffect.js +155 -0
- package/Resources/WebLibraries/three/addons/effects/StereoEffect.js +91 -0
- package/Resources/WebLibraries/three/addons/environments/ColorEnvironment.js +59 -0
- package/Resources/WebLibraries/three/addons/environments/DebugEnvironment.js +102 -0
- package/Resources/WebLibraries/three/addons/environments/RoomEnvironment.js +185 -0
- package/Resources/WebLibraries/three/addons/geometries/BoxLineGeometry.js +92 -0
- package/Resources/WebLibraries/three/addons/geometries/ConvexGeometry.js +72 -0
- package/Resources/WebLibraries/three/addons/geometries/DecalGeometry.js +420 -0
- package/Resources/WebLibraries/three/addons/geometries/LoftGeometry.js +355 -0
- package/Resources/WebLibraries/three/addons/geometries/ParametricFunctions.js +100 -0
- package/Resources/WebLibraries/three/addons/geometries/ParametricGeometry.js +172 -0
- package/Resources/WebLibraries/three/addons/geometries/RoundedBoxGeometry.js +216 -0
- package/Resources/WebLibraries/three/addons/geometries/TeapotGeometry.js +689 -0
- package/Resources/WebLibraries/three/addons/geometries/TextGeometry.js +102 -0
- package/Resources/WebLibraries/three/addons/helpers/AnimationPathHelper.js +302 -0
- package/Resources/WebLibraries/three/addons/helpers/LightProbeGridHelper.js +166 -0
- package/Resources/WebLibraries/three/addons/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/Resources/WebLibraries/three/addons/helpers/LightProbeHelper.js +166 -0
- package/Resources/WebLibraries/three/addons/helpers/LightProbeHelperGPU.js +102 -0
- package/Resources/WebLibraries/three/addons/helpers/OctreeHelper.js +109 -0
- package/Resources/WebLibraries/three/addons/helpers/PositionalAudioHelper.js +169 -0
- package/Resources/WebLibraries/three/addons/helpers/RapierHelper.js +59 -0
- package/Resources/WebLibraries/three/addons/helpers/RectAreaLightHelper.js +118 -0
- package/Resources/WebLibraries/three/addons/helpers/TextureHelper.js +265 -0
- package/Resources/WebLibraries/three/addons/helpers/TextureHelperGPU.js +214 -0
- package/Resources/WebLibraries/three/addons/helpers/VertexNormalsHelper.js +155 -0
- package/Resources/WebLibraries/three/addons/helpers/VertexTangentsHelper.js +133 -0
- package/Resources/WebLibraries/three/addons/helpers/ViewHelper.js +529 -0
- package/Resources/WebLibraries/three/addons/interactive/HTMLMesh.js +617 -0
- package/Resources/WebLibraries/three/addons/interactive/InteractiveGroup.js +224 -0
- package/Resources/WebLibraries/three/addons/interactive/SelectionBox.js +324 -0
- package/Resources/WebLibraries/three/addons/interactive/SelectionHelper.js +150 -0
- package/Resources/WebLibraries/three/addons/libs/fflate.module.js +2699 -0
- package/Resources/WebLibraries/three/addons/libs/lil-gui.module.min.js +8 -0
- package/Resources/WebLibraries/three/addons/libs/meshopt_decoder.module.js +196 -0
- package/Resources/WebLibraries/three/addons/libs/potpack.module.js +125 -0
- package/Resources/WebLibraries/three/addons/libs/stats.module.js +167 -0
- package/Resources/WebLibraries/three/addons/libs/tween.module.js +876 -0
- package/Resources/WebLibraries/three/addons/lighting/ClusteredLighting.js +153 -0
- package/Resources/WebLibraries/three/addons/lighting/DynamicLighting.js +82 -0
- package/Resources/WebLibraries/three/addons/lighting/LightMapper.js +295 -0
- package/Resources/WebLibraries/three/addons/lighting/LightProbeGrid.js +923 -0
- package/Resources/WebLibraries/three/addons/lighting/LightProbeGridUtils.js +107 -0
- package/Resources/WebLibraries/three/addons/lighting/LightProbeGridWebGL.js +846 -0
- package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGIConeTracer.js +243 -0
- package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGIIrradiance.js +43 -0
- package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGINode.js +617 -0
- package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGISceneCollector.js +793 -0
- package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGIVolume.js +1440 -0
- package/Resources/WebLibraries/three/addons/lights/LightProbeGenerator.js +337 -0
- package/Resources/WebLibraries/three/addons/lights/RectAreaLightTexturesLib.js +127 -0
- package/Resources/WebLibraries/three/addons/lights/RectAreaLightUniformsLib.js +40 -0
- package/Resources/WebLibraries/three/addons/lights/SunLight.js +100 -0
- package/Resources/WebLibraries/three/addons/lights/SunLightNode.js +56 -0
- package/Resources/WebLibraries/three/addons/lights/SunLightShadow.js +319 -0
- package/Resources/WebLibraries/three/addons/lights/SunShadowNode.js +312 -0
- package/Resources/WebLibraries/three/addons/lines/Line2.js +56 -0
- package/Resources/WebLibraries/three/addons/lines/LineGeometry.js +157 -0
- package/Resources/WebLibraries/three/addons/lines/LineMaterial.js +742 -0
- package/Resources/WebLibraries/three/addons/lines/LineSegments2.js +434 -0
- package/Resources/WebLibraries/three/addons/lines/LineSegmentsGeometry.js +298 -0
- package/Resources/WebLibraries/three/addons/lines/Wireframe.js +108 -0
- package/Resources/WebLibraries/three/addons/lines/WireframeGeometry2.js +49 -0
- package/Resources/WebLibraries/three/addons/lines/webgpu/Line2.js +46 -0
- package/Resources/WebLibraries/three/addons/lines/webgpu/LineSegments2.js +419 -0
- package/Resources/WebLibraries/three/addons/lines/webgpu/Wireframe.js +86 -0
- package/Resources/WebLibraries/three/addons/loaders/EXRLoader.js +3411 -0
- package/Resources/WebLibraries/three/addons/loaders/FBXLoader.js +4660 -0
- package/Resources/WebLibraries/three/addons/loaders/FontLoader.js +262 -0
- package/Resources/WebLibraries/three/addons/loaders/GLTFLoader.js +5006 -0
- package/Resources/WebLibraries/three/addons/loaders/HDRLoader.js +463 -0
- package/Resources/WebLibraries/three/addons/loaders/MTLLoader.js +601 -0
- package/Resources/WebLibraries/three/addons/loaders/OBJLoader.js +961 -0
- package/Resources/WebLibraries/three/addons/loaders/PLYLoader.js +992 -0
- package/Resources/WebLibraries/three/addons/loaders/RGBELoader.js +18 -0
- package/Resources/WebLibraries/three/addons/loaders/STLLoader.js +423 -0
- package/Resources/WebLibraries/three/addons/loaders/SVGLoader.js +3297 -0
- package/Resources/WebLibraries/three/addons/loaders/TGALoader.js +539 -0
- package/Resources/WebLibraries/three/addons/loaders/UltraHDRLoader.js +757 -0
- package/Resources/WebLibraries/three/addons/math/Capsule.js +159 -0
- package/Resources/WebLibraries/three/addons/math/ColorConverter.js +62 -0
- package/Resources/WebLibraries/three/addons/math/ColorSpaces.js +147 -0
- package/Resources/WebLibraries/three/addons/math/ConvexHull.js +1695 -0
- package/Resources/WebLibraries/three/addons/math/ImprovedNoise.js +88 -0
- package/Resources/WebLibraries/three/addons/math/Lut.js +317 -0
- package/Resources/WebLibraries/three/addons/math/MeshSurfaceSampler.js +315 -0
- package/Resources/WebLibraries/three/addons/math/OBB.js +535 -0
- package/Resources/WebLibraries/three/addons/math/Octree.js +825 -0
- package/Resources/WebLibraries/three/addons/math/SimplexNoise.js +470 -0
- package/Resources/WebLibraries/three/addons/misc/ConvexObjectBreaker.js +539 -0
- package/Resources/WebLibraries/three/addons/misc/GPUComputationRenderer.js +508 -0
- package/Resources/WebLibraries/three/addons/misc/Gyroscope.js +78 -0
- package/Resources/WebLibraries/three/addons/misc/MorphAnimMesh.js +119 -0
- package/Resources/WebLibraries/three/addons/misc/MorphBlendMesh.js +425 -0
- package/Resources/WebLibraries/three/addons/misc/ProgressiveLightMap.js +370 -0
- package/Resources/WebLibraries/three/addons/misc/ProgressiveLightMapGPU.js +322 -0
- package/Resources/WebLibraries/three/addons/misc/RollerCoaster.js +661 -0
- package/Resources/WebLibraries/three/addons/misc/Sculptor.js +1679 -0
- package/Resources/WebLibraries/three/addons/misc/SculptorMesh.js +1504 -0
- package/Resources/WebLibraries/three/addons/misc/SculptorTools.js +1180 -0
- package/Resources/WebLibraries/three/addons/misc/SculptorUtils.js +345 -0
- package/Resources/WebLibraries/three/addons/misc/TileCreasedNormalsPlugin.js +270 -0
- package/Resources/WebLibraries/three/addons/misc/TubePainter.js +611 -0
- package/Resources/WebLibraries/three/addons/misc/Volume.js +520 -0
- package/Resources/WebLibraries/three/addons/misc/VolumeSlice.js +275 -0
- package/Resources/WebLibraries/three/addons/modifiers/CurveModifier.js +374 -0
- package/Resources/WebLibraries/three/addons/modifiers/CurveModifierGPU.js +256 -0
- package/Resources/WebLibraries/three/addons/modifiers/EdgeSplitModifier.js +299 -0
- package/Resources/WebLibraries/three/addons/modifiers/TessellateModifier.js +340 -0
- package/Resources/WebLibraries/three/addons/objects/GroundedSkybox.js +69 -0
- package/Resources/WebLibraries/three/addons/objects/Lensflare.js +489 -0
- package/Resources/WebLibraries/three/addons/objects/LensflareMesh.js +376 -0
- package/Resources/WebLibraries/three/addons/objects/MarchingCubes.js +1261 -0
- package/Resources/WebLibraries/three/addons/objects/Reflector.js +390 -0
- package/Resources/WebLibraries/three/addons/objects/ReflectorForSSRPass.js +393 -0
- package/Resources/WebLibraries/three/addons/objects/Refractor.js +389 -0
- package/Resources/WebLibraries/three/addons/objects/ShadowMesh.js +130 -0
- package/Resources/WebLibraries/three/addons/objects/Sky.js +342 -0
- package/Resources/WebLibraries/three/addons/objects/SkyMesh.js +403 -0
- package/Resources/WebLibraries/three/addons/objects/Water.js +374 -0
- package/Resources/WebLibraries/three/addons/objects/Water2.js +403 -0
- package/Resources/WebLibraries/three/addons/objects/Water2Mesh.js +199 -0
- package/Resources/WebLibraries/three/addons/objects/WaterMesh.js +194 -0
- package/Resources/WebLibraries/three/addons/postprocessing/AfterimagePass.js +187 -0
- package/Resources/WebLibraries/three/addons/postprocessing/BloomPass.js +274 -0
- package/Resources/WebLibraries/three/addons/postprocessing/BokehPass.js +218 -0
- package/Resources/WebLibraries/three/addons/postprocessing/ClearPass.js +97 -0
- package/Resources/WebLibraries/three/addons/postprocessing/CubeTexturePass.js +146 -0
- package/Resources/WebLibraries/three/addons/postprocessing/DotScreenPass.js +114 -0
- package/Resources/WebLibraries/three/addons/postprocessing/EffectComposer.js +365 -0
- package/Resources/WebLibraries/three/addons/postprocessing/FXAAPass.js +40 -0
- package/Resources/WebLibraries/three/addons/postprocessing/FilmPass.js +113 -0
- package/Resources/WebLibraries/three/addons/postprocessing/GTAOPass.js +735 -0
- package/Resources/WebLibraries/three/addons/postprocessing/GlitchPass.js +177 -0
- package/Resources/WebLibraries/three/addons/postprocessing/HalftonePass.js +134 -0
- package/Resources/WebLibraries/three/addons/postprocessing/LUTPass.js +138 -0
- package/Resources/WebLibraries/three/addons/postprocessing/MaskPass.js +195 -0
- package/Resources/WebLibraries/three/addons/postprocessing/OutlinePass.js +776 -0
- package/Resources/WebLibraries/three/addons/postprocessing/OutputPass.js +148 -0
- package/Resources/WebLibraries/three/addons/postprocessing/Pass.js +191 -0
- package/Resources/WebLibraries/three/addons/postprocessing/RenderPass.js +193 -0
- package/Resources/WebLibraries/three/addons/postprocessing/RenderPixelatedPass.js +314 -0
- package/Resources/WebLibraries/three/addons/postprocessing/RenderTransitionPass.js +267 -0
- package/Resources/WebLibraries/three/addons/postprocessing/SAOPass.js +407 -0
- package/Resources/WebLibraries/three/addons/postprocessing/SMAAPass.js +230 -0
- package/Resources/WebLibraries/three/addons/postprocessing/SSAARenderPass.js +313 -0
- package/Resources/WebLibraries/three/addons/postprocessing/SSAOPass.js +527 -0
- package/Resources/WebLibraries/three/addons/postprocessing/SSRPass.js +858 -0
- package/Resources/WebLibraries/three/addons/postprocessing/SavePass.js +132 -0
- package/Resources/WebLibraries/three/addons/postprocessing/ShaderPass.js +135 -0
- package/Resources/WebLibraries/three/addons/postprocessing/TAARenderPass.js +243 -0
- package/Resources/WebLibraries/three/addons/postprocessing/TexturePass.js +131 -0
- package/Resources/WebLibraries/three/addons/postprocessing/UnrealBloomPass.js +541 -0
- package/Resources/WebLibraries/three/addons/shaders/ACESFilmicToneMappingShader.js +96 -0
- package/Resources/WebLibraries/three/addons/shaders/AfterimageShader.js +63 -0
- package/Resources/WebLibraries/three/addons/shaders/BasicShader.js +36 -0
- package/Resources/WebLibraries/three/addons/shaders/BleachBypassShader.js +68 -0
- package/Resources/WebLibraries/three/addons/shaders/BlendShader.js +56 -0
- package/Resources/WebLibraries/three/addons/shaders/BokehShader.js +151 -0
- package/Resources/WebLibraries/three/addons/shaders/BokehShader2.js +404 -0
- package/Resources/WebLibraries/three/addons/shaders/BrightnessContrastShader.js +62 -0
- package/Resources/WebLibraries/three/addons/shaders/ColorCorrectionShader.js +59 -0
- package/Resources/WebLibraries/three/addons/shaders/ColorifyShader.js +57 -0
- package/Resources/WebLibraries/three/addons/shaders/ConvolutionShader.js +74 -0
- package/Resources/WebLibraries/three/addons/shaders/CopyShader.js +52 -0
- package/Resources/WebLibraries/three/addons/shaders/DOFMipMapShader.js +63 -0
- package/Resources/WebLibraries/three/addons/shaders/DepthLimitedBlurShader.js +183 -0
- package/Resources/WebLibraries/three/addons/shaders/DigitalGlitch.js +104 -0
- package/Resources/WebLibraries/three/addons/shaders/DotScreenShader.js +75 -0
- package/Resources/WebLibraries/three/addons/shaders/ExposureShader.js +51 -0
- package/Resources/WebLibraries/three/addons/shaders/FXAAShader.js +298 -0
- package/Resources/WebLibraries/three/addons/shaders/FilmShader.js +73 -0
- package/Resources/WebLibraries/three/addons/shaders/FocusShader.js +94 -0
- package/Resources/WebLibraries/three/addons/shaders/FreiChenShader.js +103 -0
- package/Resources/WebLibraries/three/addons/shaders/GTAOShader.js +437 -0
- package/Resources/WebLibraries/three/addons/shaders/GammaCorrectionShader.js +52 -0
- package/Resources/WebLibraries/three/addons/shaders/HalftoneShader.js +332 -0
- package/Resources/WebLibraries/three/addons/shaders/HorizontalBlurShader.js +68 -0
- package/Resources/WebLibraries/three/addons/shaders/HorizontalTiltShiftShader.js +70 -0
- package/Resources/WebLibraries/three/addons/shaders/HueSaturationShader.js +74 -0
- package/Resources/WebLibraries/three/addons/shaders/KaleidoShader.js +65 -0
- package/Resources/WebLibraries/three/addons/shaders/LuminosityHighPassShader.js +68 -0
- package/Resources/WebLibraries/three/addons/shaders/LuminosityShader.js +54 -0
- package/Resources/WebLibraries/three/addons/shaders/MirrorShader.js +62 -0
- package/Resources/WebLibraries/three/addons/shaders/NormalMapShader.js +60 -0
- package/Resources/WebLibraries/three/addons/shaders/OutputShader.js +103 -0
- package/Resources/WebLibraries/three/addons/shaders/PoissonDenoiseShader.js +230 -0
- package/Resources/WebLibraries/three/addons/shaders/RGBShiftShader.js +61 -0
- package/Resources/WebLibraries/three/addons/shaders/SAOShader.js +201 -0
- package/Resources/WebLibraries/three/addons/shaders/SMAAShader.js +489 -0
- package/Resources/WebLibraries/three/addons/shaders/SSAOShader.js +331 -0
- package/Resources/WebLibraries/three/addons/shaders/SSRShader.js +396 -0
- package/Resources/WebLibraries/three/addons/shaders/SepiaShader.js +57 -0
- package/Resources/WebLibraries/three/addons/shaders/SobelOperatorShader.js +98 -0
- package/Resources/WebLibraries/three/addons/shaders/SubsurfaceScatteringShader.js +95 -0
- package/Resources/WebLibraries/three/addons/shaders/TechnicolorShader.js +51 -0
- package/Resources/WebLibraries/three/addons/shaders/ToonShader.js +349 -0
- package/Resources/WebLibraries/three/addons/shaders/TriangleBlurShader.js +79 -0
- package/Resources/WebLibraries/three/addons/shaders/UnpackDepthRGBAShader.js +60 -0
- package/Resources/WebLibraries/three/addons/shaders/VelocityShader.js +137 -0
- package/Resources/WebLibraries/three/addons/shaders/VerticalBlurShader.js +66 -0
- package/Resources/WebLibraries/three/addons/shaders/VerticalTiltShiftShader.js +70 -0
- package/Resources/WebLibraries/three/addons/shaders/VignetteShader.js +56 -0
- package/Resources/WebLibraries/three/addons/shaders/VolumeShader.js +285 -0
- package/Resources/WebLibraries/three/addons/shaders/WaterRefractionShader.js +106 -0
- package/Resources/WebLibraries/three/addons/textures/FlakesTexture.js +54 -0
- package/Resources/WebLibraries/three/addons/tsl/WebGLNodesHandler.js +607 -0
- package/Resources/WebLibraries/three/addons/tsl/display/AfterImageNode.js +256 -0
- package/Resources/WebLibraries/three/addons/tsl/display/AnaglyphPassNode.js +550 -0
- package/Resources/WebLibraries/three/addons/tsl/display/BilateralBlurNode.js +377 -0
- package/Resources/WebLibraries/three/addons/tsl/display/BleachBypass.js +33 -0
- package/Resources/WebLibraries/three/addons/tsl/display/BloomNode.js +599 -0
- package/Resources/WebLibraries/three/addons/tsl/display/CRT.js +150 -0
- package/Resources/WebLibraries/three/addons/tsl/display/ChromaticAberrationNode.js +163 -0
- package/Resources/WebLibraries/three/addons/tsl/display/DenoiseNode.js +354 -0
- package/Resources/WebLibraries/three/addons/tsl/display/DepthOfFieldNode.js +572 -0
- package/Resources/WebLibraries/three/addons/tsl/display/DotScreenNode.js +104 -0
- package/Resources/WebLibraries/three/addons/tsl/display/FSR1Node.js +481 -0
- package/Resources/WebLibraries/three/addons/tsl/display/FXAANode.js +357 -0
- package/Resources/WebLibraries/three/addons/tsl/display/FilmNode.js +101 -0
- package/Resources/WebLibraries/three/addons/tsl/display/GTAONode.js +727 -0
- package/Resources/WebLibraries/three/addons/tsl/display/GaussianBlurNode.js +412 -0
- package/Resources/WebLibraries/three/addons/tsl/display/GodraysNode.js +604 -0
- package/Resources/WebLibraries/three/addons/tsl/display/ImportanceSampledEnvironment.js +564 -0
- package/Resources/WebLibraries/three/addons/tsl/display/LensflareNode.js +282 -0
- package/Resources/WebLibraries/three/addons/tsl/display/Lut3DNode.js +109 -0
- package/Resources/WebLibraries/three/addons/tsl/display/MotionBlur.js +33 -0
- package/Resources/WebLibraries/three/addons/tsl/display/OITPassNode.js +341 -0
- package/Resources/WebLibraries/three/addons/tsl/display/OutlineNode.js +916 -0
- package/Resources/WebLibraries/three/addons/tsl/display/ParallaxBarrierPassNode.js +90 -0
- package/Resources/WebLibraries/three/addons/tsl/display/PixelationPassNode.js +227 -0
- package/Resources/WebLibraries/three/addons/tsl/display/RGBShiftNode.js +96 -0
- package/Resources/WebLibraries/three/addons/tsl/display/RecurrentDenoiseNode.js +812 -0
- package/Resources/WebLibraries/three/addons/tsl/display/RetroPassNode.js +263 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SMAANode.js +729 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SSAAPassNode.js +344 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SSAONode.js +422 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SSGINode.js +698 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SSRNode.js +1430 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SSSNode.js +479 -0
- package/Resources/WebLibraries/three/addons/tsl/display/Sepia.js +24 -0
- package/Resources/WebLibraries/three/addons/tsl/display/Shape.js +29 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SharpenNode.js +284 -0
- package/Resources/WebLibraries/three/addons/tsl/display/SobelOperatorNode.js +168 -0
- package/Resources/WebLibraries/three/addons/tsl/display/StereoCompositePassNode.js +190 -0
- package/Resources/WebLibraries/three/addons/tsl/display/StereoPassNode.js +117 -0
- package/Resources/WebLibraries/three/addons/tsl/display/TAAUNode.js +700 -0
- package/Resources/WebLibraries/three/addons/tsl/display/TRAANode.js +609 -0
- package/Resources/WebLibraries/three/addons/tsl/display/TemporalReprojectNode.js +1024 -0
- package/Resources/WebLibraries/three/addons/tsl/display/TransitionNode.js +141 -0
- package/Resources/WebLibraries/three/addons/tsl/display/boxBlur.js +65 -0
- package/Resources/WebLibraries/three/addons/tsl/display/depthAwareBlend.js +80 -0
- package/Resources/WebLibraries/three/addons/tsl/display/depthAwareBlur.js +63 -0
- package/Resources/WebLibraries/three/addons/tsl/display/hashBlur.js +55 -0
- package/Resources/WebLibraries/three/addons/tsl/display/lensDirt.js +30 -0
- package/Resources/WebLibraries/three/addons/tsl/display/radialBlur.js +68 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/ClusteredLightsNode.js +994 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/DynamicLightsNode.js +201 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/LightProbeGridNode.js +183 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/data/AmbientLightDataNode.js +67 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/data/DirectionalLightDataNode.js +117 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/data/HemisphereLightDataNode.js +105 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/data/PointLightDataNode.js +140 -0
- package/Resources/WebLibraries/three/addons/tsl/lighting/data/SpotLightDataNode.js +167 -0
- package/Resources/WebLibraries/three/addons/tsl/math/Bayer.js +84 -0
- package/Resources/WebLibraries/three/addons/tsl/math/curlNoise.js +107 -0
- package/Resources/WebLibraries/three/addons/tsl/math/voronoiNoise.js +112 -0
- package/Resources/WebLibraries/three/addons/tsl/shadows/TileShadowNode.js +542 -0
- package/Resources/WebLibraries/three/addons/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/Resources/WebLibraries/three/addons/tsl/utils/GroundedSkybox.js +62 -0
- package/Resources/WebLibraries/three/addons/tsl/utils/RNoise.js +51 -0
- package/Resources/WebLibraries/three/addons/tsl/utils/Raymarching.js +70 -0
- package/Resources/WebLibraries/three/addons/tsl/utils/SoftParticles.js +53 -0
- package/Resources/WebLibraries/three/addons/tsl/utils/SpecularHelpers.js +302 -0
- package/Resources/WebLibraries/three/addons/tsl/utils/TAAUtils.js +184 -0
- package/Resources/WebLibraries/three/addons/utils/BufferGeometryUtils.js +1523 -0
- package/Resources/WebLibraries/three/addons/utils/CameraUtils.js +82 -0
- package/Resources/WebLibraries/three/addons/utils/ColorUtils.js +76 -0
- package/Resources/WebLibraries/three/addons/utils/GaussianSplatUtils.js +229 -0
- package/Resources/WebLibraries/three/addons/utils/GeometryCompressionUtils.js +547 -0
- package/Resources/WebLibraries/three/addons/utils/GeometryUtils.js +226 -0
- package/Resources/WebLibraries/three/addons/utils/LDrawUtils.js +211 -0
- package/Resources/WebLibraries/three/addons/utils/SceneOptimizer.js +459 -0
- package/Resources/WebLibraries/three/addons/utils/SceneUtils.js +363 -0
- package/Resources/WebLibraries/three/addons/utils/ShadowMapViewer.js +244 -0
- package/Resources/WebLibraries/three/addons/utils/ShadowMapViewerGPU.js +233 -0
- package/Resources/WebLibraries/three/addons/utils/SkeletonUtils.js +496 -0
- package/Resources/WebLibraries/three/addons/utils/SortUtils.js +175 -0
- package/Resources/WebLibraries/three/addons/utils/UVsDebug.js +173 -0
- package/Resources/WebLibraries/three/addons/utils/WebGLTextureUtils.js +115 -0
- package/Resources/WebLibraries/three/addons/utils/WebGPUTextureUtils.js +81 -0
- package/Resources/WebLibraries/three/addons/utils/WorkerPool.js +167 -0
- package/Resources/WebLibraries/three/addons/utils/unwrapUVs.js +865 -0
- package/Resources/WebLibraries/three/three.core.js +61162 -0
- package/Resources/WebLibraries/three/three.module.js +19537 -0
- package/Resources/WebLibraries/three/three.tsl.js +41903 -0
- package/Resources/WebLibraries/three/three.webgpu.js +53714 -0
- package/Resources/share-rules.json +64 -0
- package/Resources/skills/2d-game/SKILL.md +305 -0
- package/Resources/skills/3d-game/SKILL.md +274 -0
- package/Resources/skills/accounts/SKILL.md +41 -0
- package/Resources/skills/android-design/SKILL.md +159 -0
- package/Resources/skills/app-ai/SKILL.md +154 -0
- package/Resources/skills/app-intents/SKILL.md +31 -0
- package/Resources/skills/app-kinds/SKILL.md +122 -0
- package/Resources/skills/apple-watch/SKILL.md +43 -0
- package/Resources/skills/assets/SKILL.md +183 -0
- package/Resources/skills/building-blocks/SKILL.md +97 -0
- package/Resources/skills/device-control/SKILL.md +56 -0
- package/Resources/skills/device-integrations/SKILL.md +278 -0
- package/Resources/skills/finder-files/SKILL.md +19 -0
- package/Resources/skills/game/SKILL.md +416 -0
- package/Resources/skills/game-3d/SKILL.md +12 -0
- package/Resources/skills/game-art/SKILL.md +11 -0
- package/Resources/skills/game-feel/SKILL.md +13 -0
- package/Resources/skills/game-levels/SKILL.md +12 -0
- package/Resources/skills/game-live/SKILL.md +12 -0
- package/Resources/skills/game-physics/SKILL.md +13 -0
- package/Resources/skills/game-playtest/SKILL.md +26 -0
- package/Resources/skills/game-ui/SKILL.md +278 -0
- package/Resources/skills/github-projects/SKILL.md +62 -0
- package/Resources/skills/icloud-sync/SKILL.md +30 -0
- package/Resources/skills/iphone-hardware/SKILL.md +57 -0
- package/Resources/skills/iphone-widgets/SKILL.md +53 -0
- package/Resources/skills/lg-developer-mode/SKILL.md +152 -0
- package/Resources/skills/mac-widgets/SKILL.md +60 -0
- package/Resources/skills/maps/SKILL.md +8 -0
- package/Resources/skills/menu-bar/SKILL.md +36 -0
- package/Resources/skills/more-apps/SKILL.md +53 -0
- package/Resources/skills/phone-controllers/SKILL.md +79 -0
- package/Resources/skills/phone-pages/SKILL.md +173 -0
- package/Resources/skills/roku-developer-mode/SKILL.md +106 -0
- package/Resources/skills/scene-3d/SKILL.md +27 -0
- package/Resources/skills/scripting/SKILL.md +17 -0
- package/Resources/skills/share-extension/SKILL.md +22 -0
- package/Resources/skills/tv-design/SKILL.md +72 -0
- package/Resources/skills/web-app/SKILL.md +170 -0
- package/Resources/skills/web-game/SKILL.md +95 -0
- package/Resources/skills/web-or-native/SKILL.md +108 -0
- package/Resources/skills/wish-links/SKILL.md +156 -0
- package/THIRD_PARTY_NOTICES.md +170 -0
- package/cli/ai.mjs +237 -0
- package/cli/android.mjs +941 -0
- package/cli/app-ai.mjs +473 -0
- package/cli/browser.mjs +284 -0
- package/cli/calls.mjs +594 -0
- package/cli/dev.mjs +820 -0
- package/cli/devices.mjs +984 -0
- package/cli/lamp.mjs +1326 -0
- package/cli/lampapp.mjs +332 -0
- package/cli/lamps/android-host/LampPageGateway.kt +345 -0
- package/cli/lamps/android-host/app/build.gradle.kts +40 -0
- package/cli/lamps/android-host/build.gradle.kts +4 -0
- package/cli/lamps/android-host/game/AndroidManifest.xml +33 -0
- package/cli/lamps/android-host/game/MainActivity.kt +173 -0
- package/cli/lamps/android-host/gradle/libs.versions.toml +39 -0
- package/cli/lamps/android-host/gradle.properties +8 -0
- package/cli/lamps/android-host/page/AndroidManifest.xml +35 -0
- package/cli/lamps/android-host/page/MainActivity.kt +193 -0
- package/cli/lamps/android-host/settings.gradle.kts +30 -0
- package/cli/lamps/android-host/tools.json +43 -0
- package/cli/lamps/lamp-controllers.js +2 -0
- package/cli/lamps/lamp-for-games.js +6922 -0
- package/cli/lamps/lamp.js +7082 -0
- package/cli/lamps/mac-starter/.lamp/meta.json +1 -0
- package/cli/lamps/mac-starter/APP.md +12 -0
- package/cli/lamps/mac-starter/Package.swift +8 -0
- package/cli/lamps/mac-starter/Sources/App.swift +11 -0
- package/cli/lamps/mac-starter/Sources/ContentView.swift +17 -0
- package/cli/lamps/mac-starter/Sources/LampSupport.swift +18215 -0
- package/cli/lamps/mac-starter/build.sh +336 -0
- package/cli/lamps/mac-starter/gitignore +3 -0
- package/cli/lamps/mac-starter/lamp-starter.json +6 -0
- package/cli/lamps/web-starter/APP.md +8 -0
- package/cli/lamps/web-starter/app.js +1 -0
- package/cli/lamps/web-starter/index.html +17 -0
- package/cli/lamps/web-starter/lamp-starter.json +5 -0
- package/cli/lamps/web-starter/lamp.js +7082 -0
- package/cli/lamps/web-starter/style.css +25 -0
- package/cli/link.mjs +202 -0
- package/cli/local-ai.mjs +193 -0
- package/cli/mac.mjs +621 -0
- package/cli/mdns.mjs +205 -0
- package/cli/msix.mjs +413 -0
- package/cli/network.mjs +209 -0
- package/cli/openrouter.mjs +133 -0
- package/cli/outside.mjs +203 -0
- package/cli/page.js +317 -0
- package/cli/place.mjs +298 -0
- package/cli/png.mjs +184 -0
- package/cli/share.mjs +270 -0
- package/cli/skill/SKILL.md +280 -0
- package/cli/skills.mjs +71 -0
- package/cli/state.mjs +176 -0
- package/cli/update.mjs +162 -0
- package/package.json +20 -4
- package/site/lib/quota.js +59 -0
- package/site/lib/shared-wishes.js +1727 -0
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClampToEdgeWrapping,
|
|
3
|
+
DataTexture,
|
|
4
|
+
DataUtils,
|
|
5
|
+
FileLoader,
|
|
6
|
+
HalfFloatType,
|
|
7
|
+
LinearFilter,
|
|
8
|
+
LinearMipMapLinearFilter,
|
|
9
|
+
LinearSRGBColorSpace,
|
|
10
|
+
Loader,
|
|
11
|
+
RGBAFormat,
|
|
12
|
+
UVMapping,
|
|
13
|
+
} from 'three';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* UltraHDR Image Format - https://developer.android.com/media/platform/hdr-image-format
|
|
17
|
+
*
|
|
18
|
+
* Short format brief:
|
|
19
|
+
*
|
|
20
|
+
* [JPEG headers]
|
|
21
|
+
* [Metadata describing the MPF container and both SDR and gainmap images]
|
|
22
|
+
* - XMP metadata (legacy format)
|
|
23
|
+
* - ISO 21496-1 metadata (current standard)
|
|
24
|
+
* [Optional metadata] [EXIF] [ICC Profile]
|
|
25
|
+
* [SDR image]
|
|
26
|
+
* [Gainmap image with metadata]
|
|
27
|
+
*
|
|
28
|
+
* Each section is separated by a 0xFFXX byte followed by a descriptor byte (0xFFE0, 0xFFE1, 0xFFE2.)
|
|
29
|
+
* Binary image storages are prefixed with a unique 0xFFD8 16-bit descriptor.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// Pre-calculated sRGB to linear lookup table for values 0-1023
|
|
34
|
+
const SRGB_TO_LINEAR = new Float64Array( 1024 );
|
|
35
|
+
for ( let i = 0; i < 1024; i ++ ) {
|
|
36
|
+
|
|
37
|
+
// (1/255) * 0.9478672986 = 0.003717127
|
|
38
|
+
SRGB_TO_LINEAR[ i ] = Math.pow( i * 0.003717127 + 0.0521327014, 2.4 );
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A loader for the Ultra HDR Image Format.
|
|
44
|
+
*
|
|
45
|
+
* Existing HDR or EXR textures can be converted to Ultra HDR with this [tool](https://gainmap-creator.monogrid.com/).
|
|
46
|
+
*
|
|
47
|
+
* Current feature set:
|
|
48
|
+
* - JPEG headers (required)
|
|
49
|
+
* - XMP metadata (legacy format, supported)
|
|
50
|
+
* - ISO 21496-1 metadata (current standard, supported)
|
|
51
|
+
* - XMP validation (not implemented)
|
|
52
|
+
* - EXIF profile (not implemented)
|
|
53
|
+
* - ICC profile (not implemented)
|
|
54
|
+
* - Binary storage for SDR & HDR images (required)
|
|
55
|
+
* - Gainmap metadata (required)
|
|
56
|
+
* - Non-JPEG image formats (not implemented)
|
|
57
|
+
* - Primary image as an HDR image (not implemented)
|
|
58
|
+
*
|
|
59
|
+
* ```js
|
|
60
|
+
* const loader = new UltraHDRLoader();
|
|
61
|
+
* const texture = await loader.loadAsync( 'textures/equirectangular/ice_planet_close.jpg' );
|
|
62
|
+
* texture.mapping = THREE.EquirectangularReflectionMapping;
|
|
63
|
+
*
|
|
64
|
+
* scene.background = texture;
|
|
65
|
+
* scene.environment = texture;
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @augments Loader
|
|
69
|
+
* @three_import import { UltraHDRLoader } from 'three/addons/loaders/UltraHDRLoader.js';
|
|
70
|
+
*/
|
|
71
|
+
class UltraHDRLoader extends Loader {
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Constructs a new Ultra HDR loader.
|
|
75
|
+
*
|
|
76
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
77
|
+
*/
|
|
78
|
+
constructor( manager ) {
|
|
79
|
+
|
|
80
|
+
super( manager );
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The texture type.
|
|
84
|
+
*
|
|
85
|
+
* @type {(HalfFloatType|FloatType)}
|
|
86
|
+
* @default HalfFloatType
|
|
87
|
+
*/
|
|
88
|
+
this.type = HalfFloatType;
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Sets the texture type.
|
|
94
|
+
*
|
|
95
|
+
* @param {(HalfFloatType|FloatType)} value - The texture type to set.
|
|
96
|
+
* @return {UltraHDRLoader} A reference to this loader.
|
|
97
|
+
*/
|
|
98
|
+
setDataType( value ) {
|
|
99
|
+
|
|
100
|
+
this.type = value;
|
|
101
|
+
|
|
102
|
+
return this;
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Parses the given Ultra HDR texture data.
|
|
108
|
+
*
|
|
109
|
+
* @param {ArrayBuffer} buffer - The raw texture data.
|
|
110
|
+
* @param {Function} onLoad - The `onLoad` callback.
|
|
111
|
+
*/
|
|
112
|
+
parse( buffer, onLoad ) {
|
|
113
|
+
|
|
114
|
+
const metadata = {
|
|
115
|
+
version: null,
|
|
116
|
+
baseRenditionIsHDR: null,
|
|
117
|
+
gainMapMin: null,
|
|
118
|
+
gainMapMax: null,
|
|
119
|
+
gamma: null,
|
|
120
|
+
offsetSDR: null,
|
|
121
|
+
offsetHDR: null,
|
|
122
|
+
hdrCapacityMin: null,
|
|
123
|
+
hdrCapacityMax: null,
|
|
124
|
+
};
|
|
125
|
+
const textDecoder = new TextDecoder();
|
|
126
|
+
|
|
127
|
+
const bytes = new Uint8Array( buffer );
|
|
128
|
+
|
|
129
|
+
const sections = [];
|
|
130
|
+
|
|
131
|
+
// JPEG segment-aware scanner using length headers
|
|
132
|
+
let offset = 0;
|
|
133
|
+
|
|
134
|
+
while ( offset < bytes.length - 1 ) {
|
|
135
|
+
|
|
136
|
+
// Find marker prefix
|
|
137
|
+
if ( bytes[ offset ] !== 0xff ) {
|
|
138
|
+
|
|
139
|
+
offset ++;
|
|
140
|
+
continue;
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const markerType = bytes[ offset + 1 ];
|
|
145
|
+
|
|
146
|
+
// SOI (0xD8) - Start of Image, no length field
|
|
147
|
+
if ( markerType === 0xd8 ) {
|
|
148
|
+
|
|
149
|
+
sections.push( {
|
|
150
|
+
sectionType: markerType,
|
|
151
|
+
section: bytes.subarray( offset, offset + 2 ),
|
|
152
|
+
sectionOffset: offset + 2,
|
|
153
|
+
} );
|
|
154
|
+
|
|
155
|
+
offset += 2;
|
|
156
|
+
continue;
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// APP0-APP2 segments have length headers
|
|
161
|
+
if ( markerType === 0xe0 || markerType === 0xe1 || markerType === 0xe2 ) {
|
|
162
|
+
|
|
163
|
+
// Length is stored as big-endian 16-bit value (includes length bytes, excludes marker)
|
|
164
|
+
const segmentLength = ( bytes[ offset + 2 ] << 8 ) | bytes[ offset + 3 ];
|
|
165
|
+
const segmentEnd = offset + 2 + segmentLength;
|
|
166
|
+
|
|
167
|
+
sections.push( {
|
|
168
|
+
sectionType: markerType,
|
|
169
|
+
section: bytes.subarray( offset, segmentEnd ),
|
|
170
|
+
sectionOffset: offset + 2,
|
|
171
|
+
} );
|
|
172
|
+
|
|
173
|
+
offset = segmentEnd;
|
|
174
|
+
continue;
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Skip other markers with length fields (0xC0-0xFE range, except RST and EOI)
|
|
179
|
+
if ( markerType >= 0xc0 && markerType <= 0xfe && markerType !== 0xd9 && ( markerType < 0xd0 || markerType > 0xd7 ) ) {
|
|
180
|
+
|
|
181
|
+
const segmentLength = ( bytes[ offset + 2 ] << 8 ) | bytes[ offset + 3 ];
|
|
182
|
+
offset += 2 + segmentLength;
|
|
183
|
+
continue;
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// EOI (0xD9) or RST markers (0xD0-0xD7) - no length field
|
|
188
|
+
offset += 2;
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let primaryImage, gainmapImage;
|
|
193
|
+
|
|
194
|
+
for ( let i = 0; i < sections.length; i ++ ) {
|
|
195
|
+
|
|
196
|
+
const { sectionType, section, sectionOffset } = sections[ i ];
|
|
197
|
+
|
|
198
|
+
if ( sectionType === 0xe0 ) {
|
|
199
|
+
/* JPEG Header - no useful information */
|
|
200
|
+
} else if ( sectionType === 0xe1 ) {
|
|
201
|
+
|
|
202
|
+
/* APP1: XMP Metadata */
|
|
203
|
+
|
|
204
|
+
this._parseXMPMetadata(
|
|
205
|
+
textDecoder.decode( new Uint8Array( section ) ),
|
|
206
|
+
metadata
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
} else if ( sectionType === 0xe2 ) {
|
|
210
|
+
|
|
211
|
+
/* APP2: Data Sections - MPF / ICC Profile / ISO 21496-1 Metadata */
|
|
212
|
+
|
|
213
|
+
const sectionData = new DataView( section.buffer, section.byteOffset + 2, section.byteLength - 2 );
|
|
214
|
+
|
|
215
|
+
// Check for ISO 21496-1 namespace: "urn:iso:std:iso:ts:21496:-1\0"
|
|
216
|
+
const isoNameSpace = 'urn:iso:std:iso:ts:21496:-1\0';
|
|
217
|
+
if ( section.byteLength >= isoNameSpace.length + 2 ) {
|
|
218
|
+
|
|
219
|
+
let isISO = true;
|
|
220
|
+
for ( let j = 0; j < isoNameSpace.length; j ++ ) {
|
|
221
|
+
|
|
222
|
+
if ( section[ 2 + j ] !== isoNameSpace.charCodeAt( j ) ) {
|
|
223
|
+
|
|
224
|
+
isISO = false;
|
|
225
|
+
break;
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if ( isISO ) {
|
|
232
|
+
|
|
233
|
+
// Parse ISO 21496-1 metadata
|
|
234
|
+
const isoData = section.subarray( 2 + isoNameSpace.length );
|
|
235
|
+
this._parseISOMetadata( isoData, metadata );
|
|
236
|
+
continue;
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Check for MPF
|
|
243
|
+
const sectionHeader = sectionData.getUint32( 2, false );
|
|
244
|
+
|
|
245
|
+
if ( sectionHeader === 0x4d504600 ) {
|
|
246
|
+
|
|
247
|
+
/* MPF Section */
|
|
248
|
+
|
|
249
|
+
/* Section contains a list of static bytes and ends with offsets indicating location of SDR and gainmap images */
|
|
250
|
+
/* First bytes after header indicate little / big endian ordering (0x49492A00 - LE / 0x4D4D002A - BE) */
|
|
251
|
+
/*
|
|
252
|
+
... 60 bytes indicating tags, versions, etc. ...
|
|
253
|
+
|
|
254
|
+
bytes | bits | description
|
|
255
|
+
|
|
256
|
+
4 32 primary image size
|
|
257
|
+
4 32 primary image offset
|
|
258
|
+
2 16 0x0000
|
|
259
|
+
2 16 0x0000
|
|
260
|
+
|
|
261
|
+
4 32 0x00000000
|
|
262
|
+
4 32 gainmap image size
|
|
263
|
+
4 32 gainmap image offset
|
|
264
|
+
2 16 0x0000
|
|
265
|
+
2 16 0x0000
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
const mpfLittleEndian = sectionData.getUint32( 6 ) === 0x49492a00;
|
|
269
|
+
const mpfBytesOffset = 60;
|
|
270
|
+
|
|
271
|
+
/* SDR size includes the metadata length, SDR offset is always 0 */
|
|
272
|
+
|
|
273
|
+
const primaryImageSize = sectionData.getUint32(
|
|
274
|
+
mpfBytesOffset,
|
|
275
|
+
mpfLittleEndian
|
|
276
|
+
);
|
|
277
|
+
const primaryImageOffset = sectionData.getUint32(
|
|
278
|
+
mpfBytesOffset + 4,
|
|
279
|
+
mpfLittleEndian
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
/* Gainmap size is an absolute value starting from its offset, gainmap offset needs 6 bytes padding to take into account 0x00 bytes at the end of XMP */
|
|
283
|
+
const gainmapImageSize = sectionData.getUint32(
|
|
284
|
+
mpfBytesOffset + 16,
|
|
285
|
+
mpfLittleEndian
|
|
286
|
+
);
|
|
287
|
+
const gainmapImageOffset =
|
|
288
|
+
sectionData.getUint32( mpfBytesOffset + 20, mpfLittleEndian ) +
|
|
289
|
+
sectionOffset +
|
|
290
|
+
6;
|
|
291
|
+
|
|
292
|
+
primaryImage = new Uint8Array(
|
|
293
|
+
buffer,
|
|
294
|
+
primaryImageOffset,
|
|
295
|
+
primaryImageSize
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
gainmapImage = new Uint8Array(
|
|
299
|
+
buffer,
|
|
300
|
+
gainmapImageOffset,
|
|
301
|
+
gainmapImageSize
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* Minimal sufficient validation - https://developer.android.com/media/platform/hdr-image-format#signal_of_the_format */
|
|
311
|
+
// Version can come from either XMP or ISO metadata
|
|
312
|
+
if ( ! metadata.version ) {
|
|
313
|
+
|
|
314
|
+
throw new Error( 'THREE.UltraHDRLoader: Not a valid UltraHDR image' );
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if ( primaryImage && gainmapImage ) {
|
|
319
|
+
|
|
320
|
+
this._applyGainmapToSDR(
|
|
321
|
+
metadata,
|
|
322
|
+
primaryImage,
|
|
323
|
+
gainmapImage,
|
|
324
|
+
( hdrBuffer, width, height ) => {
|
|
325
|
+
|
|
326
|
+
onLoad( {
|
|
327
|
+
width,
|
|
328
|
+
height,
|
|
329
|
+
data: hdrBuffer,
|
|
330
|
+
format: RGBAFormat,
|
|
331
|
+
type: this.type,
|
|
332
|
+
} );
|
|
333
|
+
|
|
334
|
+
},
|
|
335
|
+
( error ) => {
|
|
336
|
+
|
|
337
|
+
throw new Error( error );
|
|
338
|
+
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
} else {
|
|
343
|
+
|
|
344
|
+
throw new Error( 'THREE.UltraHDRLoader: Could not parse UltraHDR images' );
|
|
345
|
+
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Parses ISO 21496-1 gainmap metadata from binary data.
|
|
352
|
+
*
|
|
353
|
+
* @private
|
|
354
|
+
* @param {Uint8Array} data - The binary ISO metadata.
|
|
355
|
+
* @param {Object} metadata - The metadata object to populate.
|
|
356
|
+
*/
|
|
357
|
+
_parseISOMetadata( data, metadata ) {
|
|
358
|
+
|
|
359
|
+
const view = new DataView( data.buffer, data.byteOffset, data.byteLength );
|
|
360
|
+
|
|
361
|
+
// Skip minimum version (2 bytes) and writer version (2 bytes)
|
|
362
|
+
let offset = 4;
|
|
363
|
+
|
|
364
|
+
// Read flags (1 byte)
|
|
365
|
+
const flags = view.getUint8( offset );
|
|
366
|
+
offset += 1;
|
|
367
|
+
|
|
368
|
+
const backwardDirection = ( flags & 0x4 ) !== 0;
|
|
369
|
+
const useCommonDenominator = ( flags & 0x8 ) !== 0;
|
|
370
|
+
|
|
371
|
+
let gainMapMin, gainMapMax, gamma, offsetSDR, offsetHDR, hdrCapacityMin, hdrCapacityMax;
|
|
372
|
+
|
|
373
|
+
if ( useCommonDenominator ) {
|
|
374
|
+
|
|
375
|
+
// Read common denominator (4 bytes, unsigned)
|
|
376
|
+
const commonDenominator = view.getUint32( offset, false );
|
|
377
|
+
offset += 4;
|
|
378
|
+
|
|
379
|
+
// Read baseHdrHeadroom (4 bytes, unsigned)
|
|
380
|
+
const baseHdrHeadroomN = view.getUint32( offset, false );
|
|
381
|
+
offset += 4;
|
|
382
|
+
hdrCapacityMin = Math.log2( baseHdrHeadroomN / commonDenominator );
|
|
383
|
+
|
|
384
|
+
// Read alternateHdrHeadroom (4 bytes, unsigned)
|
|
385
|
+
const alternateHdrHeadroomN = view.getUint32( offset, false );
|
|
386
|
+
offset += 4;
|
|
387
|
+
hdrCapacityMax = Math.log2( alternateHdrHeadroomN / commonDenominator );
|
|
388
|
+
|
|
389
|
+
// Read first channel (or only channel) parameters
|
|
390
|
+
const gainMapMinN = view.getInt32( offset, false );
|
|
391
|
+
offset += 4;
|
|
392
|
+
gainMapMin = gainMapMinN / commonDenominator;
|
|
393
|
+
|
|
394
|
+
const gainMapMaxN = view.getInt32( offset, false );
|
|
395
|
+
offset += 4;
|
|
396
|
+
gainMapMax = gainMapMaxN / commonDenominator;
|
|
397
|
+
|
|
398
|
+
const gammaN = view.getUint32( offset, false );
|
|
399
|
+
offset += 4;
|
|
400
|
+
gamma = gammaN / commonDenominator;
|
|
401
|
+
|
|
402
|
+
const offsetSDRN = view.getInt32( offset, false );
|
|
403
|
+
offset += 4;
|
|
404
|
+
offsetSDR = ( offsetSDRN / commonDenominator ) * 255.0;
|
|
405
|
+
|
|
406
|
+
const offsetHDRN = view.getInt32( offset, false );
|
|
407
|
+
offsetHDR = ( offsetHDRN / commonDenominator ) * 255.0;
|
|
408
|
+
|
|
409
|
+
} else {
|
|
410
|
+
|
|
411
|
+
// Read baseHdrHeadroom numerator and denominator
|
|
412
|
+
const baseHdrHeadroomN = view.getUint32( offset, false );
|
|
413
|
+
offset += 4;
|
|
414
|
+
const baseHdrHeadroomD = view.getUint32( offset, false );
|
|
415
|
+
offset += 4;
|
|
416
|
+
hdrCapacityMin = Math.log2( baseHdrHeadroomN / baseHdrHeadroomD );
|
|
417
|
+
|
|
418
|
+
// Read alternateHdrHeadroom numerator and denominator
|
|
419
|
+
const alternateHdrHeadroomN = view.getUint32( offset, false );
|
|
420
|
+
offset += 4;
|
|
421
|
+
const alternateHdrHeadroomD = view.getUint32( offset, false );
|
|
422
|
+
offset += 4;
|
|
423
|
+
hdrCapacityMax = Math.log2( alternateHdrHeadroomN / alternateHdrHeadroomD );
|
|
424
|
+
|
|
425
|
+
// Read first channel parameters
|
|
426
|
+
const gainMapMinN = view.getInt32( offset, false );
|
|
427
|
+
offset += 4;
|
|
428
|
+
const gainMapMinD = view.getUint32( offset, false );
|
|
429
|
+
offset += 4;
|
|
430
|
+
gainMapMin = gainMapMinN / gainMapMinD;
|
|
431
|
+
|
|
432
|
+
const gainMapMaxN = view.getInt32( offset, false );
|
|
433
|
+
offset += 4;
|
|
434
|
+
const gainMapMaxD = view.getUint32( offset, false );
|
|
435
|
+
offset += 4;
|
|
436
|
+
gainMapMax = gainMapMaxN / gainMapMaxD;
|
|
437
|
+
|
|
438
|
+
const gammaN = view.getUint32( offset, false );
|
|
439
|
+
offset += 4;
|
|
440
|
+
const gammaD = view.getUint32( offset, false );
|
|
441
|
+
offset += 4;
|
|
442
|
+
gamma = gammaN / gammaD;
|
|
443
|
+
|
|
444
|
+
const offsetSDRN = view.getInt32( offset, false );
|
|
445
|
+
offset += 4;
|
|
446
|
+
const offsetSDRD = view.getUint32( offset, false );
|
|
447
|
+
offset += 4;
|
|
448
|
+
offsetSDR = ( offsetSDRN / offsetSDRD ) * 255.0;
|
|
449
|
+
|
|
450
|
+
const offsetHDRN = view.getInt32( offset, false );
|
|
451
|
+
offset += 4;
|
|
452
|
+
const offsetHDRD = view.getUint32( offset, false );
|
|
453
|
+
offsetHDR = ( offsetHDRN / offsetHDRD ) * 255.0;
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Convert log2 values to linear
|
|
458
|
+
metadata.version = '1.0'; // ISO standard doesn't encode version string, use default
|
|
459
|
+
metadata.baseRenditionIsHDR = backwardDirection;
|
|
460
|
+
metadata.gainMapMin = gainMapMin;
|
|
461
|
+
metadata.gainMapMax = gainMapMax;
|
|
462
|
+
metadata.gamma = gamma;
|
|
463
|
+
metadata.offsetSDR = offsetSDR;
|
|
464
|
+
metadata.offsetHDR = offsetHDR;
|
|
465
|
+
metadata.hdrCapacityMin = hdrCapacityMin;
|
|
466
|
+
metadata.hdrCapacityMax = hdrCapacityMax;
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Starts loading from the given URL and passes the loaded Ultra HDR texture
|
|
472
|
+
* to the `onLoad()` callback.
|
|
473
|
+
*
|
|
474
|
+
* @param {string} url - The path/URL of the files to be loaded. This can also be a data URI.
|
|
475
|
+
* @param {function(DataTexture, Object)} onLoad - Executed when the loading process has been finished.
|
|
476
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
477
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
478
|
+
* @return {DataTexture} The Ultra HDR texture.
|
|
479
|
+
*/
|
|
480
|
+
load( url, onLoad, onProgress, onError ) {
|
|
481
|
+
|
|
482
|
+
const texture = new DataTexture(
|
|
483
|
+
this.type === HalfFloatType ? new Uint16Array() : new Float32Array(),
|
|
484
|
+
0,
|
|
485
|
+
0,
|
|
486
|
+
RGBAFormat,
|
|
487
|
+
this.type,
|
|
488
|
+
UVMapping,
|
|
489
|
+
ClampToEdgeWrapping,
|
|
490
|
+
ClampToEdgeWrapping,
|
|
491
|
+
LinearFilter,
|
|
492
|
+
LinearMipMapLinearFilter,
|
|
493
|
+
1,
|
|
494
|
+
LinearSRGBColorSpace
|
|
495
|
+
);
|
|
496
|
+
texture.generateMipmaps = true;
|
|
497
|
+
texture.flipY = true;
|
|
498
|
+
|
|
499
|
+
const loader = new FileLoader( this.manager );
|
|
500
|
+
loader.setPriority( this.priority );
|
|
501
|
+
loader.setCache( this.cache );
|
|
502
|
+
loader.setResponseType( 'arraybuffer' );
|
|
503
|
+
loader.setRequestHeader( this.requestHeader );
|
|
504
|
+
loader.setPath( this.path );
|
|
505
|
+
loader.setWithCredentials( this.withCredentials );
|
|
506
|
+
loader.load( url, ( buffer ) => {
|
|
507
|
+
|
|
508
|
+
try {
|
|
509
|
+
|
|
510
|
+
this.parse(
|
|
511
|
+
buffer,
|
|
512
|
+
( texData ) => {
|
|
513
|
+
|
|
514
|
+
texture.image = {
|
|
515
|
+
data: texData.data,
|
|
516
|
+
width: texData.width,
|
|
517
|
+
height: texData.height,
|
|
518
|
+
};
|
|
519
|
+
texture.needsUpdate = true;
|
|
520
|
+
|
|
521
|
+
if ( onLoad ) onLoad( texture, texData );
|
|
522
|
+
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
} catch ( error ) {
|
|
527
|
+
|
|
528
|
+
if ( onError ) onError( error );
|
|
529
|
+
|
|
530
|
+
console.error( error );
|
|
531
|
+
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
}, onProgress, onError );
|
|
535
|
+
|
|
536
|
+
return texture;
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
_parseXMPMetadata( xmpDataString, metadata ) {
|
|
541
|
+
|
|
542
|
+
const domParser = new DOMParser();
|
|
543
|
+
|
|
544
|
+
const xmpXml = domParser.parseFromString(
|
|
545
|
+
xmpDataString.substring(
|
|
546
|
+
xmpDataString.indexOf( '<' ),
|
|
547
|
+
xmpDataString.lastIndexOf( '>' ) + 1
|
|
548
|
+
),
|
|
549
|
+
'text/xml'
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
/* Determine if given XMP metadata is the primary GContainer descriptor or a gainmap descriptor */
|
|
553
|
+
const [ hasHDRContainerDescriptor ] = xmpXml.getElementsByTagName(
|
|
554
|
+
'Container:Directory'
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
if ( hasHDRContainerDescriptor ) {
|
|
558
|
+
/* There's not much useful information in the container descriptor besides memory-validation */
|
|
559
|
+
} else {
|
|
560
|
+
|
|
561
|
+
/* Gainmap descriptor - defaults from https://developer.android.com/media/platform/hdr-image-format#HDR_gain_map_metadata */
|
|
562
|
+
|
|
563
|
+
const [ gainmapNode ] = xmpXml.getElementsByTagName( 'rdf:Description' );
|
|
564
|
+
|
|
565
|
+
metadata.version = gainmapNode.getAttribute( 'hdrgm:Version' );
|
|
566
|
+
metadata.baseRenditionIsHDR =
|
|
567
|
+
gainmapNode.getAttribute( 'hdrgm:BaseRenditionIsHDR' ) === 'True';
|
|
568
|
+
metadata.gainMapMin = parseFloat(
|
|
569
|
+
gainmapNode.getAttribute( 'hdrgm:GainMapMin' ) || 0.0
|
|
570
|
+
);
|
|
571
|
+
metadata.gainMapMax = parseFloat(
|
|
572
|
+
gainmapNode.getAttribute( 'hdrgm:GainMapMax' ) || 1.0
|
|
573
|
+
);
|
|
574
|
+
metadata.gamma = parseFloat(
|
|
575
|
+
gainmapNode.getAttribute( 'hdrgm:Gamma' ) || 1.0
|
|
576
|
+
);
|
|
577
|
+
metadata.offsetSDR = parseFloat(
|
|
578
|
+
gainmapNode.getAttribute( 'hdrgm:OffsetSDR' ) / ( 1 / 64 )
|
|
579
|
+
);
|
|
580
|
+
metadata.offsetHDR = parseFloat(
|
|
581
|
+
gainmapNode.getAttribute( 'hdrgm:OffsetHDR' ) / ( 1 / 64 )
|
|
582
|
+
);
|
|
583
|
+
metadata.hdrCapacityMin = parseFloat(
|
|
584
|
+
gainmapNode.getAttribute( 'hdrgm:HDRCapacityMin' ) || 0.0
|
|
585
|
+
);
|
|
586
|
+
metadata.hdrCapacityMax = parseFloat(
|
|
587
|
+
gainmapNode.getAttribute( 'hdrgm:HDRCapacityMax' ) || 1.0
|
|
588
|
+
);
|
|
589
|
+
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
_srgbToLinear( value ) {
|
|
595
|
+
|
|
596
|
+
// 0.04045 * 255 = 10.31475
|
|
597
|
+
if ( value < 10.31475 ) {
|
|
598
|
+
|
|
599
|
+
// (1/255) * 0.0773993808
|
|
600
|
+
return value * 0.000303527;
|
|
601
|
+
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if ( value < 1024 ) {
|
|
605
|
+
|
|
606
|
+
return SRGB_TO_LINEAR[ value | 0 ];
|
|
607
|
+
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// (1/255) * 0.9478672986 = 0.003717127
|
|
611
|
+
return Math.pow( value * 0.003717127 + 0.0521327014, 2.4 );
|
|
612
|
+
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
_applyGainmapToSDR(
|
|
616
|
+
metadata,
|
|
617
|
+
sdrBuffer,
|
|
618
|
+
gainmapBuffer,
|
|
619
|
+
onSuccess,
|
|
620
|
+
onError
|
|
621
|
+
) {
|
|
622
|
+
|
|
623
|
+
const decodeImage = ( data ) => createImageBitmap( new Blob( [ data ], { type: 'image/jpeg' } ) );
|
|
624
|
+
|
|
625
|
+
Promise.all( [ decodeImage( sdrBuffer ), decodeImage( gainmapBuffer ) ] )
|
|
626
|
+
.then( ( [ sdrImage, gainmapImage ] ) => {
|
|
627
|
+
|
|
628
|
+
const sdrWidth = sdrImage.width;
|
|
629
|
+
const sdrHeight = sdrImage.height;
|
|
630
|
+
const sdrImageAspect = sdrWidth / sdrHeight;
|
|
631
|
+
const gainmapImageAspect = gainmapImage.width / gainmapImage.height;
|
|
632
|
+
|
|
633
|
+
if ( sdrImageAspect !== gainmapImageAspect ) {
|
|
634
|
+
|
|
635
|
+
onError(
|
|
636
|
+
'THREE.UltraHDRLoader Error: Aspect ratio mismatch between SDR and Gainmap images'
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
return;
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const canvas = document.createElement( 'canvas' );
|
|
644
|
+
const ctx = canvas.getContext( '2d', {
|
|
645
|
+
willReadFrequently: true,
|
|
646
|
+
colorSpace: 'srgb',
|
|
647
|
+
} );
|
|
648
|
+
|
|
649
|
+
canvas.width = sdrWidth;
|
|
650
|
+
canvas.height = sdrHeight;
|
|
651
|
+
|
|
652
|
+
/* Use out-of-the-box interpolation of Canvas API to scale gainmap to fit the SDR resolution */
|
|
653
|
+
ctx.drawImage(
|
|
654
|
+
gainmapImage,
|
|
655
|
+
0,
|
|
656
|
+
0,
|
|
657
|
+
gainmapImage.width,
|
|
658
|
+
gainmapImage.height,
|
|
659
|
+
0,
|
|
660
|
+
0,
|
|
661
|
+
sdrWidth,
|
|
662
|
+
sdrHeight
|
|
663
|
+
);
|
|
664
|
+
const gainmapImageData = ctx.getImageData(
|
|
665
|
+
0,
|
|
666
|
+
0,
|
|
667
|
+
sdrWidth,
|
|
668
|
+
sdrHeight,
|
|
669
|
+
{ colorSpace: 'srgb' }
|
|
670
|
+
);
|
|
671
|
+
|
|
672
|
+
ctx.drawImage( sdrImage, 0, 0 );
|
|
673
|
+
const sdrImageData = ctx.getImageData(
|
|
674
|
+
0,
|
|
675
|
+
0,
|
|
676
|
+
sdrWidth,
|
|
677
|
+
sdrHeight,
|
|
678
|
+
{ colorSpace: 'srgb' }
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
/* HDR Recovery formula - https://developer.android.com/media/platform/hdr-image-format#use_the_gain_map_to_create_adapted_HDR_rendition */
|
|
682
|
+
|
|
683
|
+
/* 1.8 instead of 2 near-perfectly rectifies approximations introduced by precalculated SRGB_TO_LINEAR values */
|
|
684
|
+
const maxDisplayBoost = 1.8 ** ( metadata.hdrCapacityMax * 0.5 );
|
|
685
|
+
const unclampedWeightFactor =
|
|
686
|
+
( Math.log2( maxDisplayBoost ) - metadata.hdrCapacityMin ) /
|
|
687
|
+
( metadata.hdrCapacityMax - metadata.hdrCapacityMin );
|
|
688
|
+
const weightFactor = Math.min(
|
|
689
|
+
Math.max( unclampedWeightFactor, 0.0 ),
|
|
690
|
+
1.0
|
|
691
|
+
);
|
|
692
|
+
|
|
693
|
+
const sdrData = sdrImageData.data;
|
|
694
|
+
const gainmapData = gainmapImageData.data;
|
|
695
|
+
const dataLength = sdrData.length;
|
|
696
|
+
const gainMapMin = metadata.gainMapMin;
|
|
697
|
+
const gainMapMax = metadata.gainMapMax;
|
|
698
|
+
const offsetSDR = metadata.offsetSDR;
|
|
699
|
+
const offsetHDR = metadata.offsetHDR;
|
|
700
|
+
const invGamma = 1.0 / metadata.gamma;
|
|
701
|
+
const useGammaOne = metadata.gamma === 1.0;
|
|
702
|
+
const isHalfFloat = this.type === HalfFloatType;
|
|
703
|
+
const toHalfFloat = DataUtils.toHalfFloat;
|
|
704
|
+
const srgbToLinear = this._srgbToLinear;
|
|
705
|
+
|
|
706
|
+
const hdrBuffer = isHalfFloat
|
|
707
|
+
? new Uint16Array( dataLength ).fill( 15360 )
|
|
708
|
+
: new Float32Array( dataLength ).fill( 1.0 );
|
|
709
|
+
|
|
710
|
+
for ( let i = 0; i < dataLength; i += 4 ) {
|
|
711
|
+
|
|
712
|
+
for ( let c = 0; c < 3; c ++ ) {
|
|
713
|
+
|
|
714
|
+
const idx = i + c;
|
|
715
|
+
const sdrValue = sdrData[ idx ];
|
|
716
|
+
const gainmapValue = gainmapData[ idx ] * 0.00392156862745098; // 1/255
|
|
717
|
+
|
|
718
|
+
const logRecovery = useGammaOne
|
|
719
|
+
? gainmapValue
|
|
720
|
+
: Math.pow( gainmapValue, invGamma );
|
|
721
|
+
|
|
722
|
+
const logBoost = gainMapMin + ( gainMapMax - gainMapMin ) * logRecovery;
|
|
723
|
+
|
|
724
|
+
const hdrValue =
|
|
725
|
+
( sdrValue + offsetSDR ) *
|
|
726
|
+
( logBoost * weightFactor === 0.0
|
|
727
|
+
? 1.0
|
|
728
|
+
: Math.pow( 2, logBoost * weightFactor ) ) -
|
|
729
|
+
offsetHDR;
|
|
730
|
+
|
|
731
|
+
const linearHDRValue = Math.min(
|
|
732
|
+
Math.max( srgbToLinear( hdrValue ), 0 ),
|
|
733
|
+
65504
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
hdrBuffer[ idx ] = isHalfFloat
|
|
737
|
+
? toHalfFloat( linearHDRValue )
|
|
738
|
+
: linearHDRValue;
|
|
739
|
+
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
onSuccess( hdrBuffer, sdrWidth, sdrHeight );
|
|
745
|
+
|
|
746
|
+
} )
|
|
747
|
+
.catch( ( e ) => {
|
|
748
|
+
|
|
749
|
+
onError( e );
|
|
750
|
+
|
|
751
|
+
} );
|
|
752
|
+
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
export { UltraHDRLoader };
|