minerender 2.1.0-alpha.19 → 2.1.0-alpha.20
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 +2 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +32 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +33 -5
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +32 -4
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +2 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +32 -4
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +33 -5
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -66934,6 +66934,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66934
66934
|
uniform bool SHADE;
|
|
66935
66935
|
|
|
66936
66936
|
varying vec2 vUv;
|
|
66937
|
+
varying vec3 vTint;
|
|
66937
66938
|
varying float light;
|
|
66938
66939
|
varying float lift;
|
|
66939
66940
|
|
|
@@ -66968,6 +66969,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66968
66969
|
}
|
|
66969
66970
|
|
|
66970
66971
|
vUv = uv;
|
|
66972
|
+
vTint = color;
|
|
66971
66973
|
|
|
66972
66974
|
#ifdef USE_INSTANCING
|
|
66973
66975
|
gl_Position = projectionMatrix * viewMatrix * modelMatrix * instanceMatrix * vec4(position, 1.0);
|
|
@@ -66989,12 +66991,14 @@ return ${compiler2.callType("value", tagType)}
|
|
|
66989
66991
|
uniform float BRIGHTNESS;
|
|
66990
66992
|
|
|
66991
66993
|
varying vec2 vUv;
|
|
66994
|
+
varying vec3 vTint;
|
|
66992
66995
|
varying float light;
|
|
66993
66996
|
varying float lift;
|
|
66994
66997
|
|
|
66995
66998
|
void main(void)
|
|
66996
66999
|
{
|
|
66997
67000
|
vec4 color = texture2D(map, vUv);
|
|
67001
|
+
color.rgb *= vTint;
|
|
66998
67002
|
|
|
66999
67003
|
if (color.a < 0.01) discard;
|
|
67000
67004
|
|
|
@@ -77596,17 +77600,20 @@ return ${compiler2.callType("value", tagType)}
|
|
|
77596
77600
|
init_process2();
|
|
77597
77601
|
var ModelGenerator = class {
|
|
77598
77602
|
static generateItemModel(imageData, layer) {
|
|
77603
|
+
const tintindex = this.ITEM_LAYERS.indexOf(layer);
|
|
77599
77604
|
const mainElement = {
|
|
77600
77605
|
from: [0, 0, 7.5],
|
|
77601
77606
|
to: [16, 16, 8.5],
|
|
77602
77607
|
faces: {
|
|
77603
77608
|
"south": {
|
|
77604
77609
|
uv: [0, 0, 16, 16],
|
|
77605
|
-
texture: `#${layer}
|
|
77610
|
+
texture: `#${layer}`,
|
|
77611
|
+
tintindex
|
|
77606
77612
|
},
|
|
77607
77613
|
"north": {
|
|
77608
77614
|
uv: [16, 0, 0, 16],
|
|
77609
|
-
texture: `#${layer}
|
|
77615
|
+
texture: `#${layer}`,
|
|
77616
|
+
tintindex
|
|
77610
77617
|
}
|
|
77611
77618
|
},
|
|
77612
77619
|
shade: true
|
|
@@ -79920,6 +79927,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
79920
79927
|
this.isModelObject = true;
|
|
79921
79928
|
this.meshesCreated = false;
|
|
79922
79929
|
this.options = (0, import_ts_deepmerge5.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
|
|
79930
|
+
if (this.options.tints) this.options.tints = { ...this.options.tints };
|
|
79923
79931
|
console.log("ModelObject options", this.options);
|
|
79924
79932
|
}
|
|
79925
79933
|
async init() {
|
|
@@ -79949,6 +79957,20 @@ return ${compiler2.callType("value", tagType)}
|
|
|
79949
79957
|
if (this.options.uvLockRotation) {
|
|
79950
79958
|
UVMapper.lockUvs(elGeo, el.faces, this.atlas, new Euler(...this.options.uvLockRotation));
|
|
79951
79959
|
}
|
|
79960
|
+
if (this.options.tints) {
|
|
79961
|
+
const colors = new Float32Array(elGeo.getAttribute("position").count * 3).fill(1);
|
|
79962
|
+
for (const [faceIndex, faceName] of CUBE_FACES.entries()) {
|
|
79963
|
+
const tintIndex = el.faces[faceName]?.tintindex;
|
|
79964
|
+
if (tintIndex === void 0 || tintIndex < 0) continue;
|
|
79965
|
+
const tint = this.options.tints[tintIndex];
|
|
79966
|
+
if (tint === void 0) continue;
|
|
79967
|
+
const color2 = new Color(tint);
|
|
79968
|
+
for (let vertex2 = 0; vertex2 < 4; vertex2++) {
|
|
79969
|
+
color2.toArray(colors, (faceIndex * 4 + vertex2) * 3);
|
|
79970
|
+
}
|
|
79971
|
+
}
|
|
79972
|
+
elGeo.setAttribute("color", new BufferAttribute(colors, 3));
|
|
79973
|
+
}
|
|
79952
79974
|
elGeo.applyMatrix4(new Matrix4().makeTranslation((el.to[0] - el.from[0]) / 2, (el.to[1] - el.from[1]) / 2, (el.to[2] - el.from[2]) / 2));
|
|
79953
79975
|
elGeo.applyMatrix4(new Matrix4().makeTranslation(el.from[0], el.from[1], el.from[2]));
|
|
79954
79976
|
if (el.rotation) {
|
|
@@ -80005,6 +80027,7 @@ return ${compiler2.callType("value", tagType)}
|
|
|
80005
80027
|
/*TODO: get this from render options*/
|
|
80006
80028
|
);
|
|
80007
80029
|
this.iterateAllMeshes((mesh) => {
|
|
80030
|
+
if (mesh.geometry.hasAttribute("color")) mat.vertexColors = true;
|
|
80008
80031
|
mesh.material = mat;
|
|
80009
80032
|
});
|
|
80010
80033
|
if (this.atlas.hasAnimation) {
|
|
@@ -81304,8 +81327,13 @@ return ${compiler2.callType("value", tagType)}
|
|
|
81304
81327
|
const obj = await objectSupplier();
|
|
81305
81328
|
if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
|
|
81306
81329
|
console.log("instanceMeshes + key");
|
|
81307
|
-
|
|
81308
|
-
|
|
81330
|
+
let key = asset.key.serialize();
|
|
81331
|
+
if (isModelObject(obj)) {
|
|
81332
|
+
const { uvLockRotation, tints } = obj.options;
|
|
81333
|
+
if (uvLockRotation) key += `|uvlock:${uvLockRotation.join(",")}`;
|
|
81334
|
+
const palette = Object.entries(tints ?? {}).sort(([a4], [b4]) => Number(a4) - Number(b4));
|
|
81335
|
+
if (palette.length) key += `|tints:${JSON.stringify(palette)}`;
|
|
81336
|
+
}
|
|
81309
81337
|
return this.instanceManager.getOrCreate(key, async () => {
|
|
81310
81338
|
obj.scene = this;
|
|
81311
81339
|
await obj.init();
|