@forgeax/engine-render 0.1.35 → 0.1.37

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 (101) hide show
  1. package/README.md +28 -0
  2. package/dist/assembly/host-contract.d.ts +2 -2
  3. package/dist/assembly/host-contract.d.ts.map +1 -1
  4. package/dist/assembly/webgpu-vertex-layouts.d.ts.map +1 -1
  5. package/dist/{chunk-MZ4C7EHF.mjs → chunk-3F5XYSN3.mjs} +5 -5
  6. package/dist/{chunk-MZ4C7EHF.mjs.map → chunk-3F5XYSN3.mjs.map} +1 -1
  7. package/dist/{chunk-G6HDNGY7.mjs → chunk-3O2BBKEL.mjs} +24 -230
  8. package/dist/chunk-3O2BBKEL.mjs.map +1 -0
  9. package/dist/{chunk-MXTWKZO4.mjs → chunk-ARLAEJ45.mjs} +225 -4
  10. package/dist/chunk-ARLAEJ45.mjs.map +1 -0
  11. package/dist/{chunk-3XUBWRY2.mjs → chunk-E4NJYUJ2.mjs} +4 -4
  12. package/dist/{chunk-3XUBWRY2.mjs.map → chunk-E4NJYUJ2.mjs.map} +1 -1
  13. package/dist/{chunk-LM5IE7GF.mjs → chunk-N7NVXQWI.mjs} +3 -3
  14. package/dist/{chunk-LM5IE7GF.mjs.map → chunk-N7NVXQWI.mjs.map} +1 -1
  15. package/dist/{chunk-SGPUJW3F.mjs → chunk-NMSOOXBB.mjs} +3 -3
  16. package/dist/{chunk-SGPUJW3F.mjs.map → chunk-NMSOOXBB.mjs.map} +1 -1
  17. package/dist/{chunk-LNIUIKQ7.mjs → chunk-SJIPVWNB.mjs} +79 -21
  18. package/dist/chunk-SJIPVWNB.mjs.map +1 -0
  19. package/dist/construct-renderer.mjs +141 -74
  20. package/dist/construct-renderer.mjs.map +1 -1
  21. package/dist/device/device-scope.d.ts.map +1 -1
  22. package/dist/features/particle-mesh-layout.d.ts +19 -0
  23. package/dist/features/particle-mesh-layout.d.ts.map +1 -0
  24. package/dist/features/types.d.ts +5 -1
  25. package/dist/features/types.d.ts.map +1 -1
  26. package/dist/gpu-driven/production-raster.d.ts +1 -1
  27. package/dist/gpu-driven/production-raster.d.ts.map +1 -1
  28. package/dist/gpu-driven/shadow-views.d.ts +1 -1
  29. package/dist/gpu-driven/shadow-views.d.ts.map +1 -1
  30. package/dist/gpu-driven/view-gpu.d.ts +1 -1
  31. package/dist/gpu-driven/view-gpu.d.ts.map +1 -1
  32. package/dist/ibl/IblPipelineCache.d.ts.map +1 -1
  33. package/dist/index.mjs +48 -36
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/internal.mjs +5 -5
  36. package/dist/pbr-pipeline.d.ts.map +1 -1
  37. package/dist/publication/publisher.d.ts +1 -0
  38. package/dist/publication/publisher.d.ts.map +1 -1
  39. package/dist/record/frame.d.ts.map +1 -1
  40. package/dist/record/prepared-material-bindings.d.ts +1 -2
  41. package/dist/record/prepared-material-bindings.d.ts.map +1 -1
  42. package/dist/record/render-context.d.ts +2 -0
  43. package/dist/record/render-context.d.ts.map +1 -1
  44. package/dist/record/shadow-pass.d.ts +2 -2
  45. package/dist/record/shadow-pass.d.ts.map +1 -1
  46. package/dist/record/typed-frame-graph.d.ts.map +1 -1
  47. package/dist/recovery/render-system-candidate.d.ts +1 -8
  48. package/dist/recovery/render-system-candidate.d.ts.map +1 -1
  49. package/dist/render-contract.d.ts +2 -2
  50. package/dist/render-contract.d.ts.map +1 -1
  51. package/dist/render-system-extract-tail.d.ts.map +1 -1
  52. package/dist/render-system-extract.d.ts.map +1 -1
  53. package/dist/render-system.d.ts +2 -1
  54. package/dist/render-system.d.ts.map +1 -1
  55. package/dist/scene/render-scene.d.ts +2 -1
  56. package/dist/scene/render-scene.d.ts.map +1 -1
  57. package/dist/temporal/index.mjs +4 -4
  58. package/dist/typed-shadow-passes.d.ts.map +1 -1
  59. package/package.json +21 -21
  60. package/src/__tests__/device-scope-lifecycle.unit.test.ts +26 -0
  61. package/src/__tests__/gpu-driven-production.integration.test.ts +41 -1
  62. package/src/__tests__/gpu-driven-shadow-views.unit.test.ts +23 -0
  63. package/src/__tests__/ibl/precompute-submission.unit.test.ts +123 -0
  64. package/src/__tests__/ibl-residency-publication.unit.test.ts +0 -16
  65. package/src/__tests__/material-vertex-texture.browser.test.ts +7 -0
  66. package/src/__tests__/material-vertex-texture.dawn.test.ts +7 -0
  67. package/src/__tests__/material-vertex-texture.fixture.ts +31 -0
  68. package/src/__tests__/recovery-candidate-prepare.contract.test.ts +5 -0
  69. package/src/__tests__/renderer-factory-material-contract.unit.test.ts +106 -4
  70. package/src/__tests__/runtime-material-program.integration.test.ts +79 -0
  71. package/src/__tests__/vertex-layouts-ssot.unit.test.ts +23 -3
  72. package/src/assembly/host-contract.ts +2 -2
  73. package/src/assembly/webgpu-renderer.ts +12 -9
  74. package/src/assembly/webgpu-vertex-layouts.ts +2 -9
  75. package/src/device/device-scope.ts +3 -0
  76. package/src/features/particle-mesh-layout.ts +25 -0
  77. package/src/features/types.ts +5 -1
  78. package/src/gpu-driven/production-raster.ts +23 -6
  79. package/src/gpu-driven/shadow-views.ts +27 -2
  80. package/src/gpu-driven/view-gpu.ts +5 -0
  81. package/src/ibl/IblPipelineCache.ts +4 -3
  82. package/src/pbr-pipeline.ts +4 -1
  83. package/src/publication/__tests__/features.integration.test.ts +51 -0
  84. package/src/publication/__tests__/publication.integration.test.ts +59 -0
  85. package/src/publication/publisher.ts +56 -29
  86. package/src/record/__tests__/prepared-runtime-material.integration.test.ts +134 -0
  87. package/src/record/frame.ts +45 -6
  88. package/src/record/prepared-material-bindings.ts +11 -37
  89. package/src/record/render-context.ts +2 -0
  90. package/src/record/shadow-pass.ts +65 -4
  91. package/src/record/typed-frame-graph.ts +5 -1
  92. package/src/recovery/render-system-candidate.ts +1 -9
  93. package/src/render-contract.ts +2 -2
  94. package/src/render-system-extract-tail.ts +15 -6
  95. package/src/render-system-extract.ts +9 -2
  96. package/src/render-system.ts +2 -3
  97. package/src/scene/render-scene.ts +4 -2
  98. package/src/typed-shadow-passes.ts +36 -5
  99. package/dist/chunk-G6HDNGY7.mjs.map +0 -1
  100. package/dist/chunk-LNIUIKQ7.mjs.map +0 -1
  101. package/dist/chunk-MXTWKZO4.mjs.map +0 -1
@@ -1148,18 +1148,21 @@ var DeviceScope = class _DeviceScope {
1148
1148
  this.clearChildren();
1149
1149
  this._clearResources();
1150
1150
  this.lifecycleState = "retired";
1151
+ this.parent?.detachChild(this);
1151
1152
  }
1152
1153
  abandon() {
1153
1154
  if (this.lifecycleState !== "active") return;
1154
1155
  this.lifecycleState = "abandoned";
1155
1156
  this.clearChildren();
1156
1157
  this._clearResources();
1158
+ this.parent?.detachChild(this);
1157
1159
  }
1158
1160
  dispose() {
1159
1161
  if (this.lifecycleState === "disposed") return;
1160
1162
  this.lifecycleState = "disposed";
1161
1163
  this.clearChildren();
1162
1164
  this._clearResources();
1165
+ this.parent?.detachChild(this);
1163
1166
  }
1164
1167
  async replace(generation, resources) {
1165
1168
  const replacement = new _DeviceScope(generation, this.owner, this);
@@ -1985,7 +1988,7 @@ function buildPbrMaterialUserRegionEntries(paramSchema = STANDARD_PIPELINE_PARAM
1985
1988
  let entries = derived.bglEntries.map(
1986
1989
  (entry) => ({
1987
1990
  binding: entry.binding,
1988
- visibility: entry.visibility,
1991
+ visibility: entry.texture !== void 0 || entry.sampler !== void 0 ? GPU_SHADER_STAGE_VERTEX | GPU_SHADER_STAGE_FRAGMENT : entry.visibility,
1989
1992
  ...entry.buffer === void 0 ? {} : { buffer: entry.buffer },
1990
1993
  ...entry.sampler === void 0 ? {} : { sampler: entry.sampler },
1991
1994
  ...entry.texture === void 0 ? {} : { texture: entry.texture },
@@ -3263,6 +3266,224 @@ function buildGpuDrivenDraws(input) {
3263
3266
  });
3264
3267
  }
3265
3268
 
3266
- export { AtmosphereInvalidParameterError, AutoExposureCapabilityUnavailableError, AutoExposureInvalidParameterError, AutoExposureStageFailedError, AutoExposureStaleGenerationError, BarrelDistortionInvalidParameterError, COOKIE_MATRIX_BYTES, COOKIE_SLICE_CAPACITY, COOKIE_SLICE_SIZE, DEFAULT_MOTION_BLUR_PARAMS, DeviceScope, DynamicResolutionInvalidParameterError, DynamicResolutionRequiresTaaError, DynamicResolutionTimingUnavailableError, EXTENDED_LIGHTING_REQUIRED_SAMPLED_TEXTURES, EXTENDED_LIGHTING_TOPOLOGY, EnvironmentGenerationFailedError, EnvironmentSourceConflictError, EquirectProjectionFailedError, FXAA_POST_PROCESS_ID, FogCardinalityError, FrameReceiptStaleError, GPU_BUFFER_USAGE_COPY_DST, GPU_BUFFER_USAGE_COPY_SRC, GPU_BUFFER_USAGE_INDEX, GPU_BUFFER_USAGE_INDIRECT, GPU_BUFFER_USAGE_MAP_READ, GPU_BUFFER_USAGE_QUERY_RESOLVE, GPU_BUFFER_USAGE_STORAGE, GPU_BUFFER_USAGE_UNIFORM, GPU_BUFFER_USAGE_VERTEX, GPU_SHADER_STAGE_COMPUTE, GPU_SHADER_STAGE_FRAGMENT, GPU_SHADER_STAGE_VERTEX, GPU_TEXTURE_USAGE_COPY_DST, GPU_TEXTURE_USAGE_COPY_SRC, GPU_TEXTURE_USAGE_RENDER_ATTACHMENT, GPU_TEXTURE_USAGE_RENDER_ATTACHMENT_AND_TEXTURE_BINDING, GPU_TEXTURE_USAGE_STORAGE_BINDING, GPU_TEXTURE_USAGE_TEXTURE_BINDING, GpuDrivenPreparationError, IES_SLICE_CAPACITY, IES_SLICE_HEIGHT, IES_SLICE_WIDTH, InstanceProjectionStore, InstanceTransformsError, LifecycleTransaction, MOTION_BLUR_PARAMS_BYTE_SIZE, MaterialSkinAttrMissingError, MotionBlurValidationError, ObservationUnavailableError, OwnerStageFailedError, PointShadowAtlasBoundsViolationError, PointShadowAtlasUninitializedError, PointsLinesBudgetExceededError, PointsLinesInvalidStyleError, PointsLinesMaterialUnsupportedError, PointsLinesPrepareFailedError, PointsLinesStyleUnsupportedError, PointsLinesTopologyMismatchError, RENDER_PHASE_CATALOG, RenderFeatureCapabilityMissingError, RenderFeatureDrawRecordingFailedError, RenderFeaturePreparationFailedError, RenderFeaturePreparedStateMismatchError, RenderFeatureRegistrationConflictError, RenderFeatureStageFailedError, RenderIntentInvalidError, RenderTargetCapabilityMissingError, RenderTargetDescriptorInvalidError, RenderTargetOperationFailedError, RenderTargetStateInvalidError, RendererContractFailureError, RendererOperationError, SHADOW_ATLAS_DEFAULT_FACE_SIZE, SHADOW_ATLAS_DEFAULT_LAYERS, SHADOW_CASTER_SHADER_ID, SKIN_MATERIAL_SHADER_ID, SPRITE_PASS_PER_INSTANCE_REGION_VARIANT_SET, STANDARD_OUTPUT_TRANSFORM_FEATURE_ID, SceneDataUnavailableError, ShadowAtlas, ShadowInvalidConfigError, SkinMaterialMismatchError, SkinPaletteOverflowError, StandardClusterIndexOverflowError, StandardClusterTransportUnavailableError, StandardLightBudgetExceededError, StandardProfileInvalidError, TaaCapsInsufficientError, TemporalFrameSubmitError, TransmissionCapabilityMissingError, VertexColorVariantConflictError, VideoUploadUnsupportedError, VolumeDensityShapeMismatchError, VolumeInvalidBoundsError, VolumeInvalidParametersError, VolumeOwnerConflictError, buildBindGroupLayoutDescriptor, buildGpuDrivenDraws, buildGpuDrivenPbrInstancesBindGroupLayout, buildGpuDrivenPbrPipelineLayout, buildGpuDrivenPbrSkinPipelineLayout, buildPbrMaterialUserRegionEntries, buildPbrPipelineLayouts, buildPbrSkinLayouts, buildSurfaceDirectInstancesBindGroupLayout, createAutoExposureError, createAutoExposureInspection, createHdrpBindGroupLayoutDescriptor, createHdrpSkinBindGroupLayoutDescriptor, createLightResourceUnavailable, createPbrSkinMeshBindGroupEntries, createRenderTargetMaterialSource, createVisibilityBudget, deriveExtendedLightingCapability, effectiveMotionBlurSampleCount, extendedLightingSampledTextureCapacityAvailable, getOpaqueResourceIdentity, getTextureIdentity, gpuDrivenDrawKey, gpuDrivenMaterialArtifactKey, gpuDrivenShadowDrawKey, gpuDrivenSourceDrawItemIndex, hasRequiredVertexInputs, instanceCollectionCacheKey, instanceUploadRangesForResident, isCanonicalStandardPbrMaterialShader, isMotionBlurIntervalValid, isStandardPbrMaterialShader, isStandardPbrSkinMaterialShader, makeZeroCameraFallbackSnapshot, matchPass, materialBindGroupLayoutIdentity, motionBlurExposureScale, motionBlurSampleDelta, motionBlurTemporalDemand, pbrSkinMeshDynamicOffsets, physicalTextureFields, renderTargetMaterialSourceIdentity, resolveMotionBlurParams, resolvePipelineGroup2Contract, resolveRenderTargetMaterialSource, selectPasses, shadowCasterVariantSet, validateGraphTargetCaptureReadback, validateInstanceTransforms, validateMotionBlurParams, worldEntityKey };
3267
- //# sourceMappingURL=chunk-MXTWKZO4.mjs.map
3268
- //# sourceMappingURL=chunk-MXTWKZO4.mjs.map
3269
+ // src/instances-derived-bounds.ts
3270
+ var fingerprintScalar = new Float32Array(1);
3271
+ var fingerprintBits = new Uint32Array(fingerprintScalar.buffer);
3272
+ function fingerprintNumericArray(values) {
3273
+ let hash = 2166136261;
3274
+ for (let index = 0; index < values.length; index += 1) {
3275
+ fingerprintScalar[0] = Number(values[index]);
3276
+ hash = Math.imul(hash ^ (fingerprintBits[0] ?? 0), 16777619) >>> 0;
3277
+ }
3278
+ return hash >>> 0;
3279
+ }
3280
+ function finiteAabb(aabb) {
3281
+ if (aabb === void 0 || aabb.length < 6) return false;
3282
+ const minX = aabb[0];
3283
+ const minY = aabb[1];
3284
+ const minZ = aabb[2];
3285
+ const maxX = aabb[3];
3286
+ const maxY = aabb[4];
3287
+ const maxZ = aabb[5];
3288
+ return Number.isFinite(minX) && Number.isFinite(minY) && Number.isFinite(minZ) && Number.isFinite(maxX) && Number.isFinite(maxY) && Number.isFinite(maxZ) && minX <= maxX && minY <= maxY && minZ <= maxZ;
3289
+ }
3290
+ function finiteMatrix(matrix) {
3291
+ if (matrix.length < 16) return false;
3292
+ for (let index = 0; index < 16; index += 1) {
3293
+ if (!Number.isFinite(matrix[index])) return false;
3294
+ }
3295
+ return true;
3296
+ }
3297
+ function multiplyMat4(out, left, right, rightOffset = 0) {
3298
+ for (let column = 0; column < 4; column += 1) {
3299
+ const rightColumn = rightOffset + column * 4;
3300
+ const right0 = Number(right[rightColumn] ?? 0);
3301
+ const right1 = Number(right[rightColumn + 1] ?? 0);
3302
+ const right2 = Number(right[rightColumn + 2] ?? 0);
3303
+ const right3 = Number(right[rightColumn + 3] ?? 0);
3304
+ const outOffset = column * 4;
3305
+ out[outOffset] = Number(left[0] ?? 0) * right0 + Number(left[4] ?? 0) * right1 + Number(left[8] ?? 0) * right2 + Number(left[12] ?? 0) * right3;
3306
+ out[outOffset + 1] = Number(left[1] ?? 0) * right0 + Number(left[5] ?? 0) * right1 + Number(left[9] ?? 0) * right2 + Number(left[13] ?? 0) * right3;
3307
+ out[outOffset + 2] = Number(left[2] ?? 0) * right0 + Number(left[6] ?? 0) * right1 + Number(left[10] ?? 0) * right2 + Number(left[14] ?? 0) * right3;
3308
+ out[outOffset + 3] = Number(left[3] ?? 0) * right0 + Number(left[7] ?? 0) * right1 + Number(left[11] ?? 0) * right2 + Number(left[15] ?? 0) * right3;
3309
+ }
3310
+ }
3311
+ function finiteMatrixAt(values, offset) {
3312
+ if (values.length - offset < 16) return false;
3313
+ for (let index = 0; index < 16; index += 1) {
3314
+ if (!Number.isFinite(values[offset + index])) return false;
3315
+ }
3316
+ return true;
3317
+ }
3318
+ function isAffine(matrix) {
3319
+ return matrix[3] === 0 && matrix[7] === 0 && matrix[11] === 0 && matrix[15] === 1;
3320
+ }
3321
+ function includeBox(out, candidate, initialized) {
3322
+ const minX = candidate[0];
3323
+ const minY = candidate[1];
3324
+ const minZ = candidate[2];
3325
+ const maxX = candidate[3];
3326
+ const maxY = candidate[4];
3327
+ const maxZ = candidate[5];
3328
+ if (!initialized) {
3329
+ out[0] = minX;
3330
+ out[1] = minY;
3331
+ out[2] = minZ;
3332
+ out[3] = maxX;
3333
+ out[4] = maxY;
3334
+ out[5] = maxZ;
3335
+ return true;
3336
+ }
3337
+ if (minX < (out[0] ?? Number.POSITIVE_INFINITY)) out[0] = minX;
3338
+ if (minY < (out[1] ?? Number.POSITIVE_INFINITY)) out[1] = minY;
3339
+ if (minZ < (out[2] ?? Number.POSITIVE_INFINITY)) out[2] = minZ;
3340
+ if (maxX > (out[3] ?? Number.NEGATIVE_INFINITY)) out[3] = maxX;
3341
+ if (maxY > (out[4] ?? Number.NEGATIVE_INFINITY)) out[4] = maxY;
3342
+ if (maxZ > (out[5] ?? Number.NEGATIVE_INFINITY)) out[5] = maxZ;
3343
+ return true;
3344
+ }
3345
+ function transformAabb(out, local, matrix) {
3346
+ const minX = local[0];
3347
+ const minY = local[1];
3348
+ const minZ = local[2];
3349
+ const maxX = local[3];
3350
+ const maxY = local[4];
3351
+ const maxZ = local[5];
3352
+ const centerX = (minX + maxX) * 0.5;
3353
+ const centerY = (minY + maxY) * 0.5;
3354
+ const centerZ = (minZ + maxZ) * 0.5;
3355
+ const extentX = (maxX - minX) * 0.5;
3356
+ const extentY = (maxY - minY) * 0.5;
3357
+ const extentZ = (maxZ - minZ) * 0.5;
3358
+ if (isAffine(matrix)) {
3359
+ const centerWorldX = matrix[0] * centerX + matrix[4] * centerY + matrix[8] * centerZ + matrix[12];
3360
+ const centerWorldY = matrix[1] * centerX + matrix[5] * centerY + matrix[9] * centerZ + matrix[13];
3361
+ const centerWorldZ = matrix[2] * centerX + matrix[6] * centerY + matrix[10] * centerZ + matrix[14];
3362
+ const extentWorldX = Math.abs(matrix[0]) * extentX + Math.abs(matrix[4]) * extentY + Math.abs(matrix[8]) * extentZ;
3363
+ const extentWorldY = Math.abs(matrix[1]) * extentX + Math.abs(matrix[5]) * extentY + Math.abs(matrix[9]) * extentZ;
3364
+ const extentWorldZ = Math.abs(matrix[2]) * extentX + Math.abs(matrix[6]) * extentY + Math.abs(matrix[10]) * extentZ;
3365
+ out[0] = centerWorldX - extentWorldX;
3366
+ out[1] = centerWorldY - extentWorldY;
3367
+ out[2] = centerWorldZ - extentWorldZ;
3368
+ out[3] = centerWorldX + extentWorldX;
3369
+ out[4] = centerWorldY + extentWorldY;
3370
+ out[5] = centerWorldZ + extentWorldZ;
3371
+ return finiteAabb(out);
3372
+ }
3373
+ let minimumW = Number.POSITIVE_INFINITY;
3374
+ let maximumW = Number.NEGATIVE_INFINITY;
3375
+ for (let corner = 0; corner < 8; corner += 1) {
3376
+ const x = (corner & 1) === 0 ? minX : maxX;
3377
+ const y = (corner & 2) === 0 ? minY : maxY;
3378
+ const z = (corner & 4) === 0 ? minZ : maxZ;
3379
+ const w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
3380
+ if (!Number.isFinite(w)) return false;
3381
+ if (w < minimumW) minimumW = w;
3382
+ if (w > maximumW) maximumW = w;
3383
+ }
3384
+ if (minimumW <= 0 && maximumW >= 0) return false;
3385
+ let unionMinX = Number.POSITIVE_INFINITY;
3386
+ let unionMinY = Number.POSITIVE_INFINITY;
3387
+ let unionMinZ = Number.POSITIVE_INFINITY;
3388
+ let unionMaxX = Number.NEGATIVE_INFINITY;
3389
+ let unionMaxY = Number.NEGATIVE_INFINITY;
3390
+ let unionMaxZ = Number.NEGATIVE_INFINITY;
3391
+ for (let corner = 0; corner < 8; corner += 1) {
3392
+ const x = (corner & 1) === 0 ? minX : maxX;
3393
+ const y = (corner & 2) === 0 ? minY : maxY;
3394
+ const z = (corner & 4) === 0 ? minZ : maxZ;
3395
+ const rawX = matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12];
3396
+ const rawY = matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13];
3397
+ const rawZ = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
3398
+ const w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
3399
+ const projectedX = rawX / w;
3400
+ const projectedY = rawY / w;
3401
+ const projectedZ = rawZ / w;
3402
+ if (!Number.isFinite(projectedX) || !Number.isFinite(projectedY) || !Number.isFinite(projectedZ)) {
3403
+ return false;
3404
+ }
3405
+ if (projectedX < unionMinX) unionMinX = projectedX;
3406
+ if (projectedY < unionMinY) unionMinY = projectedY;
3407
+ if (projectedZ < unionMinZ) unionMinZ = projectedZ;
3408
+ if (projectedX > unionMaxX) unionMaxX = projectedX;
3409
+ if (projectedY > unionMaxY) unionMaxY = projectedY;
3410
+ if (projectedZ > unionMaxZ) unionMaxZ = projectedZ;
3411
+ }
3412
+ out[0] = unionMinX;
3413
+ out[1] = unionMinY;
3414
+ out[2] = unionMinZ;
3415
+ out[3] = unionMaxX;
3416
+ out[4] = unionMaxY;
3417
+ out[5] = unionMaxZ;
3418
+ return finiteAabb(out);
3419
+ }
3420
+ function deriveInstancesUnionBounds(input) {
3421
+ const { meshAabb, entityWorld, transforms } = input;
3422
+ if (!finiteAabb(meshAabb) || !finiteMatrix(entityWorld) || transforms === void 0) {
3423
+ return void 0;
3424
+ }
3425
+ if (transforms.length === 0 || transforms.length % 16 !== 0) return void 0;
3426
+ const local = meshAabb;
3427
+ const union = new Float32Array(6);
3428
+ const composed = new Float32Array(16);
3429
+ const transformed = new Float32Array(6);
3430
+ let initialized = false;
3431
+ for (let offset = 0; offset < transforms.length; offset += 16) {
3432
+ if (!finiteMatrixAt(transforms, offset)) return void 0;
3433
+ multiplyMat4(composed, entityWorld, transforms, offset);
3434
+ if (!finiteMatrix(composed) || !transformAabb(transformed, local, composed)) return void 0;
3435
+ initialized = includeBox(union, transformed, initialized);
3436
+ }
3437
+ return initialized && finiteAabb(union) ? union : void 0;
3438
+ }
3439
+ var InstanceBoundsCache = class {
3440
+ entries = /* @__PURE__ */ new Map();
3441
+ hits = 0;
3442
+ misses = 0;
3443
+ derives = 0;
3444
+ invalidations = 0;
3445
+ key(input) {
3446
+ return `${input.worldId === void 0 ? "" : `${input.worldId}:`}${input.entityKey}`;
3447
+ }
3448
+ get(input) {
3449
+ const previous = this.entries.get(this.key(input));
3450
+ if (previous !== void 0 && previous.meshGeneration === input.meshGeneration && previous.transformGeneration === input.transformGeneration && previous.matrixGeneration === input.matrixGeneration) {
3451
+ this.hits += 1;
3452
+ return previous.bounds;
3453
+ }
3454
+ this.misses += 1;
3455
+ this.derives += 1;
3456
+ const bounds = deriveInstancesUnionBounds(input);
3457
+ this.entries.set(this.key(input), {
3458
+ ...input.worldId === void 0 ? {} : { worldId: input.worldId },
3459
+ entityKey: input.entityKey,
3460
+ meshGeneration: input.meshGeneration,
3461
+ transformGeneration: input.transformGeneration,
3462
+ matrixGeneration: input.matrixGeneration,
3463
+ bounds
3464
+ });
3465
+ return bounds;
3466
+ }
3467
+ invalidate(entityKey, worldId) {
3468
+ if (entityKey === void 0) {
3469
+ if (this.entries.size > 0) this.invalidations += this.entries.size;
3470
+ this.entries.clear();
3471
+ } else {
3472
+ if (this.entries.delete(this.key({ entityKey, ...worldId === void 0 ? {} : { worldId } }))) {
3473
+ this.invalidations += 1;
3474
+ }
3475
+ }
3476
+ }
3477
+ inspect() {
3478
+ return {
3479
+ hits: this.hits,
3480
+ misses: this.misses,
3481
+ derives: this.derives,
3482
+ invalidations: this.invalidations
3483
+ };
3484
+ }
3485
+ };
3486
+
3487
+ export { AtmosphereInvalidParameterError, AutoExposureCapabilityUnavailableError, AutoExposureInvalidParameterError, AutoExposureStageFailedError, AutoExposureStaleGenerationError, BarrelDistortionInvalidParameterError, COOKIE_MATRIX_BYTES, COOKIE_SLICE_CAPACITY, COOKIE_SLICE_SIZE, DEFAULT_MOTION_BLUR_PARAMS, DeviceScope, DynamicResolutionInvalidParameterError, DynamicResolutionRequiresTaaError, DynamicResolutionTimingUnavailableError, EXTENDED_LIGHTING_REQUIRED_SAMPLED_TEXTURES, EXTENDED_LIGHTING_TOPOLOGY, EnvironmentGenerationFailedError, EnvironmentSourceConflictError, EquirectProjectionFailedError, FXAA_POST_PROCESS_ID, FogCardinalityError, FrameReceiptStaleError, GPU_BUFFER_USAGE_COPY_DST, GPU_BUFFER_USAGE_COPY_SRC, GPU_BUFFER_USAGE_INDEX, GPU_BUFFER_USAGE_INDIRECT, GPU_BUFFER_USAGE_MAP_READ, GPU_BUFFER_USAGE_QUERY_RESOLVE, GPU_BUFFER_USAGE_STORAGE, GPU_BUFFER_USAGE_UNIFORM, GPU_BUFFER_USAGE_VERTEX, GPU_SHADER_STAGE_COMPUTE, GPU_SHADER_STAGE_FRAGMENT, GPU_SHADER_STAGE_VERTEX, GPU_TEXTURE_USAGE_COPY_DST, GPU_TEXTURE_USAGE_COPY_SRC, GPU_TEXTURE_USAGE_RENDER_ATTACHMENT, GPU_TEXTURE_USAGE_RENDER_ATTACHMENT_AND_TEXTURE_BINDING, GPU_TEXTURE_USAGE_STORAGE_BINDING, GPU_TEXTURE_USAGE_TEXTURE_BINDING, GpuDrivenPreparationError, IES_SLICE_CAPACITY, IES_SLICE_HEIGHT, IES_SLICE_WIDTH, InstanceBoundsCache, InstanceProjectionStore, InstanceTransformsError, LifecycleTransaction, MOTION_BLUR_PARAMS_BYTE_SIZE, MaterialSkinAttrMissingError, MotionBlurValidationError, ObservationUnavailableError, OwnerStageFailedError, PointShadowAtlasBoundsViolationError, PointShadowAtlasUninitializedError, PointsLinesBudgetExceededError, PointsLinesInvalidStyleError, PointsLinesMaterialUnsupportedError, PointsLinesPrepareFailedError, PointsLinesStyleUnsupportedError, PointsLinesTopologyMismatchError, RENDER_PHASE_CATALOG, RenderFeatureCapabilityMissingError, RenderFeatureDrawRecordingFailedError, RenderFeaturePreparationFailedError, RenderFeaturePreparedStateMismatchError, RenderFeatureRegistrationConflictError, RenderFeatureStageFailedError, RenderIntentInvalidError, RenderTargetCapabilityMissingError, RenderTargetDescriptorInvalidError, RenderTargetOperationFailedError, RenderTargetStateInvalidError, RendererContractFailureError, RendererOperationError, SHADOW_ATLAS_DEFAULT_FACE_SIZE, SHADOW_ATLAS_DEFAULT_LAYERS, SHADOW_CASTER_SHADER_ID, SKIN_MATERIAL_SHADER_ID, SPRITE_PASS_PER_INSTANCE_REGION_VARIANT_SET, STANDARD_OUTPUT_TRANSFORM_FEATURE_ID, SceneDataUnavailableError, ShadowAtlas, ShadowInvalidConfigError, SkinMaterialMismatchError, SkinPaletteOverflowError, StandardClusterIndexOverflowError, StandardClusterTransportUnavailableError, StandardLightBudgetExceededError, StandardProfileInvalidError, TaaCapsInsufficientError, TemporalFrameSubmitError, TransmissionCapabilityMissingError, VertexColorVariantConflictError, VideoUploadUnsupportedError, VolumeDensityShapeMismatchError, VolumeInvalidBoundsError, VolumeInvalidParametersError, VolumeOwnerConflictError, buildBindGroupLayoutDescriptor, buildGpuDrivenDraws, buildGpuDrivenPbrInstancesBindGroupLayout, buildGpuDrivenPbrPipelineLayout, buildGpuDrivenPbrSkinPipelineLayout, buildPbrMaterialUserRegionEntries, buildPbrPipelineLayouts, buildPbrSkinLayouts, buildSurfaceDirectInstancesBindGroupLayout, createAutoExposureError, createAutoExposureInspection, createHdrpBindGroupLayoutDescriptor, createHdrpSkinBindGroupLayoutDescriptor, createLightResourceUnavailable, createPbrSkinMeshBindGroupEntries, createRenderTargetMaterialSource, createVisibilityBudget, deriveExtendedLightingCapability, deriveInstancesUnionBounds, effectiveMotionBlurSampleCount, extendedLightingSampledTextureCapacityAvailable, fingerprintNumericArray, getOpaqueResourceIdentity, getTextureIdentity, gpuDrivenDrawKey, gpuDrivenMaterialArtifactKey, gpuDrivenShadowDrawKey, gpuDrivenSourceDrawItemIndex, hasRequiredVertexInputs, instanceCollectionCacheKey, instanceUploadRangesForResident, isCanonicalStandardPbrMaterialShader, isMotionBlurIntervalValid, isStandardPbrMaterialShader, isStandardPbrSkinMaterialShader, makeZeroCameraFallbackSnapshot, matchPass, materialBindGroupLayoutIdentity, motionBlurExposureScale, motionBlurSampleDelta, motionBlurTemporalDemand, pbrSkinMeshDynamicOffsets, physicalTextureFields, renderTargetMaterialSourceIdentity, resolveMotionBlurParams, resolvePipelineGroup2Contract, resolveRenderTargetMaterialSource, selectPasses, shadowCasterVariantSet, validateGraphTargetCaptureReadback, validateInstanceTransforms, validateMotionBlurParams, worldEntityKey };
3488
+ //# sourceMappingURL=chunk-ARLAEJ45.mjs.map
3489
+ //# sourceMappingURL=chunk-ARLAEJ45.mjs.map