minerender 2.1.0-beta.0 → 2.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -2
- package/dist/browser/index.d.mts +1314 -72
- package/dist/browser/index.d.ts +1314 -72
- package/dist/browser/index.js +4568 -1212
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +4487 -1135
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +32044 -19194
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +1314 -72
- package/dist/node/index.d.ts +1314 -72
- package/dist/node/index.js +4583 -1198
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +4486 -1125
- package/dist/node/index.mjs.map +1 -1
- package/package.json +17 -9
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ V2 is in beta. See the [roadmap](https://github.com/InventivetalentDev/MineRende
|
|
|
6
6
|
Install the beta package with its three.js peer:
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
yarn add minerender@beta three@^0.
|
|
9
|
+
yarn add minerender@beta three@^0.186.1
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
In a browser application:
|
|
@@ -23,4 +23,99 @@ The package provides ESM and CommonJS entries for browsers and Node.js, plus
|
|
|
23
23
|
`dist/bundle.js` for the `MineRender` browser global. Node imports require the optional
|
|
24
24
|
native `canvas` dependency; headless rendering is still in development.
|
|
25
25
|
|
|
26
|
-
Requires Node.js 22+ or a browser with Fetch, `AbortSignal.any()`, and `AbortSignal.timeout()`.
|
|
26
|
+
Requires Node.js 22.12+ or a browser with WebGL 2, Fetch, `AbortSignal.any()`, and `AbortSignal.timeout()`.
|
|
27
|
+
|
|
28
|
+
## Resource-pack ZIPs
|
|
29
|
+
|
|
30
|
+
Register a browser `File` or `Blob` before loading models or textures:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { ArchiveAssetSource, AssetLoader, Caching } from "minerender";
|
|
34
|
+
|
|
35
|
+
AssetLoader.setVersion("1.21.11");
|
|
36
|
+
AssetLoader.addSource("pack", ArchiveAssetSource.blob(resourcePackFile));
|
|
37
|
+
Caching.clear();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`ArchiveAssetSource` reads the root `pack.mcmeta` once. Matching overlays take
|
|
41
|
+
precedence in reverse declaration order, followed by the pack's base files.
|
|
42
|
+
Both legacy `formats` ranges and modern `min_format`/`max_format` ranges are
|
|
43
|
+
supported. A pack's `filter.block` rules suppress matching files in lower-priority
|
|
44
|
+
sources, including contributions to combined fonts; the pack's own files remain available.
|
|
45
|
+
|
|
46
|
+
Packs with overlays lazily resolve the selected Minecraft version's resource and
|
|
47
|
+
data pack formats from `https://assets.mcasset.cloud/<version>/game-version.json`.
|
|
48
|
+
[MCAsset-Downloader](https://github.com/InventivetalentDev/MCAsset-Downloader) extracts
|
|
49
|
+
this file unchanged from the official client JAR's root `version.json`.
|
|
50
|
+
For offline use, older JARs without this metadata, or versions not yet re-extracted,
|
|
51
|
+
pass explicit formats:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const pack = ArchiveAssetSource.blob(resourcePackFile, { resourcePackFormat: [75, 0] });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A number selects minor version zero. Use `dataPackFormat` separately for files
|
|
58
|
+
under `data/`. Packs without overlays make no version-metadata request. Missing
|
|
59
|
+
`pack.mcmeta` keeps plain archive loading; invalid metadata rejects the lookup.
|
|
60
|
+
|
|
61
|
+
Filter expressions use JavaScript regular expressions with substring matching.
|
|
62
|
+
Namespace and path matches can come from different rules, following vanilla's
|
|
63
|
+
filter behavior. Paths include the asset type and extension, such as
|
|
64
|
+
`textures/block/stone.png`. Java-only regular expression syntax is not supported.
|
|
65
|
+
|
|
66
|
+
## Load an editable scene
|
|
67
|
+
|
|
68
|
+
The web scene editor saves versioned JSON that the library can load directly:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { AssetLoader, Renderer, SceneDocumentLoader } from "minerender";
|
|
72
|
+
|
|
73
|
+
const response = await fetch("./scene.json");
|
|
74
|
+
if (!response.ok) throw new Error("Could not fetch scene.json");
|
|
75
|
+
const definition = SceneDocumentLoader.parse(await response.json());
|
|
76
|
+
if (definition.minecraftVersion) AssetLoader.setVersion(definition.minecraftVersion);
|
|
77
|
+
|
|
78
|
+
const renderer = new Renderer({
|
|
79
|
+
controls: { enabled: true },
|
|
80
|
+
...(definition.camera ? { camera: {
|
|
81
|
+
position: definition.camera.position,
|
|
82
|
+
lookingAt: definition.camera.target
|
|
83
|
+
} } : {})
|
|
84
|
+
});
|
|
85
|
+
renderer.appendTo(document.body);
|
|
86
|
+
const scene = await SceneDocumentLoader.load(renderer.scene, definition);
|
|
87
|
+
const unsubscribe = renderer.onFrame(({ delta }) => scene.advanceAnimations(delta));
|
|
88
|
+
renderer.start();
|
|
89
|
+
|
|
90
|
+
// Release the scene when its view closes.
|
|
91
|
+
function dispose() {
|
|
92
|
+
unsubscribe();
|
|
93
|
+
scene.dispose();
|
|
94
|
+
renderer.dispose();
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
A minimal document contains a format, schema version, and object definitions:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"format": "minerender-scene",
|
|
103
|
+
"version": 1,
|
|
104
|
+
"minecraftVersion": "1.21.11",
|
|
105
|
+
"objects": [
|
|
106
|
+
{
|
|
107
|
+
"id": "stairs",
|
|
108
|
+
"type": "block",
|
|
109
|
+
"asset": "minecraft:oak_stairs",
|
|
110
|
+
"state": { "facing": "east", "half": "bottom", "shape": "straight" },
|
|
111
|
+
"position": [0, 0, 0],
|
|
112
|
+
"rotation": [0, 0, 0]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Supported object types are `skin`, `block`, `item`, `model`, `entity`, and `gui`.
|
|
119
|
+
Positions use model units (16 per block); JSON rotations use radians.
|
|
120
|
+
|
|
121
|
+
Callers apply the saved camera settings and select the matching asset version.
|