minerender 2.1.0-alpha.69 → 2.1.0-alpha.70
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 +3 -2
- package/dist/browser/index.d.ts +3 -2
- package/dist/browser/index.js +51 -14
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +54 -17
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +51 -14
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +3 -2
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.js +49 -13
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +52 -16
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three 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';
|
|
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, DataTexture, 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';
|
|
@@ -278,7 +278,6 @@ interface EntityModelCube {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
declare class Materials {
|
|
281
|
-
private static readonly MISSING_TEXTURE_SRC;
|
|
282
281
|
static get MISSING_TEXTURE(): Material;
|
|
283
282
|
static createImage(key: MaterialKey): Material;
|
|
284
283
|
static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
|
|
@@ -2316,6 +2315,8 @@ declare class TextureLoader {
|
|
|
2316
2315
|
}
|
|
2317
2316
|
|
|
2318
2317
|
declare class Textures {
|
|
2318
|
+
/** Creates the shared checkerboard from pixels without fetching or decoding an image. */
|
|
2319
|
+
static getMissing(): DataTexture;
|
|
2319
2320
|
static initTextureProps<T extends Texture>(texture: T): T;
|
|
2320
2321
|
static createImage(key: TextureKey): Texture;
|
|
2321
2322
|
static createAsset(key: AssetKey): Texture;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three 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';
|
|
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, DataTexture, 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';
|
|
@@ -278,7 +278,6 @@ interface EntityModelCube {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
declare class Materials {
|
|
281
|
-
private static readonly MISSING_TEXTURE_SRC;
|
|
282
281
|
static get MISSING_TEXTURE(): Material;
|
|
283
282
|
static createImage(key: MaterialKey): Material;
|
|
284
283
|
static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
|
|
@@ -2316,6 +2315,8 @@ declare class TextureLoader {
|
|
|
2316
2315
|
}
|
|
2317
2316
|
|
|
2318
2317
|
declare class Textures {
|
|
2318
|
+
/** Creates the shared checkerboard from pixels without fetching or decoding an image. */
|
|
2319
|
+
static getMissing(): DataTexture;
|
|
2319
2320
|
static initTextureProps<T extends Texture>(texture: T): T;
|
|
2320
2321
|
static createImage(key: TextureKey): Texture;
|
|
2321
2322
|
static createAsset(key: AssetKey): Texture;
|
package/dist/node/index.js
CHANGED
|
@@ -738,6 +738,25 @@ var init_ImageLoader = __esm({
|
|
|
738
738
|
};
|
|
739
739
|
}
|
|
740
740
|
static async loadInfo(src) {
|
|
741
|
+
if (/^data:/i.test(src.trimStart())) {
|
|
742
|
+
const url = new URL(src);
|
|
743
|
+
url.hash = "";
|
|
744
|
+
const comma = url.href.indexOf(",");
|
|
745
|
+
if (comma < 0) {
|
|
746
|
+
throw new Error("Invalid image data URL");
|
|
747
|
+
}
|
|
748
|
+
let bytes = url.href.slice(comma + 1).replace(
|
|
749
|
+
/%([\da-f]{2})/gi,
|
|
750
|
+
(_, hex) => String.fromCharCode(parseInt(hex, 16))
|
|
751
|
+
);
|
|
752
|
+
if (/; *base64 *$/i.test(url.href.slice(5, comma))) {
|
|
753
|
+
bytes = atob(bytes);
|
|
754
|
+
}
|
|
755
|
+
return this.processResponse({
|
|
756
|
+
url: src,
|
|
757
|
+
data: Uint8Array.from(bytes, (char) => char.charCodeAt(0)).buffer
|
|
758
|
+
});
|
|
759
|
+
}
|
|
741
760
|
return Requests.genericRequest({
|
|
742
761
|
url: src,
|
|
743
762
|
responseType: "arraybuffer"
|
|
@@ -824,6 +843,26 @@ var init_Textures = __esm({
|
|
|
824
843
|
init_CacheKey();
|
|
825
844
|
THREE2 = __toESM(require("three"));
|
|
826
845
|
Textures = class _Textures {
|
|
846
|
+
/** Creates the shared checkerboard from pixels without fetching or decoding an image. */
|
|
847
|
+
static getMissing() {
|
|
848
|
+
return Caching.textureCache.get("builtin:missing-texture", () => {
|
|
849
|
+
const size = 64;
|
|
850
|
+
const data = new Uint8Array(size * size * 4);
|
|
851
|
+
for (let y = 0; y < size; y++) {
|
|
852
|
+
for (let x = 0; x < size; x++) {
|
|
853
|
+
const offset = (y * size + x) * 4;
|
|
854
|
+
const color = (x + y) % 2 === 0 ? 255 : 0;
|
|
855
|
+
data[offset] = data[offset + 2] = color;
|
|
856
|
+
data[offset + 3] = 255;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const texture = new import_three4.DataTexture(data, size, size);
|
|
860
|
+
texture.colorSpace = THREE2.SRGBColorSpace;
|
|
861
|
+
texture.flipY = true;
|
|
862
|
+
texture.needsUpdate = true;
|
|
863
|
+
return this.initTextureProps(texture);
|
|
864
|
+
});
|
|
865
|
+
}
|
|
827
866
|
static initTextureProps(texture) {
|
|
828
867
|
texture.magFilter = THREE2.NearestFilter;
|
|
829
868
|
texture.minFilter = THREE2.NearestFilter;
|
|
@@ -865,13 +904,11 @@ var init_Materials = __esm({
|
|
|
865
904
|
init_TextureLoader();
|
|
866
905
|
init_Caching();
|
|
867
906
|
Materials = class _Materials {
|
|
868
|
-
static {
|
|
869
|
-
this.MISSING_TEXTURE_SRC = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC";
|
|
870
|
-
}
|
|
871
|
-
// resolved lazily: as a static field this decoded an image the moment the library was
|
|
872
|
-
// imported, which needs both a DOM and an EnvProvider to already be in place
|
|
873
907
|
static get MISSING_TEXTURE() {
|
|
874
|
-
return
|
|
908
|
+
return Caching.materialCache.get("builtin:missing-texture", () => new import_three5.MeshBasicMaterial({
|
|
909
|
+
map: Textures.getMissing(),
|
|
910
|
+
alphaTest: 0.5
|
|
911
|
+
}));
|
|
875
912
|
}
|
|
876
913
|
static createImage(key) {
|
|
877
914
|
const transparent = key.transparent || false;
|
|
@@ -2705,7 +2742,7 @@ var init_UVMapper = __esm({
|
|
|
2705
2742
|
init_CanvasImage();
|
|
2706
2743
|
init_TextureAtlas();
|
|
2707
2744
|
init_Caching();
|
|
2708
|
-
|
|
2745
|
+
init_Textures();
|
|
2709
2746
|
init_AssetKey();
|
|
2710
2747
|
init_ModelGenerator();
|
|
2711
2748
|
init_log();
|
|
@@ -2992,11 +3029,12 @@ var init_UVMapper = __esm({
|
|
|
2992
3029
|
const size = Math.ceil(s * maxWidth);
|
|
2993
3030
|
console.debug(p5, "Atlas size:", size);
|
|
2994
3031
|
const squaredSize = size * size;
|
|
2995
|
-
const missing = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC");
|
|
2996
|
-
const empty = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA5JREFUKM9jGAWjgAIAAAJAAAFSSwuTAAAAAElFTkSuQmCC");
|
|
2997
3032
|
const image = new CanvasImage(size, size);
|
|
2998
|
-
|
|
2999
|
-
image.
|
|
3033
|
+
const missing = Textures.getMissing().image;
|
|
3034
|
+
const missingPixels = image.context.createImageData(missing.width, missing.height);
|
|
3035
|
+
missingPixels.data.set(missing.data);
|
|
3036
|
+
image.putData(missingPixels, 0, 0);
|
|
3037
|
+
image.context.clearRect(0, 0, maxWidth, maxWidth);
|
|
3000
3038
|
const positions = {};
|
|
3001
3039
|
let hasTransparency = false;
|
|
3002
3040
|
let hasAnimation = false;
|
|
@@ -3062,8 +3100,6 @@ var init_UVMapper = __esm({
|
|
|
3062
3100
|
ty++;
|
|
3063
3101
|
}
|
|
3064
3102
|
}
|
|
3065
|
-
const atlasImageData = image.toDataURL();
|
|
3066
|
-
console.log(p5, "Atlas Image for", model.key, atlasImageData);
|
|
3067
3103
|
this.fillMissingTextureKeys(model.textures, positions);
|
|
3068
3104
|
if (isItemModel) {
|
|
3069
3105
|
console.debug(p5, "Generating item model for", model);
|