@driftengine/core 3.61.0
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 +202 -0
- package/NOTICE +9 -0
- package/README.md +9 -0
- package/dist/behavior/behaviorTree.d.ts +140 -0
- package/dist/behavior/behaviorTree.js +289 -0
- package/dist/build/shaderComments.d.ts +64 -0
- package/dist/build/shaderComments.js +0 -0
- package/dist/cinematic/player.d.ts +80 -0
- package/dist/cinematic/player.js +184 -0
- package/dist/cinematic/script.d.ts +63 -0
- package/dist/cinematic/script.js +141 -0
- package/dist/core/bootGate.d.ts +37 -0
- package/dist/core/bootGate.js +47 -0
- package/dist/core/loadTracker.d.ts +78 -0
- package/dist/core/loadTracker.js +106 -0
- package/dist/core/loop.d.ts +118 -0
- package/dist/core/loop.js +84 -0
- package/dist/core/messageQueue.d.ts +61 -0
- package/dist/core/messageQueue.js +104 -0
- package/dist/core/onceSet.d.ts +27 -0
- package/dist/core/onceSet.js +62 -0
- package/dist/core/preferences.d.ts +47 -0
- package/dist/core/preferences.js +140 -0
- package/dist/core/remoteSave.d.ts +154 -0
- package/dist/core/remoteSave.js +249 -0
- package/dist/core/rng.d.ts +64 -0
- package/dist/core/rng.js +72 -0
- package/dist/core/stepBudget.d.ts +91 -0
- package/dist/core/stepBudget.js +105 -0
- package/dist/core/storage.d.ts +52 -0
- package/dist/core/storage.js +85 -0
- package/dist/core/tickTrace.d.ts +72 -0
- package/dist/core/tickTrace.js +102 -0
- package/dist/core/timeCurve.d.ts +83 -0
- package/dist/core/timeCurve.js +107 -0
- package/dist/core/withDefaults.d.ts +21 -0
- package/dist/core/withDefaults.js +29 -0
- package/dist/dev/contactProbe.d.ts +41 -0
- package/dist/dev/contactProbe.js +58 -0
- package/dist/dev/fpsMeter.d.ts +45 -0
- package/dist/dev/fpsMeter.js +86 -0
- package/dist/environment/celestialClock.d.ts +141 -0
- package/dist/environment/celestialClock.js +262 -0
- package/dist/geometry/decal.d.ts +61 -0
- package/dist/geometry/decal.js +178 -0
- package/dist/geometry/filmPatch.d.ts +35 -0
- package/dist/geometry/filmPatch.js +112 -0
- package/dist/geometry/growable.d.ts +70 -0
- package/dist/geometry/growable.js +167 -0
- package/dist/geometry/lightVolume.d.ts +76 -0
- package/dist/geometry/lightVolume.js +65 -0
- package/dist/geometry/meshBuilder.d.ts +426 -0
- package/dist/geometry/meshBuilder.js +1184 -0
- package/dist/geometry/pixelFont.d.ts +59 -0
- package/dist/geometry/pixelFont.js +179 -0
- package/dist/geometry/ribbon.d.ts +101 -0
- package/dist/geometry/ribbon.js +546 -0
- package/dist/geometry/shellFill.d.ts +101 -0
- package/dist/geometry/shellFill.js +203 -0
- package/dist/geometry/spline.d.ts +162 -0
- package/dist/geometry/spline.js +527 -0
- package/dist/geometry/tangents.d.ts +30 -0
- package/dist/geometry/tangents.js +142 -0
- package/dist/geometry/textMesh.d.ts +51 -0
- package/dist/geometry/textMesh.js +57 -0
- package/dist/geometry/treeBuilder.d.ts +37 -0
- package/dist/geometry/treeBuilder.js +56 -0
- package/dist/host/display.d.ts +135 -0
- package/dist/host/display.js +114 -0
- package/dist/host/files.d.ts +25 -0
- package/dist/host/files.js +44 -0
- package/dist/host/lifecycle.d.ts +45 -0
- package/dist/host/lifecycle.js +28 -0
- package/dist/host/platformServices.d.ts +23 -0
- package/dist/host/platformServices.js +1 -0
- package/dist/host/screen.d.ts +49 -0
- package/dist/host/screen.js +90 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +320 -0
- package/dist/input/actionMap.d.ts +181 -0
- package/dist/input/actionMap.js +314 -0
- package/dist/input/activeDevice.d.ts +55 -0
- package/dist/input/activeDevice.js +83 -0
- package/dist/input/gamepadIdentity.d.ts +43 -0
- package/dist/input/gamepadIdentity.js +108 -0
- package/dist/input/gamepadMapping.d.ts +56 -0
- package/dist/input/gamepadMapping.js +91 -0
- package/dist/input/input.d.ts +281 -0
- package/dist/input/input.js +703 -0
- package/dist/input/inputHarness.d.ts +42 -0
- package/dist/input/inputHarness.js +193 -0
- package/dist/input/rightGesture.d.ts +57 -0
- package/dist/input/rightGesture.js +49 -0
- package/dist/input/rumble.d.ts +71 -0
- package/dist/input/rumble.js +119 -0
- package/dist/input/touchControls.d.ts +138 -0
- package/dist/input/touchControls.js +352 -0
- package/dist/input/typingTarget.d.ts +6 -0
- package/dist/input/typingTarget.js +27 -0
- package/dist/math/bounds.d.ts +61 -0
- package/dist/math/bounds.js +121 -0
- package/dist/math/color.d.ts +8 -0
- package/dist/math/color.js +35 -0
- package/dist/math/exact.d.ts +66 -0
- package/dist/math/exact.js +262 -0
- package/dist/math/frustum.d.ts +44 -0
- package/dist/math/frustum.js +90 -0
- package/dist/math/intersect.d.ts +76 -0
- package/dist/math/intersect.js +185 -0
- package/dist/math/scalar.d.ts +51 -0
- package/dist/math/scalar.js +99 -0
- package/dist/math/spring.d.ts +59 -0
- package/dist/math/spring.js +88 -0
- package/dist/nav/navGraph.d.ts +71 -0
- package/dist/nav/navGraph.js +111 -0
- package/dist/nav/navPath.d.ts +93 -0
- package/dist/nav/navPath.js +162 -0
- package/dist/nav/navSearch.d.ts +74 -0
- package/dist/nav/navSearch.js +198 -0
- package/dist/physics/boxSurface.d.ts +48 -0
- package/dist/physics/boxSurface.js +73 -0
- package/dist/physics/colliderSurface.d.ts +46 -0
- package/dist/physics/colliderSurface.js +146 -0
- package/dist/physics/compositeSurface.d.ts +33 -0
- package/dist/physics/compositeSurface.js +108 -0
- package/dist/physics/heightSurface.d.ts +103 -0
- package/dist/physics/heightSurface.js +153 -0
- package/dist/physics/ribbonSurface.d.ts +239 -0
- package/dist/physics/ribbonSurface.js +522 -0
- package/dist/render/ambientOcclusionPass.d.ts +53 -0
- package/dist/render/ambientOcclusionPass.js +179 -0
- package/dist/render/areaLights.d.ts +116 -0
- package/dist/render/areaLights.js +91 -0
- package/dist/render/areaShadowSet.d.ts +184 -0
- package/dist/render/areaShadowSet.js +277 -0
- package/dist/render/atmosphere.d.ts +94 -0
- package/dist/render/atmosphere.js +91 -0
- package/dist/render/backend/api.d.ts +496 -0
- package/dist/render/backend/api.js +1 -0
- package/dist/render/backend/budget.d.ts +82 -0
- package/dist/render/backend/budget.js +99 -0
- package/dist/render/backend/createRenderer.d.ts +135 -0
- package/dist/render/backend/createRenderer.js +201 -0
- package/dist/render/backend/deadline.d.ts +24 -0
- package/dist/render/backend/deadline.js +38 -0
- package/dist/render/backend/probe.d.ts +30 -0
- package/dist/render/backend/probe.js +129 -0
- package/dist/render/backend/select.d.ts +70 -0
- package/dist/render/backend/select.js +249 -0
- package/dist/render/backend/timer.d.ts +50 -0
- package/dist/render/backend/timer.js +1 -0
- package/dist/render/backend/webgl2/instanced.d.ts +21 -0
- package/dist/render/backend/webgl2/instanced.js +42 -0
- package/dist/render/backend/webgl2/morphTexture.d.ts +21 -0
- package/dist/render/backend/webgl2/morphTexture.js +55 -0
- package/dist/render/backend/webgl2/renderer.d.ts +3027 -0
- package/dist/render/backend/webgl2/renderer.js +6041 -0
- package/dist/render/backend/webgl2/skinPaletteTexture.d.ts +32 -0
- package/dist/render/backend/webgl2/skinPaletteTexture.js +68 -0
- package/dist/render/backend/webgpu/boltPass.d.ts +42 -0
- package/dist/render/backend/webgpu/boltPass.js +160 -0
- package/dist/render/backend/webgpu/buffers.d.ts +159 -0
- package/dist/render/backend/webgpu/buffers.js +402 -0
- package/dist/render/backend/webgpu/causticsPass.d.ts +36 -0
- package/dist/render/backend/webgpu/causticsPass.js +138 -0
- package/dist/render/backend/webgpu/clusterBinner.d.ts +51 -0
- package/dist/render/backend/webgpu/clusterBinner.js +206 -0
- package/dist/render/backend/webgpu/depthPass.d.ts +114 -0
- package/dist/render/backend/webgpu/depthPass.js +228 -0
- package/dist/render/backend/webgpu/device.d.ts +52 -0
- package/dist/render/backend/webgpu/device.js +121 -0
- package/dist/render/backend/webgpu/drawCommand.d.ts +43 -0
- package/dist/render/backend/webgpu/drawCommand.js +54 -0
- package/dist/render/backend/webgpu/environmentTexels.d.ts +28 -0
- package/dist/render/backend/webgpu/environmentTexels.js +79 -0
- package/dist/render/backend/webgpu/filmPass.d.ts +29 -0
- package/dist/render/backend/webgpu/filmPass.js +97 -0
- package/dist/render/backend/webgpu/flatPass.d.ts +213 -0
- package/dist/render/backend/webgpu/flatPass.js +482 -0
- package/dist/render/backend/webgpu/flockPass.d.ts +34 -0
- package/dist/render/backend/webgpu/flockPass.js +129 -0
- package/dist/render/backend/webgpu/gpuTimestamps.d.ts +94 -0
- package/dist/render/backend/webgpu/gpuTimestamps.js +213 -0
- package/dist/render/backend/webgpu/insetPass.d.ts +19 -0
- package/dist/render/backend/webgpu/insetPass.js +108 -0
- package/dist/render/backend/webgpu/instanced.d.ts +27 -0
- package/dist/render/backend/webgpu/instanced.js +49 -0
- package/dist/render/backend/webgpu/lightVolumePass.d.ts +75 -0
- package/dist/render/backend/webgpu/lightVolumePass.js +154 -0
- package/dist/render/backend/webgpu/linePass.d.ts +90 -0
- package/dist/render/backend/webgpu/linePass.js +220 -0
- package/dist/render/backend/webgpu/morphTexture.d.ts +18 -0
- package/dist/render/backend/webgpu/morphTexture.js +51 -0
- package/dist/render/backend/webgpu/panelPass.d.ts +37 -0
- package/dist/render/backend/webgpu/panelPass.js +114 -0
- package/dist/render/backend/webgpu/particlePass.d.ts +89 -0
- package/dist/render/backend/webgpu/particlePass.js +280 -0
- package/dist/render/backend/webgpu/pipelineCache.d.ts +93 -0
- package/dist/render/backend/webgpu/pipelineCache.js +140 -0
- package/dist/render/backend/webgpu/plumePass.d.ts +69 -0
- package/dist/render/backend/webgpu/plumePass.js +213 -0
- package/dist/render/backend/webgpu/pointShadowPass.d.ts +88 -0
- package/dist/render/backend/webgpu/pointShadowPass.js +280 -0
- package/dist/render/backend/webgpu/postPass.d.ts +342 -0
- package/dist/render/backend/webgpu/postPass.js +366 -0
- package/dist/render/backend/webgpu/probePass.d.ts +108 -0
- package/dist/render/backend/webgpu/probePass.js +188 -0
- package/dist/render/backend/webgpu/reflectionPass.d.ts +29 -0
- package/dist/render/backend/webgpu/reflectionPass.js +87 -0
- package/dist/render/backend/webgpu/renderer.d.ts +3082 -0
- package/dist/render/backend/webgpu/renderer.js +10911 -0
- package/dist/render/backend/webgpu/scatterPass.d.ts +95 -0
- package/dist/render/backend/webgpu/scatterPass.js +266 -0
- package/dist/render/backend/webgpu/sdfTextPass.d.ts +86 -0
- package/dist/render/backend/webgpu/sdfTextPass.js +190 -0
- package/dist/render/backend/webgpu/shaderModules.d.ts +9 -0
- package/dist/render/backend/webgpu/shaderModules.js +45 -0
- package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.d.ts +23 -0
- package/dist/render/backend/webgpu/shaders/clusterBin.wgsl.js +208 -0
- package/dist/render/backend/webgpu/skinPaletteRing.d.ts +67 -0
- package/dist/render/backend/webgpu/skinPaletteRing.js +97 -0
- package/dist/render/backend/webgpu/skinPaletteTexture.d.ts +17 -0
- package/dist/render/backend/webgpu/skinPaletteTexture.js +68 -0
- package/dist/render/backend/webgpu/skyPass.d.ts +102 -0
- package/dist/render/backend/webgpu/skyPass.js +70 -0
- package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +41 -0
- package/dist/render/backend/webgpu/surfaceTexturePass.js +228 -0
- package/dist/render/backend/webgpu/textPass.d.ts +73 -0
- package/dist/render/backend/webgpu/textPass.js +190 -0
- package/dist/render/backend/webgpu/uniformRing.d.ts +133 -0
- package/dist/render/backend/webgpu/uniformRing.js +208 -0
- package/dist/render/backend/webgpu/waterPass.d.ts +73 -0
- package/dist/render/backend/webgpu/waterPass.js +160 -0
- package/dist/render/backend/webgpu/windStreakPass.d.ts +46 -0
- package/dist/render/backend/webgpu/windStreakPass.js +153 -0
- package/dist/render/billboard.d.ts +27 -0
- package/dist/render/billboard.js +79 -0
- package/dist/render/bloomChain.d.ts +66 -0
- package/dist/render/bloomChain.js +83 -0
- package/dist/render/bloomPass.d.ts +54 -0
- package/dist/render/bloomPass.js +219 -0
- package/dist/render/boltBatch.d.ts +39 -0
- package/dist/render/boltBatch.js +121 -0
- package/dist/render/boltPool.d.ts +135 -0
- package/dist/render/boltPool.js +259 -0
- package/dist/render/boom.d.ts +46 -0
- package/dist/render/boom.js +81 -0
- package/dist/render/camera.d.ts +119 -0
- package/dist/render/camera.js +304 -0
- package/dist/render/causticsRenderer.d.ts +63 -0
- package/dist/render/causticsRenderer.js +119 -0
- package/dist/render/cinematicCamera.d.ts +102 -0
- package/dist/render/cinematicCamera.js +227 -0
- package/dist/render/clusteredLights.d.ts +260 -0
- package/dist/render/clusteredLights.js +479 -0
- package/dist/render/colourGrade.d.ts +62 -0
- package/dist/render/colourGrade.js +91 -0
- package/dist/render/compute.d.ts +74 -0
- package/dist/render/compute.js +8 -0
- package/dist/render/contextLoss.d.ts +32 -0
- package/dist/render/contextLoss.js +46 -0
- package/dist/render/debugLines.d.ts +75 -0
- package/dist/render/debugLines.js +281 -0
- package/dist/render/decalPass.d.ts +34 -0
- package/dist/render/decalPass.js +103 -0
- package/dist/render/decalProjector.d.ts +140 -0
- package/dist/render/decalProjector.js +282 -0
- package/dist/render/decalQueue.d.ts +53 -0
- package/dist/render/decalQueue.js +87 -0
- package/dist/render/depthConvention.d.ts +314 -0
- package/dist/render/depthConvention.js +346 -0
- package/dist/render/drawingBuffer.d.ts +52 -0
- package/dist/render/drawingBuffer.js +67 -0
- package/dist/render/emptyTexture.d.ts +60 -0
- package/dist/render/emptyTexture.js +103 -0
- package/dist/render/envProbeArray.d.ts +85 -0
- package/dist/render/envProbeArray.js +164 -0
- package/dist/render/equirectToCube.d.ts +54 -0
- package/dist/render/equirectToCube.js +123 -0
- package/dist/render/flockGeometry.d.ts +23 -0
- package/dist/render/flockGeometry.js +43 -0
- package/dist/render/flockRenderer.d.ts +37 -0
- package/dist/render/flockRenderer.js +70 -0
- package/dist/render/frame/arena.d.ts +32 -0
- package/dist/render/frame/arena.js +65 -0
- package/dist/render/frame/index.d.ts +18 -0
- package/dist/render/frame/index.js +4 -0
- package/dist/render/frame/replay.d.ts +34 -0
- package/dist/render/frame/replay.js +48 -0
- package/dist/render/frame/resources.d.ts +25 -0
- package/dist/render/frame/resources.js +55 -0
- package/dist/render/frame/schedule.d.ts +37 -0
- package/dist/render/frame/schedule.js +61 -0
- package/dist/render/frameView.d.ts +19 -0
- package/dist/render/frameView.js +1 -0
- package/dist/render/gizmo.d.ts +236 -0
- package/dist/render/gizmo.js +727 -0
- package/dist/render/globalMedium.d.ts +124 -0
- package/dist/render/globalMedium.js +100 -0
- package/dist/render/globalMediumPass.d.ts +101 -0
- package/dist/render/globalMediumPass.js +250 -0
- package/dist/render/gpuCapability.d.ts +111 -0
- package/dist/render/gpuCapability.js +194 -0
- package/dist/render/gpuTimer.d.ts +87 -0
- package/dist/render/gpuTimer.js +145 -0
- package/dist/render/halfFloat.d.ts +4 -0
- package/dist/render/halfFloat.js +38 -0
- package/dist/render/handleRegistry.d.ts +54 -0
- package/dist/render/handleRegistry.js +84 -0
- package/dist/render/iesProfile.d.ts +64 -0
- package/dist/render/iesProfile.js +179 -0
- package/dist/render/imageTexels.d.ts +50 -0
- package/dist/render/imageTexels.js +91 -0
- package/dist/render/instancedMesh.d.ts +48 -0
- package/dist/render/instancedMesh.js +127 -0
- package/dist/render/instances.d.ts +69 -0
- package/dist/render/instances.js +52 -0
- package/dist/render/lightBudget.d.ts +397 -0
- package/dist/render/lightBudget.js +524 -0
- package/dist/render/lightMatrix.d.ts +3 -0
- package/dist/render/lightMatrix.js +45 -0
- package/dist/render/lightVolumeDraw.d.ts +132 -0
- package/dist/render/lightVolumeDraw.js +181 -0
- package/dist/render/lineBatch.d.ts +60 -0
- package/dist/render/lineBatch.js +160 -0
- package/dist/render/linePoints.d.ts +33 -0
- package/dist/render/linePoints.js +46 -0
- package/dist/render/livePointShadowSet.d.ts +72 -0
- package/dist/render/livePointShadowSet.js +258 -0
- package/dist/render/lod.d.ts +35 -0
- package/dist/render/lod.js +65 -0
- package/dist/render/mesh.d.ts +177 -0
- package/dist/render/mesh.js +466 -0
- package/dist/render/occlusion.d.ts +81 -0
- package/dist/render/occlusion.js +378 -0
- package/dist/render/oitPass.d.ts +67 -0
- package/dist/render/oitPass.js +213 -0
- package/dist/render/orderIndependent.d.ts +92 -0
- package/dist/render/orderIndependent.js +108 -0
- package/dist/render/particleBatch.d.ts +140 -0
- package/dist/render/particleBatch.js +186 -0
- package/dist/render/particleMaterial.d.ts +54 -0
- package/dist/render/particleMaterial.js +42 -0
- package/dist/render/particlePool.d.ts +124 -0
- package/dist/render/particlePool.js +182 -0
- package/dist/render/pass.d.ts +195 -0
- package/dist/render/pass.js +9 -0
- package/dist/render/passTarget.d.ts +86 -0
- package/dist/render/passTarget.js +121 -0
- package/dist/render/pickable.d.ts +31 -0
- package/dist/render/pickable.js +172 -0
- package/dist/render/planarReflection.d.ts +59 -0
- package/dist/render/planarReflection.js +194 -0
- package/dist/render/planarReflectionDraw.d.ts +31 -0
- package/dist/render/planarReflectionDraw.js +65 -0
- package/dist/render/plumeGeometry.d.ts +25 -0
- package/dist/render/plumeGeometry.js +61 -0
- package/dist/render/plumeMaterial.d.ts +31 -0
- package/dist/render/plumeMaterial.js +64 -0
- package/dist/render/plumeRenderer.d.ts +96 -0
- package/dist/render/plumeRenderer.js +185 -0
- package/dist/render/pointLightSelection.d.ts +175 -0
- package/dist/render/pointLightSelection.js +301 -0
- package/dist/render/pointShadowArray.d.ts +95 -0
- package/dist/render/pointShadowArray.js +219 -0
- package/dist/render/pointShadowBudget.d.ts +118 -0
- package/dist/render/pointShadowBudget.js +221 -0
- package/dist/render/pointShadowImage.d.ts +265 -0
- package/dist/render/pointShadowImage.js +339 -0
- package/dist/render/pointShadowMap.d.ts +93 -0
- package/dist/render/pointShadowMap.js +167 -0
- package/dist/render/pointShadowSystem.d.ts +195 -0
- package/dist/render/pointShadowSystem.js +336 -0
- package/dist/render/prefilterEnvMap.d.ts +124 -0
- package/dist/render/prefilterEnvMap.js +146 -0
- package/dist/render/prefilterPass.d.ts +44 -0
- package/dist/render/prefilterPass.js +98 -0
- package/dist/render/probeGrid.d.ts +122 -0
- package/dist/render/probeGrid.js +174 -0
- package/dist/render/rainField.d.ts +99 -0
- package/dist/render/rainField.js +168 -0
- package/dist/render/reflectionProbe.d.ts +188 -0
- package/dist/render/reflectionProbe.js +437 -0
- package/dist/render/renderQuality.d.ts +699 -0
- package/dist/render/renderQuality.js +293 -0
- package/dist/render/rendererHarness.d.ts +39 -0
- package/dist/render/rendererHarness.js +185 -0
- package/dist/render/resolutionGovernor.d.ts +107 -0
- package/dist/render/resolutionGovernor.js +144 -0
- package/dist/render/scatterDeform.d.ts +17 -0
- package/dist/render/scatterDeform.js +46 -0
- package/dist/render/sceneTarget.d.ts +288 -0
- package/dist/render/sceneTarget.js +856 -0
- package/dist/render/screenSpaceReflection.d.ts +233 -0
- package/dist/render/screenSpaceReflection.js +415 -0
- package/dist/render/sdfFont.d.ts +77 -0
- package/dist/render/sdfFont.js +86 -0
- package/dist/render/sdfTextLayout.d.ts +46 -0
- package/dist/render/sdfTextLayout.js +145 -0
- package/dist/render/sdfTextRenderer.d.ts +75 -0
- package/dist/render/sdfTextRenderer.js +194 -0
- package/dist/render/seaState.d.ts +25 -0
- package/dist/render/seaState.js +34 -0
- package/dist/render/segmentQuads.d.ts +29 -0
- package/dist/render/segmentQuads.js +75 -0
- package/dist/render/shader.d.ts +5 -0
- package/dist/render/shader.js +172 -0
- package/dist/render/shaders/ambientOcclusion.d.ts +45 -0
- package/dist/render/shaders/ambientOcclusion.js +352 -0
- package/dist/render/shaders/arcane.d.ts +19 -0
- package/dist/render/shaders/arcane.js +102 -0
- package/dist/render/shaders/bloom.d.ts +70 -0
- package/dist/render/shaders/bloom.js +227 -0
- package/dist/render/shaders/bolt.d.ts +17 -0
- package/dist/render/shaders/bolt.js +161 -0
- package/dist/render/shaders/caustics.d.ts +38 -0
- package/dist/render/shaders/caustics.js +167 -0
- package/dist/render/shaders/conditionals.d.ts +21 -0
- package/dist/render/shaders/conditionals.js +55 -0
- package/dist/render/shaders/decalProject.d.ts +25 -0
- package/dist/render/shaders/decalProject.js +125 -0
- package/dist/render/shaders/depth.d.ts +14 -0
- package/dist/render/shaders/depth.js +114 -0
- package/dist/render/shaders/depthOfField.d.ts +41 -0
- package/dist/render/shaders/depthOfField.js +139 -0
- package/dist/render/shaders/film.d.ts +15 -0
- package/dist/render/shaders/film.js +283 -0
- package/dist/render/shaders/fire.d.ts +12 -0
- package/dist/render/shaders/fire.js +178 -0
- package/dist/render/shaders/flat/directionalShadow.d.ts +1 -0
- package/dist/render/shaders/flat/directionalShadow.js +195 -0
- package/dist/render/shaders/flat/index.d.ts +135 -0
- package/dist/render/shaders/flat/index.js +387 -0
- package/dist/render/shaders/flat/lobes.d.ts +1 -0
- package/dist/render/shaders/flat/lobes.js +398 -0
- package/dist/render/shaders/flat/main.d.ts +2 -0
- package/dist/render/shaders/flat/main.js +1630 -0
- package/dist/render/shaders/flat/pointShadow.d.ts +1 -0
- package/dist/render/shaders/flat/pointShadow.js +322 -0
- package/dist/render/shaders/flat/preamble.d.ts +15 -0
- package/dist/render/shaders/flat/preamble.js +864 -0
- package/dist/render/shaders/flat/probeGrid.d.ts +21 -0
- package/dist/render/shaders/flat/probeGrid.js +151 -0
- package/dist/render/shaders/flat/surface.d.ts +2 -0
- package/dist/render/shaders/flat/surface.js +40 -0
- package/dist/render/shaders/flock.d.ts +11 -0
- package/dist/render/shaders/flock.js +102 -0
- package/dist/render/shaders/fog.d.ts +37 -0
- package/dist/render/shaders/fog.js +98 -0
- package/dist/render/shaders/fullscreen.d.ts +16 -0
- package/dist/render/shaders/fullscreen.js +27 -0
- package/dist/render/shaders/generated/ambientOcclusion.wgsl.d.ts +65 -0
- package/dist/render/shaders/generated/ambientOcclusion.wgsl.js +71 -0
- package/dist/render/shaders/generated/arcane.wgsl.d.ts +90 -0
- package/dist/render/shaders/generated/arcane.wgsl.js +96 -0
- package/dist/render/shaders/generated/bloom.wgsl.d.ts +69 -0
- package/dist/render/shaders/generated/bloom.wgsl.js +75 -0
- package/dist/render/shaders/generated/bolt.wgsl.d.ts +118 -0
- package/dist/render/shaders/generated/bolt.wgsl.js +124 -0
- package/dist/render/shaders/generated/caustics.wgsl.d.ts +118 -0
- package/dist/render/shaders/generated/caustics.wgsl.js +124 -0
- package/dist/render/shaders/generated/decalProject.wgsl.d.ts +61 -0
- package/dist/render/shaders/generated/decalProject.wgsl.js +67 -0
- package/dist/render/shaders/generated/depth.wgsl.d.ts +131 -0
- package/dist/render/shaders/generated/depth.wgsl.js +137 -0
- package/dist/render/shaders/generated/film.wgsl.d.ts +134 -0
- package/dist/render/shaders/generated/film.wgsl.js +140 -0
- package/dist/render/shaders/generated/fire.wgsl.d.ts +128 -0
- package/dist/render/shaders/generated/fire.wgsl.js +134 -0
- package/dist/render/shaders/generated/flat.wgsl.d.ts +9163 -0
- package/dist/render/shaders/generated/flat.wgsl.js +9192 -0
- package/dist/render/shaders/generated/flock.wgsl.d.ts +73 -0
- package/dist/render/shaders/generated/flock.wgsl.js +79 -0
- package/dist/render/shaders/generated/fullscreen.wgsl.d.ts +12 -0
- package/dist/render/shaders/generated/fullscreen.wgsl.js +18 -0
- package/dist/render/shaders/generated/globalMedium.wgsl.d.ts +130 -0
- package/dist/render/shaders/generated/globalMedium.wgsl.js +136 -0
- package/dist/render/shaders/generated/lightVolume.wgsl.d.ts +230 -0
- package/dist/render/shaders/generated/lightVolume.wgsl.js +239 -0
- package/dist/render/shaders/generated/line.wgsl.d.ts +128 -0
- package/dist/render/shaders/generated/line.wgsl.js +134 -0
- package/dist/render/shaders/generated/octahedralResolve.wgsl.d.ts +51 -0
- package/dist/render/shaders/generated/octahedralResolve.wgsl.js +57 -0
- package/dist/render/shaders/generated/oitResolve.wgsl.d.ts +23 -0
- package/dist/render/shaders/generated/oitResolve.wgsl.js +29 -0
- package/dist/render/shaders/generated/panel.wgsl.d.ts +48 -0
- package/dist/render/shaders/generated/panel.wgsl.js +54 -0
- package/dist/render/shaders/generated/particle.wgsl.d.ts +332 -0
- package/dist/render/shaders/generated/particle.wgsl.js +338 -0
- package/dist/render/shaders/generated/prefilter.wgsl.d.ts +61 -0
- package/dist/render/shaders/generated/prefilter.wgsl.js +67 -0
- package/dist/render/shaders/generated/rush.wgsl.d.ts +131 -0
- package/dist/render/shaders/generated/rush.wgsl.js +137 -0
- package/dist/render/shaders/generated/scatter.wgsl.d.ts +195 -0
- package/dist/render/shaders/generated/scatter.wgsl.js +201 -0
- package/dist/render/shaders/generated/sdfText.wgsl.d.ts +69 -0
- package/dist/render/shaders/generated/sdfText.wgsl.js +75 -0
- package/dist/render/shaders/generated/sky.wgsl.d.ts +100 -0
- package/dist/render/shaders/generated/sky.wgsl.js +106 -0
- package/dist/render/shaders/generated/smoke.wgsl.d.ts +85 -0
- package/dist/render/shaders/generated/smoke.wgsl.js +91 -0
- package/dist/render/shaders/generated/ssrResolve.wgsl.d.ts +18 -0
- package/dist/render/shaders/generated/ssrResolve.wgsl.js +24 -0
- package/dist/render/shaders/generated/ssrTrace.wgsl.d.ts +86 -0
- package/dist/render/shaders/generated/ssrTrace.wgsl.js +92 -0
- package/dist/render/shaders/generated/temporalResolve.wgsl.d.ts +46 -0
- package/dist/render/shaders/generated/temporalResolve.wgsl.js +52 -0
- package/dist/render/shaders/generated/text.wgsl.d.ts +98 -0
- package/dist/render/shaders/generated/text.wgsl.js +104 -0
- package/dist/render/shaders/generated/water.wgsl.d.ts +247 -0
- package/dist/render/shaders/generated/water.wgsl.js +253 -0
- package/dist/render/shaders/generated/windStreaks.wgsl.d.ts +73 -0
- package/dist/render/shaders/generated/windStreaks.wgsl.js +79 -0
- package/dist/render/shaders/gerstner.d.ts +21 -0
- package/dist/render/shaders/gerstner.js +110 -0
- package/dist/render/shaders/globalMedium.d.ts +56 -0
- package/dist/render/shaders/globalMedium.js +393 -0
- package/dist/render/shaders/lightVolume.d.ts +61 -0
- package/dist/render/shaders/lightVolume.js +527 -0
- package/dist/render/shaders/line.d.ts +18 -0
- package/dist/render/shaders/line.js +122 -0
- package/dist/render/shaders/morph.d.ts +26 -0
- package/dist/render/shaders/morph.js +61 -0
- package/dist/render/shaders/octahedral.d.ts +76 -0
- package/dist/render/shaders/octahedral.js +161 -0
- package/dist/render/shaders/octahedralResolve.d.ts +25 -0
- package/dist/render/shaders/octahedralResolve.js +81 -0
- package/dist/render/shaders/oitResolve.d.ts +17 -0
- package/dist/render/shaders/oitResolve.js +42 -0
- package/dist/render/shaders/outputTransform.d.ts +37 -0
- package/dist/render/shaders/outputTransform.js +106 -0
- package/dist/render/shaders/panel.d.ts +17 -0
- package/dist/render/shaders/panel.js +50 -0
- package/dist/render/shaders/particle.d.ts +82 -0
- package/dist/render/shaders/particle.js +431 -0
- package/dist/render/shaders/prefilter.d.ts +37 -0
- package/dist/render/shaders/prefilter.js +276 -0
- package/dist/render/shaders/rush.d.ts +21 -0
- package/dist/render/shaders/rush.js +355 -0
- package/dist/render/shaders/scatter.d.ts +14 -0
- package/dist/render/shaders/scatter.js +206 -0
- package/dist/render/shaders/sdfText.d.ts +9 -0
- package/dist/render/shaders/sdfText.js +65 -0
- package/dist/render/shaders/skinning.d.ts +17 -0
- package/dist/render/shaders/skinning.js +59 -0
- package/dist/render/shaders/sky.d.ts +10 -0
- package/dist/render/shaders/sky.js +242 -0
- package/dist/render/shaders/smoke.d.ts +8 -0
- package/dist/render/shaders/smoke.js +88 -0
- package/dist/render/shaders/ssrResolve.d.ts +15 -0
- package/dist/render/shaders/ssrResolve.js +28 -0
- package/dist/render/shaders/ssrTrace.d.ts +22 -0
- package/dist/render/shaders/ssrTrace.js +230 -0
- package/dist/render/shaders/tangentFrame.d.ts +17 -0
- package/dist/render/shaders/tangentFrame.js +70 -0
- package/dist/render/shaders/temporalResolve.d.ts +1 -0
- package/dist/render/shaders/temporalResolve.js +150 -0
- package/dist/render/shaders/text.d.ts +17 -0
- package/dist/render/shaders/text.js +155 -0
- package/dist/render/shaders/vertexChannel.d.ts +39 -0
- package/dist/render/shaders/vertexChannel.js +69 -0
- package/dist/render/shaders/water.d.ts +18 -0
- package/dist/render/shaders/water.js +354 -0
- package/dist/render/shaders/windStreaks.d.ts +14 -0
- package/dist/render/shaders/windStreaks.js +129 -0
- package/dist/render/shadowCasters.d.ts +107 -0
- package/dist/render/shadowCasters.js +1 -0
- package/dist/render/shadowMap.d.ts +10 -0
- package/dist/render/shadowMap.js +80 -0
- package/dist/render/shotPlacement.d.ts +80 -0
- package/dist/render/shotPlacement.js +183 -0
- package/dist/render/skinPalette.d.ts +90 -0
- package/dist/render/skinPalette.js +136 -0
- package/dist/render/ssrPass.d.ts +59 -0
- package/dist/render/ssrPass.js +196 -0
- package/dist/render/surfaceSheet.d.ts +52 -0
- package/dist/render/surfaceSheet.js +99 -0
- package/dist/render/surfaceTexture.d.ts +197 -0
- package/dist/render/surfaceTexture.js +116 -0
- package/dist/render/temporalAa.d.ts +104 -0
- package/dist/render/temporalAa.js +194 -0
- package/dist/render/temporalPass.d.ts +54 -0
- package/dist/render/temporalPass.js +135 -0
- package/dist/render/textLayout.d.ts +88 -0
- package/dist/render/textLayout.js +201 -0
- package/dist/render/textRenderer.d.ts +32 -0
- package/dist/render/textRenderer.js +176 -0
- package/dist/render/thirdPersonCamera.d.ts +272 -0
- package/dist/render/thirdPersonCamera.js +479 -0
- package/dist/render/trample.d.ts +57 -0
- package/dist/render/trample.js +134 -0
- package/dist/render/translucentQueue.d.ts +76 -0
- package/dist/render/translucentQueue.js +90 -0
- package/dist/render/uniformVectorBudget.d.ts +105 -0
- package/dist/render/uniformVectorBudget.js +201 -0
- package/dist/render/uploadStep.d.ts +14 -0
- package/dist/render/uploadStep.js +14 -0
- package/dist/render/vertexDefaults.d.ts +48 -0
- package/dist/render/vertexDefaults.js +111 -0
- package/dist/render/visibility.d.ts +22 -0
- package/dist/render/visibility.js +47 -0
- package/dist/render/waterDraw.d.ts +57 -0
- package/dist/render/waterDraw.js +102 -0
- package/dist/render/waterGrid.d.ts +62 -0
- package/dist/render/waterGrid.js +151 -0
- package/dist/render/waterRenderer.d.ts +163 -0
- package/dist/render/waterRenderer.js +165 -0
- package/dist/render/wind.d.ts +45 -0
- package/dist/render/wind.js +32 -0
- package/dist/render/windField.d.ts +34 -0
- package/dist/render/windField.js +13 -0
- package/dist/render/windStreakDraw.d.ts +73 -0
- package/dist/render/windStreakDraw.js +86 -0
- package/dist/render/windStreakRenderer.d.ts +37 -0
- package/dist/render/windStreakRenderer.js +86 -0
- package/dist/scene/node.d.ts +128 -0
- package/dist/scene/node.js +319 -0
- package/dist/scene/visit.d.ts +38 -0
- package/dist/scene/visit.js +43 -0
- package/dist/ui/clipMime.d.ts +46 -0
- package/dist/ui/clipMime.js +88 -0
- package/dist/ui/exportTarget.d.ts +305 -0
- package/dist/ui/exportTarget.js +368 -0
- package/dist/ui/frameOverlay.d.ts +59 -0
- package/dist/ui/frameOverlay.js +76 -0
- package/dist/ui/framePacer.d.ts +142 -0
- package/dist/ui/framePacer.js +284 -0
- package/dist/ui/frameRecorder.d.ts +188 -0
- package/dist/ui/frameRecorder.js +221 -0
- package/dist/ui/fullscreen.d.ts +72 -0
- package/dist/ui/fullscreen.js +92 -0
- package/dist/ui/pixelCursor.d.ts +28 -0
- package/dist/ui/pixelCursor.js +66 -0
- package/dist/ui/splash.d.ts +86 -0
- package/dist/ui/splash.js +300 -0
- package/dist/ui/stillFrame.d.ts +22 -0
- package/dist/ui/stillFrame.js +40 -0
- package/package.json +60 -0
- package/src/behavior/behaviorTree.ts +346 -0
- package/src/build/shaderComments.ts +0 -0
- package/src/cinematic/player.ts +209 -0
- package/src/cinematic/script.ts +231 -0
- package/src/core/bootGate.ts +49 -0
- package/src/core/loadTracker.ts +144 -0
- package/src/core/loop.ts +211 -0
- package/src/core/messageQueue.ts +145 -0
- package/src/core/onceSet.ts +65 -0
- package/src/core/preferences.ts +177 -0
- package/src/core/remoteSave.ts +347 -0
- package/src/core/rng.ts +101 -0
- package/src/core/stepBudget.ts +136 -0
- package/src/core/storage.ts +114 -0
- package/src/core/tickTrace.ts +129 -0
- package/src/core/timeCurve.ts +175 -0
- package/src/core/withDefaults.ts +28 -0
- package/src/dev/contactProbe.ts +115 -0
- package/src/dev/fpsMeter.ts +101 -0
- package/src/environment/celestialClock.ts +385 -0
- package/src/geometry/decal.ts +260 -0
- package/src/geometry/filmPatch.ts +158 -0
- package/src/geometry/growable.ts +165 -0
- package/src/geometry/lightVolume.ts +161 -0
- package/src/geometry/meshBuilder.ts +1397 -0
- package/src/geometry/pixelFont.ts +189 -0
- package/src/geometry/ribbon.ts +790 -0
- package/src/geometry/shellFill.ts +265 -0
- package/src/geometry/spline.ts +659 -0
- package/src/geometry/tangents.ts +173 -0
- package/src/geometry/textMesh.ts +96 -0
- package/src/geometry/treeBuilder.ts +114 -0
- package/src/host/display.ts +180 -0
- package/src/host/files.ts +77 -0
- package/src/host/lifecycle.ts +63 -0
- package/src/host/platformServices.ts +23 -0
- package/src/host/screen.ts +134 -0
- package/src/index.ts +730 -0
- package/src/input/actionMap.ts +377 -0
- package/src/input/activeDevice.ts +86 -0
- package/src/input/gamepadIdentity.ts +131 -0
- package/src/input/gamepadMapping.ts +121 -0
- package/src/input/input.ts +872 -0
- package/src/input/inputHarness.ts +226 -0
- package/src/input/rightGesture.ts +76 -0
- package/src/input/rumble.ts +138 -0
- package/src/input/touchControls.ts +451 -0
- package/src/input/typingTarget.ts +26 -0
- package/src/math/bounds.ts +153 -0
- package/src/math/color.ts +37 -0
- package/src/math/exact.ts +274 -0
- package/src/math/frustum.ts +115 -0
- package/src/math/intersect.ts +228 -0
- package/src/math/scalar.ts +109 -0
- package/src/math/spring.ts +106 -0
- package/src/nav/navGraph.ts +168 -0
- package/src/nav/navPath.ts +217 -0
- package/src/nav/navSearch.ts +200 -0
- package/src/physics/boxSurface.ts +96 -0
- package/src/physics/colliderSurface.ts +213 -0
- package/src/physics/compositeSurface.ts +111 -0
- package/src/physics/heightSurface.ts +234 -0
- package/src/physics/ribbonSurface.ts +642 -0
- package/src/render/ambientOcclusionPass.ts +200 -0
- package/src/render/areaLights.ts +194 -0
- package/src/render/areaShadowSet.ts +405 -0
- package/src/render/atmosphere.ts +186 -0
- package/src/render/backend/api.ts +802 -0
- package/src/render/backend/budget.ts +139 -0
- package/src/render/backend/createRenderer.ts +343 -0
- package/src/render/backend/deadline.ts +37 -0
- package/src/render/backend/probe.ts +152 -0
- package/src/render/backend/select.ts +288 -0
- package/src/render/backend/timer.ts +59 -0
- package/src/render/backend/webgl2/instanced.ts +46 -0
- package/src/render/backend/webgl2/morphTexture.ts +58 -0
- package/src/render/backend/webgl2/renderer.ts +7484 -0
- package/src/render/backend/webgl2/skinPaletteTexture.ts +70 -0
- package/src/render/backend/webgpu/boltPass.ts +205 -0
- package/src/render/backend/webgpu/buffers.ts +553 -0
- package/src/render/backend/webgpu/causticsPass.ts +174 -0
- package/src/render/backend/webgpu/clusterBinner.ts +259 -0
- package/src/render/backend/webgpu/depthPass.ts +261 -0
- package/src/render/backend/webgpu/device.ts +148 -0
- package/src/render/backend/webgpu/drawCommand.ts +79 -0
- package/src/render/backend/webgpu/environmentTexels.ts +96 -0
- package/src/render/backend/webgpu/filmPass.ts +123 -0
- package/src/render/backend/webgpu/flatPass.ts +635 -0
- package/src/render/backend/webgpu/flockPass.ts +163 -0
- package/src/render/backend/webgpu/gpuTimestamps.ts +255 -0
- package/src/render/backend/webgpu/insetPass.ts +123 -0
- package/src/render/backend/webgpu/instanced.ts +55 -0
- package/src/render/backend/webgpu/lightVolumePass.ts +203 -0
- package/src/render/backend/webgpu/linePass.ts +270 -0
- package/src/render/backend/webgpu/morphTexture.ts +61 -0
- package/src/render/backend/webgpu/panelPass.ts +138 -0
- package/src/render/backend/webgpu/particlePass.ts +370 -0
- package/src/render/backend/webgpu/pipelineCache.ts +152 -0
- package/src/render/backend/webgpu/plumePass.ts +292 -0
- package/src/render/backend/webgpu/pointShadowPass.ts +368 -0
- package/src/render/backend/webgpu/postPass.ts +470 -0
- package/src/render/backend/webgpu/probePass.ts +218 -0
- package/src/render/backend/webgpu/reflectionPass.ts +137 -0
- package/src/render/backend/webgpu/renderer.ts +13004 -0
- package/src/render/backend/webgpu/scatterPass.ts +354 -0
- package/src/render/backend/webgpu/sdfTextPass.ts +220 -0
- package/src/render/backend/webgpu/shaderModules.ts +49 -0
- package/src/render/backend/webgpu/shaders/clusterBin.wgsl.ts +219 -0
- package/src/render/backend/webgpu/skinPaletteRing.ts +105 -0
- package/src/render/backend/webgpu/skinPaletteTexture.ts +79 -0
- package/src/render/backend/webgpu/skyPass.ts +85 -0
- package/src/render/backend/webgpu/surfaceTexturePass.ts +257 -0
- package/src/render/backend/webgpu/textPass.ts +224 -0
- package/src/render/backend/webgpu/uniformRing.ts +228 -0
- package/src/render/backend/webgpu/waterPass.ts +211 -0
- package/src/render/backend/webgpu/windStreakPass.ts +196 -0
- package/src/render/billboard.ts +108 -0
- package/src/render/bloomChain.ts +101 -0
- package/src/render/bloomPass.ts +256 -0
- package/src/render/boltBatch.ts +141 -0
- package/src/render/boltPool.ts +360 -0
- package/src/render/boom.ts +123 -0
- package/src/render/camera.ts +348 -0
- package/src/render/causticsRenderer.ts +171 -0
- package/src/render/cinematicCamera.ts +278 -0
- package/src/render/clusteredLights.ts +598 -0
- package/src/render/colourGrade.ts +109 -0
- package/src/render/compute.ts +83 -0
- package/src/render/contextLoss.ts +50 -0
- package/src/render/debugLines.ts +411 -0
- package/src/render/decalPass.ts +124 -0
- package/src/render/decalProjector.ts +390 -0
- package/src/render/decalQueue.ts +110 -0
- package/src/render/depthConvention.ts +383 -0
- package/src/render/drawingBuffer.ts +89 -0
- package/src/render/emptyTexture.ts +130 -0
- package/src/render/envProbeArray.ts +201 -0
- package/src/render/equirectToCube.ts +160 -0
- package/src/render/flockGeometry.ts +53 -0
- package/src/render/flockRenderer.ts +111 -0
- package/src/render/frame/arena.ts +93 -0
- package/src/render/frame/index.ts +29 -0
- package/src/render/frame/replay.ts +50 -0
- package/src/render/frame/resources.ts +61 -0
- package/src/render/frame/schedule.ts +85 -0
- package/src/render/frameView.ts +20 -0
- package/src/render/gizmo.ts +923 -0
- package/src/render/globalMedium.ts +154 -0
- package/src/render/globalMediumPass.ts +323 -0
- package/src/render/gpuCapability.ts +244 -0
- package/src/render/gpuTimer.ts +182 -0
- package/src/render/halfFloat.ts +39 -0
- package/src/render/handleRegistry.ts +96 -0
- package/src/render/iesProfile.ts +215 -0
- package/src/render/imageTexels.ts +109 -0
- package/src/render/instancedMesh.ts +187 -0
- package/src/render/instances.ts +92 -0
- package/src/render/lightBudget.ts +655 -0
- package/src/render/lightMatrix.ts +69 -0
- package/src/render/lightVolumeDraw.ts +216 -0
- package/src/render/lineBatch.ts +180 -0
- package/src/render/linePoints.ts +61 -0
- package/src/render/livePointShadowSet.ts +285 -0
- package/src/render/lod.ts +86 -0
- package/src/render/mesh.ts +536 -0
- package/src/render/occlusion.ts +406 -0
- package/src/render/oitPass.ts +230 -0
- package/src/render/orderIndependent.ts +136 -0
- package/src/render/particleBatch.ts +299 -0
- package/src/render/particleMaterial.ts +84 -0
- package/src/render/particlePool.ts +291 -0
- package/src/render/pass.ts +203 -0
- package/src/render/passTarget.ts +225 -0
- package/src/render/pickable.ts +222 -0
- package/src/render/planarReflection.ts +233 -0
- package/src/render/planarReflectionDraw.ts +87 -0
- package/src/render/plumeGeometry.ts +75 -0
- package/src/render/plumeMaterial.ts +99 -0
- package/src/render/plumeRenderer.ts +272 -0
- package/src/render/pointLightSelection.ts +447 -0
- package/src/render/pointShadowArray.ts +276 -0
- package/src/render/pointShadowBudget.ts +305 -0
- package/src/render/pointShadowImage.ts +470 -0
- package/src/render/pointShadowMap.ts +228 -0
- package/src/render/pointShadowSystem.ts +408 -0
- package/src/render/prefilterEnvMap.ts +162 -0
- package/src/render/prefilterPass.ts +115 -0
- package/src/render/probeGrid.ts +248 -0
- package/src/render/rainField.ts +240 -0
- package/src/render/reflectionProbe.ts +530 -0
- package/src/render/renderQuality.ts +1054 -0
- package/src/render/rendererHarness.ts +214 -0
- package/src/render/resolutionGovernor.ts +189 -0
- package/src/render/scatterDeform.ts +72 -0
- package/src/render/sceneTarget.ts +1032 -0
- package/src/render/screenSpaceReflection.ts +524 -0
- package/src/render/sdfFont.ts +157 -0
- package/src/render/sdfTextLayout.ts +206 -0
- package/src/render/sdfTextRenderer.ts +233 -0
- package/src/render/seaState.ts +55 -0
- package/src/render/segmentQuads.ts +92 -0
- package/src/render/shader.ts +190 -0
- package/src/render/shaders/ambientOcclusion.ts +354 -0
- package/src/render/shaders/arcane.ts +103 -0
- package/src/render/shaders/bloom.ts +232 -0
- package/src/render/shaders/bolt.ts +164 -0
- package/src/render/shaders/caustics.ts +169 -0
- package/src/render/shaders/conditionals.ts +58 -0
- package/src/render/shaders/decalProject.ts +127 -0
- package/src/render/shaders/depth.ts +131 -0
- package/src/render/shaders/depthOfField.ts +141 -0
- package/src/render/shaders/film.ts +285 -0
- package/src/render/shaders/fire.ts +180 -0
- package/src/render/shaders/flat/directionalShadow.ts +196 -0
- package/src/render/shaders/flat/index.ts +502 -0
- package/src/render/shaders/flat/lobes.ts +399 -0
- package/src/render/shaders/flat/main.ts +1631 -0
- package/src/render/shaders/flat/pointShadow.ts +323 -0
- package/src/render/shaders/flat/preamble.ts +875 -0
- package/src/render/shaders/flat/probeGrid.ts +152 -0
- package/src/render/shaders/flat/surface.ts +41 -0
- package/src/render/shaders/flock.ts +103 -0
- package/src/render/shaders/fog.ts +99 -0
- package/src/render/shaders/fullscreen.ts +28 -0
- package/src/render/shaders/generated/ambientOcclusion.wgsl.ts +74 -0
- package/src/render/shaders/generated/arcane.wgsl.ts +98 -0
- package/src/render/shaders/generated/bloom.wgsl.ts +79 -0
- package/src/render/shaders/generated/bolt.wgsl.ts +127 -0
- package/src/render/shaders/generated/caustics.wgsl.ts +127 -0
- package/src/render/shaders/generated/decalProject.wgsl.ts +69 -0
- package/src/render/shaders/generated/depth.wgsl.ts +142 -0
- package/src/render/shaders/generated/film.wgsl.ts +143 -0
- package/src/render/shaders/generated/fire.wgsl.ts +137 -0
- package/src/render/shaders/generated/flat.wgsl.ts +9195 -0
- package/src/render/shaders/generated/flock.wgsl.ts +82 -0
- package/src/render/shaders/generated/fullscreen.wgsl.ts +20 -0
- package/src/render/shaders/generated/globalMedium.wgsl.ts +139 -0
- package/src/render/shaders/generated/lightVolume.wgsl.ts +242 -0
- package/src/render/shaders/generated/line.wgsl.ts +137 -0
- package/src/render/shaders/generated/octahedralResolve.wgsl.ts +60 -0
- package/src/render/shaders/generated/oitResolve.wgsl.ts +31 -0
- package/src/render/shaders/generated/panel.wgsl.ts +57 -0
- package/src/render/shaders/generated/particle.wgsl.ts +343 -0
- package/src/render/shaders/generated/prefilter.wgsl.ts +69 -0
- package/src/render/shaders/generated/rush.wgsl.ts +139 -0
- package/src/render/shaders/generated/scatter.wgsl.ts +205 -0
- package/src/render/shaders/generated/sdfText.wgsl.ts +78 -0
- package/src/render/shaders/generated/sky.wgsl.ts +109 -0
- package/src/render/shaders/generated/smoke.wgsl.ts +93 -0
- package/src/render/shaders/generated/ssrResolve.wgsl.ts +26 -0
- package/src/render/shaders/generated/ssrTrace.wgsl.ts +94 -0
- package/src/render/shaders/generated/temporalResolve.wgsl.ts +54 -0
- package/src/render/shaders/generated/text.wgsl.ts +107 -0
- package/src/render/shaders/generated/water.wgsl.ts +256 -0
- package/src/render/shaders/generated/windStreaks.wgsl.ts +82 -0
- package/src/render/shaders/gerstner.ts +110 -0
- package/src/render/shaders/globalMedium.ts +396 -0
- package/src/render/shaders/lightVolume.ts +546 -0
- package/src/render/shaders/line.ts +125 -0
- package/src/render/shaders/morph.ts +62 -0
- package/src/render/shaders/octahedral.ts +170 -0
- package/src/render/shaders/octahedralResolve.ts +83 -0
- package/src/render/shaders/oitResolve.ts +42 -0
- package/src/render/shaders/outputTransform.ts +107 -0
- package/src/render/shaders/panel.ts +51 -0
- package/src/render/shaders/particle.ts +438 -0
- package/src/render/shaders/prefilter.ts +278 -0
- package/src/render/shaders/rush.ts +357 -0
- package/src/render/shaders/scatter.ts +211 -0
- package/src/render/shaders/sdfText.ts +68 -0
- package/src/render/shaders/skinning.ts +59 -0
- package/src/render/shaders/sky.ts +243 -0
- package/src/render/shaders/smoke.ts +89 -0
- package/src/render/shaders/ssrResolve.ts +28 -0
- package/src/render/shaders/ssrTrace.ts +233 -0
- package/src/render/shaders/tangentFrame.ts +70 -0
- package/src/render/shaders/temporalResolve.ts +151 -0
- package/src/render/shaders/text.ts +156 -0
- package/src/render/shaders/vertexChannel.ts +71 -0
- package/src/render/shaders/water.ts +356 -0
- package/src/render/shaders/windStreaks.ts +130 -0
- package/src/render/shadowCasters.ts +124 -0
- package/src/render/shadowMap.ts +89 -0
- package/src/render/shotPlacement.ts +266 -0
- package/src/render/skinPalette.ts +157 -0
- package/src/render/ssrPass.ts +241 -0
- package/src/render/surfaceSheet.ts +158 -0
- package/src/render/surfaceTexture.ts +310 -0
- package/src/render/temporalAa.ts +221 -0
- package/src/render/temporalPass.ts +153 -0
- package/src/render/textLayout.ts +239 -0
- package/src/render/textRenderer.ts +201 -0
- package/src/render/thirdPersonCamera.ts +578 -0
- package/src/render/trample.ts +140 -0
- package/src/render/translucentQueue.ts +161 -0
- package/src/render/uniformVectorBudget.ts +246 -0
- package/src/render/uploadStep.ts +14 -0
- package/src/render/vertexDefaults.ts +115 -0
- package/src/render/visibility.ts +56 -0
- package/src/render/waterDraw.ts +167 -0
- package/src/render/waterGrid.ts +180 -0
- package/src/render/waterRenderer.ts +352 -0
- package/src/render/wind.ts +79 -0
- package/src/render/windField.ts +50 -0
- package/src/render/windStreakDraw.ts +131 -0
- package/src/render/windStreakRenderer.ts +130 -0
- package/src/scene/node.ts +336 -0
- package/src/scene/visit.ts +82 -0
- package/src/ui/clipMime.ts +109 -0
- package/src/ui/exportTarget.ts +491 -0
- package/src/ui/frameOverlay.ts +159 -0
- package/src/ui/framePacer.ts +351 -0
- package/src/ui/frameRecorder.ts +333 -0
- package/src/ui/fullscreen.ts +113 -0
- package/src/ui/pixelCursor.ts +99 -0
- package/src/ui/splash.ts +347 -0
- package/src/ui/stillFrame.ts +44 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allocation-free wall-clock sampling for a procedural sun, moon and clouds.
|
|
3
|
+
*
|
|
4
|
+
* **Two models, and a caller chooses by whether it names a place.** Without a `CelestialSite` this
|
|
5
|
+
* is what it has always been: a sun swung through a fixed arc, peaking at the same altitude every
|
|
6
|
+
* day of every year wherever the world is meant to be. With one, it is the standard solar-position
|
|
7
|
+
* arithmetic — a declination from the day of the year, an hour angle from the clock, and an
|
|
8
|
+
* altitude and azimuth from those and the latitude.
|
|
9
|
+
*
|
|
10
|
+
* **The simplified model is kept rather than replaced**, and that is the engine's ordinary rule
|
|
11
|
+
* rather than a soft touch: every world authored against this engine has its lighting tuned against
|
|
12
|
+
* that arc, and a model that silently moved the sun would move every shadow, every exposure and
|
|
13
|
+
* every night in every consumer at once. A caller that passes no site gets the same numbers it got
|
|
14
|
+
* before, bit for bit, which `celestialClock.test.ts` asserts against literals rather than against
|
|
15
|
+
* a second implementation.
|
|
16
|
+
*
|
|
17
|
+
* **What the simplified model gives up, said plainly, because a consumer worked it out for
|
|
18
|
+
* themselves first:** no latitude, so the sun reaches 66° at noon on the equator and at the pole
|
|
19
|
+
* alike; no season, so the arc is the same in December as in June; an azimuth that sweeps a whole
|
|
20
|
+
* turn in a day where a real one swings through rather less; and a moon pinned exactly opposite the
|
|
21
|
+
* sun, which contradicts the phase reported beside it — a crescent that rises at midnight. All four
|
|
22
|
+
* are fixed by naming a site.
|
|
23
|
+
*
|
|
24
|
+
* **A site can also name its clock, and until 2026-09-03 nothing could.** The hour was read off the
|
|
25
|
+
* timestamp through the *host machine's* time zone, so one argument put the sun in four places on
|
|
26
|
+
* four machines — solar noon at 12:00 under `TZ=UTC`, 10:00 in Rome, 16:00 in New York, 03:00 in
|
|
27
|
+
* Tokyo — and the only way to say an hour was to build a timestamp whose host offset cancelled the
|
|
28
|
+
* one being added. `longitudeDeg` and `utcOffsetHours` are the way to say it instead: either one
|
|
29
|
+
* makes the timestamp a UTC instant and the engine derives the site's own hour, so the sky is a
|
|
30
|
+
* function of the arguments alone. It was found by a player in Italy watching the sun set before
|
|
31
|
+
* six, which is what the workaround cost when the host disagreed with the world.
|
|
32
|
+
*/
|
|
33
|
+
import { TAU, smoothstep } from '../math/scalar.js';
|
|
34
|
+
const MS_PER_DAY = 86_400_000;
|
|
35
|
+
/** One hour, for shifting an instant into a site's own zone. */
|
|
36
|
+
const MS_PER_HOUR = 3_600_000;
|
|
37
|
+
/**
|
|
38
|
+
* How high the sun climbs at noon in the model that knows no latitude: 1.15 radians, 66 degrees.
|
|
39
|
+
*
|
|
40
|
+
* Unused by the sited model, which derives the altitude instead, and kept because every world
|
|
41
|
+
* authored before 2026-08-27 is tuned against it.
|
|
42
|
+
*/
|
|
43
|
+
const MAX_ELEVATION = 1.15;
|
|
44
|
+
/** Earth's axial tilt, and the default a site takes when it names none. */
|
|
45
|
+
const OBLIQUITY_DEG = 23.44;
|
|
46
|
+
/** Days in the year the declination is derived against. */
|
|
47
|
+
const YEAR_DAYS = 365;
|
|
48
|
+
const DEG = Math.PI / 180;
|
|
49
|
+
const LUNAR_CYCLE_DAYS = 29.530_588_67;
|
|
50
|
+
const NEW_MOON_EPOCH_MS = Date.UTC(2000, 0, 6, 18, 14);
|
|
51
|
+
const TWILIGHT = 0.12;
|
|
52
|
+
/**
|
|
53
|
+
* Reused because `celestialStateAt` runs every frame; `new Date` would allocate.
|
|
54
|
+
*
|
|
55
|
+
* It holds the caller's timestamp verbatim when the site names no zone, and the same instant
|
|
56
|
+
* shifted into the site's zone when it does — so the UTC getters read that site's wall clock.
|
|
57
|
+
*/
|
|
58
|
+
const scratchDate = new Date(0);
|
|
59
|
+
export function createCelestialState() {
|
|
60
|
+
return {
|
|
61
|
+
sunDir: [0, 1, 0],
|
|
62
|
+
moonDir: [0, -1, 0],
|
|
63
|
+
dayFactor: 1,
|
|
64
|
+
nightFactor: 0,
|
|
65
|
+
moonPhase: 0,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Visible fraction: new at 0/1, quarters at 0.25/0.75, full at 0.5. */
|
|
69
|
+
export function moonIllumination(phase) {
|
|
70
|
+
return 0.5 - Math.cos(phase * TAU) * 0.5;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Convert a timestamp and an authored azimuth into sky state.
|
|
74
|
+
*
|
|
75
|
+
* The caller decides where the timestamp comes from and must keep it out of a deterministic
|
|
76
|
+
* simulation if wall time should not affect gameplay.
|
|
77
|
+
*
|
|
78
|
+
* `sunAzimuth` is **where the world's north points**, as an angle in the xz plane from +x toward
|
|
79
|
+
* +z. It was an arbitrary offset in the model that knows no latitude and it means the same thing
|
|
80
|
+
* there; with a site it becomes load-bearing, because the sun's own azimuth is then derived and
|
|
81
|
+
* this is what relates it to the world's axes.
|
|
82
|
+
*
|
|
83
|
+
* **`site` is what turns the simplified model into the sited one**, and omitting it is not a
|
|
84
|
+
* degraded mode — it is the model every world here was authored against. See the header.
|
|
85
|
+
*
|
|
86
|
+
* **Which hour the timestamp names depends on whether the site states a zone**, and that is the
|
|
87
|
+
* one thing to get right before anything else here matters:
|
|
88
|
+
*
|
|
89
|
+
* - **A site naming `longitudeDeg` or `utcOffsetHours`** makes `whenMs` a plain **UTC instant** —
|
|
90
|
+
* `Date.now()`, or `Date.UTC(…)` for an hour chosen outright — and the engine derives that
|
|
91
|
+
* site's own hour from it. The answer is then a function of the arguments and of nothing else,
|
|
92
|
+
* which is the only form that gives every machine the same sky.
|
|
93
|
+
* - **A site naming neither, or no site at all**, reads the hour off the timestamp through the
|
|
94
|
+
* **host machine's** time zone, which is what this function has always done. Every world
|
|
95
|
+
* authored against it is tuned that way, so it is kept exactly: the same argument gives the same
|
|
96
|
+
* numbers, bit for bit. But the same argument on another machine gives another hour, so a caller
|
|
97
|
+
* in this form must build the timestamp from local parts — `new Date(y, m, d, h)` — for the
|
|
98
|
+
* host's offset to cancel rather than be added.
|
|
99
|
+
*
|
|
100
|
+
* **`moonPhase` is the reason the first form is worth taking even where the sun already looks
|
|
101
|
+
* right.** It comes from the timestamp's absolute value rather than from the hour, so the
|
|
102
|
+
* build-it-from-local-parts trick that steadies the sun leaves the moon drifting by the host's
|
|
103
|
+
* offset — a fiftieth of a lunar cycle across the world, invisible and still not a fact about the
|
|
104
|
+
* world.
|
|
105
|
+
*
|
|
106
|
+
* **The equation of time stays the caller's**, and it is the last correction left: a real sun runs
|
|
107
|
+
* up to about a quarter of an hour ahead of or behind mean time across the year, from the Earth's
|
|
108
|
+
* eccentricity and its tilt. The zone and the meridian are the engine's as soon as a site states
|
|
109
|
+
* them; this one is not, because it is a property of the planet's orbit rather than of the place,
|
|
110
|
+
* and a world with an obliquity of its own has an equation of time of its own. A caller measuring
|
|
111
|
+
* a shadow against an almanac applies it to the timestamp; a caller lighting a world does not care.
|
|
112
|
+
*/
|
|
113
|
+
export function celestialStateAt(whenMs, sunAzimuth, out, site) {
|
|
114
|
+
const cycles = (whenMs - NEW_MOON_EPOCH_MS) / MS_PER_DAY / LUNAR_CYCLE_DAYS;
|
|
115
|
+
const phase = cycles - Math.floor(cycles);
|
|
116
|
+
out.moonPhase = phase;
|
|
117
|
+
if (site === undefined) {
|
|
118
|
+
scratchDate.setTime(whenMs);
|
|
119
|
+
simplified(hostHours(scratchDate), sunAzimuth, out);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
/*
|
|
123
|
+
* The zone, or nothing.
|
|
124
|
+
*
|
|
125
|
+
* A longitude alone implies its own offset, so a site that gives one and not the other still
|
|
126
|
+
* describes a consistent clock: `undefined` here means the site named neither, which is the
|
|
127
|
+
* one case that falls back to the host's.
|
|
128
|
+
*/
|
|
129
|
+
const meridianDeg = site.longitudeDeg;
|
|
130
|
+
const offsetHours = site.utcOffsetHours ?? (meridianDeg === undefined ? undefined : meridianDeg / 15);
|
|
131
|
+
if (offsetHours === undefined) {
|
|
132
|
+
scratchDate.setTime(whenMs);
|
|
133
|
+
sited(hostHours(scratchDate), site.dayOfYear ?? hostDayOfYear(scratchDate), sunAzimuth, phase, site, out);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
/*
|
|
137
|
+
* Shifted into the site's zone, so the UTC getters read its wall clock; the meridian then
|
|
138
|
+
* carries that clock the rest of the way to solar time, which is where the hour angle is
|
|
139
|
+
* measured from. That correction is zero for a place at the centre of its zone and up to
|
|
140
|
+
* half an hour at its edges. It can push the hour past midnight either way and nothing needs
|
|
141
|
+
* it wrapped: an hour angle is an angle, and the calendar day is the site's rather than the
|
|
142
|
+
* sun's.
|
|
143
|
+
*/
|
|
144
|
+
scratchDate.setTime(whenMs + offsetHours * MS_PER_HOUR);
|
|
145
|
+
const solar = utcHours(scratchDate) + (meridianDeg ?? offsetHours * 15) / 15 - offsetHours;
|
|
146
|
+
sited(solar, site.dayOfYear ?? utcDayOfYear(scratchDate), sunAzimuth, phase, site, out);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
out.dayFactor = smoothstep(-TWILIGHT, TWILIGHT, out.sunDir[1]);
|
|
150
|
+
out.nightFactor = 1 - out.dayFactor;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The model that knows no latitude, unchanged since it was written.
|
|
154
|
+
*
|
|
155
|
+
* A sine of the day's fraction scaled to a fixed peak, an azimuth sweeping a whole turn, and a moon
|
|
156
|
+
* pinned exactly opposite. Every number a world authored before 2026-08-27 was tuned against.
|
|
157
|
+
*/
|
|
158
|
+
function simplified(hours, sunAzimuth, out) {
|
|
159
|
+
const fraction = hours / 24;
|
|
160
|
+
const elevation = Math.sin((fraction - 0.25) * TAU) * MAX_ELEVATION;
|
|
161
|
+
const azimuth = sunAzimuth + (fraction - 0.25) * TAU;
|
|
162
|
+
const cosElevation = Math.cos(elevation);
|
|
163
|
+
const sx = cosElevation * Math.cos(azimuth);
|
|
164
|
+
const sy = Math.sin(elevation);
|
|
165
|
+
const sz = cosElevation * Math.sin(azimuth);
|
|
166
|
+
out.sunDir[0] = sx;
|
|
167
|
+
out.sunDir[1] = sy;
|
|
168
|
+
out.sunDir[2] = sz;
|
|
169
|
+
out.moonDir[0] = -sx;
|
|
170
|
+
out.moonDir[1] = -sy;
|
|
171
|
+
out.moonDir[2] = -sz;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The sited model: a declination, an hour angle, and the two spherical formulas over them.
|
|
175
|
+
*
|
|
176
|
+
* **Standard solar-position arithmetic and deliberately the plain form of it.** The declination is
|
|
177
|
+
* Cooper's equation, `ε · sin(2π (284 + N) / 365)`, which is within about half a degree of the
|
|
178
|
+
* truth all year; the altitude and azimuth are the spherical law of cosines and its companion. A
|
|
179
|
+
* more accurate model exists — the equation of centre, nutation, refraction — and buys a fraction
|
|
180
|
+
* of a degree for a sky nobody is navigating by.
|
|
181
|
+
*
|
|
182
|
+
* **The moon follows its phase rather than the sun's opposite**, which is what makes the position
|
|
183
|
+
* and the phase agree at last. The phase *is* the elongation: at new moon the moon shares the sun's
|
|
184
|
+
* ecliptic longitude and its hour angle, so it is up in the daytime and invisible; at full it is
|
|
185
|
+
* half a turn away in both, so it rises as the sun sets. Its own five-degree orbital inclination is
|
|
186
|
+
* ignored, which is what makes this a line rather than a page and costs the moon up to five degrees
|
|
187
|
+
* of altitude.
|
|
188
|
+
*
|
|
189
|
+
* **It takes an hour and a day rather than a `Date`**, because which clock those came off is the
|
|
190
|
+
* caller's question and settled before this is reached — see `celestialStateAt`. The model itself
|
|
191
|
+
* has no time zone in it at all.
|
|
192
|
+
*/
|
|
193
|
+
function sited(hours, day, northAzimuth, phase, site, out) {
|
|
194
|
+
const latitude = Math.max(-90, Math.min(90, site.latitudeDeg)) * DEG;
|
|
195
|
+
const obliquity = (site.obliquityDeg ?? OBLIQUITY_DEG) * DEG;
|
|
196
|
+
/* Ecliptic longitude measured from the point that puts the solstices where they belong. */
|
|
197
|
+
const sunLongitude = (TAU * (284 + day)) / YEAR_DAYS;
|
|
198
|
+
const sunHourAngle = (hours - 12) * (Math.PI / 12);
|
|
199
|
+
place(latitude, Math.asin(Math.sin(obliquity) * Math.sin(sunLongitude)), sunHourAngle, northAzimuth, out.sunDir);
|
|
200
|
+
/*
|
|
201
|
+
* The moon, a phase's worth of longitude ahead of the sun and the same amount behind in hour
|
|
202
|
+
* angle — because an hour angle is the sky turning westward and a longitude is the moon crawling
|
|
203
|
+
* eastward through it.
|
|
204
|
+
*/
|
|
205
|
+
const moonLongitude = sunLongitude + phase * TAU;
|
|
206
|
+
place(latitude, Math.asin(Math.sin(obliquity) * Math.sin(moonLongitude)), sunHourAngle - phase * TAU, northAzimuth, out.moonDir);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A declination and an hour angle at a latitude, into a world-space direction.
|
|
210
|
+
*
|
|
211
|
+
* `sin(alt) = sin φ sin δ + cos φ cos δ cos H` is the altitude; the azimuth is the `atan2` form,
|
|
212
|
+
* which needs no quadrant test and is stable at the poles where the cosine form divides by nearly
|
|
213
|
+
* nothing. It comes out measured from **south**, so half a turn puts it on north, and the world's
|
|
214
|
+
* own north then rotates the whole sky into place.
|
|
215
|
+
*/
|
|
216
|
+
function place(latitude, declination, hourAngle, northAzimuth, out) {
|
|
217
|
+
const sinLat = Math.sin(latitude);
|
|
218
|
+
const cosLat = Math.cos(latitude);
|
|
219
|
+
const sinDec = Math.sin(declination);
|
|
220
|
+
const cosDec = Math.cos(declination);
|
|
221
|
+
const sinAlt = sinLat * sinDec + cosLat * cosDec * Math.cos(hourAngle);
|
|
222
|
+
const altitude = Math.asin(Math.max(-1, Math.min(1, sinAlt)));
|
|
223
|
+
const fromSouth = Math.atan2(Math.sin(hourAngle) * cosDec, Math.cos(hourAngle) * cosDec * sinLat - sinDec * cosLat);
|
|
224
|
+
const azimuth = northAzimuth + fromSouth + Math.PI;
|
|
225
|
+
const cosAltitude = Math.cos(altitude);
|
|
226
|
+
out[0] = cosAltitude * Math.cos(azimuth);
|
|
227
|
+
out[1] = Math.sin(altitude);
|
|
228
|
+
out[2] = cosAltitude * Math.sin(azimuth);
|
|
229
|
+
}
|
|
230
|
+
/** The hour, with its minutes and seconds, off the host machine's own clock. */
|
|
231
|
+
function hostHours(date) {
|
|
232
|
+
return date.getHours() + date.getMinutes() / 60 + date.getSeconds() / 3600;
|
|
233
|
+
}
|
|
234
|
+
/** The same, off an instant already shifted into the site's zone. See `scratchDate`. */
|
|
235
|
+
function utcHours(date) {
|
|
236
|
+
return date.getUTCHours() + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Which day of the year a host-local date falls on, 1 to 366.
|
|
240
|
+
*
|
|
241
|
+
* From the date's own month and day rather than a difference of timestamps, because a difference
|
|
242
|
+
* across a daylight-saving boundary is an hour short and lands on the previous day for an hour of
|
|
243
|
+
* every spring.
|
|
244
|
+
*/
|
|
245
|
+
function hostDayOfYear(date) {
|
|
246
|
+
const start = Date.UTC(date.getFullYear(), 0, 1);
|
|
247
|
+
const here = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
248
|
+
return Math.round((here - start) / MS_PER_DAY) + 1;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The same for an instant already shifted into the site's zone, read through the UTC getters.
|
|
252
|
+
*
|
|
253
|
+
* A separate four lines rather than a flag, because the pair is the whole difference between the
|
|
254
|
+
* two clocks this function can be asked about and folding them together hides it. No daylight
|
|
255
|
+
* saving to step around here: the shift was a constant, so the difference of timestamps would
|
|
256
|
+
* have done — it is written this way to read beside its neighbour.
|
|
257
|
+
*/
|
|
258
|
+
function utcDayOfYear(date) {
|
|
259
|
+
const start = Date.UTC(date.getUTCFullYear(), 0, 1);
|
|
260
|
+
const here = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
261
|
+
return Math.round((here - start) / MS_PER_DAY) + 1;
|
|
262
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { MeshData } from '../render/mesh.ts';
|
|
2
|
+
import type { Vec3 } from '../math/color.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A decal, as the receiving surface's own geometry clipped to a box and lifted off it.
|
|
5
|
+
*
|
|
6
|
+
* **A forward renderer cannot write a decal cheaply into a G-buffer, because there is no G-buffer**,
|
|
7
|
+
* and that is the fact every decal design here has to start from. What a forward renderer *can* do
|
|
8
|
+
* is the older technique, and it is the better-looking one: take the triangles the projector box
|
|
9
|
+
* covers, clip them to it, and draw that. The decal is then made of the surface, so it follows
|
|
10
|
+
* every curve and every bump exactly, which a projector re-drawing a quad cannot.
|
|
11
|
+
*
|
|
12
|
+
* **What it replaces, in a consumer's own words.** Their road patches are strips of geometry lifted
|
|
13
|
+
* two millimetres above the carriageway: it works, it is a draw call per patch for something that
|
|
14
|
+
* exists only to sit on top of something else, and it does not follow a curved surface. Puddles
|
|
15
|
+
* after a storm, oil stains and skid marks were all waiting on the same row. This is one mesh for
|
|
16
|
+
* as many marks as you project into it, and it is the road's own shape.
|
|
17
|
+
*
|
|
18
|
+
* **Built once, not per frame.** A decal is authored or placed by an event — a tyre locks, a barrel
|
|
19
|
+
* leaks — and then it is scenery. That is what makes clipping on the CPU the right cost: it happens
|
|
20
|
+
* at the moment the mark is made, and every frame afterwards it is one more mesh in the batch.
|
|
21
|
+
*
|
|
22
|
+
* **Its limits, stated rather than discovered.** It is a *static* decal: the receiving mesh is
|
|
23
|
+
* sampled as it is, so a decal on something that later deforms rides the old shape. It reads
|
|
24
|
+
* positions and normals and nothing else, so the mark takes its own colour rather than tinting what
|
|
25
|
+
* is underneath. And a projector box covering a hundred thousand triangles clips a hundred thousand
|
|
26
|
+
* triangles, so a caller marking a large world hands in the piece of it they mean.
|
|
27
|
+
*/
|
|
28
|
+
export interface DecalOptions {
|
|
29
|
+
/** Middle of the projector box, world space. */
|
|
30
|
+
readonly center: Vec3;
|
|
31
|
+
/** Half-size across, up, and along the projection. The third is how deep the box reaches. */
|
|
32
|
+
readonly halfExtents: Vec3;
|
|
33
|
+
/**
|
|
34
|
+
* The direction the decal is projected *along* — for a mark on the ground, straight down.
|
|
35
|
+
*
|
|
36
|
+
* A surface is marked when it faces back along this. Need not be normalised.
|
|
37
|
+
*/
|
|
38
|
+
readonly forward: Vec3;
|
|
39
|
+
/** Which way is up in the decal's own image, so a mark can be turned. Need not be normalised. */
|
|
40
|
+
readonly up: Vec3;
|
|
41
|
+
readonly color?: Vec3;
|
|
42
|
+
/**
|
|
43
|
+
* How far the decal is lifted off the surface, metres. Two millimetres by default.
|
|
44
|
+
*
|
|
45
|
+
* **Not a depth-bias setting in disguise.** The lift is along each vertex's own normal, so it
|
|
46
|
+
* survives a surface that curves away under it where a constant depth offset would not, and it is
|
|
47
|
+
* small enough to be invisible at a metre and large enough to beat a 24-bit depth buffer at fifty.
|
|
48
|
+
*/
|
|
49
|
+
readonly offsetM?: number;
|
|
50
|
+
/**
|
|
51
|
+
* How far from facing the projector a surface may be turned and still be marked, as a cosine.
|
|
52
|
+
*
|
|
53
|
+
* The reason this is not zero: a triangle exactly edge-on to the projector clips to a sliver of
|
|
54
|
+
* zero area that still costs six vertices, and one a hair past edge-on produces a mark stretched
|
|
55
|
+
* along a wall it was never aimed at. 0.1 keeps everything within about 84° of facing.
|
|
56
|
+
*/
|
|
57
|
+
readonly facingCos?: number;
|
|
58
|
+
readonly emissive?: number;
|
|
59
|
+
readonly specular?: number;
|
|
60
|
+
}
|
|
61
|
+
export declare function projectDecal(target: MeshData, options: DecalOptions): MeshData;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/** Room for one clipped polygon: six planes can each add a vertex to a triangle. */
|
|
2
|
+
const MAX_POLYGON = 12;
|
|
3
|
+
/** Position in box space and normal in world space, per vertex, in both ping-pong buffers. */
|
|
4
|
+
const A = new Float64Array(MAX_POLYGON * 6);
|
|
5
|
+
const B = new Float64Array(MAX_POLYGON * 6);
|
|
6
|
+
export function projectDecal(target, options) {
|
|
7
|
+
const half = options.halfExtents;
|
|
8
|
+
const hx = half[0];
|
|
9
|
+
const hy = half[1];
|
|
10
|
+
const hz = half[2];
|
|
11
|
+
if (!(hx > 0 && hy > 0 && hz > 0)) {
|
|
12
|
+
throw new Error(`projectDecal: halfExtents must be positive, got ${hx}, ${hy}, ${hz}`);
|
|
13
|
+
}
|
|
14
|
+
/* The box's own basis. `forward` is the projection axis and `right` closes the frame. */
|
|
15
|
+
const f = unit(options.forward);
|
|
16
|
+
let u = unit(options.up);
|
|
17
|
+
const r = cross(u, f);
|
|
18
|
+
const rLength = Math.hypot(r[0], r[1], r[2]);
|
|
19
|
+
if (rLength === 0) {
|
|
20
|
+
throw new Error('projectDecal: up is parallel to forward, so the box has no orientation');
|
|
21
|
+
}
|
|
22
|
+
r[0] /= rLength;
|
|
23
|
+
r[1] /= rLength;
|
|
24
|
+
r[2] /= rLength;
|
|
25
|
+
/* Re-derived so the frame is orthonormal even where the caller's up was not perpendicular. */
|
|
26
|
+
u = cross(f, r);
|
|
27
|
+
const facingCos = options.facingCos ?? 0.1;
|
|
28
|
+
const offsetM = options.offsetM ?? 0.002;
|
|
29
|
+
const colour = options.color ?? [1, 1, 1];
|
|
30
|
+
const emissive = options.emissive ?? 0;
|
|
31
|
+
const specular = options.specular ?? 0;
|
|
32
|
+
const centre = options.center;
|
|
33
|
+
const positions = [];
|
|
34
|
+
const normals = [];
|
|
35
|
+
const colors = [];
|
|
36
|
+
const emissives = [];
|
|
37
|
+
const speculars = [];
|
|
38
|
+
const uvs = [];
|
|
39
|
+
const indices = [];
|
|
40
|
+
const triangles = target.indices.length / 3;
|
|
41
|
+
for (let t = 0; t < triangles; t++) {
|
|
42
|
+
const i0 = target.indices[t * 3] ?? 0;
|
|
43
|
+
const i1 = target.indices[t * 3 + 1] ?? 0;
|
|
44
|
+
const i2 = target.indices[t * 3 + 2] ?? 0;
|
|
45
|
+
/*
|
|
46
|
+
* The *geometric* normal decides whether the triangle is marked, not the shaded one. A smooth
|
|
47
|
+
* sphere's vertex normals fan out around a triangle, so a facing test on any one of them turns
|
|
48
|
+
* a decal on and off along an edge nobody can see; the plane the triangle actually lies in is
|
|
49
|
+
* the thing the projector either sees or does not.
|
|
50
|
+
*/
|
|
51
|
+
const nx = geoNormal(target, i0, i1, i2, 0);
|
|
52
|
+
const ny = geoNormal(target, i0, i1, i2, 1);
|
|
53
|
+
const nz = geoNormal(target, i0, i1, i2, 2);
|
|
54
|
+
const facing = -(nx * f[0] + ny * f[1] + nz * f[2]);
|
|
55
|
+
if (facing < facingCos)
|
|
56
|
+
continue;
|
|
57
|
+
let count = 3;
|
|
58
|
+
for (let corner = 0; corner < 3; corner++) {
|
|
59
|
+
const v = corner === 0 ? i0 : corner === 1 ? i1 : i2;
|
|
60
|
+
const px = (target.positions[v * 3] ?? 0) - centre[0];
|
|
61
|
+
const py = (target.positions[v * 3 + 1] ?? 0) - centre[1];
|
|
62
|
+
const pz = (target.positions[v * 3 + 2] ?? 0) - centre[2];
|
|
63
|
+
A[corner * 6] = px * r[0] + py * r[1] + pz * r[2];
|
|
64
|
+
A[corner * 6 + 1] = px * u[0] + py * u[1] + pz * u[2];
|
|
65
|
+
A[corner * 6 + 2] = px * f[0] + py * f[1] + pz * f[2];
|
|
66
|
+
A[corner * 6 + 3] = target.normals[v * 3] ?? 0;
|
|
67
|
+
A[corner * 6 + 4] = target.normals[v * 3 + 1] ?? 0;
|
|
68
|
+
A[corner * 6 + 5] = target.normals[v * 3 + 2] ?? 0;
|
|
69
|
+
}
|
|
70
|
+
/* Sutherland–Hodgman against the six faces of the box, in the box's own space where each is a
|
|
71
|
+
comparison against a constant. */
|
|
72
|
+
let source = A;
|
|
73
|
+
let sink = B;
|
|
74
|
+
for (let axis = 0; axis < 3 && count > 0; axis++) {
|
|
75
|
+
const limit = axis === 0 ? hx : axis === 1 ? hy : hz;
|
|
76
|
+
for (const sign of [1, -1]) {
|
|
77
|
+
count = clip(source, count, sink, axis, sign, limit);
|
|
78
|
+
const swap = source;
|
|
79
|
+
source = sink;
|
|
80
|
+
sink = swap;
|
|
81
|
+
if (count === 0)
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (count < 3)
|
|
86
|
+
continue;
|
|
87
|
+
const base = positions.length / 3;
|
|
88
|
+
for (let v = 0; v < count; v++) {
|
|
89
|
+
const bx = source[v * 6] ?? 0;
|
|
90
|
+
const by = source[v * 6 + 1] ?? 0;
|
|
91
|
+
const bz = source[v * 6 + 2] ?? 0;
|
|
92
|
+
let vnx = source[v * 6 + 3] ?? 0;
|
|
93
|
+
let vny = source[v * 6 + 4] ?? 0;
|
|
94
|
+
let vnz = source[v * 6 + 5] ?? 0;
|
|
95
|
+
/* An interpolated normal is shorter than unit between two that differ. */
|
|
96
|
+
const length = Math.hypot(vnx, vny, vnz) || 1;
|
|
97
|
+
vnx /= length;
|
|
98
|
+
vny /= length;
|
|
99
|
+
vnz /= length;
|
|
100
|
+
positions.push(centre[0] + r[0] * bx + u[0] * by + f[0] * bz + vnx * offsetM, centre[1] + r[1] * bx + u[1] * by + f[1] * bz + vny * offsetM, centre[2] + r[2] * bx + u[2] * by + f[2] * bz + vnz * offsetM);
|
|
101
|
+
normals.push(vnx, vny, vnz);
|
|
102
|
+
colors.push(colour[0], colour[1], colour[2]);
|
|
103
|
+
emissives.push(emissive);
|
|
104
|
+
speculars.push(specular);
|
|
105
|
+
/* The projection is the mapping: across the box is u, up the box is v. */
|
|
106
|
+
uvs.push(bx / (hx * 2) + 0.5, by / (hy * 2) + 0.5);
|
|
107
|
+
}
|
|
108
|
+
for (let v = 2; v < count; v++)
|
|
109
|
+
indices.push(base, base + v - 1, base + v);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
positions: Float32Array.from(positions),
|
|
113
|
+
normals: Float32Array.from(normals),
|
|
114
|
+
colors: Float32Array.from(colors),
|
|
115
|
+
emissive: Float32Array.from(emissives),
|
|
116
|
+
specular: Float32Array.from(speculars),
|
|
117
|
+
uvs: Float32Array.from(uvs),
|
|
118
|
+
indices: Uint32Array.from(indices),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Keep the part of the polygon on the inside of one box face, interpolating across the crossings.
|
|
123
|
+
*
|
|
124
|
+
* Every attribute is carried through the same `t`, which is what makes a clipped normal the normal
|
|
125
|
+
* the surface had at that point rather than one of the corners'.
|
|
126
|
+
*/
|
|
127
|
+
function clip(source, count, sink, axis, sign, limit) {
|
|
128
|
+
let out = 0;
|
|
129
|
+
for (let i = 0; i < count; i++) {
|
|
130
|
+
const j = (i + 1) % count;
|
|
131
|
+
const di = sign * (source[i * 6 + axis] ?? 0) - limit;
|
|
132
|
+
const dj = sign * (source[j * 6 + axis] ?? 0) - limit;
|
|
133
|
+
if (di <= 0) {
|
|
134
|
+
if (out < MAX_POLYGON)
|
|
135
|
+
copy(source, i, sink, out++);
|
|
136
|
+
}
|
|
137
|
+
if (di > 0 !== dj > 0) {
|
|
138
|
+
const t = di / (di - dj);
|
|
139
|
+
if (out < MAX_POLYGON) {
|
|
140
|
+
for (let k = 0; k < 6; k++) {
|
|
141
|
+
const a = source[i * 6 + k] ?? 0;
|
|
142
|
+
const b = source[j * 6 + k] ?? 0;
|
|
143
|
+
sink[out * 6 + k] = a + (b - a) * t;
|
|
144
|
+
}
|
|
145
|
+
out++;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
function copy(source, from, sink, to) {
|
|
152
|
+
for (let k = 0; k < 6; k++)
|
|
153
|
+
sink[to * 6 + k] = source[from * 6 + k] ?? 0;
|
|
154
|
+
}
|
|
155
|
+
/** One component of the triangle's own plane normal, unit length. */
|
|
156
|
+
function geoNormal(mesh, i0, i1, i2, component) {
|
|
157
|
+
const ax = mesh.positions[i0 * 3] ?? 0;
|
|
158
|
+
const ay = mesh.positions[i0 * 3 + 1] ?? 0;
|
|
159
|
+
const az = mesh.positions[i0 * 3 + 2] ?? 0;
|
|
160
|
+
const ux = (mesh.positions[i1 * 3] ?? 0) - ax;
|
|
161
|
+
const uy = (mesh.positions[i1 * 3 + 1] ?? 0) - ay;
|
|
162
|
+
const uz = (mesh.positions[i1 * 3 + 2] ?? 0) - az;
|
|
163
|
+
const vx = (mesh.positions[i2 * 3] ?? 0) - ax;
|
|
164
|
+
const vy = (mesh.positions[i2 * 3 + 1] ?? 0) - ay;
|
|
165
|
+
const vz = (mesh.positions[i2 * 3 + 2] ?? 0) - az;
|
|
166
|
+
const nx = uy * vz - uz * vy;
|
|
167
|
+
const ny = uz * vx - ux * vz;
|
|
168
|
+
const nz = ux * vy - uy * vx;
|
|
169
|
+
const length = Math.hypot(nx, ny, nz) || 1;
|
|
170
|
+
return (component === 0 ? nx : component === 1 ? ny : nz) / length;
|
|
171
|
+
}
|
|
172
|
+
function unit(v) {
|
|
173
|
+
const length = Math.hypot(v[0], v[1], v[2]) || 1;
|
|
174
|
+
return [v[0] / length, v[1] / length, v[2] / length];
|
|
175
|
+
}
|
|
176
|
+
function cross(a, b) {
|
|
177
|
+
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
178
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rounded, feathered patch lying on a swept surface.
|
|
3
|
+
*
|
|
4
|
+
* The shape a spill has. Not a rectangle, not a decal, not a box: an irregular
|
|
5
|
+
* lens that follows the surface's curvature and bank and dissolves at its rim.
|
|
6
|
+
*
|
|
7
|
+
* The rim is the whole reason this exists. A patch drawn with a hard edge reads as
|
|
8
|
+
* a sticker on the world no matter what material it is made of, because a real
|
|
9
|
+
* puddle is thinnest where it ends — so this emits a *coverage* value per vertex,
|
|
10
|
+
* 1 through the middle and 0 around the outside, and the film shader turns that
|
|
11
|
+
* into alpha. Geometry supplies the silhouette; the shader supplies the wetness.
|
|
12
|
+
*
|
|
13
|
+
* Textureless and engine-generic: it takes a curve, a window along it, a width and
|
|
14
|
+
* a seed, and knows nothing about oil, water or what a slick is for.
|
|
15
|
+
*/
|
|
16
|
+
import type { MeshData } from '../render/mesh.ts';
|
|
17
|
+
import type { Spline } from './spline.ts';
|
|
18
|
+
import type { Vec3 } from '../math/color.ts';
|
|
19
|
+
export interface FilmPatchOptions {
|
|
20
|
+
/** Arc-length window on the curve. */
|
|
21
|
+
fromM: number;
|
|
22
|
+
toM: number;
|
|
23
|
+
/** Lateral centre and half-width, metres from the centreline. */
|
|
24
|
+
centreM: number;
|
|
25
|
+
halfWidthM: number;
|
|
26
|
+
/** Height above the surface. Small: this is a film, not a kerb. */
|
|
27
|
+
liftM: number;
|
|
28
|
+
color: Vec3;
|
|
29
|
+
/**
|
|
30
|
+
* Shape seed. Two patches with the same window and the same seed are the same
|
|
31
|
+
* patch, which is what keeps a day's world identical on every device.
|
|
32
|
+
*/
|
|
33
|
+
seed: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function buildFilmPatch(spline: Spline, options: FilmPatchOptions): MeshData;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createSplineSample } from './spline.js';
|
|
2
|
+
/**
|
|
3
|
+
* Stations along the patch, and vertices across it.
|
|
4
|
+
*
|
|
5
|
+
* Nine across is what a soft rim costs: the outer pair carry zero coverage, so
|
|
6
|
+
* they contribute silhouette rather than colour, and the falloff needs a couple of
|
|
7
|
+
* rings inside them or the shoulder becomes a visible band.
|
|
8
|
+
*/
|
|
9
|
+
const MIN_STATIONS = 7;
|
|
10
|
+
const STATION_SPACING_M = 0.7;
|
|
11
|
+
const ACROSS = 9;
|
|
12
|
+
/**
|
|
13
|
+
* How much the outline wanders, as a fraction of the half-width.
|
|
14
|
+
*
|
|
15
|
+
* Enough that no two slicks are the same lens and none of them looks drawn with a
|
|
16
|
+
* compass; not so much that the patch stops reading as one connected spill.
|
|
17
|
+
*/
|
|
18
|
+
const WOBBLE = 0.28;
|
|
19
|
+
export function buildFilmPatch(spline, options) {
|
|
20
|
+
const spanM = Math.max(options.toM - options.fromM, 0.1);
|
|
21
|
+
const stations = Math.max(MIN_STATIONS, Math.ceil(spanM / STATION_SPACING_M) | 1);
|
|
22
|
+
const vertexCount = stations * ACROSS;
|
|
23
|
+
const positions = new Float32Array(vertexCount * 3);
|
|
24
|
+
const normals = new Float32Array(vertexCount * 3);
|
|
25
|
+
const colors = new Float32Array(vertexCount * 3);
|
|
26
|
+
const coverage = new Float32Array(vertexCount);
|
|
27
|
+
const indices = new Uint32Array((stations - 1) * (ACROSS - 1) * 6);
|
|
28
|
+
const sample = createSplineSample();
|
|
29
|
+
// Two incommensurable frequencies per axis, so the outline does not repeat
|
|
30
|
+
// across a long patch, and phases from the seed so each one is its own shape.
|
|
31
|
+
const phaseA = (options.seed % 1000) * 0.0063;
|
|
32
|
+
const phaseB = (options.seed % 997) * 0.0157;
|
|
33
|
+
let v = 0;
|
|
34
|
+
let i = 0;
|
|
35
|
+
for (let s = 0; s < stations; s++) {
|
|
36
|
+
// -1 at the near end, +1 at the far end.
|
|
37
|
+
const along = (s / (stations - 1)) * 2 - 1;
|
|
38
|
+
const d = options.fromM + ((along + 1) / 2) * spanM;
|
|
39
|
+
spline.sampleAt(d, sample);
|
|
40
|
+
/*
|
|
41
|
+
* An ellipse, roughened.
|
|
42
|
+
*
|
|
43
|
+
* The circular profile is what rounds the ends — a patch whose width is
|
|
44
|
+
* constant to its last station has square ends however soft its sides are.
|
|
45
|
+
*/
|
|
46
|
+
const profile = Math.sqrt(Math.max(1 - along * along, 0));
|
|
47
|
+
/*
|
|
48
|
+
* The wobble only ever eats *inward*.
|
|
49
|
+
*
|
|
50
|
+
* Written first as `1 ± wobble`, which is the obvious form and is wrong: the
|
|
51
|
+
* half-width then reaches 1.28× what the caller asked for, and a caller like an
|
|
52
|
+
* oil slick has a physics window that is exactly this band. Ground that looks
|
|
53
|
+
* wet and grips normally is a lie, and ground that grips nowhere near what is
|
|
54
|
+
* drawn is worse. Subtracting keeps the silhouette inside the contract by
|
|
55
|
+
* construction rather than by a tolerance.
|
|
56
|
+
*/
|
|
57
|
+
const dent = 0.6 * (0.5 + 0.5 * Math.sin(along * 3.7 + phaseA)) +
|
|
58
|
+
0.4 * (0.5 + 0.5 * Math.sin(along * 8.3 + phaseB));
|
|
59
|
+
const half = options.halfWidthM * profile * (1 - WOBBLE * dent);
|
|
60
|
+
for (let a = 0; a < ACROSS; a++) {
|
|
61
|
+
// -1 at one edge, +1 at the other.
|
|
62
|
+
const across = (a / (ACROSS - 1)) * 2 - 1;
|
|
63
|
+
const lateral = options.centreM + across * half;
|
|
64
|
+
const o = v * 3;
|
|
65
|
+
positions[o] = sample.x + sample.rightX * lateral + sample.normalX * options.liftM;
|
|
66
|
+
positions[o + 1] = sample.y + sample.rightY * lateral + sample.normalY * options.liftM;
|
|
67
|
+
positions[o + 2] = sample.z + sample.rightZ * lateral + sample.normalZ * options.liftM;
|
|
68
|
+
normals[o] = sample.normalX;
|
|
69
|
+
normals[o + 1] = sample.normalY;
|
|
70
|
+
normals[o + 2] = sample.normalZ;
|
|
71
|
+
colors[o] = options.color[0];
|
|
72
|
+
colors[o + 1] = options.color[1];
|
|
73
|
+
colors[o + 2] = options.color[2];
|
|
74
|
+
/*
|
|
75
|
+
* Coverage falls off in both directions at once, and multiplying the two is
|
|
76
|
+
* what keeps the corners honest — a patch feathered only across its width
|
|
77
|
+
* still ends in two hard lines at the ends.
|
|
78
|
+
*/
|
|
79
|
+
const acrossFade = 1 - across * across;
|
|
80
|
+
const alongFade = 1 - along * along;
|
|
81
|
+
coverage[v] = Math.max(acrossFade, 0) * Math.max(alongFade, 0);
|
|
82
|
+
v++;
|
|
83
|
+
}
|
|
84
|
+
if (s === 0)
|
|
85
|
+
continue;
|
|
86
|
+
for (let a = 0; a < ACROSS - 1; a++) {
|
|
87
|
+
const here = s * ACROSS + a;
|
|
88
|
+
const back = here - ACROSS;
|
|
89
|
+
/*
|
|
90
|
+
* Wound so the patch faces *up*.
|
|
91
|
+
*
|
|
92
|
+
* The first version had every triangle facing down — measured, 224 of 224 — which under
|
|
93
|
+
* back-face culling means the slick was never drawn at all. That cost a whole session
|
|
94
|
+
* hunting the shader while looking straight at the patch: the shader was fine and the
|
|
95
|
+
* geometry was inside out.
|
|
96
|
+
*
|
|
97
|
+
* The lesson is the same one the ribbon taught, and it is why the test below measures the
|
|
98
|
+
* cross product of the triangle rather than reading `normals`: the stored normals are the
|
|
99
|
+
* *surface's*, written by hand and pointing up whatever the winding does, so asking them
|
|
100
|
+
* whether the winding is right is asking the wrong array.
|
|
101
|
+
*/
|
|
102
|
+
indices[i] = back;
|
|
103
|
+
indices[i + 1] = back + 1;
|
|
104
|
+
indices[i + 2] = here;
|
|
105
|
+
indices[i + 3] = back + 1;
|
|
106
|
+
indices[i + 4] = here + 1;
|
|
107
|
+
indices[i + 5] = here;
|
|
108
|
+
i += 6;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { positions, normals, colors, emissive: coverage, indices };
|
|
112
|
+
}
|