minerender 2.1.0-alpha.53 → 2.1.0-alpha.54

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.
@@ -1,5 +1,5 @@
1
1
  import * as three from 'three';
2
- import { Vector3, PixelFormat, BoxGeometry, Material, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points, Group } from 'three';
2
+ import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points, Group } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
5
  import { Buffer } from 'buffer';
@@ -200,11 +200,98 @@ interface ListAsset extends MinecraftAsset {
200
200
  files: string[];
201
201
  }
202
202
 
203
+ interface EntityLayer {
204
+ key: BasicAssetKey;
205
+ texture?: AssetKey;
206
+ layer: EntityModelLayer;
207
+ /** How this draw is rendered; defaults to the geometry layer's own mode, then `cutout`. */
208
+ render?: EntityRenderMode;
209
+ /** Label of the state colour that multiplies the texture, from the pass that selected this draw. */
210
+ tint?: string;
211
+ }
212
+ interface EntityModel extends EntityLayer {
213
+ id: string;
214
+ /** Root transform from the dataset; see {@link EntityTransformOp}. */
215
+ transform?: EntityTransformOp[];
216
+ /**
217
+ * Selected draws in draw order; the top-level fields describe the first selection.
218
+ * A key is the geometry layer's name; a further draw of the same geometry (a pass with another texture) is keyed `<layer>#<n>`, from 2.
219
+ */
220
+ layers?: Record<string, EntityLayer>;
221
+ }
222
+ interface EntityModelFile extends MinecraftAsset {
223
+ id: string;
224
+ transform?: EntityTransformOp[];
225
+ layers: Record<string, EntityModelLayer>;
226
+ /** Extra draws vanilla adds on top of `main`, in draw order. */
227
+ passes?: EntityModelPass[];
228
+ }
229
+ /** Vanilla render type of a draw; see the dataset README for the mode table. */
230
+ type EntityRenderMode = "cutout" | "cutout_cull" | "cutout_z_offset" | "solid" | "translucent" | "translucent_emissive" | "eyes" | "energy_swirl" | "breeze_wind" | "water_mask";
231
+ interface EntityModelPass {
232
+ /** Geometry layer of the same file; a pass on `main` draws that geometry again. */
233
+ layer: string;
234
+ /** Present only when it differs from the layer's own. */
235
+ textureLocation?: string;
236
+ /** Present only when it differs from the layer's own. */
237
+ render?: EntityRenderMode;
238
+ /** Entity state that enables the draw, e.g. `powered`; without it the pass is always drawn. */
239
+ when?: string;
240
+ /** State colour that multiplies the texture, e.g. `wool_color`. */
241
+ tint?: string;
242
+ }
243
+ /**
244
+ * One operation vanilla's renderer applies before drawing a model, in call order:
245
+ * each one is applied on top of the previous, so the last reaches the vertices first.
246
+ * Translations use model units and rotations use radians, like part poses.
247
+ */
248
+ type EntityTransformOp = {
249
+ scale: [number, number, number];
250
+ } | {
251
+ translate: [number, number, number];
252
+ } | {
253
+ rotate: [number, number, number];
254
+ };
255
+ interface EntityModelLayer {
256
+ texture: [number, number];
257
+ textureLocation?: string;
258
+ /** Omitted for `cutout`. */
259
+ render?: EntityRenderMode;
260
+ root: EntityModelPart;
261
+ }
262
+ interface EntityModelPart {
263
+ pose: {
264
+ offset: [number, number, number];
265
+ rotation: [number, number, number];
266
+ scale?: [number, number, number];
267
+ };
268
+ texture?: [number, number];
269
+ cubes: EntityModelCube[];
270
+ children: Record<string, EntityModelPart>;
271
+ }
272
+ interface EntityModelCube {
273
+ origin: [number, number, number];
274
+ size: [number, number, number];
275
+ uv: [number, number];
276
+ grow?: [number, number, number];
277
+ mirror?: boolean;
278
+ }
279
+
203
280
  declare class Materials {
204
281
  private static readonly MISSING_TEXTURE_SRC;
205
282
  static get MISSING_TEXTURE(): Material;
206
283
  static createImage(key: MaterialKey): Material;
207
284
  static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
285
+ /** Whether vanilla's render type for the mode culls back faces. */
286
+ static entityModeCulls(mode?: EntityRenderMode): boolean;
287
+ /** UV offset per tick of entity age for the scrolling modes, as vanilla's texture matrix applies it. */
288
+ static entityModeScroll(mode?: EntityRenderMode): [number, number] | undefined;
289
+ /**
290
+ * Entity material for one of vanilla's render types. Entities are unlit here, so the lit and full-bright modes
291
+ * differ only in blending and depth state. Culling is not a material property: {@link entityModeCulls} decides
292
+ * whether the geometry gets inward faces.
293
+ */
294
+ static createEntityCanvasMaterial(canvas: HTMLCanvasElement, mode?: EntityRenderMode, tint?: ColorRepresentation): MeshBasicMaterial;
208
295
  static createGuiCanvasMaterial(canvas: HTMLCanvasElement): MeshBasicMaterial;
209
296
  static createShadedCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
210
297
  static getImage(key: MaterialKey): Material;
@@ -735,47 +822,12 @@ declare class DefaultBlockStates implements MinecraftAsset {
735
822
  [k: string]: BlockStatePropertyDefaults;
736
823
  }
737
824
 
738
- interface EntityLayer {
739
- key: BasicAssetKey;
740
- texture?: AssetKey;
741
- layer: EntityModelLayer;
742
- }
743
- interface EntityModel extends EntityLayer {
744
- id: string;
745
- /** Selected layers; the top-level fields describe the first selection. */
746
- layers?: Record<string, EntityLayer>;
747
- }
748
- interface EntityModelFile extends MinecraftAsset {
749
- id: string;
750
- layers: Record<string, EntityModelLayer>;
751
- }
752
- interface EntityModelLayer {
753
- texture: [number, number];
754
- textureLocation?: string;
755
- root: EntityModelPart;
756
- }
757
- interface EntityModelPart {
758
- pose: {
759
- offset: [number, number, number];
760
- rotation: [number, number, number];
761
- scale?: [number, number, number];
762
- };
763
- texture?: [number, number];
764
- cubes: EntityModelCube[];
765
- children: Record<string, EntityModelPart>;
766
- }
767
- interface EntityModelCube {
768
- origin: [number, number, number];
769
- size: [number, number, number];
770
- uv: [number, number];
771
- grow?: [number, number, number];
772
- mirror?: boolean;
773
- }
774
-
775
825
  declare class Entities {
776
826
  static getEntityList(): Promise<string[]>;
777
827
  private static getModelFile;
778
828
  static getLayerList(modelKey: BasicAssetKey): Promise<string[]>;
829
+ /** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
830
+ static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
779
831
  static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
780
832
  static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
781
833
  /** @deprecated Use getEntityList(); block entities share the entity dataset. */
@@ -785,9 +837,14 @@ declare class Entities {
785
837
  }
786
838
  interface EntityModelOptions {
787
839
  layer?: string;
788
- /** Layer names in draw order; defaults to layer or "main". */
840
+ /** Layer names in draw order; an explicit selection draws exactly these layers and no dataset passes. */
789
841
  layers?: string[];
790
- /** Per-layer texture overrides. The positional texture key applies to the first selected layer. */
842
+ /**
843
+ * Entity states that enable the dataset's conditional passes, e.g. `["powered"]` for a charged creeper.
844
+ * Without `layer`/`layers`, `main` and every unconditional pass are always drawn.
845
+ */
846
+ when?: string[];
847
+ /** Per-layer texture overrides, keyed like `EntityModel.layers`. The positional texture key applies to the first selected layer. */
791
848
  textures?: Record<string, BasicAssetKey>;
792
849
  }
793
850
 
@@ -997,9 +1054,18 @@ declare class EntityObject extends SceneObject {
997
1054
  static readonly DEFAULT_OPTIONS: EntityObjectOptions;
998
1055
  readonly options: EntityObjectOptions;
999
1056
  private meshesCreated;
1057
+ /** Scrolling materials are owned: their texture offset follows this entity's age. */
1058
+ private readonly scrollMaterials;
1059
+ private scrollTicker;
1060
+ /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
1061
+ age: number;
1000
1062
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
1001
1063
  init(): Promise<void>;
1002
1064
  dispose(): void;
1065
+ disposeAndRemoveAllChildren(): void;
1066
+ private clearScrollMaterials;
1067
+ /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
1068
+ private updateScroll;
1003
1069
  getLayerGroup(name: string): Maybe<Object3D>;
1004
1070
  getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
1005
1071
  getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
@@ -1011,7 +1077,13 @@ declare class EntityObject extends SceneObject {
1011
1077
  protected applyTextures(): Promise<void>;
1012
1078
  }
1013
1079
  interface EntityObjectOptions extends SceneObjectOptions {
1080
+ /**
1081
+ * `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
1082
+ * By default the model's dataset transform is used, or the flip for models without one.
1083
+ */
1014
1084
  flip?: boolean;
1085
+ /** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */
1086
+ tints?: Record<string, ColorRepresentation>;
1015
1087
  }
1016
1088
  declare function isEntityObject(obj: any): obj is EntityObject;
1017
1089
 
@@ -1558,6 +1630,34 @@ declare class SceneExporter {
1558
1630
 
1559
1631
  declare class GuiHelper {
1560
1632
  static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
1633
+ /** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
1634
+ static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
1635
+ }
1636
+ type GuiRecipeIngredientValue = string | {
1637
+ item: string;
1638
+ } | {
1639
+ tag: string;
1640
+ };
1641
+ type GuiRecipeIngredient = GuiRecipeIngredientValue | readonly GuiRecipeIngredientValue[];
1642
+ type GuiRecipe = ({
1643
+ type: "minecraft:crafting_shaped" | "crafting_shaped";
1644
+ pattern: readonly string[];
1645
+ key: Readonly<Record<string, GuiRecipeIngredient>>;
1646
+ } | {
1647
+ type: "minecraft:crafting_shapeless" | "crafting_shapeless";
1648
+ ingredients: readonly GuiRecipeIngredient[];
1649
+ }) & {
1650
+ result: {
1651
+ id: string;
1652
+ count?: number;
1653
+ } | {
1654
+ item: string;
1655
+ count?: number;
1656
+ };
1657
+ };
1658
+ interface GuiRecipeOptions {
1659
+ /** Selects a concrete item ID or model AssetKey for a tag or alternatives array. */
1660
+ resolveIngredient?: (ingredient: GuiRecipeIngredient) => string | AssetKey;
1561
1661
  }
1562
1662
 
1563
1663
  declare class OrbitControls {
@@ -2086,4 +2186,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
2086
2186
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
2087
2187
  }
2088
2188
 
2089
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, 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, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, 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, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
2189
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, 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, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, 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 FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, 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, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
@@ -1,5 +1,5 @@
1
1
  import * as three from 'three';
2
- import { Vector3, PixelFormat, BoxGeometry, Material, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points, Group } from 'three';
2
+ import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points, Group } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
5
  import { Buffer } from 'buffer';
@@ -200,11 +200,98 @@ interface ListAsset extends MinecraftAsset {
200
200
  files: string[];
201
201
  }
202
202
 
203
+ interface EntityLayer {
204
+ key: BasicAssetKey;
205
+ texture?: AssetKey;
206
+ layer: EntityModelLayer;
207
+ /** How this draw is rendered; defaults to the geometry layer's own mode, then `cutout`. */
208
+ render?: EntityRenderMode;
209
+ /** Label of the state colour that multiplies the texture, from the pass that selected this draw. */
210
+ tint?: string;
211
+ }
212
+ interface EntityModel extends EntityLayer {
213
+ id: string;
214
+ /** Root transform from the dataset; see {@link EntityTransformOp}. */
215
+ transform?: EntityTransformOp[];
216
+ /**
217
+ * Selected draws in draw order; the top-level fields describe the first selection.
218
+ * A key is the geometry layer's name; a further draw of the same geometry (a pass with another texture) is keyed `<layer>#<n>`, from 2.
219
+ */
220
+ layers?: Record<string, EntityLayer>;
221
+ }
222
+ interface EntityModelFile extends MinecraftAsset {
223
+ id: string;
224
+ transform?: EntityTransformOp[];
225
+ layers: Record<string, EntityModelLayer>;
226
+ /** Extra draws vanilla adds on top of `main`, in draw order. */
227
+ passes?: EntityModelPass[];
228
+ }
229
+ /** Vanilla render type of a draw; see the dataset README for the mode table. */
230
+ type EntityRenderMode = "cutout" | "cutout_cull" | "cutout_z_offset" | "solid" | "translucent" | "translucent_emissive" | "eyes" | "energy_swirl" | "breeze_wind" | "water_mask";
231
+ interface EntityModelPass {
232
+ /** Geometry layer of the same file; a pass on `main` draws that geometry again. */
233
+ layer: string;
234
+ /** Present only when it differs from the layer's own. */
235
+ textureLocation?: string;
236
+ /** Present only when it differs from the layer's own. */
237
+ render?: EntityRenderMode;
238
+ /** Entity state that enables the draw, e.g. `powered`; without it the pass is always drawn. */
239
+ when?: string;
240
+ /** State colour that multiplies the texture, e.g. `wool_color`. */
241
+ tint?: string;
242
+ }
243
+ /**
244
+ * One operation vanilla's renderer applies before drawing a model, in call order:
245
+ * each one is applied on top of the previous, so the last reaches the vertices first.
246
+ * Translations use model units and rotations use radians, like part poses.
247
+ */
248
+ type EntityTransformOp = {
249
+ scale: [number, number, number];
250
+ } | {
251
+ translate: [number, number, number];
252
+ } | {
253
+ rotate: [number, number, number];
254
+ };
255
+ interface EntityModelLayer {
256
+ texture: [number, number];
257
+ textureLocation?: string;
258
+ /** Omitted for `cutout`. */
259
+ render?: EntityRenderMode;
260
+ root: EntityModelPart;
261
+ }
262
+ interface EntityModelPart {
263
+ pose: {
264
+ offset: [number, number, number];
265
+ rotation: [number, number, number];
266
+ scale?: [number, number, number];
267
+ };
268
+ texture?: [number, number];
269
+ cubes: EntityModelCube[];
270
+ children: Record<string, EntityModelPart>;
271
+ }
272
+ interface EntityModelCube {
273
+ origin: [number, number, number];
274
+ size: [number, number, number];
275
+ uv: [number, number];
276
+ grow?: [number, number, number];
277
+ mirror?: boolean;
278
+ }
279
+
203
280
  declare class Materials {
204
281
  private static readonly MISSING_TEXTURE_SRC;
205
282
  static get MISSING_TEXTURE(): Material;
206
283
  static createImage(key: MaterialKey): Material;
207
284
  static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
285
+ /** Whether vanilla's render type for the mode culls back faces. */
286
+ static entityModeCulls(mode?: EntityRenderMode): boolean;
287
+ /** UV offset per tick of entity age for the scrolling modes, as vanilla's texture matrix applies it. */
288
+ static entityModeScroll(mode?: EntityRenderMode): [number, number] | undefined;
289
+ /**
290
+ * Entity material for one of vanilla's render types. Entities are unlit here, so the lit and full-bright modes
291
+ * differ only in blending and depth state. Culling is not a material property: {@link entityModeCulls} decides
292
+ * whether the geometry gets inward faces.
293
+ */
294
+ static createEntityCanvasMaterial(canvas: HTMLCanvasElement, mode?: EntityRenderMode, tint?: ColorRepresentation): MeshBasicMaterial;
208
295
  static createGuiCanvasMaterial(canvas: HTMLCanvasElement): MeshBasicMaterial;
209
296
  static createShadedCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
210
297
  static getImage(key: MaterialKey): Material;
@@ -735,47 +822,12 @@ declare class DefaultBlockStates implements MinecraftAsset {
735
822
  [k: string]: BlockStatePropertyDefaults;
736
823
  }
737
824
 
738
- interface EntityLayer {
739
- key: BasicAssetKey;
740
- texture?: AssetKey;
741
- layer: EntityModelLayer;
742
- }
743
- interface EntityModel extends EntityLayer {
744
- id: string;
745
- /** Selected layers; the top-level fields describe the first selection. */
746
- layers?: Record<string, EntityLayer>;
747
- }
748
- interface EntityModelFile extends MinecraftAsset {
749
- id: string;
750
- layers: Record<string, EntityModelLayer>;
751
- }
752
- interface EntityModelLayer {
753
- texture: [number, number];
754
- textureLocation?: string;
755
- root: EntityModelPart;
756
- }
757
- interface EntityModelPart {
758
- pose: {
759
- offset: [number, number, number];
760
- rotation: [number, number, number];
761
- scale?: [number, number, number];
762
- };
763
- texture?: [number, number];
764
- cubes: EntityModelCube[];
765
- children: Record<string, EntityModelPart>;
766
- }
767
- interface EntityModelCube {
768
- origin: [number, number, number];
769
- size: [number, number, number];
770
- uv: [number, number];
771
- grow?: [number, number, number];
772
- mirror?: boolean;
773
- }
774
-
775
825
  declare class Entities {
776
826
  static getEntityList(): Promise<string[]>;
777
827
  private static getModelFile;
778
828
  static getLayerList(modelKey: BasicAssetKey): Promise<string[]>;
829
+ /** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
830
+ static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
779
831
  static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
780
832
  static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
781
833
  /** @deprecated Use getEntityList(); block entities share the entity dataset. */
@@ -785,9 +837,14 @@ declare class Entities {
785
837
  }
786
838
  interface EntityModelOptions {
787
839
  layer?: string;
788
- /** Layer names in draw order; defaults to layer or "main". */
840
+ /** Layer names in draw order; an explicit selection draws exactly these layers and no dataset passes. */
789
841
  layers?: string[];
790
- /** Per-layer texture overrides. The positional texture key applies to the first selected layer. */
842
+ /**
843
+ * Entity states that enable the dataset's conditional passes, e.g. `["powered"]` for a charged creeper.
844
+ * Without `layer`/`layers`, `main` and every unconditional pass are always drawn.
845
+ */
846
+ when?: string[];
847
+ /** Per-layer texture overrides, keyed like `EntityModel.layers`. The positional texture key applies to the first selected layer. */
791
848
  textures?: Record<string, BasicAssetKey>;
792
849
  }
793
850
 
@@ -997,9 +1054,18 @@ declare class EntityObject extends SceneObject {
997
1054
  static readonly DEFAULT_OPTIONS: EntityObjectOptions;
998
1055
  readonly options: EntityObjectOptions;
999
1056
  private meshesCreated;
1057
+ /** Scrolling materials are owned: their texture offset follows this entity's age. */
1058
+ private readonly scrollMaterials;
1059
+ private scrollTicker;
1060
+ /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
1061
+ age: number;
1000
1062
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
1001
1063
  init(): Promise<void>;
1002
1064
  dispose(): void;
1065
+ disposeAndRemoveAllChildren(): void;
1066
+ private clearScrollMaterials;
1067
+ /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
1068
+ private updateScroll;
1003
1069
  getLayerGroup(name: string): Maybe<Object3D>;
1004
1070
  getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
1005
1071
  getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
@@ -1011,7 +1077,13 @@ declare class EntityObject extends SceneObject {
1011
1077
  protected applyTextures(): Promise<void>;
1012
1078
  }
1013
1079
  interface EntityObjectOptions extends SceneObjectOptions {
1080
+ /**
1081
+ * `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
1082
+ * By default the model's dataset transform is used, or the flip for models without one.
1083
+ */
1014
1084
  flip?: boolean;
1085
+ /** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */
1086
+ tints?: Record<string, ColorRepresentation>;
1015
1087
  }
1016
1088
  declare function isEntityObject(obj: any): obj is EntityObject;
1017
1089
 
@@ -1558,6 +1630,34 @@ declare class SceneExporter {
1558
1630
 
1559
1631
  declare class GuiHelper {
1560
1632
  static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
1633
+ /** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
1634
+ static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
1635
+ }
1636
+ type GuiRecipeIngredientValue = string | {
1637
+ item: string;
1638
+ } | {
1639
+ tag: string;
1640
+ };
1641
+ type GuiRecipeIngredient = GuiRecipeIngredientValue | readonly GuiRecipeIngredientValue[];
1642
+ type GuiRecipe = ({
1643
+ type: "minecraft:crafting_shaped" | "crafting_shaped";
1644
+ pattern: readonly string[];
1645
+ key: Readonly<Record<string, GuiRecipeIngredient>>;
1646
+ } | {
1647
+ type: "minecraft:crafting_shapeless" | "crafting_shapeless";
1648
+ ingredients: readonly GuiRecipeIngredient[];
1649
+ }) & {
1650
+ result: {
1651
+ id: string;
1652
+ count?: number;
1653
+ } | {
1654
+ item: string;
1655
+ count?: number;
1656
+ };
1657
+ };
1658
+ interface GuiRecipeOptions {
1659
+ /** Selects a concrete item ID or model AssetKey for a tag or alternatives array. */
1660
+ resolveIngredient?: (ingredient: GuiRecipeIngredient) => string | AssetKey;
1561
1661
  }
1562
1662
 
1563
1663
  declare class OrbitControls {
@@ -2086,4 +2186,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
2086
2186
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
2087
2187
  }
2088
2188
 
2089
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, 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, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, 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, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
2189
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, 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, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, 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 FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, 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, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, registerNodeEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };