@aura3d/rendering 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/package.json +38 -4
  2. package/AGENTS.md +0 -46
  3. package/src/ArchitecturalLightingFixtures.ts +0 -241
  4. package/src/ArchitecturalMaterialCatalog.ts +0 -130
  5. package/src/ArchitecturalMeasurementFixtures.ts +0 -155
  6. package/src/BRDFLut.ts +0 -47
  7. package/src/CameraFraming.ts +0 -200
  8. package/src/CanonicalSceneFixtures.ts +0 -95
  9. package/src/CascadedShadowMaps.ts +0 -449
  10. package/src/ColorManagement.ts +0 -127
  11. package/src/CullingFixtures.ts +0 -280
  12. package/src/DecalGeometry.ts +0 -26
  13. package/src/DepthPass.ts +0 -110
  14. package/src/EnvironmentBackgroundPass.ts +0 -194
  15. package/src/EnvironmentBackgroundResources.ts +0 -309
  16. package/src/EnvironmentLighting.ts +0 -96
  17. package/src/EnvironmentMapResources.ts +0 -1026
  18. package/src/EnvironmentPipeline.ts +0 -69
  19. package/src/EnvironmentPlatform.ts +0 -1306
  20. package/src/EnvironmentPreset.ts +0 -155
  21. package/src/Exposure.ts +0 -66
  22. package/src/ExternalParityRenderPreset.ts +0 -725
  23. package/src/ForwardPass.ts +0 -1668
  24. package/src/FrameVisualMetrics.ts +0 -301
  25. package/src/Geometry.ts +0 -461
  26. package/src/GeometryPrimitives.ts +0 -2
  27. package/src/HDRRenderPipeline.ts +0 -94
  28. package/src/IBL.ts +0 -86
  29. package/src/IndexBuffer.ts +0 -57
  30. package/src/InstancedPBRMaterial.ts +0 -186
  31. package/src/InstancedUnlitMaterial.ts +0 -60
  32. package/src/Instancing.ts +0 -19
  33. package/src/LightCollector.ts +0 -82
  34. package/src/LightUniforms.ts +0 -47
  35. package/src/LightingDebug.ts +0 -80
  36. package/src/LightingDefaults.ts +0 -79
  37. package/src/LightingRig.ts +0 -301
  38. package/src/LineGeometry.ts +0 -2
  39. package/src/Material.ts +0 -209
  40. package/src/MaterialBinding.ts +0 -131
  41. package/src/MaterialInstance.ts +0 -59
  42. package/src/MaterialPresets.ts +0 -272
  43. package/src/MorphTarget.ts +0 -124
  44. package/src/MorphTargetPlan.ts +0 -178
  45. package/src/MorphUnlitMaterial.ts +0 -60
  46. package/src/NormalMappedPBRMaterial.ts +0 -188
  47. package/src/OceanFixtures.ts +0 -318
  48. package/src/PBRLightingDefaults.ts +0 -12
  49. package/src/PBRMaterial.ts +0 -442
  50. package/src/PMREM.ts +0 -53
  51. package/src/PbrReference.ts +0 -681
  52. package/src/PostProcessPass.ts +0 -2507
  53. package/src/ProceduralTextureFixtures.ts +0 -393
  54. package/src/ProductTurntableFixtures.ts +0 -815
  55. package/src/Raycaster.ts +0 -21
  56. package/src/ReflectionProbe.ts +0 -13
  57. package/src/ReflectionSurfaces.ts +0 -219
  58. package/src/RenderBackend.ts +0 -43
  59. package/src/RenderDebugViews.ts +0 -138
  60. package/src/RenderDevice.ts +0 -836
  61. package/src/RenderGraph.ts +0 -194
  62. package/src/RenderPass.ts +0 -27
  63. package/src/RenderPipeline.ts +0 -101
  64. package/src/RenderQueue.ts +0 -12
  65. package/src/RenderState.ts +0 -12
  66. package/src/Renderer.ts +0 -2631
  67. package/src/RendererDebugOverlay.ts +0 -80
  68. package/src/RendererFeatureGates.ts +0 -150
  69. package/src/RendererPostprocessPlan.ts +0 -279
  70. package/src/RendererTiming.ts +0 -251
  71. package/src/RendererVisualPipelineReport.ts +0 -836
  72. package/src/ResourceLifecycle.ts +0 -21
  73. package/src/Sampler.ts +0 -37
  74. package/src/SceneOptimization.ts +0 -518
  75. package/src/ShaderChunks.ts +0 -393
  76. package/src/ShaderLibrary.ts +0 -2766
  77. package/src/ShaderModule.ts +0 -36
  78. package/src/ShaderPreprocessor.ts +0 -260
  79. package/src/ShaderReflection.ts +0 -201
  80. package/src/ShadowMap.ts +0 -237
  81. package/src/ShadowPass.ts +0 -198
  82. package/src/ShadowProjection.ts +0 -115
  83. package/src/SkinnedLitMaterial.ts +0 -397
  84. package/src/SkinnedUnlitMaterial.ts +0 -63
  85. package/src/SkinningBounds.ts +0 -131
  86. package/src/SpaceEnvironmentFixtures.ts +0 -200
  87. package/src/SpriteGeometry.ts +0 -21
  88. package/src/StereoCameraRig.ts +0 -127
  89. package/src/StereoEffects.ts +0 -274
  90. package/src/TerrainFixtures.ts +0 -180
  91. package/src/Texture.ts +0 -307
  92. package/src/TextureBinding.ts +0 -91
  93. package/src/TexturedPBRMaterial.ts +0 -1112
  94. package/src/TexturedUnlitMaterial.ts +0 -67
  95. package/src/ToneMapping.ts +0 -105
  96. package/src/UniformBinder.ts +0 -16
  97. package/src/UniformLayout.ts +0 -129
  98. package/src/UnlitMaterial.ts +0 -75
  99. package/src/VegetationFixtures.ts +0 -314
  100. package/src/VertexBuffer.ts +0 -120
  101. package/src/VertexFormat.ts +0 -171
  102. package/src/VoxelWorldFixtures.ts +0 -280
  103. package/src/WeatherFixtures.ts +0 -223
  104. package/src/WebGL2Device.ts +0 -2280
  105. package/src/WebGL2StateCache.ts +0 -330
  106. package/src/WebGPUDevice.ts +0 -2877
  107. package/src/WebGPURenderToTextureProof.ts +0 -139
  108. package/src/advanced-runtime/AdvancedRenderer.ts +0 -73
  109. package/src/advanced-runtime/index.ts +0 -9
  110. package/src/animation/AnimationMaterialStyle.ts +0 -32
  111. package/src/animation/AnimationRenderPreset.ts +0 -45
  112. package/src/animation/AnimationToonMaterial.ts +0 -387
  113. package/src/animation/AnimationVisualQuality.ts +0 -71
  114. package/src/animation/applyAnimationRenderPreset.ts +0 -180
  115. package/src/animation/index.ts +0 -5
  116. package/src/cinematic/BloomPass.ts +0 -26
  117. package/src/cinematic/CinematicDepthComposition.ts +0 -30
  118. package/src/cinematic/CinematicEvidence.ts +0 -123
  119. package/src/cinematic/CinematicLightingRig.ts +0 -144
  120. package/src/cinematic/CinematicMaterialPresets.ts +0 -130
  121. package/src/cinematic/CinematicPostProcess.ts +0 -83
  122. package/src/cinematic/DepthHazePass.ts +0 -30
  123. package/src/cinematic/EmissivePracticalLightSystem.ts +0 -45
  124. package/src/cinematic/FilmGrainPass.ts +0 -24
  125. package/src/cinematic/FogVolumeSystem.ts +0 -30
  126. package/src/cinematic/GlowCardSystem.ts +0 -44
  127. package/src/cinematic/RainParticleSystem.ts +0 -151
  128. package/src/cinematic/VignettePass.ts +0 -25
  129. package/src/cinematic/WetReflectionApproximation.ts +0 -27
  130. package/src/cinematic/index.ts +0 -14
  131. package/src/effects/CollisionModule.ts +0 -64
  132. package/src/effects/ColorModule.ts +0 -60
  133. package/src/effects/ForceModule.ts +0 -25
  134. package/src/effects/GPUParticleBackend.ts +0 -569
  135. package/src/effects/Particle.ts +0 -108
  136. package/src/effects/ParticleDiagnostics.ts +0 -224
  137. package/src/effects/ParticleEffectPresets.ts +0 -147
  138. package/src/effects/ParticleEmitter.ts +0 -326
  139. package/src/effects/ParticleModule.ts +0 -26
  140. package/src/effects/ParticleRenderPass.ts +0 -117
  141. package/src/effects/ParticleRenderer.ts +0 -132
  142. package/src/effects/ParticleSystem.ts +0 -333
  143. package/src/effects/SizeModule.ts +0 -56
  144. package/src/effects/TrailModule.ts +0 -72
  145. package/src/effects/VelocityModule.ts +0 -75
  146. package/src/effects/index.ts +0 -15
  147. package/src/index.ts +0 -925
  148. package/src/materials/AlphaSorting.ts +0 -30
  149. package/src/materials/MaterialExtensions.ts +0 -42
  150. package/src/materials/PhysicalMaterial.ts +0 -133
  151. package/src/materials/TransmissionPass.ts +0 -51
  152. package/src/performance/BVH.ts +0 -18
  153. package/src/performance/Batcher.ts +0 -2
  154. package/src/performance/FrustumCuller.ts +0 -9
  155. package/src/performance/LOD.ts +0 -20
  156. package/src/performance/Octree.ts +0 -10
  157. package/src/performance/RenderItemSorting.ts +0 -170
  158. package/src/performance/RendererStats.ts +0 -43
  159. package/src/performance/ResourceBudget.ts +0 -44
  160. package/src/postprocess/BloomPass.ts +0 -28
  161. package/src/postprocess/CinematicDiagnostics.ts +0 -642
  162. package/src/postprocess/ColorGradingPass.ts +0 -24
  163. package/src/postprocess/DepthOfFieldPass.ts +0 -12
  164. package/src/postprocess/EffectComposer.ts +0 -349
  165. package/src/postprocess/SSAOPass.ts +0 -20
  166. package/src/postprocess/index.ts +0 -34
  167. package/src/production-runtime/AnimationControlsPipeline.ts +0 -77
  168. package/src/production-runtime/PBRHDRPipeline.ts +0 -381
  169. package/src/production-runtime/ProductionEffectsPipeline.ts +0 -85
  170. package/src/production-runtime/ProductionRendererTypes.ts +0 -136
  171. package/src/production-runtime/ProductionRuntimeRenderer.ts +0 -172
  172. package/src/production-runtime/ProductionWebGL2Renderer.ts +0 -313
  173. package/src/production-runtime/ProductionWebGPURenderer.ts +0 -396
  174. package/src/production-runtime/TransmissionBackdropCapture.ts +0 -130
  175. package/src/production-runtime/animation/MorphTargetRenderer.ts +0 -2
  176. package/src/production-runtime/animation/SkinningRenderer.ts +0 -2
  177. package/src/production-runtime/backends/RendererBackend.ts +0 -17
  178. package/src/production-runtime/backends/WebGL2RendererBackend.ts +0 -30
  179. package/src/production-runtime/backends/WebGPURendererBackend.ts +0 -24
  180. package/src/production-runtime/backends/webgl2/WebGL2Buffer.ts +0 -2
  181. package/src/production-runtime/backends/webgl2/WebGL2Capabilities.ts +0 -2
  182. package/src/production-runtime/backends/webgl2/WebGL2RenderTarget.ts +0 -2
  183. package/src/production-runtime/backends/webgl2/WebGL2Shader.ts +0 -2
  184. package/src/production-runtime/backends/webgl2/WebGL2StateCache.ts +0 -1
  185. package/src/production-runtime/backends/webgl2/WebGL2Texture.ts +0 -2
  186. package/src/production-runtime/backends/webgpu/WebGPUBuffer.ts +0 -2
  187. package/src/production-runtime/backends/webgpu/WebGPUCapabilities.ts +0 -2
  188. package/src/production-runtime/backends/webgpu/WebGPURenderTarget.ts +0 -2
  189. package/src/production-runtime/backends/webgpu/WebGPUShader.ts +0 -2
  190. package/src/production-runtime/backends/webgpu/WebGPUTexture.ts +0 -2
  191. package/src/production-runtime/color/ColorManagement.ts +0 -3
  192. package/src/production-runtime/color/ToneMapping.ts +0 -7
  193. package/src/production-runtime/diagnostics/FrameCapture.ts +0 -2
  194. package/src/production-runtime/diagnostics/GPUCapabilities.ts +0 -2
  195. package/src/production-runtime/diagnostics/RendererStats.ts +0 -2
  196. package/src/production-runtime/environment/EnvironmentMap.ts +0 -1
  197. package/src/production-runtime/environment/HDRLoader.ts +0 -57
  198. package/src/production-runtime/environment/PMREMGenerator.ts +0 -713
  199. package/src/production-runtime/framegraph/FrameGraph.ts +0 -18
  200. package/src/production-runtime/framegraph/RenderPass.ts +0 -15
  201. package/src/production-runtime/geometry/ProjectedDecalGeometry.ts +0 -439
  202. package/src/production-runtime/index.ts +0 -127
  203. package/src/production-runtime/lights/LightManager.ts +0 -7
  204. package/src/production-runtime/lights/ShadowMapRenderer.ts +0 -5
  205. package/src/production-runtime/materials/GLTFMaterialAdapter.ts +0 -6
  206. package/src/production-runtime/materials/GLTFPBRMaterialAdapter.ts +0 -2
  207. package/src/production-runtime/materials/MaterialCompiler.ts +0 -7
  208. package/src/production-runtime/materials/MaterialTextureBindings.ts +0 -5
  209. package/src/production-runtime/materials/PBRMaterial.ts +0 -2
  210. package/src/production-runtime/materials/PBRShaderFeatures.ts +0 -2
  211. package/src/production-runtime/passes/ContactShadowPass.ts +0 -184
  212. package/src/production-runtime/passes/DepthPrepass.ts +0 -7
  213. package/src/production-runtime/passes/OpaquePass.ts +0 -7
  214. package/src/production-runtime/passes/ShadowPass.ts +0 -7
  215. package/src/production-runtime/passes/SkyboxPass.ts +0 -7
  216. package/src/production-runtime/passes/ToneMappingPass.ts +0 -7
  217. package/src/production-runtime/passes/TransparentPass.ts +0 -7
  218. package/src/production-runtime/postprocess/BloomPass.ts +0 -51
  219. package/src/production-runtime/postprocess/ColorGradingPass.ts +0 -49
  220. package/src/production-runtime/postprocess/DOFPass.ts +0 -47
  221. package/src/production-runtime/postprocess/FXAAPass.ts +0 -53
  222. package/src/production-runtime/postprocess/ProductionEffectComposer.ts +0 -78
  223. package/src/production-runtime/postprocess/ProductionPostProcessTypes.ts +0 -174
  224. package/src/production-runtime/postprocess/SSAOPass.ts +0 -45
  225. package/src/production-runtime/resources/GPUBuffer.ts +0 -2
  226. package/src/production-runtime/resources/GPUTexture.ts +0 -2
  227. package/src/production-runtime/resources/RenderTarget.ts +0 -3
  228. package/src/production-runtime/resources/ResourceCache.ts +0 -7
  229. package/src/production-runtime/scene/Camera.ts +0 -1
  230. package/src/production-runtime/scene/Lights.ts +0 -2
  231. package/src/production-runtime/scene/RenderableMesh.ts +0 -2
  232. package/src/production-runtime/scene/RenderablePrimitive.ts +0 -1
  233. package/src/production-runtime/scene/RenderableScene.ts +0 -4
  234. package/src/production-runtime/shaders/ShaderProgramLibrary.ts +0 -7
  235. package/src/production-runtime/shaders/chunks/brdf.glsl +0 -2
  236. package/src/production-runtime/shaders/chunks/ibl.glsl +0 -3
  237. package/src/production-runtime/shaders/chunks/pbr.frag.glsl +0 -47
  238. package/src/production-runtime/shaders/chunks/pbr.vert.glsl +0 -8
  239. package/src/production-runtime/shaders/chunks/shadows.glsl +0 -2
  240. package/src/production-runtime/shaders/wgsl/pbr.wgsl +0 -3
  241. package/src/production-runtime/shaders/wgsl/postprocess.wgsl +0 -2
  242. package/src/production-runtime/shaders/wgsl/skybox.wgsl +0 -2
  243. package/src/shaders/depth.frag.glsl +0 -5
  244. package/src/shaders/depth.vert.glsl +0 -8
  245. package/src/shaders/pbr-direct.frag.glsl +0 -687
  246. package/src/shaders/pbr-direct.vert.glsl +0 -18
  247. package/src/shaders/unlit.frag.glsl +0 -18
  248. package/src/shaders/unlit.vert.glsl +0 -13
  249. package/src/shadows/CascadedShadowPipeline.ts +0 -53
  250. package/src/shadows/ContactShadows.ts +0 -106
  251. package/src/shadows/ShadowDebugViews.ts +0 -46
  252. package/src/threejs-compatibility/InstancingSystem.ts +0 -17
  253. package/src/threejs-compatibility/LightingSystem.ts +0 -22
  254. package/src/threejs-compatibility/MaterialSystem.ts +0 -9
  255. package/src/threejs-compatibility/RenderTargetSystem.ts +0 -35
  256. package/src/threejs-compatibility/RendererDiagnostics.ts +0 -61
  257. package/src/threejs-compatibility/SceneRenderer.ts +0 -34
  258. package/src/threejs-compatibility/ShadowSystem.ts +0 -19
  259. package/src/threejs-compatibility/TextureSystem.ts +0 -19
  260. package/src/threejs-compatibility/ThreeCompatRenderer.ts +0 -90
  261. package/src/threejs-compatibility/TransparencySystem.ts +0 -19
  262. package/src/threejs-compatibility/index.ts +0 -29
  263. package/src/threejs-compatibility/performance/BVH.ts +0 -14
  264. package/src/threejs-compatibility/performance/FrustumCulling.ts +0 -10
  265. package/src/threejs-compatibility/performance/Instancing.ts +0 -4
  266. package/src/threejs-compatibility/performance/LODSystem.ts +0 -16
  267. package/src/threejs-compatibility/performance/OcclusionCulling.ts +0 -6
  268. package/src/threejs-compatibility/performance/RaycastAcceleration.ts +0 -12
  269. package/src/threejs-compatibility/performance/RendererProfiler.ts +0 -19
  270. package/src/threejs-compatibility/performance/TextureStreaming.ts +0 -4
  271. package/src/threejs-compatibility/performance/index.ts +0 -12
  272. package/src/threejs-compatibility/postprocess/BloomPass.ts +0 -16
  273. package/src/threejs-compatibility/postprocess/ColorGradingPass.ts +0 -16
  274. package/src/threejs-compatibility/postprocess/DepthOfFieldPass.ts +0 -21
  275. package/src/threejs-compatibility/postprocess/EffectComposer.ts +0 -14
  276. package/src/threejs-compatibility/postprocess/FXAAPass.ts +0 -15
  277. package/src/threejs-compatibility/postprocess/MotionBlurPass.ts +0 -20
  278. package/src/threejs-compatibility/postprocess/OutlinePass.ts +0 -21
  279. package/src/threejs-compatibility/postprocess/PostProcessTypes.ts +0 -169
  280. package/src/threejs-compatibility/postprocess/RenderPass.ts +0 -9
  281. package/src/threejs-compatibility/postprocess/SMAAPass.ts +0 -15
  282. package/src/threejs-compatibility/postprocess/SSAOPass.ts +0 -21
  283. package/src/threejs-compatibility/postprocess/ShaderPass.ts +0 -7
  284. package/src/threejs-compatibility/postprocess/TAAPass.ts +0 -15
  285. package/src/threejs-compatibility/postprocess/VignettePass.ts +0 -16
  286. package/src/threejs-compatibility/postprocess/index.ts +0 -15
  287. package/src/threejs-compatibility/shaders/NodeMaterial.ts +0 -21
  288. package/src/threejs-compatibility/shaders/RawShaderMaterial.ts +0 -6
  289. package/src/threejs-compatibility/shaders/ShaderDiagnostics.ts +0 -17
  290. package/src/threejs-compatibility/shaders/ShaderMaterial.ts +0 -18
  291. package/src/threejs-compatibility/shaders/ThreeCompatShaderChunks.ts +0 -6
  292. package/src/threejs-compatibility/shaders/Uniforms.ts +0 -18
  293. package/src/threejs-compatibility/shaders/index.ts +0 -9
  294. package/src/threejs-compatibility/vfx/GPUPointCloud.ts +0 -7
  295. package/src/threejs-compatibility/vfx/LineRenderer.ts +0 -13
  296. package/src/threejs-compatibility/vfx/ParticleSystem.ts +0 -23
  297. package/src/threejs-compatibility/vfx/SpriteSystem.ts +0 -14
  298. package/src/threejs-compatibility/vfx/TrailRenderer.ts +0 -8
  299. package/src/threejs-compatibility/vfx/VFXDiagnostics.ts +0 -23
  300. package/src/threejs-compatibility/vfx/index.ts +0 -9
  301. package/src/threejs-example-parity/index.ts +0 -205
  302. package/src/webgpu/WebGPUBuffer.ts +0 -1
  303. package/src/webgpu/WebGPUCompute.ts +0 -2
  304. package/src/webgpu/WebGPUPipelineCache.ts +0 -15
  305. package/src/webgpu/WebGPUPostProcess.ts +0 -2
  306. package/src/webgpu/WebGPUTexture.ts +0 -2
  307. package/tsconfig.json +0 -26
  308. package/vitest.config.ts +0 -20
@@ -1,180 +0,0 @@
1
- export type TerrainFixtureBiome = "water" | "beach" | "grassland" | "forest" | "rock" | "snow";
2
-
3
- export interface TerrainHeightfieldFixtureOptions {
4
- readonly width?: number;
5
- readonly height?: number;
6
- readonly seed?: number;
7
- readonly minHeight?: number;
8
- readonly maxHeight?: number;
9
- }
10
-
11
- export interface TerrainHeightfieldSample {
12
- readonly x: number;
13
- readonly y: number;
14
- readonly height: number;
15
- readonly moisture: number;
16
- readonly temperature: number;
17
- readonly biome: TerrainFixtureBiome;
18
- }
19
-
20
- export interface TerrainHeightfieldFixture {
21
- readonly id: "external-parity-old-branch-terrain-heightfield";
22
- readonly width: number;
23
- readonly height: number;
24
- readonly seed: number;
25
- readonly minHeight: number;
26
- readonly maxHeight: number;
27
- readonly data: Float32Array;
28
- readonly samples: readonly TerrainHeightfieldSample[];
29
- readonly biomeCounts: Readonly<Record<TerrainFixtureBiome, number>>;
30
- readonly meanHeight: number;
31
- readonly roughness: number;
32
- readonly riverCellCount: number;
33
- readonly hash: string;
34
- readonly source: "origin-master-terrain-generator-adapted";
35
- readonly claimBoundary: string;
36
- }
37
-
38
- const terrainBiomes: readonly TerrainFixtureBiome[] = ["water", "beach", "grassland", "forest", "rock", "snow"] as const;
39
-
40
- export function createTerrainHeightfieldFixture(options: TerrainHeightfieldFixtureOptions = {}): TerrainHeightfieldFixture {
41
- const width = options.width ?? 32;
42
- const height = options.height ?? 32;
43
- if (!Number.isInteger(width) || width < 8 || !Number.isInteger(height) || height < 8) {
44
- throw new RangeError("Terrain heightfield fixture dimensions must be integer values >= 8.");
45
- }
46
- const seed = options.seed ?? 0x7434_2025;
47
- if (!Number.isInteger(seed)) {
48
- throw new RangeError("Terrain heightfield fixture seed must be an integer.");
49
- }
50
- const minHeight = finite(options.minHeight ?? -0.12, "minHeight");
51
- const maxHeight = finite(options.maxHeight ?? 0.42, "maxHeight");
52
- if (maxHeight <= minHeight) {
53
- throw new RangeError("Terrain heightfield fixture maxHeight must be greater than minHeight.");
54
- }
55
- const data = new Float32Array(width * height);
56
- const biomeCounts = Object.fromEntries(terrainBiomes.map((biome) => [biome, 0])) as Record<TerrainFixtureBiome, number>;
57
- let sum = 0;
58
- let roughness = 0;
59
- let riverCellCount = 0;
60
- const samples: TerrainHeightfieldSample[] = [];
61
- for (let y = 0; y < height; y += 1) {
62
- for (let x = 0; x < width; x += 1) {
63
- const u = x / Math.max(1, width - 1);
64
- const v = y / Math.max(1, height - 1);
65
- const base = fractalNoise(u * 3.3, v * 3.3, seed, 5);
66
- const detail = fractalNoise(u * 13.7 + 4.1, v * 13.7 - 2.4, seed ^ 0x4f53, 3);
67
- const river = Math.max(0, 1 - Math.abs(v - (0.48 + Math.sin(u * Math.PI * 2.2) * 0.08)) * 32);
68
- const normalized = clamp(base * 0.82 + detail * 0.18 - river * 0.22, 0, 1);
69
- const value = minHeight + normalized * (maxHeight - minHeight);
70
- data[y * width + x] = value;
71
- sum += value;
72
- if (river > 0.35) riverCellCount += 1;
73
- const moisture = clamp(fractalNoise(u * 2.4 + 7.2, v * 2.4 - 1.8, seed ^ 0x9ab1, 4) + river * 0.28, 0, 1);
74
- const temperature = clamp((1 - v) * 0.78 + fractalNoise(u * 1.8 - 3.2, v * 1.8 + 5.8, seed ^ 0x1c0d, 3) * 0.22 - normalized * 0.38, 0, 1);
75
- const biome = biomeFor(normalized, moisture, temperature, river);
76
- biomeCounts[biome] += 1;
77
- if (x % Math.max(1, Math.floor(width / 4)) === 0 && y % Math.max(1, Math.floor(height / 4)) === 0) {
78
- samples.push({ x, y, height: Number(value.toFixed(4)), moisture: Number(moisture.toFixed(4)), temperature: Number(temperature.toFixed(4)), biome });
79
- }
80
- if (x > 0) roughness += Math.abs(value - (data[y * width + x - 1] ?? value));
81
- if (y > 0) roughness += Math.abs(value - (data[(y - 1) * width + x] ?? value));
82
- }
83
- }
84
- return {
85
- id: "external-parity-old-branch-terrain-heightfield",
86
- width,
87
- height,
88
- seed,
89
- minHeight,
90
- maxHeight,
91
- data,
92
- samples,
93
- biomeCounts,
94
- meanHeight: Number((sum / data.length).toFixed(5)),
95
- roughness: Number((roughness / Math.max(1, data.length * 2 - width - height)).toFixed(5)),
96
- riverCellCount,
97
- hash: hashFloat32(data),
98
- source: "origin-master-terrain-generator-adapted",
99
- claimBoundary: "Deterministic heightfield, biome, roughness, and river-cell telemetry adapted from the old terrain generator concepts; this is a bounded local fixture, not full terrain ECS, erosion, collision, vegetation, or streaming terrain parity."
100
- };
101
- }
102
-
103
- export function sampleTerrainHeightfield(fixture: TerrainHeightfieldFixture, u: number, v: number): TerrainHeightfieldSample {
104
- const x = Math.max(0, Math.min(fixture.width - 1, Math.round(clamp(u, 0, 1) * (fixture.width - 1))));
105
- const y = Math.max(0, Math.min(fixture.height - 1, Math.round(clamp(v, 0, 1) * (fixture.height - 1))));
106
- const height = fixture.data[y * fixture.width + x] ?? 0;
107
- const normalized = (height - fixture.minHeight) / Math.max(0.0001, fixture.maxHeight - fixture.minHeight);
108
- const moisture = clamp(fractalNoise((x / fixture.width) * 2.4 + 7.2, (y / fixture.height) * 2.4 - 1.8, fixture.seed ^ 0x9ab1, 4), 0, 1);
109
- const temperature = clamp((1 - y / fixture.height) * 0.78 + fractalNoise((x / fixture.width) * 1.8 - 3.2, (y / fixture.height) * 1.8 + 5.8, fixture.seed ^ 0x1c0d, 3) * 0.22 - normalized * 0.38, 0, 1);
110
- return { x, y, height: Number(height.toFixed(4)), moisture: Number(moisture.toFixed(4)), temperature: Number(temperature.toFixed(4)), biome: biomeFor(normalized, moisture, temperature, 0) };
111
- }
112
-
113
- function biomeFor(height: number, moisture: number, temperature: number, river: number): TerrainFixtureBiome {
114
- if (height < 0.18 || river > 0.62) return "water";
115
- if (height < 0.24) return "beach";
116
- if (height > 0.78 && temperature < 0.34) return "snow";
117
- if (height > 0.68) return "rock";
118
- if (moisture > 0.58) return "forest";
119
- return "grassland";
120
- }
121
-
122
- function fractalNoise(x: number, y: number, seed: number, octaves: number): number {
123
- let value = 0;
124
- let amplitude = 0.5;
125
- let frequency = 1;
126
- let total = 0;
127
- for (let octave = 0; octave < octaves; octave += 1) {
128
- value += smoothNoise(x * frequency, y * frequency, seed + octave * 1013) * amplitude;
129
- total += amplitude;
130
- amplitude *= 0.5;
131
- frequency *= 2;
132
- }
133
- return total === 0 ? 0 : value / total;
134
- }
135
-
136
- function smoothNoise(x: number, y: number, seed: number): number {
137
- const x0 = Math.floor(x);
138
- const y0 = Math.floor(y);
139
- const tx = x - x0;
140
- const ty = y - y0;
141
- const a = valueNoise(x0, y0, seed);
142
- const b = valueNoise(x0 + 1, y0, seed);
143
- const c = valueNoise(x0, y0 + 1, seed);
144
- const d = valueNoise(x0 + 1, y0 + 1, seed);
145
- const sx = tx * tx * (3 - 2 * tx);
146
- const sy = ty * ty * (3 - 2 * ty);
147
- return lerp(lerp(a, b, sx), lerp(c, d, sx), sy);
148
- }
149
-
150
- function valueNoise(x: number, y: number, seed: number): number {
151
- let value = Math.imul(x, 374761393) ^ Math.imul(y, 668265263) ^ seed;
152
- value = Math.imul(value ^ (value >>> 13), 1274126177);
153
- return ((value ^ (value >>> 16)) >>> 0) / 0xffffffff;
154
- }
155
-
156
- function hashFloat32(values: Float32Array): string {
157
- let hash = 0x811c9dc5;
158
- const view = new DataView(new ArrayBuffer(4));
159
- for (const value of values) {
160
- view.setFloat32(0, value, true);
161
- for (let index = 0; index < 4; index += 1) {
162
- hash ^= view.getUint8(index);
163
- hash = Math.imul(hash, 0x01000193) >>> 0;
164
- }
165
- }
166
- return hash.toString(16).padStart(8, "0");
167
- }
168
-
169
- function finite(value: number, label: string): number {
170
- if (!Number.isFinite(value)) throw new RangeError(`Terrain heightfield fixture ${label} must be finite.`);
171
- return value;
172
- }
173
-
174
- function lerp(left: number, right: number, amount: number): number {
175
- return left + (right - left) * amount;
176
- }
177
-
178
- function clamp(value: number, min: number, max: number): number {
179
- return Math.max(min, Math.min(max, value));
180
- }
package/src/Texture.ts DELETED
@@ -1,307 +0,0 @@
1
- export type TextureCompressedFormat = "bc1-rgba-unorm" | "bc3-rgba-unorm" | "etc2-rgba8unorm" | "astc-4x4-rgba-unorm";
2
- export type TextureFormat = "rgba8" | "rgba16f" | "rgba32f" | "depth24" | TextureCompressedFormat;
3
- export type TextureColorSpace = "linear" | "srgb";
4
- export type TexturePixelData = Uint8Array | Uint8ClampedArray | Uint16Array | Float32Array;
5
- export type TextureDimension = "2d" | "cube";
6
- export type TextureCubeFace = "px" | "nx" | "py" | "ny" | "pz" | "nz";
7
-
8
- export interface TextureMipLevelDescriptor {
9
- readonly width: number;
10
- readonly height: number;
11
- readonly data: TexturePixelData;
12
- }
13
-
14
- export interface TextureMipLevel {
15
- readonly width: number;
16
- readonly height: number;
17
- readonly data: TexturePixelData;
18
- }
19
-
20
- export interface TextureCubeFaceDescriptor {
21
- readonly face: TextureCubeFace;
22
- readonly mipLevels: readonly TextureMipLevelDescriptor[];
23
- }
24
-
25
- export interface TextureCubeFaceLevel {
26
- readonly face: TextureCubeFace;
27
- readonly mipLevels: readonly TextureMipLevel[];
28
- }
29
-
30
- export interface TextureDescriptor {
31
- readonly width: number;
32
- readonly height: number;
33
- readonly dimension?: TextureDimension;
34
- readonly format?: TextureFormat;
35
- readonly colorSpace?: TextureColorSpace;
36
- readonly label?: string;
37
- readonly data?: TexturePixelData;
38
- readonly mipLevels?: readonly TextureMipLevelDescriptor[];
39
- readonly cubeFaces?: readonly TextureCubeFaceDescriptor[];
40
- readonly source?: TexImageSource;
41
- readonly fallbackData?: Uint8Array | Uint8ClampedArray;
42
- readonly fallbackMipLevels?: readonly TextureMipLevelDescriptor[];
43
- }
44
-
45
- export class Texture {
46
- public readonly width: number;
47
- public readonly height: number;
48
- public readonly dimension: TextureDimension;
49
- public readonly format: TextureFormat;
50
- public readonly colorSpace: TextureColorSpace;
51
- public readonly label: string;
52
- public readonly data: TexturePixelData | null;
53
- public readonly mipLevels: readonly TextureMipLevel[];
54
- public readonly cubeFaces: readonly TextureCubeFaceLevel[];
55
- public readonly source: TexImageSource | null;
56
- public readonly fallbackData: Uint8Array | null;
57
- public readonly fallbackMipLevels: readonly TextureMipLevel[];
58
- public disposed = false;
59
-
60
- constructor(descriptor: TextureDescriptor) {
61
- if (!Number.isInteger(descriptor.width) || descriptor.width <= 0) {
62
- throw new Error("Texture width must be a positive integer");
63
- }
64
- if (!Number.isInteger(descriptor.height) || descriptor.height <= 0) {
65
- throw new Error("Texture height must be a positive integer");
66
- }
67
- this.width = descriptor.width;
68
- this.height = descriptor.height;
69
- this.dimension = descriptor.dimension ?? (descriptor.cubeFaces ? "cube" : "2d");
70
- this.format = descriptor.format ?? "rgba8";
71
- this.colorSpace = descriptor.colorSpace ?? "linear";
72
- this.label = descriptor.label ?? "texture";
73
- if (this.dimension === "cube" && descriptor.width !== descriptor.height) {
74
- throw new Error("Cube textures require square width and height");
75
- }
76
- if (descriptor.data && descriptor.source) {
77
- throw new Error("Texture cannot define both raw pixel data and image source");
78
- }
79
- if (descriptor.mipLevels && descriptor.source) {
80
- throw new Error("Texture cannot define both mipLevels and image source");
81
- }
82
- if (descriptor.data && descriptor.mipLevels) {
83
- throw new Error("Texture cannot define both data and mipLevels");
84
- }
85
- this.data = descriptor.data ? clonePixelData(descriptor.data) : null;
86
- this.mipLevels = descriptor.mipLevels ? cloneMipLevels(descriptor.mipLevels, "mipLevels") : [];
87
- this.cubeFaces = descriptor.cubeFaces ? cloneCubeFaces(descriptor.cubeFaces) : [];
88
- this.source = descriptor.source ?? null;
89
- this.fallbackData = descriptor.fallbackData ? new Uint8Array(descriptor.fallbackData) : null;
90
- this.fallbackMipLevels = descriptor.fallbackMipLevels ? cloneMipLevels(descriptor.fallbackMipLevels, "fallbackMipLevels") : [];
91
- if (this.dimension === "cube") {
92
- if (this.data || this.mipLevels.length > 0 || this.source || this.fallbackData || this.fallbackMipLevels.length > 0) {
93
- throw new Error("Cube textures must define cubeFaces instead of 2D data, mipLevels, source, or fallbacks");
94
- }
95
- if (isCompressedTextureFormat(this.format) || this.format === "depth24") {
96
- throw new Error("Cube textures currently support rgba8, rgba16f, or rgba32f formats");
97
- }
98
- validateCubeFaces(this.cubeFaces, this.width, this.height, this.format);
99
- return;
100
- }
101
- if (this.cubeFaces.length > 0) {
102
- throw new Error("2D textures cannot define cubeFaces");
103
- }
104
- if (isCompressedTextureFormat(this.format)) {
105
- if (!this.data && this.mipLevels.length === 0) {
106
- throw new Error("Compressed textures require compressed data bytes");
107
- }
108
- if (this.source) {
109
- throw new Error("Compressed textures cannot use TexImageSource uploads");
110
- }
111
- const levels = this.textureLevels;
112
- for (const [index, level] of levels.entries()) {
113
- const expected = compressedTextureByteLength(level.width, level.height, this.format);
114
- if (level.data.byteLength !== expected) {
115
- throw new Error(`Compressed texture mip level ${index} for ${this.format} must contain ${expected} bytes`);
116
- }
117
- }
118
- if (levels[0]?.width !== this.width || levels[0]?.height !== this.height) {
119
- throw new Error("Compressed texture first mip level must match width and height");
120
- }
121
- if (this.fallbackData && this.fallbackData.byteLength !== this.width * this.height * 4) {
122
- throw new Error("Compressed texture fallbackData must contain exactly width * height * 4 RGBA8 bytes");
123
- }
124
- for (const [index, level] of this.fallbackTextureLevels.entries()) {
125
- if (level.data.byteLength !== level.width * level.height * 4) {
126
- throw new Error(`Compressed texture fallback mip level ${index} must contain exactly width * height * 4 RGBA8 bytes`);
127
- }
128
- }
129
- if (this.fallbackTextureLevels.length > 0 && (this.fallbackTextureLevels[0]?.width !== this.width || this.fallbackTextureLevels[0]?.height !== this.height)) {
130
- throw new Error("Compressed texture first fallback mip level must match width and height");
131
- }
132
- } else {
133
- if (this.source && this.format !== "rgba8") {
134
- throw new Error("TexImageSource uploads are only supported for rgba8 textures");
135
- }
136
- if (this.format === "depth24" && (this.data || this.mipLevels.length > 0 || this.source)) {
137
- throw new Error("Depth textures cannot define color data, mipLevels, or image sources");
138
- }
139
- if (this.mipLevels.length > 0) {
140
- validateTextureMipLevels(this.mipLevels, this.width, this.height, this.format, "mipLevels");
141
- }
142
- if (this.data) {
143
- validateTexturePixelData(this.data, this.width, this.height, this.format, "texture data");
144
- }
145
- if (this.fallbackData) {
146
- throw new Error("fallbackData is only valid for compressed textures");
147
- }
148
- if (this.fallbackMipLevels.length > 0) {
149
- throw new Error("fallbackMipLevels are only valid for compressed textures");
150
- }
151
- }
152
- }
153
-
154
- dispose(): void {
155
- this.disposed = true;
156
- }
157
-
158
- get byteLength(): number {
159
- if (isCompressedTextureFormat(this.format)) {
160
- const format = this.format;
161
- return this.textureLevels.reduce((total, level) => total + compressedTextureByteLength(level.width, level.height, format), 0);
162
- }
163
- if (this.dimension === "cube") {
164
- return this.cubeFaces.reduce((total, face) => total + face.mipLevels.reduce((faceTotal, level) => faceTotal + level.data.byteLength, 0), 0);
165
- }
166
- if (this.mipLevels.length > 0) {
167
- return this.mipLevels.reduce((total, level) => total + level.data.byteLength, 0);
168
- }
169
- return this.width * this.height * bytesPerPixel(this.format);
170
- }
171
-
172
- get fallbackByteLength(): number {
173
- return this.fallbackTextureLevels.reduce((total, level) => total + level.data.byteLength, 0);
174
- }
175
-
176
- get textureLevels(): readonly TextureMipLevel[] {
177
- if (this.mipLevels.length > 0) return this.mipLevels;
178
- return this.data ? [{ width: this.width, height: this.height, data: this.data }] : [];
179
- }
180
-
181
- get fallbackTextureLevels(): readonly TextureMipLevel[] {
182
- if (this.fallbackMipLevels.length > 0) return this.fallbackMipLevels;
183
- return this.fallbackData ? [{ width: this.width, height: this.height, data: this.fallbackData }] : [];
184
- }
185
- }
186
-
187
- export function bytesPerPixel(format: TextureFormat): number {
188
- switch (format) {
189
- case "rgba8":
190
- return 4;
191
- case "rgba16f":
192
- return 8;
193
- case "rgba32f":
194
- return 16;
195
- case "depth24":
196
- return 4;
197
- case "bc1-rgba-unorm":
198
- case "bc3-rgba-unorm":
199
- case "etc2-rgba8unorm":
200
- case "astc-4x4-rgba-unorm":
201
- return 0;
202
- }
203
- }
204
-
205
- export function isCompressedTextureFormat(format: TextureFormat): format is TextureCompressedFormat {
206
- return format === "bc1-rgba-unorm" || format === "bc3-rgba-unorm" || format === "etc2-rgba8unorm" || format === "astc-4x4-rgba-unorm";
207
- }
208
-
209
- export function compressedTextureByteLength(width: number, height: number, format: TextureCompressedFormat): number {
210
- const blocksWide = Math.max(1, Math.ceil(width / 4));
211
- const blocksHigh = Math.max(1, Math.ceil(height / 4));
212
- return blocksWide * blocksHigh * compressedBlockByteLength(format);
213
- }
214
-
215
- export function compressedBlockByteLength(format: TextureCompressedFormat): number {
216
- switch (format) {
217
- case "bc1-rgba-unorm":
218
- return 8;
219
- case "bc3-rgba-unorm":
220
- case "etc2-rgba8unorm":
221
- case "astc-4x4-rgba-unorm":
222
- return 16;
223
- }
224
- }
225
-
226
- function cloneMipLevels(levels: readonly TextureMipLevelDescriptor[], label: string): TextureMipLevel[] {
227
- if (levels.length === 0) {
228
- throw new Error(`${label} must contain at least one level`);
229
- }
230
- return levels.map((level, index) => {
231
- if (!Number.isInteger(level.width) || level.width <= 0) {
232
- throw new Error(`${label} level ${index} width must be a positive integer`);
233
- }
234
- if (!Number.isInteger(level.height) || level.height <= 0) {
235
- throw new Error(`${label} level ${index} height must be a positive integer`);
236
- }
237
- return { width: level.width, height: level.height, data: clonePixelData(level.data) };
238
- });
239
- }
240
-
241
- function cloneCubeFaces(faces: readonly TextureCubeFaceDescriptor[]): TextureCubeFaceLevel[] {
242
- if (faces.length !== 6) {
243
- throw new Error("Cube textures require exactly six faces");
244
- }
245
- return faces.map((face) => ({
246
- face: face.face,
247
- mipLevels: cloneMipLevels(face.mipLevels, `cubeFaces.${face.face}.mipLevels`)
248
- }));
249
- }
250
-
251
- function clonePixelData(data: TexturePixelData): TexturePixelData {
252
- if (data instanceof Uint8ClampedArray) return new Uint8ClampedArray(data);
253
- if (data instanceof Uint16Array) return new Uint16Array(data);
254
- if (data instanceof Float32Array) return new Float32Array(data);
255
- return new Uint8Array(data);
256
- }
257
-
258
- function validateCubeFaces(faces: readonly TextureCubeFaceLevel[], width: number, height: number, format: TextureFormat): void {
259
- const expectedFaces: readonly TextureCubeFace[] = ["px", "nx", "py", "ny", "pz", "nz"];
260
- const seen = new Set<TextureCubeFace>();
261
- for (const face of faces) {
262
- if (!expectedFaces.includes(face.face)) {
263
- throw new Error(`Unsupported cube texture face: ${face.face}`);
264
- }
265
- if (seen.has(face.face)) {
266
- throw new Error(`Duplicate cube texture face: ${face.face}`);
267
- }
268
- seen.add(face.face);
269
- validateTextureMipLevels(face.mipLevels, width, height, format, `cubeFaces.${face.face}.mipLevels`);
270
- }
271
- for (const face of expectedFaces) {
272
- if (!seen.has(face)) {
273
- throw new Error(`Missing cube texture face: ${face}`);
274
- }
275
- }
276
- }
277
-
278
- function validateTextureMipLevels(levels: readonly TextureMipLevel[], width: number, height: number, format: TextureFormat, label: string): void {
279
- if (levels[0]?.width !== width || levels[0]?.height !== height) {
280
- throw new Error(`${label} first level must match width and height`);
281
- }
282
- for (const [index, level] of levels.entries()) {
283
- validateTexturePixelData(level.data, level.width, level.height, format, `${label} level ${index}`);
284
- }
285
- }
286
-
287
- function validateTexturePixelData(data: TexturePixelData, width: number, height: number, format: TextureFormat, label: string): void {
288
- if (format === "rgba8") {
289
- if (!(data instanceof Uint8Array) && !(data instanceof Uint8ClampedArray)) {
290
- throw new Error(`${label} for rgba8 textures must be Uint8Array or Uint8ClampedArray`);
291
- }
292
- } else if (format === "rgba16f") {
293
- if (!(data instanceof Uint16Array)) {
294
- throw new Error(`${label} for rgba16f textures must be Uint16Array half-float data`);
295
- }
296
- } else if (format === "rgba32f") {
297
- if (!(data instanceof Float32Array)) {
298
- throw new Error(`${label} for rgba32f textures must be Float32Array data`);
299
- }
300
- } else if (format === "depth24") {
301
- throw new Error(`${label} is not valid for depth24 textures`);
302
- }
303
- const expected = width * height * bytesPerPixel(format);
304
- if (data.byteLength !== expected) {
305
- throw new Error(`${label} for ${format} textures must contain exactly ${expected} bytes`);
306
- }
307
- }
@@ -1,91 +0,0 @@
1
- import { Sampler } from "./Sampler";
2
- import { Texture, type TextureColorSpace, type TextureDimension } from "./Texture";
3
-
4
- export interface TextureBindingDescriptor {
5
- readonly name: string;
6
- readonly texture?: Texture | null;
7
- readonly sampler?: Sampler;
8
- readonly required?: boolean;
9
- readonly ready?: boolean;
10
- readonly expectedColorSpace?: TextureColorSpace;
11
- readonly expectedDimension?: TextureDimension;
12
- readonly transform?: TextureTransformDescriptor;
13
- }
14
-
15
- export interface TextureTransformDescriptor {
16
- readonly offset?: readonly [number, number];
17
- readonly scale?: readonly [number, number];
18
- readonly rotation?: number;
19
- }
20
-
21
- export interface TextureBindingValidation {
22
- readonly ok: boolean;
23
- readonly diagnostics: readonly string[];
24
- readonly warnings: readonly string[];
25
- }
26
-
27
- export class TextureBinding {
28
- public readonly name: string;
29
- public readonly texture: Texture | null;
30
- public readonly sampler: Sampler;
31
- public readonly required: boolean;
32
- public readonly ready: boolean;
33
- public readonly expectedColorSpace?: TextureColorSpace;
34
- public readonly expectedDimension?: TextureDimension;
35
- public readonly offset: readonly [number, number];
36
- public readonly scale: readonly [number, number];
37
- public readonly rotation: number;
38
-
39
- constructor(descriptor: TextureBindingDescriptor) {
40
- if (!descriptor.name.trim()) {
41
- throw new Error("Texture binding name is required");
42
- }
43
- this.name = descriptor.name;
44
- this.texture = descriptor.texture ?? null;
45
- this.sampler = descriptor.sampler ?? new Sampler();
46
- this.required = descriptor.required ?? false;
47
- this.ready = descriptor.ready ?? true;
48
- this.expectedColorSpace = descriptor.expectedColorSpace;
49
- this.expectedDimension = descriptor.expectedDimension;
50
- this.offset = descriptor.transform?.offset ? [descriptor.transform.offset[0], descriptor.transform.offset[1]] : [0, 0];
51
- this.scale = descriptor.transform?.scale ? [descriptor.transform.scale[0], descriptor.transform.scale[1]] : [1, 1];
52
- this.rotation = descriptor.transform?.rotation ?? 0;
53
- }
54
-
55
- validate(): TextureBindingValidation {
56
- const diagnostics: string[] = [];
57
- const warnings: string[] = [];
58
- if (this.required && !this.texture) {
59
- diagnostics.push(`Missing required texture: ${this.name}`);
60
- } else if (!this.required && !this.texture) {
61
- warnings.push(`Optional texture is not bound; using fallback texture: ${this.name}`);
62
- }
63
- if (this.texture?.disposed) {
64
- diagnostics.push(`Texture is disposed: ${this.name}`);
65
- }
66
- if (this.texture && !this.ready) {
67
- diagnostics.push(`Texture is not ready: ${this.name}`);
68
- }
69
- if (this.texture && this.expectedColorSpace && this.texture.colorSpace !== this.expectedColorSpace) {
70
- diagnostics.push(`Texture ${this.name} colorSpace must be ${this.expectedColorSpace}, got ${this.texture.colorSpace}`);
71
- }
72
- if (this.texture && this.expectedDimension && this.texture.dimension !== this.expectedDimension) {
73
- diagnostics.push(`Texture ${this.name} dimension must be ${this.expectedDimension}, got ${this.texture.dimension}`);
74
- }
75
- if (![...this.offset, ...this.scale, this.rotation].every(Number.isFinite)) {
76
- diagnostics.push(`Texture transform must contain finite values: ${this.name}`);
77
- }
78
- return { ok: diagnostics.length === 0, diagnostics, warnings };
79
- }
80
-
81
- transformUV(uv: readonly [number, number]): readonly [number, number] {
82
- const scaledX = uv[0] * this.scale[0];
83
- const scaledY = uv[1] * this.scale[1];
84
- const cos = Math.cos(this.rotation);
85
- const sin = Math.sin(this.rotation);
86
- return [
87
- scaledX * cos - scaledY * sin + this.offset[0],
88
- scaledX * sin + scaledY * cos + this.offset[1]
89
- ];
90
- }
91
- }