minerender 2.1.0-alpha.121 → 2.1.0-alpha.122

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.
@@ -1672,6 +1672,8 @@ declare class BlockObject extends SceneObject {
1672
1672
  private removeEntities;
1673
1673
  /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
1674
1674
  get blockEntities(): readonly EntityObject[];
1675
+ /** Model placements drawn for this block, including its fluid surface. */
1676
+ get models(): readonly (ModelObject | InstanceReference<ModelObject>)[];
1675
1677
  /** Sets visibility for this block's model instances and block entities. */
1676
1678
  setVisible(visible: boolean): void;
1677
1679
  /**
@@ -3805,6 +3807,8 @@ interface SectionGeometryPage {
3805
3807
  uvBounds: Float32Array;
3806
3808
  colors: Float32Array;
3807
3809
  indices: Uint32Array;
3810
+ /** Owning section cell for each quad; each quad contributes two consecutive triangles. */
3811
+ blockIndices: Uint16Array;
3808
3812
  }
3809
3813
  /** Builds section-local geometry from visible quads, with bounded atlas pages per layer. */
3810
3814
  declare function buildSectionGeometry(input: SectionGeometryInput): SectionGeometryPage[];
@@ -3838,6 +3842,9 @@ interface SectionFluids {
3838
3842
  /** Merged terrain geometry and atlas pages for one 16×16×16 section. Owns its generated render resources. */
3839
3843
  declare class SectionMesh extends Group {
3840
3844
  private readonly ownedMeshes;
3845
+ private readonly blockIndices;
3846
+ /** Returns the owning section cell for a triangle hit on this mesh's merged geometry. */
3847
+ getBlockIndex(hit: Intersection): number | undefined;
3841
3848
  /** Builds section-local meshes from visible quads. `maxAtlasSize` limits each atlas dimension in pixels. */
3842
3849
  static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number, fluids?: SectionFluids, lighting?: Pick<SectionGeometryInput, "light" | "ambientLight" | "ambientOcclusion">): SectionMesh;
3843
3850
  /** Builds section-local meshes in a browser worker when available, with synchronous fallback. */
@@ -3869,6 +3876,20 @@ declare class SectionModels {
3869
3876
  clear(): void;
3870
3877
  }
3871
3878
 
3879
+ /** The nearest rendered block triangle hit by a world raycast. */
3880
+ interface WorldBlockIntersection {
3881
+ /** Integer world block coordinates of the geometry's owner. */
3882
+ position: Vector3;
3883
+ /** Detached block data; use world setters to change the block. */
3884
+ block: Block;
3885
+ /** Hit position in scene units. */
3886
+ point: Vector3;
3887
+ /** Unit face normal in scene space. Sloped and rotated faces retain their geometric normal. */
3888
+ normal: Vector3;
3889
+ /** Distance from the ray origin, in scene units. */
3890
+ distance: number;
3891
+ }
3892
+
3872
3893
  /**
3873
3894
  * A 16×16×16 block section and its render objects.
3874
3895
  * Constructor coordinates identify the section. Block accessors use world block coordinates
@@ -3889,6 +3910,7 @@ declare class Chunk<SectionMeshing extends boolean = false> {
3889
3910
  readonly z: number;
3890
3911
  private readonly data;
3891
3912
  private readonly renderedBlocks;
3913
+ private readonly objectBlocks;
3892
3914
  private readonly sectionBlocks;
3893
3915
  private readonly hiddenBlocks;
3894
3916
  private readonly fluidCells;
@@ -3900,6 +3922,8 @@ declare class Chunk<SectionMeshing extends boolean = false> {
3900
3922
  private meshGeneration;
3901
3923
  private ambientOcclusionCells?;
3902
3924
  constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined, neighborCell?: ((x: number, y: number, z: number) => number) | undefined, biomeAt?: ((x: number, y: number, z: number) => Maybe<string>) | undefined, onBiomesChanged?: ((biomes?: readonly string[]) => Promise<void>) | undefined, lightAt?: ((x: number, y: number, z: number) => number) | undefined, onLightCleared?: (() => Promise<void>) | undefined, ambientLight?: number);
3925
+ /** Finds the nearest owned block hit across sections, testing each shared mesh once. */
3926
+ static raycast<SectionMeshing extends boolean>(chunks: Iterable<Chunk<SectionMeshing>>, raycaster: Raycaster): WorldBlockIntersection | undefined;
3903
3927
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
3904
3928
  getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
3905
3929
  getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
@@ -3987,6 +4011,11 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
3987
4011
  private readonly pendingCulling;
3988
4012
  private culling?;
3989
4013
  constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
4014
+ /**
4015
+ * Returns the nearest visible block geometry hit, respecting the raycaster's layers and near/far range.
4016
+ * Includes fluids and block entities; texture alpha does not change triangle intersections.
4017
+ */
4018
+ raycast(raycaster: Raycaster): WorldBlockIntersection | undefined;
3990
4019
  /** Whether neighboring opaque cubes shade block-face corners. Defaults to false. */
3991
4020
  get ambientOcclusion(): boolean;
3992
4021
  /** Rebuilds loaded blocks with or without corner shading. Block data and saved lighting are preserved. */
@@ -4227,4 +4256,4 @@ declare class NodeRenderer extends Renderer {
4227
4256
  dispose(): void;
4228
4257
  }
4229
4258
 
4230
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
4259
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
@@ -1672,6 +1672,8 @@ declare class BlockObject extends SceneObject {
1672
1672
  private removeEntities;
1673
1673
  /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
1674
1674
  get blockEntities(): readonly EntityObject[];
1675
+ /** Model placements drawn for this block, including its fluid surface. */
1676
+ get models(): readonly (ModelObject | InstanceReference<ModelObject>)[];
1675
1677
  /** Sets visibility for this block's model instances and block entities. */
1676
1678
  setVisible(visible: boolean): void;
1677
1679
  /**
@@ -3805,6 +3807,8 @@ interface SectionGeometryPage {
3805
3807
  uvBounds: Float32Array;
3806
3808
  colors: Float32Array;
3807
3809
  indices: Uint32Array;
3810
+ /** Owning section cell for each quad; each quad contributes two consecutive triangles. */
3811
+ blockIndices: Uint16Array;
3808
3812
  }
3809
3813
  /** Builds section-local geometry from visible quads, with bounded atlas pages per layer. */
3810
3814
  declare function buildSectionGeometry(input: SectionGeometryInput): SectionGeometryPage[];
@@ -3838,6 +3842,9 @@ interface SectionFluids {
3838
3842
  /** Merged terrain geometry and atlas pages for one 16×16×16 section. Owns its generated render resources. */
3839
3843
  declare class SectionMesh extends Group {
3840
3844
  private readonly ownedMeshes;
3845
+ private readonly blockIndices;
3846
+ /** Returns the owning section cell for a triangle hit on this mesh's merged geometry. */
3847
+ getBlockIndex(hit: Intersection): number | undefined;
3841
3848
  /** Builds section-local meshes from visible quads. `maxAtlasSize` limits each atlas dimension in pixels. */
3842
3849
  static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number, fluids?: SectionFluids, lighting?: Pick<SectionGeometryInput, "light" | "ambientLight" | "ambientOcclusion">): SectionMesh;
3843
3850
  /** Builds section-local meshes in a browser worker when available, with synchronous fallback. */
@@ -3869,6 +3876,20 @@ declare class SectionModels {
3869
3876
  clear(): void;
3870
3877
  }
3871
3878
 
3879
+ /** The nearest rendered block triangle hit by a world raycast. */
3880
+ interface WorldBlockIntersection {
3881
+ /** Integer world block coordinates of the geometry's owner. */
3882
+ position: Vector3;
3883
+ /** Detached block data; use world setters to change the block. */
3884
+ block: Block;
3885
+ /** Hit position in scene units. */
3886
+ point: Vector3;
3887
+ /** Unit face normal in scene space. Sloped and rotated faces retain their geometric normal. */
3888
+ normal: Vector3;
3889
+ /** Distance from the ray origin, in scene units. */
3890
+ distance: number;
3891
+ }
3892
+
3872
3893
  /**
3873
3894
  * A 16×16×16 block section and its render objects.
3874
3895
  * Constructor coordinates identify the section. Block accessors use world block coordinates
@@ -3889,6 +3910,7 @@ declare class Chunk<SectionMeshing extends boolean = false> {
3889
3910
  readonly z: number;
3890
3911
  private readonly data;
3891
3912
  private readonly renderedBlocks;
3913
+ private readonly objectBlocks;
3892
3914
  private readonly sectionBlocks;
3893
3915
  private readonly hiddenBlocks;
3894
3916
  private readonly fluidCells;
@@ -3900,6 +3922,8 @@ declare class Chunk<SectionMeshing extends boolean = false> {
3900
3922
  private meshGeneration;
3901
3923
  private ambientOcclusionCells?;
3902
3924
  constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined, neighborCell?: ((x: number, y: number, z: number) => number) | undefined, biomeAt?: ((x: number, y: number, z: number) => Maybe<string>) | undefined, onBiomesChanged?: ((biomes?: readonly string[]) => Promise<void>) | undefined, lightAt?: ((x: number, y: number, z: number) => number) | undefined, onLightCleared?: (() => Promise<void>) | undefined, ambientLight?: number);
3925
+ /** Finds the nearest owned block hit across sections, testing each shared mesh once. */
3926
+ static raycast<SectionMeshing extends boolean>(chunks: Iterable<Chunk<SectionMeshing>>, raycaster: Raycaster): WorldBlockIntersection | undefined;
3903
3927
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
3904
3928
  getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
3905
3929
  getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
@@ -3987,6 +4011,11 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
3987
4011
  private readonly pendingCulling;
3988
4012
  private culling?;
3989
4013
  constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
4014
+ /**
4015
+ * Returns the nearest visible block geometry hit, respecting the raycaster's layers and near/far range.
4016
+ * Includes fluids and block entities; texture alpha does not change triangle intersections.
4017
+ */
4018
+ raycast(raycaster: Raycaster): WorldBlockIntersection | undefined;
3990
4019
  /** Whether neighboring opaque cubes shade block-face corners. Defaults to false. */
3991
4020
  get ambientOcclusion(): boolean;
3992
4021
  /** Rebuilds loaded blocks with or without corner shading. Block data and saved lighting are preserved. */
@@ -4227,4 +4256,4 @@ declare class NodeRenderer extends Renderer {
4227
4256
  dispose(): void;
4228
4257
  }
4229
4258
 
4230
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
4259
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
@@ -12633,6 +12633,10 @@ var BlockObject = class _BlockObject extends SceneObject {
12633
12633
  get blockEntities() {
12634
12634
  return this._entities;
12635
12635
  }
12636
+ /** Model placements drawn for this block, including its fluid surface. */
12637
+ get models() {
12638
+ return this._models;
12639
+ }
12636
12640
  /** Sets visibility for this block's model instances and block entities. */
12637
12641
  setVisible(visible) {
12638
12642
  this.visible = visible;
@@ -17771,6 +17775,13 @@ var MineRenderWorld = class {
17771
17775
  if (options.sectionMeshing) this.sectionModels = new SectionModels(options.maxAtlasSize);
17772
17776
  if (options.renderEntities) this.entities = new WorldEntities(scene);
17773
17777
  }
17778
+ /**
17779
+ * Returns the nearest visible block geometry hit, respecting the raycaster's layers and near/far range.
17780
+ * Includes fluids and block entities; texture alpha does not change triangle intersections.
17781
+ */
17782
+ raycast(raycaster) {
17783
+ return Chunk.raycast(this._chunks.values(), raycaster);
17784
+ }
17774
17785
  /** Whether neighboring opaque cubes shade block-face corners. Defaults to false. */
17775
17786
  get ambientOcclusion() {
17776
17787
  return this._ambientOcclusion;
@@ -18445,6 +18456,7 @@ function buildSectionGeometry(input) {
18445
18456
  const positions = new Float32Array(faces * 12), normals = new Float32Array(faces * 12);
18446
18457
  const uvs = new Float32Array(faces * 8), uvBounds = new Float32Array(faces * 16), colors = new Float32Array(faces * 12);
18447
18458
  const outputIndices = new Uint32Array(faces * 6);
18459
+ const blockIndices = new Uint16Array(faces);
18448
18460
  let vertex = 0, indexOffset = 0;
18449
18461
  for (const entry of page.entries) {
18450
18462
  const template = templateData[templates[entry]];
@@ -18459,6 +18471,7 @@ function buildSectionGeometry(input) {
18459
18471
  const ambientMask = ambientOcclusion && template.ambientOcclusion !== false ? sectionAmbientOcclusionMask(ambientOcclusion, lightIndex) : 0;
18460
18472
  for (let quad = 0; quad < template.quads; quad++) {
18461
18473
  if (cullMasks[entry] & template.cullFaces[quad]) continue;
18474
+ blockIndices[indexOffset / 6] = indices[entry];
18462
18475
  if (ambientMask) quadAmbientOcclusion(template.positions, template.normals, quad, ambientMask, cornerBrightness2);
18463
18476
  const brightness = light ? lightBrightness(light[lightIndex + LIGHT_SAMPLE_OFFSETS[quadLightIndex(template.positions, template.normals, quad)]], ambientLight) : 1;
18464
18477
  const start = vertex;
@@ -18491,6 +18504,7 @@ function buildSectionGeometry(input) {
18491
18504
  const mapV = (v) => 1 - (placement.y + (1 - v) * atlas.height) / page.height;
18492
18505
  const lightIndex = (y + 1) * 324 + (z + 1) * 18 + x + 1;
18493
18506
  for (let quad = 0; quad < quads.sprites.length; quad++) {
18507
+ blockIndices[indexOffset / 6] = x + z * 16 + y * 256;
18494
18508
  const rect = quads.sprites[quad] === 0 ? data.still : data.flow;
18495
18509
  const brightness = light ? lightBrightness(fluidLightLevel(
18496
18510
  light[lightIndex],
@@ -18521,11 +18535,11 @@ function buildSectionGeometry(input) {
18521
18535
  indexOffset += 6;
18522
18536
  }
18523
18537
  }
18524
- return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, indices: outputIndices };
18538
+ return { layer: page.layer, width: page.width, height: page.height, placements: page.placements, positions, normals, uvs, uvBounds, colors, indices: outputIndices, blockIndices };
18525
18539
  });
18526
18540
  }
18527
18541
  function sectionGeometryTransferables(pages) {
18528
- return pages.flatMap((page) => [page.positions.buffer, page.normals.buffer, page.uvs.buffer, page.uvBounds.buffer, page.colors.buffer, page.indices.buffer]);
18542
+ return pages.flatMap((page) => [page.positions.buffer, page.normals.buffer, page.uvs.buffer, page.uvBounds.buffer, page.colors.buffer, page.indices.buffer, page.blockIndices.buffer]);
18529
18543
  }
18530
18544
 
18531
18545
  // src/world/SectionWorker.ts
@@ -18684,6 +18698,12 @@ var SectionMesh = class _SectionMesh extends import_three43.Group {
18684
18698
  constructor() {
18685
18699
  super(...arguments);
18686
18700
  this.ownedMeshes = [];
18701
+ this.blockIndices = /* @__PURE__ */ new Map();
18702
+ }
18703
+ /** Returns the owning section cell for a triangle hit on this mesh's merged geometry. */
18704
+ getBlockIndex(hit) {
18705
+ if (hit.faceIndex === void 0 || hit.faceIndex === null) return void 0;
18706
+ return this.blockIndices.get(hit.object)?.[Math.floor(hit.faceIndex / 2)];
18687
18707
  }
18688
18708
  /** Builds section-local meshes from visible quads. `maxAtlasSize` limits each atlas dimension in pixels. */
18689
18709
  static build(entries, maxAtlasSize = 2048, fluids, lighting) {
@@ -18726,6 +18746,7 @@ var SectionMesh = class _SectionMesh extends import_three43.Group {
18726
18746
  const texture = material.uniforms?.map?.value ?? material.map;
18727
18747
  const mesh = new import_three43.Mesh(geometry, material);
18728
18748
  section.add(mesh);
18749
+ section.blockIndices.set(mesh, page.blockIndices);
18729
18750
  const unsubscribe = [];
18730
18751
  for (const { atlas: id, x, y } of page.placements) {
18731
18752
  const atlas = atlases[id];
@@ -18751,6 +18772,7 @@ var SectionMesh = class _SectionMesh extends import_three43.Group {
18751
18772
  mesh.material.dispose();
18752
18773
  texture?.dispose();
18753
18774
  }
18775
+ this.blockIndices.clear();
18754
18776
  this.removeFromParent();
18755
18777
  super.dispose();
18756
18778
  }
@@ -18760,6 +18782,8 @@ var SectionMesh = class _SectionMesh extends import_three43.Group {
18760
18782
  init_FluidGeometry();
18761
18783
  init_FluidQuads();
18762
18784
  init_CubeFace();
18785
+ init_InstanceReference();
18786
+ init_three();
18763
18787
  var WATER_TINT2 = new import_three44.Color(4159204).toArray();
18764
18788
  var Chunk = class _Chunk {
18765
18789
  constructor(scene, x, y, z, onBlocksChanged, sectionModels, neighborCell, biomeAt, onBiomesChanged, lightAt, onLightCleared, ambientLight = 0) {
@@ -18773,6 +18797,7 @@ var Chunk = class _Chunk {
18773
18797
  this.ambientLight = ambientLight;
18774
18798
  this.data = new ChunkData();
18775
18799
  this.renderedBlocks = /* @__PURE__ */ new Map();
18800
+ this.objectBlocks = /* @__PURE__ */ new Set();
18776
18801
  this.sectionBlocks = /* @__PURE__ */ new Map();
18777
18802
  this.hiddenBlocks = /* @__PURE__ */ new Set();
18778
18803
  this.fluidCells = new Uint8Array(4096);
@@ -18784,6 +18809,89 @@ var Chunk = class _Chunk {
18784
18809
  this.y = y;
18785
18810
  this.z = z;
18786
18811
  }
18812
+ /** Finds the nearest owned block hit across sections, testing each shared mesh once. */
18813
+ static raycast(chunks, raycaster) {
18814
+ const roots = /* @__PURE__ */ new Map();
18815
+ const targets = /* @__PURE__ */ new Map();
18816
+ const meshes = (root, scene) => {
18817
+ const cached2 = roots.get(root);
18818
+ if (cached2) return cached2;
18819
+ const result = [];
18820
+ roots.set(root, result);
18821
+ let attached = false;
18822
+ for (let parent = root; parent; parent = parent.parent) {
18823
+ if (!parent.visible) return result;
18824
+ if (parent === scene) attached = true;
18825
+ }
18826
+ if (!attached) return result;
18827
+ root.updateWorldMatrix(true, true);
18828
+ root.traverseVisible((object4) => {
18829
+ if (isMesh(object4) && raycaster.layers.test(object4.layers)) result.push(object4);
18830
+ });
18831
+ return result;
18832
+ };
18833
+ const add = (root, owner, reference) => {
18834
+ for (const mesh of meshes(root, owner.chunk.scene)) {
18835
+ if (reference && reference.instanceable.getInstanceReference(mesh, reference.index) !== reference) continue;
18836
+ let entry = targets.get(mesh);
18837
+ if (!entry) targets.set(mesh, entry = { owners: /* @__PURE__ */ new Map() });
18838
+ entry.owners.set(reference?.index, owner);
18839
+ }
18840
+ };
18841
+ for (const chunk of chunks) {
18842
+ for (const index of chunk.objectBlocks) {
18843
+ const block = chunk.renderedBlocks.get(index).object;
18844
+ if (!block || !block.visible || chunk.hiddenBlocks.has(index)) continue;
18845
+ const owner = { chunk, index };
18846
+ for (const model of block.models) {
18847
+ if (isInstanceReference(model)) {
18848
+ if (model.instanceable.isInstanceActive(model.index, model)) add(model.instanceable, owner, model);
18849
+ } else {
18850
+ add(model, owner);
18851
+ }
18852
+ }
18853
+ for (const entity of block.blockEntities) add(entity, owner);
18854
+ }
18855
+ if (chunk.sectionMesh) {
18856
+ for (const mesh of meshes(chunk.sectionMesh, chunk.scene)) {
18857
+ targets.set(mesh, { owners: /* @__PURE__ */ new Map(), section: { chunk, mesh: chunk.sectionMesh } });
18858
+ }
18859
+ }
18860
+ }
18861
+ for (const hit of raycaster.intersectObjects([...targets.keys()], false)) {
18862
+ if (!hit.face) continue;
18863
+ const mesh = hit.object;
18864
+ const material = Array.isArray(mesh.material) ? mesh.material[hit.face.materialIndex] : mesh.material;
18865
+ if (!material?.visible) continue;
18866
+ const entry = targets.get(mesh);
18867
+ let owner = entry.owners.get(hit.instanceId) ?? entry.owners.get(void 0);
18868
+ if (entry.section) {
18869
+ const index = entry.section.mesh.getBlockIndex(hit);
18870
+ if (index !== void 0) owner = { chunk: entry.section.chunk, index };
18871
+ }
18872
+ if (!owner || owner.chunk.hiddenBlocks.has(owner.index)) continue;
18873
+ const info = owner.chunk.renderedBlocks.get(owner.index);
18874
+ if (!info) continue;
18875
+ const matrix = mesh.matrixWorld.clone();
18876
+ if (isInstancedMesh(mesh) && hit.instanceId !== void 0) {
18877
+ const instance = new import_three44.Matrix4();
18878
+ mesh.getMatrixAt(hit.instanceId, instance);
18879
+ matrix.multiply(instance);
18880
+ }
18881
+ return {
18882
+ position: new import_three44.Vector3(
18883
+ owner.chunk.x * 16 + owner.index % 16,
18884
+ owner.chunk.y * 16 + Math.floor(owner.index / 256),
18885
+ owner.chunk.z * 16 + Math.floor(owner.index / 16) % 16
18886
+ ),
18887
+ block: info.block,
18888
+ point: hit.point.clone(),
18889
+ normal: hit.face.normal.clone().applyNormalMatrix(new import_three44.Matrix3().getNormalMatrix(matrix)),
18890
+ distance: hit.distance
18891
+ };
18892
+ }
18893
+ return void 0;
18894
+ }
18787
18895
  getBlockAt(posOrX, y, z) {
18788
18896
  if (typeof posOrX == "number") {
18789
18897
  return this.getBlockAt(new import_three44.Vector3(posOrX, y, z));
@@ -18904,6 +19012,7 @@ var Chunk = class _Chunk {
18904
19012
  if (this.fluidCells[index]) this.meshDirty = true;
18905
19013
  this.fluidCells[index] = 0;
18906
19014
  this.renderedBlocks.delete(index);
19015
+ this.objectBlocks.delete(index);
18907
19016
  const worldPos = new import_three44.Vector3(
18908
19017
  this.x * 16 + index % 16,
18909
19018
  this.y * 16 + Math.floor(index / 256),
@@ -18946,6 +19055,7 @@ var Chunk = class _Chunk {
18946
19055
  this.renderedBlocks.set(index, { get block() {
18947
19056
  return readBlock();
18948
19057
  }, object: object4 });
19058
+ if (object4) this.objectBlocks.add(index);
18949
19059
  } catch (error) {
18950
19060
  this.data.assign(index, 0);
18951
19061
  this.fluidCells[index] = 0;
@@ -18964,6 +19074,7 @@ var Chunk = class _Chunk {
18964
19074
  this.fluidCells.fill(0);
18965
19075
  this.waterTints = void 0;
18966
19076
  this.renderedBlocks.clear();
19077
+ this.objectBlocks.clear();
18967
19078
  this.hiddenBlocks.clear();
18968
19079
  this.meshDirty = true;
18969
19080
  this.data.copyFrom(data);
@@ -19013,6 +19124,7 @@ var Chunk = class _Chunk {
19013
19124
  this.renderedBlocks.set(index, { get block() {
19014
19125
  return readBlock();
19015
19126
  }, object: void 0 });
19127
+ this.objectBlocks.delete(index);
19016
19128
  } catch (error) {
19017
19129
  this.data.assign(index, 0);
19018
19130
  this.fluidCells[index] = 0;
@@ -19038,10 +19150,12 @@ var Chunk = class _Chunk {
19038
19150
  this.z * 256 + Math.floor(index / 16) % 16 * 16
19039
19151
  ));
19040
19152
  this.renderedBlocks.get(index).object = object4;
19153
+ this.objectBlocks.add(index);
19041
19154
  } catch (error) {
19042
19155
  this.data.assign(index, 0);
19043
19156
  this.fluidCells[index] = 0;
19044
19157
  this.renderedBlocks.delete(index);
19158
+ this.objectBlocks.delete(index);
19045
19159
  object4?.removeFromScene();
19046
19160
  if (!failed) failure = error;
19047
19161
  failed = true;
@@ -19302,6 +19416,7 @@ var Chunk = class _Chunk {
19302
19416
  this.sectionMesh = void 0;
19303
19417
  this.meshDirty = false;
19304
19418
  this.renderedBlocks.clear();
19419
+ this.objectBlocks.clear();
19305
19420
  this.hiddenBlocks.clear();
19306
19421
  this.fluidCells.fill(0);
19307
19422
  this.waterTints = void 0;