minerender 2.1.0-alpha.67 → 2.1.0-alpha.68
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/dist/browser/index.d.mts +28 -4
- package/dist/browser/index.d.ts +28 -4
- package/dist/browser/index.js +249 -177
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +100 -28
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +86 -11
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +28 -4
- package/dist/node/index.d.ts +28 -4
- package/dist/node/index.js +250 -177
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +100 -28
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -4335,8 +4335,8 @@ var init_EntityObject = __esm({
|
|
|
4335
4335
|
// src/three/BufferGeometryUtils.js
|
|
4336
4336
|
import {
|
|
4337
4337
|
BufferAttribute as BufferAttribute4,
|
|
4338
|
-
BufferGeometry as
|
|
4339
|
-
Float32BufferAttribute as
|
|
4338
|
+
BufferGeometry as BufferGeometry3,
|
|
4339
|
+
Float32BufferAttribute as Float32BufferAttribute5,
|
|
4340
4340
|
InterleavedBuffer,
|
|
4341
4341
|
InterleavedBufferAttribute,
|
|
4342
4342
|
TriangleFanDrawMode,
|
|
@@ -4355,7 +4355,7 @@ function mergeBufferGeometries(geometries, useGroups = false) {
|
|
|
4355
4355
|
const attributes = {};
|
|
4356
4356
|
const morphAttributes = {};
|
|
4357
4357
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
4358
|
-
const mergedGeometry = new
|
|
4358
|
+
const mergedGeometry = new BufferGeometry3();
|
|
4359
4359
|
let offset = 0;
|
|
4360
4360
|
for (let i = 0; i < geometries.length; ++i) {
|
|
4361
4361
|
const geometry = geometries[i];
|
|
@@ -4864,8 +4864,8 @@ function computeMorphedAttributes(object) {
|
|
|
4864
4864
|
}
|
|
4865
4865
|
}
|
|
4866
4866
|
}
|
|
4867
|
-
const morphedPositionAttribute = new
|
|
4868
|
-
const morphedNormalAttribute = new
|
|
4867
|
+
const morphedPositionAttribute = new Float32BufferAttribute5(modifiedPosition, 3);
|
|
4868
|
+
const morphedNormalAttribute = new Float32BufferAttribute5(modifiedNormal, 3);
|
|
4869
4869
|
return {
|
|
4870
4870
|
positionAttribute,
|
|
4871
4871
|
normalAttribute,
|
|
@@ -5359,7 +5359,7 @@ var init_fluidBlocks = __esm({
|
|
|
5359
5359
|
});
|
|
5360
5360
|
|
|
5361
5361
|
// src/model/fluid/FluidGeometry.ts
|
|
5362
|
-
import { BufferGeometry as
|
|
5362
|
+
import { BufferGeometry as BufferGeometry5, Float32BufferAttribute as Float32BufferAttribute6 } from "three";
|
|
5363
5363
|
function getBlockFluidState(key, state) {
|
|
5364
5364
|
const rule = key && fluidRules[key.toNamespacedString()];
|
|
5365
5365
|
if (rule) return {
|
|
@@ -5377,7 +5377,7 @@ function ownHeight(sample) {
|
|
|
5377
5377
|
return (level === 0 || level >= 8 ? 8 : 8 - level) / 9;
|
|
5378
5378
|
}
|
|
5379
5379
|
function createFluidGeometry(kind, sample) {
|
|
5380
|
-
const geometry = new
|
|
5380
|
+
const geometry = new BufferGeometry5();
|
|
5381
5381
|
const positions = [], normals = [], uvs = [], indices = [];
|
|
5382
5382
|
const self = sample(0, 0, 0);
|
|
5383
5383
|
const height = (x, z) => {
|
|
@@ -5476,9 +5476,9 @@ function createFluidGeometry(kind, sample) {
|
|
|
5476
5476
|
1
|
|
5477
5477
|
);
|
|
5478
5478
|
}
|
|
5479
|
-
geometry.setAttribute("position", new
|
|
5480
|
-
geometry.setAttribute("normal", new
|
|
5481
|
-
geometry.setAttribute("uv", new
|
|
5479
|
+
geometry.setAttribute("position", new Float32BufferAttribute6(positions, 3));
|
|
5480
|
+
geometry.setAttribute("normal", new Float32BufferAttribute6(normals, 3));
|
|
5481
|
+
geometry.setAttribute("uv", new Float32BufferAttribute6(uvs, 2));
|
|
5482
5482
|
geometry.setIndex(indices);
|
|
5483
5483
|
return geometry;
|
|
5484
5484
|
}
|
|
@@ -8844,6 +8844,85 @@ var GuiHelper = class {
|
|
|
8844
8844
|
}
|
|
8845
8845
|
};
|
|
8846
8846
|
|
|
8847
|
+
// src/gui/GuiTextureGeometry.ts
|
|
8848
|
+
import { BufferGeometry as BufferGeometry2, Float32BufferAttribute as Float32BufferAttribute4, PlaneGeometry } from "three";
|
|
8849
|
+
function createGuiTextureGeometry(width, height, imageWidth, imageHeight, crop, scaling) {
|
|
8850
|
+
if (crop || !scaling || scaling.type === "stretch") {
|
|
8851
|
+
const [x, y, w, h] = crop ?? [0, 0, imageWidth, imageHeight];
|
|
8852
|
+
const geometry = new PlaneGeometry(width, height);
|
|
8853
|
+
const uv = geometry.getAttribute("uv");
|
|
8854
|
+
for (let i = 0; i < uv.count; i++) {
|
|
8855
|
+
uv.setXY(
|
|
8856
|
+
i,
|
|
8857
|
+
(x + uv.getX(i) * w) / imageWidth,
|
|
8858
|
+
1 - (y + (1 - uv.getY(i)) * h) / imageHeight
|
|
8859
|
+
);
|
|
8860
|
+
}
|
|
8861
|
+
return geometry;
|
|
8862
|
+
}
|
|
8863
|
+
const sw = scaling.width, sh = scaling.height;
|
|
8864
|
+
if (![sw, sh].every((value) => Number.isInteger(value) && value > 0)) {
|
|
8865
|
+
throw new Error("GUI sprite dimensions must be positive integers");
|
|
8866
|
+
}
|
|
8867
|
+
if (![width, height].every((value) => Number.isFinite(value) && value >= 0)) {
|
|
8868
|
+
throw new Error("GUI output dimensions must be finite and nonnegative");
|
|
8869
|
+
}
|
|
8870
|
+
const positions = [], uvs = [], normals = [], indices = [];
|
|
8871
|
+
function quad(x, y, w, h, u, v, uw, vh) {
|
|
8872
|
+
if (w <= 0 || h <= 0) return;
|
|
8873
|
+
const index = positions.length / 3;
|
|
8874
|
+
const left = x - width / 2, top = height / 2 - y;
|
|
8875
|
+
positions.push(left, top, 0, left + w, top, 0, left, top - h, 0, left + w, top - h, 0);
|
|
8876
|
+
uvs.push(
|
|
8877
|
+
u / sw,
|
|
8878
|
+
1 - v / sh,
|
|
8879
|
+
(u + uw) / sw,
|
|
8880
|
+
1 - v / sh,
|
|
8881
|
+
u / sw,
|
|
8882
|
+
1 - (v + vh) / sh,
|
|
8883
|
+
(u + uw) / sw,
|
|
8884
|
+
1 - (v + vh) / sh
|
|
8885
|
+
);
|
|
8886
|
+
normals.push(0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1);
|
|
8887
|
+
indices.push(index, index + 2, index + 1, index + 2, index + 3, index + 1);
|
|
8888
|
+
}
|
|
8889
|
+
function tile(x, y, w, h, u, v, tw, th) {
|
|
8890
|
+
for (let dy = 0; dy < h; dy += th) {
|
|
8891
|
+
for (let dx = 0; dx < w; dx += tw) {
|
|
8892
|
+
const cw = Math.min(tw, w - dx), ch = Math.min(th, h - dy);
|
|
8893
|
+
quad(x + dx, y + dy, cw, ch, u, v, cw, ch);
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8896
|
+
}
|
|
8897
|
+
if (scaling.type === "tile") {
|
|
8898
|
+
tile(0, 0, width, height, 0, 0, sw, sh);
|
|
8899
|
+
} else {
|
|
8900
|
+
let segments = function(size, sourceSize, start, end) {
|
|
8901
|
+
if (size === sourceSize) return [[0, size, 0, sourceSize]];
|
|
8902
|
+
start = Math.min(start, Math.floor(size / 2));
|
|
8903
|
+
end = Math.min(end, Math.floor(size / 2));
|
|
8904
|
+
return [
|
|
8905
|
+
[0, start, 0, start],
|
|
8906
|
+
[start, size - start - end, start, sourceSize - start - end],
|
|
8907
|
+
[size - end, end, sourceSize - end, end]
|
|
8908
|
+
];
|
|
8909
|
+
};
|
|
8910
|
+
const border = typeof scaling.border === "number" ? { left: scaling.border, top: scaling.border, right: scaling.border, bottom: scaling.border } : scaling.border;
|
|
8911
|
+
if (!border || typeof scaling.border === "number" && scaling.border <= 0 || ![border.left, border.top, border.right, border.bottom].every((value) => Number.isInteger(value) && value >= 0) || border.left + border.right >= sw || border.top + border.bottom >= sh) {
|
|
8912
|
+
throw new Error("GUI nine-slice borders must be nonnegative integers with a nonempty center");
|
|
8913
|
+
}
|
|
8914
|
+
const columns = segments(width, sw, border.left, border.right);
|
|
8915
|
+
const rows = segments(height, sh, border.top, border.bottom);
|
|
8916
|
+
for (const [y, h, v, vh] of rows) {
|
|
8917
|
+
for (const [x, w, u, uw] of columns) {
|
|
8918
|
+
if (w <= 0 || h <= 0) continue;
|
|
8919
|
+
(scaling.stretch_inner ? quad : tile)(x, y, w, h, u, v, uw, vh);
|
|
8920
|
+
}
|
|
8921
|
+
}
|
|
8922
|
+
}
|
|
8923
|
+
return new BufferGeometry2().setAttribute("position", new Float32BufferAttribute4(positions, 3)).setAttribute("normal", new Float32BufferAttribute4(normals, 3)).setAttribute("uv", new Float32BufferAttribute4(uvs, 2)).setIndex(indices);
|
|
8924
|
+
}
|
|
8925
|
+
|
|
8847
8926
|
// src/gui/scene/GuiObject.ts
|
|
8848
8927
|
init_AssetKey();
|
|
8849
8928
|
init_ModelTextures();
|
|
@@ -8854,7 +8933,7 @@ init_Materials();
|
|
|
8854
8933
|
init_ModelObject();
|
|
8855
8934
|
init_DisplayPosition();
|
|
8856
8935
|
init_GuiLight();
|
|
8857
|
-
import { Box2, Box3 as Box32, Matrix4 as Matrix410, Mesh as Mesh6,
|
|
8936
|
+
import { Box2, Box3 as Box32, Matrix4 as Matrix410, Mesh as Mesh6, Vector2 as Vector23 } from "three";
|
|
8858
8937
|
var GuiObject = class extends SceneObject {
|
|
8859
8938
|
constructor(textureLayers, options) {
|
|
8860
8939
|
super({ ...options, instanceMeshes: false, mergeMeshes: false });
|
|
@@ -8895,18 +8974,10 @@ var GuiObject = class extends SceneObject {
|
|
|
8895
8974
|
const key = typeof layer.texture === "string" ? AssetKey.parse("textures", layer.texture) : layer.texture;
|
|
8896
8975
|
const material = await this.loadMaterial(key);
|
|
8897
8976
|
const image = material.map.image;
|
|
8898
|
-
const
|
|
8899
|
-
const [width, height] = layer.size ?? [
|
|
8900
|
-
const geometry =
|
|
8977
|
+
const scaling = layer.crop ? void 0 : (await ModelTextures.getMeta(key))?.gui?.scaling;
|
|
8978
|
+
const [width, height] = layer.size ?? (layer.crop ? layer.crop.slice(2) : scaling && scaling.type !== "stretch" ? [scaling.width, scaling.height] : [image.width, image.height]);
|
|
8979
|
+
const geometry = createGuiTextureGeometry(width, height, image.width, image.height, layer.crop, scaling);
|
|
8901
8980
|
this.geometries.add(geometry);
|
|
8902
|
-
const uv = geometry.getAttribute("uv");
|
|
8903
|
-
for (let i = 0; i < uv.count; i++) {
|
|
8904
|
-
uv.setXY(
|
|
8905
|
-
i,
|
|
8906
|
-
(cropX + uv.getX(i) * cropWidth) / image.width,
|
|
8907
|
-
1 - (cropY + (1 - uv.getY(i)) * cropHeight) / image.height
|
|
8908
|
-
);
|
|
8909
|
-
}
|
|
8910
8981
|
const mesh = new Mesh6(geometry, material);
|
|
8911
8982
|
mesh.name = `mesh:${layer.name ?? index}`;
|
|
8912
8983
|
mesh.position.set(x + width / 2, -y - height / 2, depth);
|
|
@@ -14836,7 +14907,7 @@ init_Model();
|
|
|
14836
14907
|
// src/world/SectionMesh.ts
|
|
14837
14908
|
init_CanvasCompat();
|
|
14838
14909
|
init_Materials();
|
|
14839
|
-
import { BufferGeometry as
|
|
14910
|
+
import { BufferGeometry as BufferGeometry7, Float32BufferAttribute as Float32BufferAttribute7, Group, Mesh as Mesh9 } from "three";
|
|
14840
14911
|
var SectionMesh = class _SectionMesh extends Group {
|
|
14841
14912
|
constructor() {
|
|
14842
14913
|
super(...arguments);
|
|
@@ -14910,11 +14981,11 @@ var SectionMesh = class _SectionMesh extends Group {
|
|
|
14910
14981
|
for (let corner = 0; corner < 6; corner++) indices.push(start + sourceIndices.getX(face * 6 + corner) - face * 4);
|
|
14911
14982
|
}
|
|
14912
14983
|
}
|
|
14913
|
-
const geometry = new
|
|
14914
|
-
geometry.setAttribute("position", new
|
|
14915
|
-
geometry.setAttribute("normal", new
|
|
14916
|
-
geometry.setAttribute("uv", new
|
|
14917
|
-
geometry.setAttribute("color", new
|
|
14984
|
+
const geometry = new BufferGeometry7();
|
|
14985
|
+
geometry.setAttribute("position", new Float32BufferAttribute7(positions, 3));
|
|
14986
|
+
geometry.setAttribute("normal", new Float32BufferAttribute7(normals, 3));
|
|
14987
|
+
geometry.setAttribute("uv", new Float32BufferAttribute7(uvs, 2));
|
|
14988
|
+
geometry.setAttribute("color", new Float32BufferAttribute7(colors, 3));
|
|
14918
14989
|
geometry.setIndex(indices);
|
|
14919
14990
|
geometry.computeBoundingBox();
|
|
14920
14991
|
geometry.computeBoundingSphere();
|
|
@@ -15239,6 +15310,7 @@ export {
|
|
|
15239
15310
|
computeTangents,
|
|
15240
15311
|
createCanvas2 as createCanvas,
|
|
15241
15312
|
createFluidGeometry,
|
|
15313
|
+
createGuiTextureGeometry,
|
|
15242
15314
|
createImage,
|
|
15243
15315
|
entityAnimationTime,
|
|
15244
15316
|
estimateBytesUsed,
|