minerender 2.1.0-alpha.75 → 2.1.0-alpha.77

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 CHANGED
@@ -62,3 +62,60 @@ Filter expressions use JavaScript regular expressions with substring matching.
62
62
  Namespace and path matches can come from different rules, following vanilla's
63
63
  filter behavior. Paths include the asset type and extension, such as
64
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.