@threenative/core 0.3.15 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { mrt, velocity, output, context } from 'three/tsl';
3
3
  import { BatchedMesh, DataTexture } from 'three';
4
4
 
5
5
  // src/version.ts
6
- var CORE_VERSION = "0.3.15";
6
+ var CORE_VERSION = "0.3.16";
7
7
  var THREE_NATIVE_BATCHED_VELOCITY_PATCH = "threeNativeBatchedVelocityPatch";
8
8
  function isBatchedMeshVelocityPatched() {
9
9
  return Reflect.get(BatchedMesh, THREE_NATIVE_BATCHED_VELOCITY_PATCH) === true;
@@ -1,4 +1,4 @@
1
- import { isEngineRenderHook, markStreamedGeometry, upgradeStreamedGeometry, GEOMETRY_ASSET_KEY, TN_VIRTUAL_GEOMETRY, VirtualGeometryPlugin, TN_DISCRETE_LOD, DiscreteLodPlugin, isStreamedGeometry, DISCRETE_LOD_DEFAULT_HYSTERESIS, lodChainOf, registerModelLodController, selectLodFor, biasedLodDistance, selectLodLevel } from './chunk-QAMSM3Z5.js';
1
+ import { isEngineRenderHook, markStreamedGeometry, upgradeStreamedGeometry, GEOMETRY_ASSET_KEY, TN_VIRTUAL_GEOMETRY, VirtualGeometryPlugin, TN_DISCRETE_LOD, DiscreteLodPlugin, isStreamedGeometry, DISCRETE_LOD_DEFAULT_HYSTERESIS, lodChainOf, registerModelLodController, lodBias, selectLodFor, biasedLodDistance, selectLodLevel } from './chunk-OMGIYWW7.js';
2
2
  import { debugRequested, countDebug, readLaunchFlag, measureDebug } from './chunk-VQRPEOKY.js';
3
3
  import { isNative } from './chunk-XDTZ4QMO.js';
4
4
  import { AnimationAction, AnimationMixer, Matrix4, NumberKeyframeTrack, Skeleton, Vector3, BufferGeometry, Color, BufferAttribute, Matrix3, Mesh, InstancedBufferGeometry, Object3D, Texture, InstancedMesh, Quaternion, NoColorSpace, SRGBColorSpace, Sphere, RGBA_ASTC_4x4_Format, Frustum, Box3, InstancedBufferAttribute } from 'three';
@@ -5240,6 +5240,22 @@ function attachInstancedLod(mesh, options) {
5240
5240
  const sphere = new Sphere();
5241
5241
  let children = [];
5242
5242
  let triangles = 0;
5243
+ const engine = instancedLodHooks(mesh);
5244
+ let attached = false;
5245
+ function attachEngine(hooks) {
5246
+ const authored = options.lods !== void 0;
5247
+ hooks.attach.call(
5248
+ mesh,
5249
+ children,
5250
+ Array.from(partitionOf),
5251
+ authored ? distances : [],
5252
+ [local.center.x, local.center.y, local.center.z, local.radius],
5253
+ authored ? null : [...chain?.errors ?? []],
5254
+ budget,
5255
+ hysteresis
5256
+ );
5257
+ attached = true;
5258
+ }
5243
5259
  function ensureChildren() {
5244
5260
  if (children.length > 0) return;
5245
5261
  children = groups.flatMap(
@@ -5271,6 +5287,11 @@ function attachInstancedLod(mesh, options) {
5271
5287
  },
5272
5288
  update(camera, viewportHeight) {
5273
5289
  ensureChildren();
5290
+ if (engine !== void 0) {
5291
+ if (!attached) attachEngine(engine);
5292
+ triangles = engine.update.call(mesh, camera, viewportHeight, lodBias());
5293
+ return;
5294
+ }
5274
5295
  triangles = 0;
5275
5296
  mesh.updateWorldMatrix(true, false);
5276
5297
  camera.getWorldPosition(cameraPosition);
@@ -5333,6 +5354,7 @@ function attachInstancedLod(mesh, options) {
5333
5354
  child.dispose();
5334
5355
  }
5335
5356
  children = [];
5357
+ attached = false;
5336
5358
  mesh.geometry = base;
5337
5359
  triangles = 0;
5338
5360
  }
@@ -5351,6 +5373,15 @@ function attachInstancedLod(mesh, options) {
5351
5373
  ensureChildren();
5352
5374
  mesh.addEventListener("dispose", () => controller.release());
5353
5375
  }
5376
+ function instancedLodHooks(mesh) {
5377
+ const carrier = mesh;
5378
+ const attach = carrier.__tnInstancedLodAttach;
5379
+ const update = carrier.__tnInstancedLodUpdate;
5380
+ return typeof attach === "function" && typeof update === "function" ? {
5381
+ attach,
5382
+ update
5383
+ } : void 0;
5384
+ }
5354
5385
 
5355
5386
  // src/streamed-textures.ts
5356
5387
  var TEXTURE_SLOTS = [
@@ -6885,6 +6916,9 @@ function freezeRoot(root, engine) {
6885
6916
  const snapshot = existing?.snapshot ?? new Float64Array(SNAPSHOT_LENGTH2);
6886
6917
  writeSnapshot(root, snapshot);
6887
6918
  const version = (existing?.version ?? 0) + 1;
6919
+ const watch = root.__tnStaticWatch;
6920
+ if (typeof watch === "function") watch.call(root);
6921
+ if (existing === void 0) engineRoots = void 0;
6888
6922
  frozen.set(
6889
6923
  root,
6890
6924
  engine ? { objects, root, snapshot, version, parent: root.parent, fresh: true } : { objects, root, snapshot, version }
@@ -6893,6 +6927,7 @@ function freezeRoot(root, engine) {
6893
6927
  }
6894
6928
  function unmarkStatic(root) {
6895
6929
  if (!frozen.delete(root)) return;
6930
+ engineRoots = void 0;
6896
6931
  if (worldSilenced.delete(root)) root.matrixWorldAutoUpdate = true;
6897
6932
  root.traverse((object2) => {
6898
6933
  if (composeSilenced.delete(object2)) object2.matrixAutoUpdate = true;
@@ -6915,8 +6950,24 @@ function staticRoots() {
6915
6950
  return [...frozen.keys()];
6916
6951
  }
6917
6952
  var rearmedSinceCensus = 0;
6953
+ var engineRoots;
6918
6954
  function refreshStaticTransforms() {
6919
6955
  if (frozen.size === 0) return;
6956
+ const first = frozen.keys().next().value;
6957
+ const changed = first.__tnStaticChanged;
6958
+ if (typeof changed === "function") {
6959
+ if (engineRoots === void 0) {
6960
+ engineRoots = [...frozen.keys()];
6961
+ first.__tnStaticRoots.call(first, engineRoots);
6962
+ }
6963
+ const roots = engineRoots;
6964
+ for (const index of changed.call(first)) {
6965
+ const root = roots[index];
6966
+ freezeRoot(root, frozen.get(root)?.parent !== void 0);
6967
+ rearmedSinceCensus += 1;
6968
+ }
6969
+ return;
6970
+ }
6920
6971
  parentMovedThisFrame.clear();
6921
6972
  for (const entry of frozen.values()) {
6922
6973
  const engine = entry.parent !== void 0;
@@ -6968,6 +7019,7 @@ function staticTransformCensus() {
6968
7019
  }
6969
7020
  function resetStaticTransforms() {
6970
7021
  frozen.clear();
7022
+ engineRoots = void 0;
6971
7023
  parentMovedThisFrame.clear();
6972
7024
  rearmedSinceCensus = 0;
6973
7025
  }
@@ -747,6 +747,9 @@ var LOD_BIAS_KEY = /* @__PURE__ */ Symbol.for("threenative.lodBias");
747
747
  var lodBiasHost = globalThis;
748
748
  var lodBiasState = lodBiasHost[LOD_BIAS_KEY] ?? { value: 1 };
749
749
  lodBiasHost[LOD_BIAS_KEY] = lodBiasState;
750
+ function lodBias() {
751
+ return lodBiasState.value;
752
+ }
750
753
  function setLodBias(bias) {
751
754
  lodBiasState.value = Number.isFinite(bias) && bias >= 1 ? bias : 1;
752
755
  }
@@ -879,6 +882,31 @@ var ModelLod = class {
879
882
  get base() {
880
883
  return this.#chain.base;
881
884
  }
885
+ /** PRD-898 J2: whether the engine's batched selection can run this one (the join authority cannot). */
886
+ get batchable() {
887
+ return this.#rung === void 0 || !this.#authority;
888
+ }
889
+ #attached = false;
890
+ /** The mesh for `__tnModelLodSelect`, its chain handed to the engine on first use. */
891
+ engineMesh() {
892
+ if (!this.#attached) {
893
+ const { center, radius } = this.#chain.sphere;
894
+ this.#mesh.__tnModelLodAttach(
895
+ [...this.#chain.errors],
896
+ [center.x, center.y, center.z, radius],
897
+ this.#policy.maxPixelError,
898
+ this.#policy.hysteresis,
899
+ this.#current
900
+ );
901
+ this.#attached = true;
902
+ }
903
+ return this.#mesh;
904
+ }
905
+ /** The level the engine's batched selection chose. */
906
+ applyLevel(index) {
907
+ this.#current = index;
908
+ this.#mesh.geometry = this.#chain.levels[index];
909
+ }
882
910
  get triangles() {
883
911
  const rung = this.#rung;
884
912
  if (rung?.isHidden(this.#mesh)) return this.#authority ? rung.triangles : 0;
@@ -1570,6 +1598,17 @@ function trackRoot2(root) {
1570
1598
  hookSubtree2(tracking, root);
1571
1599
  return tracking;
1572
1600
  }
1601
+ var engineBatch = [];
1602
+ function selectBatched(select, camera, batched, viewportHeight) {
1603
+ if (batched.length !== engineBatch.length || batched.some((entry, i) => entry !== engineBatch[i])) {
1604
+ const meshes = batched.map((entry) => entry.engineMesh());
1605
+ camera.__tnModelLodMeshes(meshes);
1606
+ engineBatch = batched;
1607
+ }
1608
+ const changed = select.call(camera, viewportHeight, lodBias());
1609
+ for (let i = 0; i < changed.length; i += 2)
1610
+ batched[changed[i]].applyLevel(changed[i + 1]);
1611
+ }
1573
1612
  function updateModelLods(root, camera, viewportHeight) {
1574
1613
  camera.updateMatrixWorld();
1575
1614
  if (!isGraphNode2(root)) {
@@ -1584,14 +1623,20 @@ function updateModelLods(root, camera, viewportHeight) {
1584
1623
  return triangles2;
1585
1624
  }
1586
1625
  const tracking = trackRoot2(root);
1626
+ const hook = camera.__tnModelLodSelect;
1627
+ const select = typeof hook === "function" ? hook : void 0;
1628
+ const batched = [];
1587
1629
  for (const mesh of tracking.items) {
1588
1630
  const entry = controllerFor(mesh);
1589
1631
  if (entry === void 0) {
1590
1632
  if (!streaming.has(mesh.geometry)) tracking.items.delete(mesh);
1591
1633
  continue;
1592
1634
  }
1593
- entry.update(camera, viewportHeight);
1635
+ if (select !== void 0 && entry instanceof ModelLod && entry.batchable) batched.push(entry);
1636
+ else entry.update(camera, viewportHeight);
1594
1637
  }
1638
+ if (select !== void 0 && batched.length > 0)
1639
+ selectBatched(select, camera, batched, viewportHeight);
1595
1640
  let triangles = 0;
1596
1641
  for (const mesh of tracking.items) triangles += controllers.get(mesh)?.triangles ?? 0;
1597
1642
  return triangles;
@@ -2234,4 +2279,4 @@ function reconcile(passes, drafts) {
2234
2279
  });
2235
2280
  }
2236
2281
 
2237
- export { ClusterView, ClusteredMesh, DEFAULT_VIEW_MARGIN, DISCRETE_LOD_DEFAULT_ERROR_PIXELS, DISCRETE_LOD_DEFAULT_HYSTERESIS, DiscreteLodPlugin, GEOMETRY_ASSET_KEY, GEOMETRY_CAPTURE_CAPABILITY, GEOMETRY_CAPTURE_DEFAULT_LIMIT, GEOMETRY_CAPTURE_MAX_LIMIT, GEOMETRY_CAPTURE_SORTS, GEOMETRY_CAPTURE_TIMEOUT_MS, GEOMETRY_CAPTURE_WALK_CAP, GeometryCapture, LOD_NEAR_PLANE, TN_DISCRETE_LOD, TN_VIRTUAL_GEOMETRY, VirtualGeometryPlugin, assertViewMargin, baseGeometryOf, biasedLodDistance, clusterTableRadius, isEngineRenderHook, isLodJoinProxy, isStreamedGeometry, lodChainOf, lodPixelScale, markEngineRenderHook, markStreamedGeometry, outsideFrustum, pixelsPerUnit, projectedLodError, registerModelLodController, rendererBackendIdentity, selectClusterCut, selectLodFor, selectLodLevel, setLodBias, setModelLodLayers, updateClusteredMeshes, updateModelLods, upgradeStreamedGeometry, worldFrustum, worldSphere };
2282
+ export { ClusterView, ClusteredMesh, DEFAULT_VIEW_MARGIN, DISCRETE_LOD_DEFAULT_ERROR_PIXELS, DISCRETE_LOD_DEFAULT_HYSTERESIS, DiscreteLodPlugin, GEOMETRY_ASSET_KEY, GEOMETRY_CAPTURE_CAPABILITY, GEOMETRY_CAPTURE_DEFAULT_LIMIT, GEOMETRY_CAPTURE_MAX_LIMIT, GEOMETRY_CAPTURE_SORTS, GEOMETRY_CAPTURE_TIMEOUT_MS, GEOMETRY_CAPTURE_WALK_CAP, GeometryCapture, LOD_NEAR_PLANE, TN_DISCRETE_LOD, TN_VIRTUAL_GEOMETRY, VirtualGeometryPlugin, assertViewMargin, baseGeometryOf, biasedLodDistance, clusterTableRadius, isEngineRenderHook, isLodJoinProxy, isStreamedGeometry, lodBias, lodChainOf, lodPixelScale, markEngineRenderHook, markStreamedGeometry, outsideFrustum, pixelsPerUnit, projectedLodError, registerModelLodController, rendererBackendIdentity, selectClusterCut, selectLodFor, selectLodLevel, setLodBias, setModelLodLayers, updateClusteredMeshes, updateModelLods, upgradeStreamedGeometry, worldFrustum, worldSphere };
package/dist/hot.js CHANGED
@@ -80,6 +80,15 @@ function diagnostics(game, reloads) {
80
80
  physics: typeof physics?.numBodies === "function" ? physics.numBodies() : null
81
81
  };
82
82
  }
83
+ function notPlain(value, prototype, path) {
84
+ const named = prototype.constructor?.name;
85
+ const name = typeof named === "string" && named.length > 0 ? named : "class instance";
86
+ const keys = Object.keys(value).map((key) => key.replace(/^_/u, ""));
87
+ const shape = keys.length > 0 && keys.length <= 6 ? `{ ${keys.join(", ")} } as a plain object` : "its data as plain values";
88
+ return new Error(
89
+ `Hot reload state ${path} must contain only plain objects: it is a ${name}. Store ${shape} and rebuild the ${name} where the code needs it.`
90
+ );
91
+ }
83
92
  function visitPortable(value, path, ancestors) {
84
93
  if (value === null) return;
85
94
  if (typeof value === "string" || typeof value === "boolean") return;
@@ -98,8 +107,7 @@ function visitPortable(value, path, ancestors) {
98
107
  return;
99
108
  }
100
109
  const prototype = Object.getPrototypeOf(value);
101
- if (prototype !== Object.prototype && prototype !== null)
102
- throw new Error(`Hot reload state ${path} must contain only plain objects.`);
110
+ if (prototype !== Object.prototype && prototype !== null) throw notPlain(value, prototype, path);
103
111
  ancestors.add(value);
104
112
  for (const key of Object.keys(value))
105
113
  visitPortable(value[key], `${path}.${key}`, ancestors);
package/dist/index.d.ts CHANGED
@@ -10,8 +10,8 @@ import * as three_webgpu from 'three/webgpu';
10
10
  import { StorageTexture, ComputeNode, UniformNode, Node, TextureNode, CubeRenderTarget, WebGPURenderer, NodeMaterial, StorageBufferNode, StructTypeNode, Data3DTexture, ShadowBaseNode, NodeBuilder, NodeFrame, SpriteNodeMaterial, StorageTextureNode, Storage3DTexture } from 'three/webgpu';
11
11
  import { I as IRendererLike, h as IStageGpuReading, F as FramePassKind, a as IFrameBudgetWindow } from './renderer-BtOSseYf.js';
12
12
  export { D as DEFAULT_PIPELINE_CENSUS_LIMIT, i as DEFAULT_TARGET_FPS, j as FRAME_BUDGET_MARKER, k as FRAME_BUDGET_PHASES, l as FRAME_HITCH_MARKER, m as FrameBudget, n as FrameBudgetPhase, o as FrameCounters, p as ICounterDevice, g as IFrameBudgetOptions, q as IFrameBudgetPassSummary, b as IFrameBudgetSimulation, r as IFrameBudgetSummary, s as IFrameCounters, d as IFramePhaseSample, f as IPipelineCensus, t as IPipelineCensusCounts, u as IPipelineCensusEvent, v as IPipelineCensusOptions, w as IPipelineProvenance, x as IPipelineShaderObservation, y as IPlatformInfo, z as IRenderChainApplied, A as IRenderChainBudgetWindow, B as IRenderChainDroppedStage, C as IRenderChainOptions, E as IRenderChainRenderer, G as IRenderChainRequest, H as IRenderChainStage, J as IRenderChainStageContext, K as IRenderChainVelocityMeasurement, L as IRenderChainVelocityReport, M as IRenderChainVelocityRequest, N as IRenderChainVelocityResult, c as IRenderPassSample, O as ITargetFps, P as IVelocityRenderPass, Q as MAX_TARGET_FPS, R as MainDrawSource, S as PIPELINE_CENSUS_CAPABILITY, T as PIPELINE_CENSUS_VERSION, U as PipelineCensus, V as PipelineCensusMode, W as PipelineCensusStatus, X as PlatformFormFactor, Y as PlatformOS, Z as PlatformRuntime, _ as RENDER_CHAIN_MARKER, $ as RENDER_CHAIN_STAGE_ORDER, a0 as RENDER_CHAIN_TIERS, a1 as RenderChain, a2 as RenderChainSource, a3 as RenderChainStageId, a4 as RenderChainStageName, a5 as RenderChainTier, a6 as RenderChainTierRequest, a7 as RenderChainVelocitySource, a8 as TargetFpsSource, a9 as VELOCITY_OUTPUT_NAME, aa as VELOCITY_PREVIOUS_BONE_MATRICES, ab as VELOCITY_PREVIOUS_INSTANCE_MATRICES, ac as VELOCITY_PREVIOUS_WORLD_MATRIX, ad as VelocityTracker, ae as counterDeviceOf, af as createPipelineCensus, ag as ensureVelocityOutput, ah as getPlatform, ai as isConsole, aj as isMobile, ak as isNative, al as isPs4, am as isTouchscreenAvailable, an as isWeb, ao as prewarm, ap as readRenderChainObservation, aq as readRenderChainReport, ar as readVelocityPreviousBoneMatrices, as as readVelocityPreviousMatrices, at as readVelocityPreviousWorldMatrix, au as resolveTargetFps, av as snapRefreshRate, aw as stageGpuReading, ax as velocityTexture, ay as withVelocityContext } from './renderer-BtOSseYf.js';
13
- import { I as IComputeDriven$1, a as IGPUReadbackSample, d as IBudgetCandidate } from './model-lod-DPTzeCcD.js';
14
- export { C as ComputeDrivenRegistry, D as DISCRETE_LOD_DEFAULT_ERROR_PIXELS, e as DISCRETE_LOD_DEFAULT_HYSTERESIS, G as GPUReadback, f as IGPUReadbackOptions, g as baseGeometryOf, i as isStreamedGeometry, l as lodChainOf, h as lodPixelScale, u as updateModelLods } from './model-lod-DPTzeCcD.js';
13
+ import { I as IComputeDriven$1, a as IGPUReadbackSample, d as IBudgetCandidate } from './model-lod-B921F6kQ.js';
14
+ export { C as ComputeDrivenRegistry, D as DISCRETE_LOD_DEFAULT_ERROR_PIXELS, e as DISCRETE_LOD_DEFAULT_HYSTERESIS, G as GPUReadback, f as IGPUReadbackOptions, g as baseGeometryOf, i as isStreamedGeometry, l as lodChainOf, h as lodPixelScale, u as updateModelLods } from './model-lod-B921F6kQ.js';
15
15
  import { T as TracedReflections, G as GIVisualizeMode } from './quality-BADStsTn.js';
16
16
  export { A as AutoExposureNode, C as ChainStage, E as EPIC_SSGI, F as FinalGatherMethod, a as GIVisualize, b as GI_VISUALIZE_MODES, I as IExposureSettings, c as IGIVisualizeOptions, d as IGiTier, e as IReflectionRoute, f as IShadowFilter, g as IShadowTier, h as ITracedHit, i as ITracedRay, j as ITracedReflectionsOptions, k as IWorldEnvironmentOptions, l as IWorldEnvironmentStageContext, m as IWorldEnvironmentTarget, O as OutputRenderer, Q as QualityTier, S as ScreenSpaceAA, n as SsgiQuality, o as TonemapMode, W as WorldEnvironment, p as exposureSettings, q as installFilmicToneMapping, r as qualityPreset, s as qualityTiers } from './quality-BADStsTn.js';
17
17
  import { SkyMesh } from 'three/addons/objects/SkyMesh.js';
@@ -4431,6 +4431,7 @@ interface IScatterFieldStats {
4431
4431
  * @situation scatter fallen logs, twigs, leaf litter, stones and ferns over a forest floor
4432
4432
  * @situation stream instanced props of any baked mesh round the player without one draw per prop
4433
4433
  * @situation place rocks, debris or plants on a heightfield with distance thinning and level of detail
4434
+ * @alias scatter rocks, debris and plants over terrain
4434
4435
  * @constraint call `update(follow)` once per rendered frame
4435
4436
  * @constraint `place` runs once per candidate per tile build: return false for paths and clearings
4436
4437
  * @constraint rotating or scaling the field is not supported; translating it is
@@ -5571,13 +5572,6 @@ interface IMeasureThreePoseOptions {
5571
5572
  * invisible hitbox. The result is JSON-safe so it can cross the browser playtest bridge.
5572
5573
  */
5573
5574
  declare function measureThreePose(object: Object3D, options?: IMeasureThreePoseOptions): IThreePoseMeasurement;
5574
- /**
5575
- * Cheap world-space bounds for a posed model.
5576
- *
5577
- * The first call pays the precise vertex walk to build a conservative skin envelope. Later calls
5578
- * read one world-matrix translation per contributing bone and allocate nothing. The returned
5579
- * object is cached for the root and updated in place; copy it if it must outlive the next call.
5580
- */
5581
5575
  declare function posedBounds(root: Object3D, meshes?: readonly Object3D[]): IThreePoseBounds;
5582
5576
 
5583
5577
  type ReplayPointer = readonly [number, number, number, number, number];
@@ -5829,6 +5823,6 @@ declare function boneLengths(root: Object3D): IBoneLengthSnapshot;
5829
5823
  */
5830
5824
  declare function boneLengthDeviations(root: Object3D, bind: IBoneLengthSnapshot, options?: IBoneLengthDeviationsOptions): IBoneLengthDeviationReport;
5831
5825
 
5832
- declare const version = "0.3.15";
5826
+ declare const version = "0.3.16";
5833
5827
 
5834
5828
  export { ATLAS_PADDING, ATMOSPHERE_LUT_RESOLUTIONS, AnimationComposer, AnimationPlayer, Atmosphere, type AtmosphereDirection, AtmosphereLuts, type AtmosphereRgb, Billboard3D, type BillboardLockAxis, BlendSpace1D, BlendSpace2D, BudgetLadder, type BudgetVerdict, ClusteredBatch, ClusteredMesh, DEV_GLOBAL_KEY, Daylight, type DevGlobal, ENVIRONMENT_TOO_SMALL_MARKER, FlightModel, FluidField2D, FluidParticles3D, FramePassKind, GIBudget, type GIMethod, GIVisualizeMode, GI_METHODS, GPUParticles3D, GPUSceneBVH, type GPUSceneBVHTraceFunction, GRASS_FIELD_ATTRIBUTES, GrassField3D, GroundSnap, type IAddInSlicesOptions, type IAddInSlicesProgress, type IAddInSlicesReport, type IAircraftAirframe, type IAnimationComposerOptions, type IAnimationLayer, type IAnimationMask, type IAnimationMotionDelta, type IAnimationPlayOptions, type IAnimationPlayerOptions, type IAnimationRootMotionOptions, type IAnimationUpdateRateReport, type IAtmosphereLutResolution, type IAtmosphereLutResolutions, type IAtmosphereOptions, type IAtmosphereParameterPatch, type IAtmosphereParameters, type IAtmosphereScenePass, type IBillboard3DOptions, type IBoneContactReport, type IBoneLengthDeviation, type IBoneLengthDeviationReport, type IBoneLengthDeviationsOptions, type IBoneLengthSnapshot, type IBonePoseError, type IBudgetLadderOptions, type IBudgetWindow, type IClipBindingReport, type IClipCoverageReport, type IClipPoseErrorOptions, type IClipPoseErrorReport, type IClipPoseSubject, type IClipTrackBinding, type IClusterTable, type IClusteredBatchBuildOptions, type IClusteredBatchOptions, type IClusteredMeshOptions, type IClusteredPlacement, IComputeDriven$1 as IComputeDriven, type IDaylightOptions, type IDevTools, type IEmitParticleRequest, type IFlightAxes, type IFlightControls, type IFlightDeck, type IFlightEnvironment, type IFlightForces, type IFlightModelOptions, type IFlightModifiers, type IFlightQuaternion, type IFlightState, type IFlightVector3, type IFluidBounds, type IFluidCollider, type IFluidFieldOptions, type IFluidFieldSampler, type IFluidFieldVector2, type IFluidParticlesOptions, type IFluidParticlesStats, IFrameBudgetWindow, type IGIBudgetOptions, type IGIBudgetReport, type IGPUParticles3DOptions, type IGPUParticles3DRuntime, type IGPUParticles3DSpawnBuffers, type IGPUParticles3DSpawnRequest, type IGPUParticles3DStats, IGPUReadbackSample, type IGPUSceneBVHMaterialGroup, type IGPUSceneBVHOptions, IGamePluginHooks, IGamePluginRuntime, IGeometryCaptureReport, IGeometryCaptureRequest, type IGrassField3DOptions, type IGrassFieldBlade, type IGrassFieldBounds, type IGrassFieldNodes, type IGrassFieldStats, type IGroundSnapOptions, type IInstancedBatchBuildOptions, type IInstancedBatchOptions, type IInstancedPlacement, type ILampShadowStats, type ILaunchFailure, type ILoadAllOptions, type ILoadAllProgress, type IMatrixWorldReport, type IMeasureThreePoseOptions, type IMergeByMaterialOptions, type IMergePart, type IMergePartsOptions, type INormaliseToMetresOptions, type IPathFollow3DOptions, type IPathFollow3DProjection, type IPathFollow3DSample, type IProbeVolumeBakeProgress, type IProbeVolumeCoefficient, type IProbeVolumeObservation, type IProbeVolumeOptions, type IRadianceCacheOptions, type IReplayOptions, type IReplayRecording, type IReplayRecordingSample, type IResolvedAtmosphereParameters, type IRippleFieldFlow, type IRippleFieldOptions, type IScatterField3DOptions, type IScatterFieldBounds, type IScatterFieldStats, type IScatterPart, type IScatterPlacement, type IScatterPoint, type ISceneShape, type ISceneWarning, type IScreenProbeCamera, type IScreenProbeGatherOptions, type IScreenProbeGatherReport, type IShadowFilterBudgetOptions, type IShadowFilterReport, type IShortRangeAOCamera, type IShortRangeAOOptions, type IShortRangeAOReport, type ISkeletalMesh3DOptions, type ISkyCaptureOptions, type ISoftBody3DOptions, type ISoftBodyCollision, type ISolarPosition, type ISolarPositionInput, type ISourceAngleShadowInputs, type ISourceAngleShadowOptions, type ISpanProbeTarget, type ISpanSummary, type ISpanWindow, type ISpectralOceanCascade, type ISpectralOceanHeight, type ISpectralOceanOptions, type ISpriteAnimator3DOptions, type ISpriteFrame3D, IStageGpuReading, type IStaticTransformCensus, type IStrideReport, type ISurfaceCacheMaterial, type ISurfaceCacheOptions, type ISurfaceCacheReport, type ISurfaceCacheTexture, type ISurfaceLight, type ISurfaceLightsOptions, type IThreePoseBounds, type IThreePoseMeasurement, type ITracerPool3DOptions, type ITracerSpawnOptions, type IUnlitFoliageWarning, type IValidationReport, type IVirtualShadowOptions, type IVirtualShadowStats, type IWaterReflectionOptions, type IWaterSurfaceOptions, type IWaveFieldDomainWarp, type IWaveFieldGraphOptions, type IWaveFieldOptions, type IWaveFieldSample, type IWaveFieldWave, InstancedBatch, LAMP_SHADOW_MARKER, LUT_RESOLUTIONS, type LaunchFailureKind, type MatrixWorldMode, MatrixWorldPass, NEUTRAL_FLIGHT_MODIFIERS, type NormaliseAxis, OPACITY_IGNORED_MARKER, PROBE_VOLUME_MARKER, PathFollow3D, ProbeVolume, type ProbeVolumeDensity, RENDERLIST_VALIDATE_FLAG, RENDERLIST_VALIDATE_MARKER, RadianceCache, type Recording, RenderListValidator, type ReplayPointer, RippleField, SCENE_WARNING_MARKER, SHADOW_FILTER_TIERS, SHADOW_STAGES, SPANS, SPANS_FLAG, SPANS_MARKER, SPAN_COUNT, SPAN_NAMES, STATIC_TRANSFORM_MARKER, ScatterField3D, ScreenProbeGather, type ScreenProbePass, ShadowFilterBudget, type ShadowFilterTier, ShortRangeAO, SkeletalMesh3D, SkyCapture, SkyCaptureSchedule, SoftBody3D, type SpanId, SpanRecorder, SpectralOcean, SpriteAnimator3D, type SpritePlaybackMode, SurfaceCache, SurfaceLights, type ThreePoseQuaternion, type ThreePoseVector, TracedReflections, TracerPool3D, UNLIT_FOLIAGE_FIX, UNLIT_FOLIAGE_MARKER, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_MARKER, VIRTUAL_SHADOW_MOVER_LAYER, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, VirtualShadowNode, WaterSurface3D, type WaveDirection, WaveField, addFoliageBackLight, addInSlices, addSpan, aerodynamicCoefficients, airDensity, aircraftMass, alwaysRender, attachToBone, attitudeAxes, beginSpan, boneContact, boneLengthDeviations, boneLengths, bvhIntersectFirstHit, clipBoneCoverage, clipPoseError, clipTrackBindings, createReplayDriver, debugFlag, debugValue, describeSceneShape, describeSceneWarning, devGlobal, directionFromSolarPosition, directionalTransmittance, displayPeriodMs, endSpan, ev100FromCamera, ev100FromExposure, ev100FromLuminance, exposeDebug, exposureFromEv100, formatSceneWarning, formatSpansWindow, formatUnlitFoliageWarning, formatValidationReport, gearClearance, installSpanProbes, invalidateStatic, isStatic, lampPenumbraTangent, lampShadowMarker, loadAll, lookDiagnostics, markStatic, measureThreePose, mergeByMaterial, mergeParts, normaliseToMetres, onLaunchFailure, parseReplayRecording, penumbraUv, posedBounds, publishDevGlobal, rayStruct, readGIMarker, readLampShadowMarker, readProbeVolumeObservation, readShadowTierMarker, readVirtualShadowMarker, refreshStaticTransforms, renderListValidationRequested, renderTrapAudit, replay, resetStaticTransforms, resolveAtmosphereLutResolutions, resolveAtmosphereParameters, sceneWarning, setAttitude, setSpanRecorder, skeletonBones, softCircleDataTexture, solarPosition, solarPositionAt, sourceAngleShadowFilter, sourceRadiusShadowFilter, spanNow, spanRecorder, spansRequested, staticTransformCensus, thinCards, unlitFoliageWarning, unmarkStatic, updateAtmosphereParameters, updateClusteredMeshes, useRoughDiffuse, validateWorldMatrices, version, zenithTransmittance };
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { onUiIntent, publishUiState } from './chunk-2GPHICV6.js';
2
2
  import { installQuietMarkers, uninstallQuietMarkers } from './chunk-QAQHYOWY.js';
3
- import { animationPacketReaders, animationPacketTimeReaders, trackAnimationRate, animationPacketTime, animationPacketMethodsPristine, untrackAnimationRate, beginSpan, SPANS, endSpan, autoBatchOf, isAutoBatchMerged, spanRecorder, DEFAULT_CLIP_EXTENTS, DEFAULT_MAX_LEVEL_RATIO, clipLadder, VIRTUAL_SHADOW_MOVER_LAYER, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, VIRTUAL_SHADOW_KEY_LAYER, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_SMALL_CASTER_LAYER, frustumPlanes, rendererFacts, animationPacketField, DEFAULT_TARGET_FPS, worldSilencedByFreeze, composeSilencedByFreeze, isStatic, prepareSceneEnvironment, STARTUP_COMPILE_BUDGET_MS, warmUpComputeNodes, createAssetLoader, AutoBatch, RenderCameraCull, StartupReadiness, measureStartupOffscreenBytes, STARTUP_OFFSCREEN_BYTES_MARKER, reportUnusedModelsLater, warmUpSceneWithCompletion, resolveTargetFps, SpanRecorder, formatSpansWindow, staticTransformCensus, STATIC_TRANSFORM_MARKER, spansRequested, setSpanRecorder, noteSliceFrame, refreshStaticTransforms, spanNow, addSpan, drawWorld, staticRoots, endSliceFrames, warmUpScene, createProjectionScanWorkspace, scanProjection, isRenderable, releaseProjectionScanWorkspace, STARTUP_STALL_MS, sceneNeedsEnvironmentPreparation, STARTUP_STABLE_WINDOW_MS, geometryVersionSum, hasRenderHook, uniformUnchanged, isSimilarityTransform, SkinnedBatch, isLight, baseColorOf, observeAnimationRates, displacesVertices, hasMorphAttributes, MIN_BATCH_MEMBERS } from './chunk-GEMQJBY4.js';
4
- export { ASSET_LATE_MARKER, DEFAULT_TARGET_FPS, InstancedBatch, MAX_TARGET_FPS, SPANS, SPANS_FLAG, SPANS_MARKER, SPAN_COUNT, SPAN_NAMES, STATIC_TRANSFORM_MARKER, SpanRecorder, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_MOVER_LAYER, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, addInSlices, addSpan, alwaysRender, beginSpan, createAssetLoader, endSpan, fetchAsset, formatSpansWindow, invalidateStatic, isStatic, loadAll, markStatic, mergeByMaterial, mergeParts, reconcileMirroredClips, refreshStaticTransforms, resetStaticTransforms, resolveTargetFps, setSpanRecorder, snapRefreshRate, spanNow, spanRecorder, spansRequested, staticTransformCensus, unmarkStatic, warmUpScene } from './chunk-GEMQJBY4.js';
3
+ import { animationPacketReaders, animationPacketTimeReaders, trackAnimationRate, animationPacketTime, animationPacketMethodsPristine, untrackAnimationRate, beginSpan, SPANS, endSpan, autoBatchOf, isAutoBatchMerged, spanRecorder, DEFAULT_CLIP_EXTENTS, DEFAULT_MAX_LEVEL_RATIO, clipLadder, VIRTUAL_SHADOW_MOVER_LAYER, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, VIRTUAL_SHADOW_KEY_LAYER, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_SMALL_CASTER_LAYER, frustumPlanes, rendererFacts, animationPacketField, DEFAULT_TARGET_FPS, worldSilencedByFreeze, composeSilencedByFreeze, isStatic, prepareSceneEnvironment, STARTUP_COMPILE_BUDGET_MS, warmUpComputeNodes, createAssetLoader, AutoBatch, RenderCameraCull, StartupReadiness, measureStartupOffscreenBytes, STARTUP_OFFSCREEN_BYTES_MARKER, reportUnusedModelsLater, warmUpSceneWithCompletion, resolveTargetFps, SpanRecorder, formatSpansWindow, staticTransformCensus, STATIC_TRANSFORM_MARKER, spansRequested, setSpanRecorder, noteSliceFrame, refreshStaticTransforms, spanNow, addSpan, drawWorld, staticRoots, endSliceFrames, warmUpScene, createProjectionScanWorkspace, scanProjection, isRenderable, releaseProjectionScanWorkspace, STARTUP_STALL_MS, sceneNeedsEnvironmentPreparation, STARTUP_STABLE_WINDOW_MS, geometryVersionSum, hasRenderHook, uniformUnchanged, isSimilarityTransform, SkinnedBatch, isLight, baseColorOf, observeAnimationRates, displacesVertices, hasMorphAttributes, MIN_BATCH_MEMBERS } from './chunk-FQURMC2F.js';
4
+ export { ASSET_LATE_MARKER, DEFAULT_TARGET_FPS, InstancedBatch, MAX_TARGET_FPS, SPANS, SPANS_FLAG, SPANS_MARKER, SPAN_COUNT, SPAN_NAMES, STATIC_TRANSFORM_MARKER, SpanRecorder, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_MOVER_LAYER, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, addInSlices, addSpan, alwaysRender, beginSpan, createAssetLoader, endSpan, fetchAsset, formatSpansWindow, invalidateStatic, isStatic, loadAll, markStatic, mergeByMaterial, mergeParts, reconcileMirroredClips, refreshStaticTransforms, resetStaticTransforms, resolveTargetFps, setSpanRecorder, snapRefreshRate, spanNow, spanRecorder, spansRequested, staticTransformCensus, unmarkStatic, warmUpScene } from './chunk-FQURMC2F.js';
5
5
  export { CameraShake, GPUParticles3D } from './chunk-H4J6IAJE.js';
6
6
  import { GPUReadback } from './chunk-QWJEMUUT.js';
7
7
  export { GPUReadback } from './chunk-QWJEMUUT.js';
8
8
  export { addFoliageBackLight } from './chunk-GXY7B3JG.js';
9
- import { CORE_VERSION, RENDER_CHAIN_TIERS, publishDirectRenderChainReport, FrameCounters, counterDeviceOf, createCrossingReader, createEngineCounterReader, VelocityTracker, createPipelineCensus, isBatchedMeshVelocityPatched, ensureBatchedMeshVelocity, setBatchedMeshMatrixWithVelocity, setBatchedMeshPreviousMatrix, disposeBatchedMeshVelocity, RenderChain } from './chunk-VBBYWGAT.js';
10
- export { DEFAULT_PIPELINE_CENSUS_LIMIT, FrameCounters, PIPELINE_CENSUS_CAPABILITY, PIPELINE_CENSUS_VERSION, PipelineCensus, RENDER_CHAIN_MARKER, RENDER_CHAIN_STAGE_ORDER, RENDER_CHAIN_TIERS, RenderChain, VELOCITY_OUTPUT_NAME, VELOCITY_PREVIOUS_BONE_MATRICES, VELOCITY_PREVIOUS_INSTANCE_MATRICES, VELOCITY_PREVIOUS_WORLD_MATRIX, VelocityTracker, counterDeviceOf, createPipelineCensus, ensureVelocityOutput, readRenderChainObservation, readRenderChainReport, readVelocityPreviousBoneMatrices, readVelocityPreviousMatrices, readVelocityPreviousWorldMatrix, velocityTexture, withVelocityContext } from './chunk-VBBYWGAT.js';
11
- import { isLodJoinProxy, baseGeometryOf, ClusterView, DEFAULT_VIEW_MARGIN, assertViewMargin, clusterTableRadius, pixelsPerUnit, worldFrustum, outsideFrustum, selectClusterCut, lodChainOf, GeometryCapture, updateClusteredMeshes, updateModelLods, rendererBackendIdentity } from './chunk-QAMSM3Z5.js';
12
- export { ClusteredMesh, DISCRETE_LOD_DEFAULT_ERROR_PIXELS, DISCRETE_LOD_DEFAULT_HYSTERESIS, GEOMETRY_ASSET_KEY, GEOMETRY_CAPTURE_DEFAULT_LIMIT, GEOMETRY_CAPTURE_MAX_LIMIT, GEOMETRY_CAPTURE_SORTS, GEOMETRY_CAPTURE_TIMEOUT_MS, GEOMETRY_CAPTURE_WALK_CAP, baseGeometryOf, isStreamedGeometry, lodChainOf, lodPixelScale, updateClusteredMeshes, updateModelLods } from './chunk-QAMSM3Z5.js';
9
+ import { CORE_VERSION, RENDER_CHAIN_TIERS, publishDirectRenderChainReport, FrameCounters, counterDeviceOf, createCrossingReader, createEngineCounterReader, VelocityTracker, createPipelineCensus, isBatchedMeshVelocityPatched, ensureBatchedMeshVelocity, setBatchedMeshMatrixWithVelocity, setBatchedMeshPreviousMatrix, disposeBatchedMeshVelocity, RenderChain } from './chunk-5C4TCWI3.js';
10
+ export { DEFAULT_PIPELINE_CENSUS_LIMIT, FrameCounters, PIPELINE_CENSUS_CAPABILITY, PIPELINE_CENSUS_VERSION, PipelineCensus, RENDER_CHAIN_MARKER, RENDER_CHAIN_STAGE_ORDER, RENDER_CHAIN_TIERS, RenderChain, VELOCITY_OUTPUT_NAME, VELOCITY_PREVIOUS_BONE_MATRICES, VELOCITY_PREVIOUS_INSTANCE_MATRICES, VELOCITY_PREVIOUS_WORLD_MATRIX, VelocityTracker, counterDeviceOf, createPipelineCensus, ensureVelocityOutput, readRenderChainObservation, readRenderChainReport, readVelocityPreviousBoneMatrices, readVelocityPreviousMatrices, readVelocityPreviousWorldMatrix, velocityTexture, withVelocityContext } from './chunk-5C4TCWI3.js';
11
+ import { isLodJoinProxy, baseGeometryOf, ClusterView, DEFAULT_VIEW_MARGIN, assertViewMargin, clusterTableRadius, pixelsPerUnit, worldFrustum, outsideFrustum, selectClusterCut, lodChainOf, GeometryCapture, updateClusteredMeshes, updateModelLods, rendererBackendIdentity } from './chunk-OMGIYWW7.js';
12
+ export { ClusteredMesh, DISCRETE_LOD_DEFAULT_ERROR_PIXELS, DISCRETE_LOD_DEFAULT_HYSTERESIS, GEOMETRY_ASSET_KEY, GEOMETRY_CAPTURE_DEFAULT_LIMIT, GEOMETRY_CAPTURE_MAX_LIMIT, GEOMETRY_CAPTURE_SORTS, GEOMETRY_CAPTURE_TIMEOUT_MS, GEOMETRY_CAPTURE_WALK_CAP, baseGeometryOf, isStreamedGeometry, lodChainOf, lodPixelScale, updateClusteredMeshes, updateModelLods } from './chunk-OMGIYWW7.js';
13
13
  import { debugRequested, countDebug, formatDebugReport, debugHotCalls, readLaunchFlag, observeDebugGc, measureDebug } from './chunk-VQRPEOKY.js';
14
14
  export { debugFlag, debugValue, exposeDebug } from './chunk-VQRPEOKY.js';
15
15
  export { AudioBus, resetAudioCueLedger } from './chunk-U4YHUKKL.js';
@@ -95,6 +95,35 @@ function countEngineBatch(batches) {
95
95
  const bag = host.__tnEngineCost;
96
96
  bag.animationTickBatches = (bag.animationTickBatches ?? 0) + batches;
97
97
  }
98
+
99
+ // src/engine-hooks.ts
100
+ var COPY_MATRIX_WORLD_HOOK = "__tnCopyMatrixWorld";
101
+ function hookOf(object3) {
102
+ const hook = object3[COPY_MATRIX_WORLD_HOOK];
103
+ return typeof hook === "function" ? hook : void 0;
104
+ }
105
+ function hasCopyMatrixWorldHook(object3) {
106
+ return hookOf(object3) !== void 0;
107
+ }
108
+ function copyMatrixWorld(object3, target) {
109
+ const hook = hookOf(object3);
110
+ if (hook === void 0) return false;
111
+ hook.call(object3, target);
112
+ return true;
113
+ }
114
+ var SPHERE_BOUNDS_HOOK = "__tnSphereBounds";
115
+ var SPHERE_BOUNDS_ATTACH_HOOK = "__tnSphereBoundsAttach";
116
+ function sphereBoundsHook(root) {
117
+ const carrier = root;
118
+ const attach = carrier[SPHERE_BOUNDS_ATTACH_HOOK];
119
+ const bounds = carrier[SPHERE_BOUNDS_HOOK];
120
+ return typeof attach === "function" && typeof bounds === "function" ? {
121
+ attach,
122
+ bounds
123
+ } : void 0;
124
+ }
125
+
126
+ // src/pose-measure.ts
98
127
  function syncSkinBindings(root) {
99
128
  root.traverse((object3) => {
100
129
  const skinned = object3;
@@ -356,11 +385,31 @@ function getEnvelope(root, requestedMeshes) {
356
385
  else cached.push(envelope);
357
386
  return envelope;
358
387
  }
388
+ var engineEnvelope = /* @__PURE__ */ new WeakMap();
359
389
  function posedBounds(root, meshes) {
360
390
  const envelope = getEnvelope(root, meshes);
361
- root.updateWorldMatrix(true, true);
362
- rawBounds(envelope, envelope.raw);
363
391
  const raw = envelope.raw;
392
+ const engine = sphereBoundsHook(root);
393
+ if (engine === void 0) {
394
+ root.updateWorldMatrix(true, true);
395
+ rawBounds(envelope, raw);
396
+ } else {
397
+ if (engineEnvelope.get(root) !== envelope) {
398
+ engine.attach.call(
399
+ root,
400
+ [...envelope.bones.map((s) => s.bone), ...envelope.statics.map((s) => s.object)],
401
+ [...envelope.bones.map((s) => s.radius), ...envelope.statics.map((s) => s.radius)]
402
+ );
403
+ engineEnvelope.set(root, envelope);
404
+ }
405
+ const box = engine.bounds.call(root);
406
+ raw.minX = box[0] ?? Number.POSITIVE_INFINITY;
407
+ raw.minY = box[1] ?? Number.POSITIVE_INFINITY;
408
+ raw.minZ = box[2] ?? Number.POSITIVE_INFINITY;
409
+ raw.maxX = box[3] ?? Number.NEGATIVE_INFINITY;
410
+ raw.maxY = box[4] ?? Number.NEGATIVE_INFINITY;
411
+ raw.maxZ = box[5] ?? Number.NEGATIVE_INFINITY;
412
+ }
364
413
  const min8 = envelope.result.min;
365
414
  const max11 = envelope.result.max;
366
415
  const size = envelope.result.size;
@@ -672,22 +721,6 @@ function deltaFromRest(bone, rest, world, out) {
672
721
  out.copy(rest).invert().premultiply(world);
673
722
  }
674
723
 
675
- // src/engine-hooks.ts
676
- var COPY_MATRIX_WORLD_HOOK = "__tnCopyMatrixWorld";
677
- function hookOf(object3) {
678
- const hook = object3[COPY_MATRIX_WORLD_HOOK];
679
- return typeof hook === "function" ? hook : void 0;
680
- }
681
- function hasCopyMatrixWorldHook(object3) {
682
- return hookOf(object3) !== void 0;
683
- }
684
- function copyMatrixWorld(object3, target) {
685
- const hook = hookOf(object3);
686
- if (hook === void 0) return false;
687
- hook.call(object3, target);
688
- return true;
689
- }
690
-
691
724
  // src/rig-preparation.ts
692
725
  var FNV_OFFSET = 2166136261;
693
726
  var FNV_PRIME = 16777619;
@@ -32020,16 +32053,18 @@ var GroundSnap = class {
32020
32053
  if (!Number.isFinite(dt) || dt < 0)
32021
32054
  throw new Error("GroundSnap dt must be finite and non-negative.");
32022
32055
  validateMaxRate(this.maxRate);
32023
- const before = posedBounds(this.model, this.meshes);
32024
- if (!Number.isFinite(before.min[1])) {
32056
+ const lowest = posedBounds(this.model, this.meshes).min[1];
32057
+ if (!Number.isFinite(lowest)) {
32025
32058
  this.clearance = null;
32026
32059
  return;
32027
32060
  }
32028
- const desired = surfaceY - before.min[1];
32061
+ const desired = surfaceY - lowest;
32029
32062
  const correction = this.maxRate === void 0 || desired > 0 ? desired : Math.max(desired, -this.maxRate * dt);
32030
- if (this.enabled) this.applyWorldCorrection(group, correction);
32031
- const after = posedBounds(this.model, this.meshes);
32032
- this.clearance = after.min[1] - surfaceY;
32063
+ const moved = this.enabled && correction !== 0;
32064
+ if (moved) this.applyWorldCorrection(group, correction);
32065
+ if (!moved) this.clearance = lowest - surfaceY;
32066
+ else if (carries(group, this.model)) this.clearance = lowest + correction - surfaceY;
32067
+ else this.clearance = posedBounds(this.model, this.meshes).min[1] - surfaceY;
32033
32068
  }
32034
32069
  applyWorldCorrection(group, correction) {
32035
32070
  const parent = group.parent;
@@ -32056,6 +32091,11 @@ var GroundSnap = class {
32056
32091
  return estimate.min[1] - precise.min[1];
32057
32092
  }
32058
32093
  };
32094
+ function carries(group, model) {
32095
+ for (let node = model; node !== null; node = node.parent)
32096
+ if (node === group) return true;
32097
+ return false;
32098
+ }
32059
32099
  function validateMaxRate(maxRate) {
32060
32100
  if (maxRate !== void 0 && (!Number.isFinite(maxRate) || maxRate < 0)) {
32061
32101
  throw new Error("GroundSnap maxRate must be finite and non-negative.");
@@ -212,16 +212,6 @@ declare function baseGeometryOf(mesh: Mesh): BufferGeometry;
212
212
  * geometry.
213
213
  */
214
214
  declare function lodChainOf(geometry: BufferGeometry): ILodChain | undefined;
215
- /**
216
- * Takes every discrete-LOD mesh under `root` through this frame's selection.
217
- *
218
- * The engine calls this itself, once a frame, after matrices are synced and before the render.
219
- * Multi-view callers that need the finest level across passes use {@link selectLodLevel} directly;
220
- * this entry point selects for the one camera it is handed — which is the main view, and is at
221
- * least as fine as a shadow pass of lower resolution needs.
222
- *
223
- * @returns triangles the managed meshes will submit this frame.
224
- */
225
215
  declare function updateModelLods(root: {
226
216
  traverse(callback: (object: object) => void): void;
227
217
  }, camera: Camera, viewportHeight: number): number;
package/dist/playtest.js CHANGED
@@ -1,5 +1,5 @@
1
- import { PIPELINE_CENSUS_CAPABILITY, discardEngineCountsSinceLastFrame, readRenderChainObservation, CORE_VERSION } from './chunk-VBBYWGAT.js';
2
- import { GEOMETRY_CAPTURE_CAPABILITY } from './chunk-QAMSM3Z5.js';
1
+ import { PIPELINE_CENSUS_CAPABILITY, discardEngineCountsSinceLastFrame, readRenderChainObservation, CORE_VERSION } from './chunk-5C4TCWI3.js';
2
+ import { GEOMETRY_CAPTURE_CAPABILITY } from './chunk-OMGIYWW7.js';
3
3
  import './chunk-VQRPEOKY.js';
4
4
  import { audioRuntimeSnapshot } from './chunk-U4YHUKKL.js';
5
5
  import './chunk-XDTZ4QMO.js';
package/dist/world.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Group, Vector3, BufferGeometry, Mesh, Object3D, LOD, Camera, Matrix4, Material, Box3, Texture, Data3DTexture } from 'three';
2
- import { I as IComputeDriven, a as IGPUReadbackSample, b as ILodView, c as IModelLodPolicy } from './model-lod-DPTzeCcD.js';
2
+ import { I as IComputeDriven, a as IGPUReadbackSample, b as ILodView, c as IModelLodPolicy } from './model-lod-B921F6kQ.js';
3
3
  import { I as IRendererLike } from './renderer-BtOSseYf.js';
4
4
  import { I as IAssetLoader } from './assets-CfMKnOsK.js';
5
5
  import { Node } from 'three/webgpu';
package/dist/world.js CHANGED
@@ -1,6 +1,6 @@
1
- import { SPANS, createAssetLoader, addInSlices, yieldToHost, batchRecords, drainMeshPool, spanRecorder, spanNow, addSpan, fetchAsset, placedBox, InstancedBatch, INSTANCED_LOD_MAX_PIXEL_ERROR, dropPooledFor, DRAW_ARGS_BYTES, parkMesh, warmUpSceneWithCompletion, loadAll, warmUpScene, markStatic, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, pooledCapacity, pooledMesh, displacesVertices, DEFAULT_TARGET_FPS, STORAGE_PLAIN, argsWords, NO_LOCAL, SLOT_NONE, LOCAL_WORDS, storageAttribute, SOURCE_FLOOR, PLACEMENT_ROWS, DRAW_ARGS_WORDS, growBuffer, addRange, PLACEMENT_WORDS, VEC4_WORDS, composeSilencedByFreeze, worldSilencedByFreeze, isStatic, markEngineStatic, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_KEY_LAYER, VIRTUAL_SHADOW_SMALL_CASTER_LAYER, frustumPlanes, rendererFacts, mergeByMaterial, VALIDATE_EVERY, TALLY_EVERY, nodes } from './chunk-GEMQJBY4.js';
1
+ import { SPANS, createAssetLoader, addInSlices, yieldToHost, batchRecords, drainMeshPool, spanRecorder, spanNow, addSpan, fetchAsset, placedBox, InstancedBatch, INSTANCED_LOD_MAX_PIXEL_ERROR, dropPooledFor, DRAW_ARGS_BYTES, parkMesh, warmUpSceneWithCompletion, loadAll, warmUpScene, markStatic, VIRTUAL_SHADOW_WIDE_CASTER_LAYER, pooledCapacity, pooledMesh, displacesVertices, DEFAULT_TARGET_FPS, STORAGE_PLAIN, argsWords, NO_LOCAL, SLOT_NONE, LOCAL_WORDS, storageAttribute, SOURCE_FLOOR, PLACEMENT_ROWS, DRAW_ARGS_WORDS, growBuffer, addRange, PLACEMENT_WORDS, VEC4_WORDS, composeSilencedByFreeze, worldSilencedByFreeze, isStatic, markEngineStatic, VIRTUAL_SHADOW_CASTER_LAYER, VIRTUAL_SHADOW_KEY_LAYER, VIRTUAL_SHADOW_SMALL_CASTER_LAYER, frustumPlanes, rendererFacts, mergeByMaterial, VALIDATE_EVERY, TALLY_EVERY, nodes } from './chunk-FQURMC2F.js';
2
2
  import { GPUReadback } from './chunk-QWJEMUUT.js';
3
- import { baseGeometryOf, worldSphere, selectLodFor, projectedLodError, selectLodLevel, setLodBias, markEngineRenderHook, biasedLodDistance, isLodJoinProxy, setModelLodLayers, LOD_NEAR_PLANE, GEOMETRY_ASSET_KEY, isEngineRenderHook, lodChainOf, DISCRETE_LOD_DEFAULT_HYSTERESIS } from './chunk-QAMSM3Z5.js';
3
+ import { baseGeometryOf, worldSphere, selectLodFor, projectedLodError, selectLodLevel, setLodBias, markEngineRenderHook, biasedLodDistance, isLodJoinProxy, setModelLodLayers, LOD_NEAR_PLANE, GEOMETRY_ASSET_KEY, isEngineRenderHook, lodChainOf, DISCRETE_LOD_DEFAULT_HYSTERESIS } from './chunk-OMGIYWW7.js';
4
4
  import { readLaunchFlag, readLaunchValues, readLaunchValue } from './chunk-VQRPEOKY.js';
5
5
  import './chunk-XDTZ4QMO.js';
6
6
  import './chunk-VP43GIWW.js';