minerender 2.1.0-alpha.1 → 2.1.0-alpha.11
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 +2 -0
- package/dist/browser/index.d.mts +194 -136
- package/dist/browser/index.d.ts +194 -136
- package/dist/browser/index.js +1488 -1275
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1704 -1491
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +3559 -4936
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +193 -135
- package/dist/node/index.d.ts +193 -135
- package/dist/node/index.js +1882 -1598
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1295 -1013
- package/dist/node/index.mjs.map +1 -1
- package/package.json +7 -9
package/dist/browser/index.js
CHANGED
|
@@ -28,14 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
32
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
33
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
34
|
-
if (decorator = decorators[i])
|
|
35
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
36
|
-
if (kind && result) __defProp(target, key, result);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
31
|
|
|
40
32
|
// ../../node_modules/ts-deepmerge/dist/index.js
|
|
41
33
|
var require_dist = __commonJS({
|
|
@@ -45,8 +37,8 @@ var require_dist = __commonJS({
|
|
|
45
37
|
__assign = Object.assign || function(t) {
|
|
46
38
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
47
39
|
s = arguments[i];
|
|
48
|
-
for (var
|
|
49
|
-
t[
|
|
40
|
+
for (var p12 in s) if (Object.prototype.hasOwnProperty.call(s, p12))
|
|
41
|
+
t[p12] = s[p12];
|
|
50
42
|
}
|
|
51
43
|
return t;
|
|
52
44
|
};
|
|
@@ -90,7 +82,7 @@ var require_dist = __commonJS({
|
|
|
90
82
|
return false;
|
|
91
83
|
};
|
|
92
84
|
var PROTECTED_KEYS = ["__proto__"];
|
|
93
|
-
var
|
|
85
|
+
var merge10 = function() {
|
|
94
86
|
var objects = [];
|
|
95
87
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
96
88
|
objects[_i] = arguments[_i];
|
|
@@ -101,9 +93,9 @@ var require_dist = __commonJS({
|
|
|
101
93
|
return;
|
|
102
94
|
}
|
|
103
95
|
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
104
|
-
result[key] =
|
|
96
|
+
result[key] = merge10.options.mergeArrays ? Array.from(new Set(result[key].concat(current[key]))) : current[key];
|
|
105
97
|
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
106
|
-
result[key] =
|
|
98
|
+
result[key] = merge10(result[key], current[key]);
|
|
107
99
|
} else {
|
|
108
100
|
result[key] = current[key];
|
|
109
101
|
}
|
|
@@ -114,18 +106,18 @@ var require_dist = __commonJS({
|
|
|
114
106
|
var defaultOptions = {
|
|
115
107
|
mergeArrays: true
|
|
116
108
|
};
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
merge10.options = defaultOptions;
|
|
110
|
+
merge10.withOptions = function(options) {
|
|
119
111
|
var objects = [];
|
|
120
112
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
121
113
|
objects[_i - 1] = arguments[_i];
|
|
122
114
|
}
|
|
123
|
-
|
|
124
|
-
var result =
|
|
125
|
-
|
|
115
|
+
merge10.options = __assign({ mergeArrays: true }, options);
|
|
116
|
+
var result = merge10.apply(void 0, __spreadArray([], __read(objects), false));
|
|
117
|
+
merge10.options = defaultOptions;
|
|
126
118
|
return result;
|
|
127
119
|
};
|
|
128
|
-
exports.default =
|
|
120
|
+
exports.default = merge10;
|
|
129
121
|
}
|
|
130
122
|
});
|
|
131
123
|
|
|
@@ -135,6 +127,7 @@ __export(index_browser_exports, {
|
|
|
135
127
|
AXES: () => AXES,
|
|
136
128
|
ArchiveAssetSource: () => ArchiveAssetSource,
|
|
137
129
|
AssetKey: () => AssetKey,
|
|
130
|
+
AssetLoadError: () => AssetLoadError,
|
|
138
131
|
AssetLoader: () => AssetLoader,
|
|
139
132
|
AssetParser: () => AssetParser,
|
|
140
133
|
AssetSource: () => AssetSource,
|
|
@@ -192,6 +185,7 @@ __export(index_browser_exports, {
|
|
|
192
185
|
OrbitControls: () => OrbitControls,
|
|
193
186
|
PersistentCache: () => PersistentCache,
|
|
194
187
|
Renderer: () => Renderer,
|
|
188
|
+
RequestError: () => RequestError,
|
|
195
189
|
Requests: () => Requests,
|
|
196
190
|
SKIN_PARTS: () => SKIN_PARTS,
|
|
197
191
|
SceneInspector: () => SceneInspector,
|
|
@@ -308,17 +302,20 @@ var _PersistentCache = class _PersistentCache {
|
|
|
308
302
|
static open(name) {
|
|
309
303
|
return Env.provider.openCache(name, _PersistentCache.VERSION);
|
|
310
304
|
}
|
|
305
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
311
306
|
async getOrLoad(key, loader) {
|
|
312
307
|
let v = await this.get(key);
|
|
313
308
|
if (typeof v === "undefined" || v === null) {
|
|
314
309
|
v = await loader(key);
|
|
315
|
-
|
|
310
|
+
if (typeof v !== "undefined" && v !== null) {
|
|
311
|
+
await this.put(key, v);
|
|
312
|
+
}
|
|
316
313
|
}
|
|
317
314
|
return v;
|
|
318
315
|
}
|
|
319
316
|
};
|
|
320
317
|
/** Bump to invalidate every persisted entry. */
|
|
321
|
-
_PersistentCache.VERSION =
|
|
318
|
+
_PersistentCache.VERSION = 2;
|
|
322
319
|
var PersistentCache = _PersistentCache;
|
|
323
320
|
|
|
324
321
|
// src/env/browser/BrowserCache.ts
|
|
@@ -419,7 +416,8 @@ var BrowserEnv = class {
|
|
|
419
416
|
}
|
|
420
417
|
openCache(name, version) {
|
|
421
418
|
return new BrowserCache(import_localforage.default.createInstance({
|
|
422
|
-
|
|
419
|
+
// IndexedDB schema upgrades retain records; each cache generation needs its own database.
|
|
420
|
+
name: name + version,
|
|
423
421
|
version
|
|
424
422
|
}));
|
|
425
423
|
}
|
|
@@ -547,7 +545,10 @@ function serializeMeshKey(key) {
|
|
|
547
545
|
// src/cache/Caching.ts
|
|
548
546
|
var import_loading_cache = require("@inventivetalent/loading-cache");
|
|
549
547
|
var import_time = require("@inventivetalent/time");
|
|
550
|
-
var
|
|
548
|
+
var _Caching = class _Caching {
|
|
549
|
+
static createAssetCache() {
|
|
550
|
+
return import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
551
|
+
}
|
|
551
552
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
552
553
|
static get all() {
|
|
553
554
|
return [
|
|
@@ -564,7 +565,10 @@ var Caching = class {
|
|
|
564
565
|
this.rawModelCache,
|
|
565
566
|
this.mergedModelCache,
|
|
566
567
|
this.modelTextureAtlasCache,
|
|
567
|
-
this.blockStateCache
|
|
568
|
+
this.blockStateCache,
|
|
569
|
+
this.listAssetCache,
|
|
570
|
+
this.defaultBlockStatesCache,
|
|
571
|
+
this.entityModelsCache
|
|
568
572
|
];
|
|
569
573
|
}
|
|
570
574
|
static clear() {
|
|
@@ -575,8 +579,8 @@ var Caching = class {
|
|
|
575
579
|
/**
|
|
576
580
|
* Clears every cache and stops its expiry timer.
|
|
577
581
|
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
582
|
+
* Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
|
|
583
|
+
* Use {@link shutdown} to also stop requests and the shared Ticker.
|
|
580
584
|
*/
|
|
581
585
|
static end() {
|
|
582
586
|
for (const cache of this.all) {
|
|
@@ -590,20 +594,24 @@ var Caching = class {
|
|
|
590
594
|
};
|
|
591
595
|
}
|
|
592
596
|
};
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
597
|
+
_Caching.rawImageCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(5)).buildAsync();
|
|
598
|
+
_Caching.imageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
599
|
+
_Caching.canvasImageDataCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
600
|
+
_Caching.wrappedImageCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(10)).buildAsync();
|
|
601
|
+
_Caching.boxGeometryCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(20)).build();
|
|
602
|
+
_Caching.textureCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).build();
|
|
603
|
+
_Caching.materialCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).build();
|
|
604
|
+
_Caching.boxMeshCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).build();
|
|
605
|
+
_Caching.textureAssetCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
606
|
+
_Caching.textureMetaCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
607
|
+
_Caching.rawModelCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
608
|
+
_Caching.mergedModelCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
609
|
+
_Caching.modelTextureAtlasCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
610
|
+
_Caching.blockStateCache = import_loading_cache.Caches.builder().expireAfterWrite(import_time.Time.minutes(10)).expireAfterAccess(import_time.Time.minutes(5)).expirationInterval(import_time.Time.seconds(30)).buildAsync();
|
|
611
|
+
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
612
|
+
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
613
|
+
_Caching.entityModelsCache = _Caching.createAssetCache();
|
|
614
|
+
var Caching = _Caching;
|
|
607
615
|
|
|
608
616
|
// src/Geometries.ts
|
|
609
617
|
var Geometries = class _Geometries {
|
|
@@ -624,13 +632,14 @@ var Geometries = class _Geometries {
|
|
|
624
632
|
};
|
|
625
633
|
|
|
626
634
|
// src/Materials.ts
|
|
627
|
-
var
|
|
635
|
+
var import_three5 = require("three");
|
|
628
636
|
|
|
629
637
|
// src/texture/Textures.ts
|
|
630
|
-
var
|
|
638
|
+
var import_three4 = require("three");
|
|
631
639
|
|
|
632
640
|
// src/texture/TextureLoader.ts
|
|
633
|
-
var
|
|
641
|
+
var import_three3 = require("three");
|
|
642
|
+
var THREE = __toESM(require("three"));
|
|
634
643
|
|
|
635
644
|
// src/canvas/CanvasCompat.ts
|
|
636
645
|
function createImage(width, height) {
|
|
@@ -641,9 +650,7 @@ function createCanvas(width, height) {
|
|
|
641
650
|
}
|
|
642
651
|
|
|
643
652
|
// src/request/Requests.ts
|
|
644
|
-
var import_axios = __toESM(require("axios"));
|
|
645
653
|
var import_jobqu = require("jobqu");
|
|
646
|
-
var import_time2 = require("@inventivetalent/time");
|
|
647
654
|
|
|
648
655
|
// src/util/log.ts
|
|
649
656
|
var Reset = "\x1B[0m";
|
|
@@ -653,198 +660,170 @@ function prefix(prefix2) {
|
|
|
653
660
|
return `${FgGreen}MR${BgBlack}${prefix2 ?? ""}${Reset}`;
|
|
654
661
|
}
|
|
655
662
|
|
|
656
|
-
// src/
|
|
657
|
-
var
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
this.
|
|
662
|
-
this.
|
|
663
|
-
|
|
664
|
-
submit(task) {
|
|
665
|
-
this.queue.push(task);
|
|
666
|
-
}
|
|
667
|
-
run() {
|
|
668
|
-
for (let i = 0; i < this.batch; i++) {
|
|
669
|
-
this.runNext();
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
runNext() {
|
|
673
|
-
let next = this.queue.shift();
|
|
674
|
-
if (next) next();
|
|
663
|
+
// src/request/Requests.ts
|
|
664
|
+
var p = prefix("Requests");
|
|
665
|
+
var RequestError = class extends Error {
|
|
666
|
+
constructor(message, response, cause) {
|
|
667
|
+
super(message);
|
|
668
|
+
this.response = response;
|
|
669
|
+
this.cause = cause;
|
|
670
|
+
this.name = "RequestError";
|
|
675
671
|
}
|
|
676
672
|
};
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
|
|
673
|
+
async function fetchRequest(config, defaultBaseURL) {
|
|
674
|
+
const { url, baseURL = defaultBaseURL, timeout = 5e3, responseType = "json", signal, ...options } = config;
|
|
675
|
+
const target = baseURL && !/^([a-z][a-z\d+.-]*:|\/\/)/i.test(url) ? `${baseURL.replace(/\/+$/, "")}/${url.replace(/^\/+/, "")}` : url;
|
|
676
|
+
const headers = new Headers(options.headers);
|
|
677
|
+
if (typeof window === "undefined" && !headers.has("User-Agent")) {
|
|
678
|
+
headers.set("User-Agent", "MineRender");
|
|
679
|
+
}
|
|
680
|
+
const attemptSignal = AbortSignal.any([
|
|
681
|
+
...signal ? [signal] : [],
|
|
682
|
+
...timeout === 0 ? [] : [AbortSignal.timeout(timeout)]
|
|
683
|
+
]);
|
|
684
|
+
const request = new Request(target, { ...options, headers, signal: attemptSignal });
|
|
685
|
+
attemptSignal.throwIfAborted();
|
|
686
|
+
try {
|
|
687
|
+
const response = await fetch(request);
|
|
688
|
+
const result = {
|
|
689
|
+
data: void 0,
|
|
690
|
+
status: response.status,
|
|
691
|
+
statusText: response.statusText,
|
|
692
|
+
headers: response.headers,
|
|
693
|
+
url: response.url
|
|
694
|
+
};
|
|
695
|
+
if (!response.ok) {
|
|
696
|
+
await response.body?.cancel().catch(() => {
|
|
697
|
+
});
|
|
698
|
+
throw new RequestError(`Request failed with status ${response.status}`, result);
|
|
699
|
+
}
|
|
700
|
+
const emptyBody = request.method === "HEAD" || response.status === 204 || response.status === 205;
|
|
701
|
+
const data = responseType === "arraybuffer" ? await response.arrayBuffer() : emptyBody || response.body === null ? void 0 : await response.json();
|
|
702
|
+
return { ...result, data };
|
|
703
|
+
} catch (error) {
|
|
704
|
+
attemptSignal.throwIfAborted();
|
|
705
|
+
if (/^https?:/.test(request.url) && request.redirect !== "error" && error instanceof TypeError) {
|
|
706
|
+
throw new RequestError("Network request failed", void 0, error);
|
|
701
707
|
}
|
|
708
|
+
throw error;
|
|
702
709
|
}
|
|
703
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
704
|
-
}
|
|
705
|
-
function applyModelPartRotation(modelPart, geometry) {
|
|
706
|
-
const origin = new import_three3.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
707
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
708
|
-
geometry.rotateX(toRadians(modelPart.pitch));
|
|
709
|
-
geometry.rotateY(toRadians(modelPart.yaw));
|
|
710
|
-
geometry.rotateZ(toRadians(modelPart.roll));
|
|
711
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
712
710
|
}
|
|
713
|
-
function
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
711
|
+
async function abortable(promise, signal) {
|
|
712
|
+
if (!signal) return promise;
|
|
713
|
+
let abort;
|
|
714
|
+
const cancelled = new Promise((_, reject) => {
|
|
715
|
+
abort = () => reject(signal.reason);
|
|
716
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
717
|
+
if (signal.aborted) abort();
|
|
718
|
+
});
|
|
719
|
+
try {
|
|
720
|
+
return await Promise.race([promise, cancelled]);
|
|
721
|
+
} finally {
|
|
722
|
+
signal.removeEventListener("abort", abort);
|
|
724
723
|
}
|
|
725
724
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
let axes = new import_three3.AxesHelper(1);
|
|
735
|
-
obj.add(axes);
|
|
736
|
-
}
|
|
737
|
-
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
738
|
-
let boxGeo = new import_three3.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
739
|
-
let wireGeo = new import_three3.EdgesGeometry(boxGeo);
|
|
740
|
-
let wireMat = new import_three3.LineBasicMaterial({ color, linewidth: w });
|
|
741
|
-
let wireframe = new import_three3.LineSegments(wireGeo, wireMat);
|
|
742
|
-
obj.add(wireframe);
|
|
743
|
-
let axes = new import_three3.AxesHelper(1);
|
|
744
|
-
obj.add(axes);
|
|
745
|
-
}
|
|
746
|
-
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
747
|
-
let wireGeo = new import_three3.EdgesGeometry(geo);
|
|
748
|
-
let wireMat = new import_three3.LineBasicMaterial({ color, linewidth: w });
|
|
749
|
-
let wireframe = new import_three3.LineSegments(wireGeo, wireMat);
|
|
750
|
-
mesh.add(wireframe);
|
|
751
|
-
let axes = new import_three3.AxesHelper(1);
|
|
752
|
-
mesh.add(axes);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// src/util/performance.ts
|
|
756
|
-
function captureException(e, ...extra) {
|
|
757
|
-
console.error(e, extra);
|
|
758
|
-
}
|
|
759
|
-
function timingStart(marker) {
|
|
760
|
-
console.time(marker);
|
|
761
|
-
}
|
|
762
|
-
function timingEnd(marker) {
|
|
763
|
-
console.timeEnd(marker);
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
// src/util/three.ts
|
|
767
|
-
function isObject3D(obj) {
|
|
768
|
-
return obj.isObject3D;
|
|
769
|
-
}
|
|
770
|
-
function isMesh(obj) {
|
|
771
|
-
return obj.isMesh;
|
|
772
|
-
}
|
|
773
|
-
function isInstancedMesh(obj) {
|
|
774
|
-
return obj.isInstancedMesh;
|
|
775
|
-
}
|
|
776
|
-
function isPerspectiveCamera(obj) {
|
|
777
|
-
return obj.isPerspectiveCamera;
|
|
778
|
-
}
|
|
779
|
-
function isOrthographicCamera(obj) {
|
|
780
|
-
return obj.isOrthographicCamera;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
// src/request/Requests.ts
|
|
784
|
-
var p = prefix("Requests");
|
|
785
|
-
if (typeof window === "undefined") {
|
|
786
|
-
import_axios.default.defaults.headers["User-Agent"] = "MineRender";
|
|
787
|
-
}
|
|
788
|
-
var _Requests = class _Requests {
|
|
789
|
-
static genericRequest(request) {
|
|
790
|
-
return this.genericQueue.add(request).catch(async (e) => {
|
|
791
|
-
console.debug(p, "generic catch", e.code, e);
|
|
792
|
-
if (this.shouldRetry(e, request)) {
|
|
793
|
-
await sleep(100);
|
|
794
|
-
return this.genericRequest(request);
|
|
795
|
-
}
|
|
796
|
-
throw e;
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
static mcAssetRequest(request) {
|
|
800
|
-
return this.mcAssetRequestQueue.add(request).catch((e) => {
|
|
801
|
-
console.debug(p, "mcAssetRequest catch", e.code, e);
|
|
802
|
-
throw e;
|
|
803
|
-
});
|
|
725
|
+
var RequestQueue = class {
|
|
726
|
+
constructor() {
|
|
727
|
+
this.pendingRequests = 0;
|
|
728
|
+
this.stopped = new AbortController();
|
|
729
|
+
this.queue = new import_jobqu.JobQueue(
|
|
730
|
+
(request) => fetchRequest(request, this.baseURL),
|
|
731
|
+
{ interval: 10, maxPerRun: 1, maxActive: 8 }
|
|
732
|
+
);
|
|
804
733
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
734
|
+
async request(request) {
|
|
735
|
+
this.pendingRequests++;
|
|
736
|
+
const signal = request.signal;
|
|
737
|
+
try {
|
|
738
|
+
for (let retries = 0; ; retries++) {
|
|
739
|
+
signal?.throwIfAborted();
|
|
740
|
+
try {
|
|
741
|
+
return await abortable(this.queue.add(request), signal);
|
|
742
|
+
} catch (error) {
|
|
743
|
+
console.debug(p, "Request failed", error);
|
|
744
|
+
const delay = this.retryDelay(error, request, retries);
|
|
745
|
+
if (delay === void 0) {
|
|
746
|
+
throw error;
|
|
812
747
|
}
|
|
813
|
-
|
|
814
|
-
request["minerenderRetry"] = 3;
|
|
815
|
-
return true;
|
|
748
|
+
await this.waitForRetry(delay, signal);
|
|
816
749
|
}
|
|
817
750
|
}
|
|
751
|
+
} finally {
|
|
752
|
+
if (signal?.aborted) {
|
|
753
|
+
this.queue.remove(request);
|
|
754
|
+
}
|
|
755
|
+
this.pendingRequests--;
|
|
818
756
|
}
|
|
819
|
-
|
|
757
|
+
}
|
|
758
|
+
retryDelay(error, request, retries) {
|
|
759
|
+
if (this.stopped.signal.aborted || retries >= 3 || (request.method ?? "get").toLowerCase() !== "get" || request.signal?.aborted) {
|
|
760
|
+
return void 0;
|
|
761
|
+
}
|
|
762
|
+
if (error instanceof RequestError) {
|
|
763
|
+
const status = error.response?.status;
|
|
764
|
+
if (status !== void 0 && status !== 408 && status !== 429 && !(status >= 500 && status < 600)) return void 0;
|
|
765
|
+
} else if (!(error instanceof DOMException && error.name === "TimeoutError")) {
|
|
766
|
+
return void 0;
|
|
767
|
+
}
|
|
768
|
+
let delay = 100 * 2 ** retries;
|
|
769
|
+
const retryAfter = error instanceof RequestError ? error.response?.headers.get("Retry-After") : void 0;
|
|
770
|
+
if (retryAfter !== void 0 && retryAfter !== null) {
|
|
771
|
+
const seconds = Number(retryAfter);
|
|
772
|
+
if (!retryAfter.trim() || !Number.isFinite(seconds) || seconds < 0) {
|
|
773
|
+
return void 0;
|
|
774
|
+
}
|
|
775
|
+
delay = Math.max(delay, seconds * 1e3);
|
|
776
|
+
}
|
|
777
|
+
return delay;
|
|
778
|
+
}
|
|
779
|
+
async waitForRetry(delay, signal) {
|
|
780
|
+
let timer;
|
|
781
|
+
const waiting = new Promise((resolve) => {
|
|
782
|
+
timer = setTimeout(resolve, delay);
|
|
783
|
+
});
|
|
784
|
+
try {
|
|
785
|
+
await abortable(waiting, AbortSignal.any([this.stopped.signal, ...signal ? [signal] : []]));
|
|
786
|
+
} finally {
|
|
787
|
+
clearTimeout(timer);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
get pendingSize() {
|
|
791
|
+
return this.pendingRequests;
|
|
792
|
+
}
|
|
793
|
+
end() {
|
|
794
|
+
this.queue.end();
|
|
795
|
+
this.stopped.abort(new import_jobqu.JobCancelledError("ended"));
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
var Requests = class {
|
|
799
|
+
static genericRequest(request) {
|
|
800
|
+
return this.genericQueue.request(request);
|
|
801
|
+
}
|
|
802
|
+
static mcAssetRequest(request) {
|
|
803
|
+
return this.mcAssetRequestQueue.request(request);
|
|
820
804
|
}
|
|
821
805
|
static setMcAssetRoot(root) {
|
|
822
|
-
this.
|
|
806
|
+
this.mcAssetRequestQueue.baseURL = root;
|
|
823
807
|
}
|
|
808
|
+
/** Counts unsettled calls, including retry delays and requests still running after shutdown. */
|
|
824
809
|
static get queueSizes() {
|
|
825
810
|
return {
|
|
826
|
-
generic: this.genericQueue.
|
|
827
|
-
mcAsset: this.mcAssetRequestQueue.
|
|
811
|
+
generic: this.genericQueue.pendingSize,
|
|
812
|
+
mcAsset: this.mcAssetRequestQueue.pendingSize
|
|
828
813
|
};
|
|
829
814
|
}
|
|
830
815
|
/**
|
|
831
|
-
*
|
|
832
|
-
*
|
|
816
|
+
* Permanently stops both queues and rejects waiting, retrying, and future requests.
|
|
817
|
+
* Requests already running can finish. Idle queues hold no timer, so Node can exit without
|
|
818
|
+
* this cleanup. See {@link shutdown}.
|
|
833
819
|
*/
|
|
834
820
|
static end() {
|
|
835
821
|
this.genericQueue.end();
|
|
836
822
|
this.mcAssetRequestQueue.end();
|
|
837
823
|
}
|
|
838
824
|
};
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
});
|
|
842
|
-
_Requests.mcAssetInstance = import_axios.default.create({
|
|
843
|
-
timeout: 5e3
|
|
844
|
-
});
|
|
845
|
-
_Requests.genericQueue = new import_jobqu.JobQueue((request) => _Requests.axiosInstance.request(request), import_time2.Time.millis(10), 1);
|
|
846
|
-
_Requests.mcAssetRequestQueue = new import_jobqu.JobQueue((request) => _Requests.mcAssetInstance.request(request), import_time2.Time.millis(10), 1);
|
|
847
|
-
var Requests = _Requests;
|
|
825
|
+
Requests.genericQueue = new RequestQueue();
|
|
826
|
+
Requests.mcAssetRequestQueue = new RequestQueue();
|
|
848
827
|
|
|
849
828
|
// src/WrappedImage.ts
|
|
850
829
|
var WrappedImage = class {
|
|
@@ -909,29 +888,41 @@ var ImageLoader = class _ImageLoader {
|
|
|
909
888
|
static async loadAsync(src) {
|
|
910
889
|
return new Promise((resolve, reject) => {
|
|
911
890
|
const image = this._createImage();
|
|
912
|
-
image.src = src;
|
|
913
891
|
image.onload = () => resolve(image);
|
|
914
|
-
image.onerror = (err) => reject(err);
|
|
892
|
+
image.onerror = (err) => reject(err instanceof Error ? err : new Error("Failed to decode image"));
|
|
893
|
+
image.src = src;
|
|
915
894
|
});
|
|
916
895
|
}
|
|
917
896
|
static loadElement(src, onload, onerr) {
|
|
918
897
|
const image = this._createImage();
|
|
919
|
-
image.src = src;
|
|
920
898
|
if (onload)
|
|
921
899
|
image.onload = onload;
|
|
922
900
|
if (onerr)
|
|
923
901
|
image.onerror = onerr;
|
|
902
|
+
image.src = src;
|
|
924
903
|
return image;
|
|
925
904
|
}
|
|
926
905
|
static async loadData(src) {
|
|
927
906
|
console.debug(p2, "loadData", src);
|
|
928
|
-
|
|
907
|
+
const image = await this.loadCanvasData(src);
|
|
908
|
+
return image.data.getImageData(0, 0, image.width, image.height);
|
|
929
909
|
}
|
|
930
910
|
static async loadCanvasData(src) {
|
|
931
|
-
|
|
911
|
+
const keyStr = serializeImageKey({ src });
|
|
912
|
+
const info = this.getInfo(src);
|
|
913
|
+
const cached = Caching.rawImageCache.getIfPresent(keyStr);
|
|
914
|
+
try {
|
|
915
|
+
return await this.infoToCanvasData(await info);
|
|
916
|
+
} catch (err) {
|
|
917
|
+
if (cached && Caching.rawImageCache.getIfPresent(keyStr) === cached) {
|
|
918
|
+
Caching.rawImageCache.invalidate(keyStr);
|
|
919
|
+
}
|
|
920
|
+
throw err;
|
|
921
|
+
}
|
|
932
922
|
}
|
|
933
923
|
static async infoToCanvasData(info) {
|
|
934
|
-
const
|
|
924
|
+
const type = info.type === "jpg" ? "jpeg" : info.type ?? "png";
|
|
925
|
+
const image = await _ImageLoader.loadAsync(`data:image/${type};base64,${info.data.toString("base64")}`);
|
|
935
926
|
const canvas = createCanvas(info.width, info.height);
|
|
936
927
|
const context = canvas.getContext("2d");
|
|
937
928
|
context.drawImage(image, 0, 0);
|
|
@@ -942,11 +933,8 @@ var ImageLoader = class _ImageLoader {
|
|
|
942
933
|
};
|
|
943
934
|
}
|
|
944
935
|
static async infoToData(info) {
|
|
945
|
-
const image = await
|
|
946
|
-
|
|
947
|
-
const context = canvas.getContext("2d");
|
|
948
|
-
context.drawImage(image, 0, 0);
|
|
949
|
-
return context.getImageData(0, 0, canvas.width, canvas.height);
|
|
936
|
+
const image = await this.infoToCanvasData(info);
|
|
937
|
+
return image.data.getImageData(0, 0, image.width, image.height);
|
|
950
938
|
}
|
|
951
939
|
static async getData(src) {
|
|
952
940
|
const keyStr = serializeImageKey({ src });
|
|
@@ -961,38 +949,25 @@ var ImageLoader = class _ImageLoader {
|
|
|
961
949
|
});
|
|
962
950
|
}
|
|
963
951
|
static async processResponse(response) {
|
|
964
|
-
const src = response.
|
|
952
|
+
const src = response.url;
|
|
965
953
|
const data = import_buffer.Buffer.from(response.data);
|
|
966
954
|
const { width, height, type } = Env.provider.imageSize(data);
|
|
955
|
+
if (!width || !height) {
|
|
956
|
+
throw new Error("Invalid or unsupported image dimensions");
|
|
957
|
+
}
|
|
967
958
|
return {
|
|
968
959
|
src,
|
|
969
|
-
width
|
|
970
|
-
height
|
|
960
|
+
width,
|
|
961
|
+
height,
|
|
971
962
|
type,
|
|
972
963
|
data
|
|
973
964
|
};
|
|
974
965
|
}
|
|
975
966
|
static async loadInfo(src) {
|
|
976
|
-
if (src.startsWith("data:image/png;base64")) {
|
|
977
|
-
return this.processResponse({
|
|
978
|
-
config: {
|
|
979
|
-
url: src
|
|
980
|
-
},
|
|
981
|
-
data: import_buffer.Buffer.from(src.substr("data:image/png;base64,".length), "base64")
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
967
|
return Requests.genericRequest({
|
|
985
968
|
url: src,
|
|
986
969
|
responseType: "arraybuffer"
|
|
987
|
-
}).then(this.processResponse)
|
|
988
|
-
return {
|
|
989
|
-
src,
|
|
990
|
-
width: 0,
|
|
991
|
-
height: 0,
|
|
992
|
-
type: void 0,
|
|
993
|
-
data: import_buffer.Buffer.from([0])
|
|
994
|
-
};
|
|
995
|
-
});
|
|
970
|
+
}).then(this.processResponse);
|
|
996
971
|
}
|
|
997
972
|
static async getInfo(src) {
|
|
998
973
|
const keyStr = serializeImageKey({ src });
|
|
@@ -1014,38 +989,50 @@ var ImageLoader = class _ImageLoader {
|
|
|
1014
989
|
|
|
1015
990
|
// src/texture/TextureLoader.ts
|
|
1016
991
|
var TextureLoader = class {
|
|
992
|
+
/** Reports whether image loading failed, so cached textures can be retried. */
|
|
993
|
+
static hasFailed(texture) {
|
|
994
|
+
return this.failedTextures.has(texture);
|
|
995
|
+
}
|
|
1017
996
|
static createTexture() {
|
|
1018
|
-
return new
|
|
997
|
+
return new import_three3.Texture();
|
|
1019
998
|
}
|
|
1020
|
-
static loadInBackground(src, format =
|
|
999
|
+
static loadInBackground(src, format = import_three3.RGBAFormat, rotation = 0) {
|
|
1021
1000
|
const texture = this.createTexture();
|
|
1022
|
-
|
|
1023
|
-
image
|
|
1001
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
1002
|
+
const image = ImageLoader.loadElement(src, () => {
|
|
1024
1003
|
texture.needsUpdate = true;
|
|
1025
|
-
}
|
|
1004
|
+
}, (error) => {
|
|
1005
|
+
this.failedTextures.add(texture);
|
|
1006
|
+
console.warn("Failed to load texture", src, error);
|
|
1007
|
+
});
|
|
1026
1008
|
texture.image = image;
|
|
1027
1009
|
texture.format = format;
|
|
1028
1010
|
texture.rotation = rotation;
|
|
1029
1011
|
return Textures.initTextureProps(texture);
|
|
1030
1012
|
}
|
|
1031
|
-
static load(src, format =
|
|
1032
|
-
const texture = new
|
|
1013
|
+
static load(src, format = import_three3.RGBAFormat, rotation = 0) {
|
|
1014
|
+
const texture = new import_three3.Texture();
|
|
1015
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
1033
1016
|
ImageLoader.getData(src).then((image) => {
|
|
1034
|
-
texture.needsUpdate = true;
|
|
1035
1017
|
texture.image = image;
|
|
1018
|
+
texture.needsUpdate = true;
|
|
1019
|
+
}).catch((error) => {
|
|
1020
|
+
this.failedTextures.add(texture);
|
|
1021
|
+
console.warn("Failed to load texture", src, error);
|
|
1036
1022
|
});
|
|
1037
1023
|
texture.format = format;
|
|
1038
1024
|
texture.rotation = rotation;
|
|
1039
1025
|
return Textures.initTextureProps(texture);
|
|
1040
1026
|
}
|
|
1041
1027
|
};
|
|
1028
|
+
TextureLoader.failedTextures = /* @__PURE__ */ new WeakSet();
|
|
1042
1029
|
|
|
1043
1030
|
// src/texture/Textures.ts
|
|
1044
|
-
var
|
|
1031
|
+
var THREE2 = __toESM(require("three"));
|
|
1045
1032
|
var Textures = class _Textures {
|
|
1046
1033
|
static initTextureProps(texture) {
|
|
1047
|
-
texture.magFilter =
|
|
1048
|
-
texture.minFilter =
|
|
1034
|
+
texture.magFilter = THREE2.NearestFilter;
|
|
1035
|
+
texture.minFilter = THREE2.NearestFilter;
|
|
1049
1036
|
texture.anisotropy = 0;
|
|
1050
1037
|
return texture;
|
|
1051
1038
|
}
|
|
@@ -1053,13 +1040,19 @@ var Textures = class _Textures {
|
|
|
1053
1040
|
return TextureLoader.load(key.src, key.format, key.rotation);
|
|
1054
1041
|
}
|
|
1055
1042
|
static createAsset(key) {
|
|
1056
|
-
return new
|
|
1043
|
+
return new import_three4.Texture();
|
|
1057
1044
|
}
|
|
1058
1045
|
static createCanvasTexture(canvas) {
|
|
1059
|
-
|
|
1046
|
+
const texture = new import_three4.CanvasTexture(canvas);
|
|
1047
|
+
texture.colorSpace = THREE2.SRGBColorSpace;
|
|
1048
|
+
return this.initTextureProps(texture);
|
|
1060
1049
|
}
|
|
1061
1050
|
static getImage(key) {
|
|
1062
1051
|
const keyStr = serializeTextureKey(key);
|
|
1052
|
+
const cached = Caching.textureCache.peek(keyStr);
|
|
1053
|
+
if (cached && TextureLoader.hasFailed(cached)) {
|
|
1054
|
+
Caching.textureCache.invalidate(keyStr);
|
|
1055
|
+
}
|
|
1063
1056
|
return Caching.textureCache.get(keyStr, (k) => {
|
|
1064
1057
|
return _Textures.createImage(key);
|
|
1065
1058
|
});
|
|
@@ -1075,26 +1068,26 @@ var _Materials = class _Materials {
|
|
|
1075
1068
|
}
|
|
1076
1069
|
static createImage(key) {
|
|
1077
1070
|
const transparent = key.transparent || false;
|
|
1078
|
-
return new
|
|
1071
|
+
return new import_three5.MeshBasicMaterial({
|
|
1079
1072
|
map: Textures.getImage(key.texture),
|
|
1080
1073
|
transparent,
|
|
1081
|
-
side: transparent ?
|
|
1074
|
+
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1082
1075
|
alphaTest: 0.5
|
|
1083
1076
|
});
|
|
1084
1077
|
}
|
|
1085
1078
|
static createBasicCanvasMaterial(canvas, transparent = false, shade = false) {
|
|
1086
1079
|
if (shade) {
|
|
1087
|
-
return new
|
|
1080
|
+
return new import_three5.MeshStandardMaterial({
|
|
1088
1081
|
map: Textures.createCanvasTexture(canvas),
|
|
1089
1082
|
transparent,
|
|
1090
|
-
side: transparent ?
|
|
1083
|
+
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1091
1084
|
alphaTest: 0.5
|
|
1092
1085
|
});
|
|
1093
1086
|
}
|
|
1094
|
-
return new
|
|
1087
|
+
return new import_three5.MeshBasicMaterial({
|
|
1095
1088
|
map: Textures.createCanvasTexture(canvas),
|
|
1096
1089
|
transparent,
|
|
1097
|
-
side: transparent ?
|
|
1090
|
+
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1098
1091
|
alphaTest: 0.5
|
|
1099
1092
|
});
|
|
1100
1093
|
}
|
|
@@ -1173,16 +1166,19 @@ var _Materials = class _Materials {
|
|
|
1173
1166
|
gl_FragColor = vec4(lift + color.rgb * light2, 1.0);
|
|
1174
1167
|
|
|
1175
1168
|
}
|
|
1169
|
+
|
|
1170
|
+
#include <tonemapping_fragment>
|
|
1171
|
+
#include <colorspace_fragment>
|
|
1176
1172
|
}
|
|
1177
1173
|
`;
|
|
1178
1174
|
try {
|
|
1179
|
-
return new
|
|
1175
|
+
return new import_three5.ShaderMaterial({
|
|
1180
1176
|
uniforms: {
|
|
1181
1177
|
SHADE: { value: true },
|
|
1182
1178
|
BRIGHTNESS: { value: 1 },
|
|
1183
1179
|
EMISSIVE: { value: false },
|
|
1184
1180
|
base: {
|
|
1185
|
-
value: new
|
|
1181
|
+
value: new import_three5.Color(12698049)
|
|
1186
1182
|
/*TODO*/
|
|
1187
1183
|
},
|
|
1188
1184
|
map: { value: Textures.createCanvasTexture(canvas) }
|
|
@@ -1191,7 +1187,7 @@ var _Materials = class _Materials {
|
|
|
1191
1187
|
fragmentShader: fragShader,
|
|
1192
1188
|
vertexColors: true,
|
|
1193
1189
|
transparent,
|
|
1194
|
-
side: transparent ?
|
|
1190
|
+
side: transparent ? import_three5.DoubleSide : import_three5.FrontSide,
|
|
1195
1191
|
alphaTest: 0.5
|
|
1196
1192
|
});
|
|
1197
1193
|
} catch (e) {
|
|
@@ -1201,6 +1197,10 @@ var _Materials = class _Materials {
|
|
|
1201
1197
|
}
|
|
1202
1198
|
static getImage(key) {
|
|
1203
1199
|
const keyStr = serializeMaterialKey(key);
|
|
1200
|
+
const map = Caching.materialCache.peek(keyStr)?.map;
|
|
1201
|
+
if (map && TextureLoader.hasFailed(map)) {
|
|
1202
|
+
Caching.materialCache.invalidate(keyStr);
|
|
1203
|
+
}
|
|
1204
1204
|
return Caching.materialCache.get(keyStr, (k) => {
|
|
1205
1205
|
return _Materials.createImage(key);
|
|
1206
1206
|
});
|
|
@@ -1225,10 +1225,10 @@ _Materials.MISSING_TEXTURE_SRC = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA
|
|
|
1225
1225
|
var Materials = _Materials;
|
|
1226
1226
|
|
|
1227
1227
|
// src/Meshes.ts
|
|
1228
|
-
var
|
|
1228
|
+
var import_three6 = require("three");
|
|
1229
1229
|
var Meshes = class _Meshes {
|
|
1230
1230
|
static createBox(key) {
|
|
1231
|
-
return new
|
|
1231
|
+
return new import_three6.Mesh(Geometries.getBox(key.geometry), Materials.getImage(key.material));
|
|
1232
1232
|
}
|
|
1233
1233
|
static getBox(key) {
|
|
1234
1234
|
const keyStr = serializeMeshKey(key);
|
|
@@ -1305,12 +1305,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1305
1305
|
return a.join("/");
|
|
1306
1306
|
}
|
|
1307
1307
|
getFullPath() {
|
|
1308
|
-
let
|
|
1308
|
+
let p12 = [];
|
|
1309
1309
|
if (this.type) {
|
|
1310
|
-
|
|
1310
|
+
p12.push(this.type);
|
|
1311
1311
|
}
|
|
1312
|
-
|
|
1313
|
-
return
|
|
1312
|
+
p12.push(this.path);
|
|
1313
|
+
return p12.join("/");
|
|
1314
1314
|
}
|
|
1315
1315
|
toNamespacedString() {
|
|
1316
1316
|
return this.namespace + ":" + this.getFullPath();
|
|
@@ -1335,7 +1335,7 @@ var ModelMerger = class {
|
|
|
1335
1335
|
merged = (0, import_ts_deepmerge.default)(merged, parentModel);
|
|
1336
1336
|
}
|
|
1337
1337
|
merged = (0, import_ts_deepmerge.default)(merged, model);
|
|
1338
|
-
merged.hierarchy = models.map((m) => m.parent).filter((
|
|
1338
|
+
merged.hierarchy = models.map((m) => m.parent).filter((p12) => `${p12}`);
|
|
1339
1339
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1340
1340
|
return merged;
|
|
1341
1341
|
}
|
|
@@ -1354,9 +1354,6 @@ var ModelMerger = class {
|
|
|
1354
1354
|
}
|
|
1355
1355
|
};
|
|
1356
1356
|
|
|
1357
|
-
// src/assets/Models.ts
|
|
1358
|
-
var import_typescript_memoize = require("typescript-memoize");
|
|
1359
|
-
|
|
1360
1357
|
// src/assets/source/parser/AssetParsers.ts
|
|
1361
1358
|
var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
1362
1359
|
AssetParser2["MODEL"] = "model";
|
|
@@ -1370,14 +1367,14 @@ var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
|
1370
1367
|
})(AssetParser || {});
|
|
1371
1368
|
|
|
1372
1369
|
// src/assets/Models.ts
|
|
1373
|
-
var
|
|
1370
|
+
var Models = class _Models {
|
|
1374
1371
|
// opened lazily: touching the store at import time would hit IndexedDB/disk just for loading
|
|
1375
1372
|
// the library, and would require an EnvProvider before any entry has had a chance to register
|
|
1376
1373
|
static get PERSISTENT_CACHE() {
|
|
1377
1374
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-models"));
|
|
1378
1375
|
}
|
|
1379
1376
|
static async getItemList() {
|
|
1380
|
-
|
|
1377
|
+
const key = new AssetKey(
|
|
1381
1378
|
DEFAULT_NAMESPACE,
|
|
1382
1379
|
"_list",
|
|
1383
1380
|
"models",
|
|
@@ -1385,7 +1382,10 @@ var _Models = class _Models {
|
|
|
1385
1382
|
"assets",
|
|
1386
1383
|
".json",
|
|
1387
1384
|
DEFAULT_ROOT
|
|
1388
|
-
)
|
|
1385
|
+
);
|
|
1386
|
+
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1387
|
+
return AssetLoader.get(key, "list" /* LIST */);
|
|
1388
|
+
}).then((r) => r?.files ?? []);
|
|
1389
1389
|
}
|
|
1390
1390
|
static async loadAndMerge(key) {
|
|
1391
1391
|
const model = await this.getRaw(key);
|
|
@@ -1432,19 +1432,15 @@ var _Models = class _Models {
|
|
|
1432
1432
|
return this.PERSISTENT_CACHE.clear();
|
|
1433
1433
|
}
|
|
1434
1434
|
};
|
|
1435
|
-
__decorateClass([
|
|
1436
|
-
(0, import_typescript_memoize.Memoize)()
|
|
1437
|
-
], _Models, "getItemList", 1);
|
|
1438
|
-
var Models = _Models;
|
|
1439
1435
|
|
|
1440
1436
|
// src/assets/BlockStates.ts
|
|
1441
|
-
var import_typescript_memoize2 = require("typescript-memoize");
|
|
1442
1437
|
var BlockStates = class {
|
|
1443
1438
|
static get PERSISTENT_CACHE() {
|
|
1444
1439
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-blockstates"));
|
|
1445
1440
|
}
|
|
1441
|
+
// BlockState names are hardcoded
|
|
1446
1442
|
static async getList() {
|
|
1447
|
-
|
|
1443
|
+
const key = new AssetKey(
|
|
1448
1444
|
DEFAULT_NAMESPACE,
|
|
1449
1445
|
"_list",
|
|
1450
1446
|
"blockstates",
|
|
@@ -1452,11 +1448,16 @@ var BlockStates = class {
|
|
|
1452
1448
|
"assets",
|
|
1453
1449
|
".json",
|
|
1454
1450
|
DEFAULT_ROOT
|
|
1455
|
-
)
|
|
1451
|
+
);
|
|
1452
|
+
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1453
|
+
return AssetLoader.get(key, "list" /* LIST */);
|
|
1454
|
+
}).then((r) => r?.files ?? []);
|
|
1456
1455
|
}
|
|
1457
1456
|
static async getDefaultStates() {
|
|
1458
1457
|
const key = AssetKey.parse("blockstates", "minerender:defaultBlockStates");
|
|
1459
|
-
return
|
|
1458
|
+
return Caching.defaultBlockStatesCache.get(key.serialize(), () => {
|
|
1459
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
1460
|
+
});
|
|
1460
1461
|
}
|
|
1461
1462
|
static async getDefaultState(key) {
|
|
1462
1463
|
const defaultStates = await this.getDefaultStates();
|
|
@@ -1495,12 +1496,6 @@ var BlockStates = class {
|
|
|
1495
1496
|
await this.PERSISTENT_CACHE.clear();
|
|
1496
1497
|
}
|
|
1497
1498
|
};
|
|
1498
|
-
__decorateClass([
|
|
1499
|
-
(0, import_typescript_memoize2.Memoize)()
|
|
1500
|
-
], BlockStates, "getList", 1);
|
|
1501
|
-
__decorateClass([
|
|
1502
|
-
(0, import_typescript_memoize2.Memoize)()
|
|
1503
|
-
], BlockStates, "getDefaultStates", 1);
|
|
1504
1499
|
var DefaultBlockStates = class {
|
|
1505
1500
|
};
|
|
1506
1501
|
|
|
@@ -1527,82 +1522,213 @@ var AssetSource = class {
|
|
|
1527
1522
|
constructor() {
|
|
1528
1523
|
}
|
|
1529
1524
|
};
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1525
|
+
var AssetLoadError = class extends Error {
|
|
1526
|
+
constructor(source, key, path, cause) {
|
|
1527
|
+
super(`Failed to load ${key.toNamespacedString()} from ${path}${cause instanceof Error ? `: ${cause.message}` : ""}`);
|
|
1528
|
+
this.source = source;
|
|
1529
|
+
this.key = key;
|
|
1530
|
+
this.path = path;
|
|
1531
|
+
this.cause = cause;
|
|
1532
|
+
this.name = "AssetLoadError";
|
|
1537
1533
|
}
|
|
1538
1534
|
};
|
|
1539
1535
|
|
|
1540
|
-
// src/
|
|
1541
|
-
var
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
const namespaceKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, key.root);
|
|
1555
|
-
const namespaced = await this.load(namespaceKey, parser);
|
|
1556
|
-
if (typeof namespaced !== "undefined") {
|
|
1557
|
-
return namespaced;
|
|
1558
|
-
}
|
|
1559
|
-
if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
|
|
1560
|
-
console.info(p3, "Retrying", key, "with default root+namespace");
|
|
1561
|
-
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
|
|
1562
|
-
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
1563
|
-
if (typeof namespacedRooted !== "undefined") {
|
|
1564
|
-
return namespacedRooted;
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
} else if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
|
|
1568
|
-
console.info(p3, "Retrying", key, "with default root");
|
|
1569
|
-
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
|
|
1570
|
-
const rooted = await this.load(rootKey, parser);
|
|
1571
|
-
if (typeof rooted !== "undefined") {
|
|
1572
|
-
return rooted;
|
|
1573
|
-
}
|
|
1536
|
+
// src/util/BatchedExecutor.ts
|
|
1537
|
+
var BatchedExecutor = class {
|
|
1538
|
+
constructor(interval = 1, batch = 30) {
|
|
1539
|
+
this.interval = interval;
|
|
1540
|
+
this.batch = batch;
|
|
1541
|
+
this.queue = [];
|
|
1542
|
+
this.task = setInterval(() => this.run());
|
|
1543
|
+
}
|
|
1544
|
+
submit(task) {
|
|
1545
|
+
this.queue.push(task);
|
|
1546
|
+
}
|
|
1547
|
+
run() {
|
|
1548
|
+
for (let i = 0; i < this.batch; i++) {
|
|
1549
|
+
this.runNext();
|
|
1574
1550
|
}
|
|
1575
|
-
return void 0;
|
|
1576
1551
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1552
|
+
runNext() {
|
|
1553
|
+
let next = this.queue.shift();
|
|
1554
|
+
if (next) next();
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
// src/util/model.ts
|
|
1559
|
+
var import_three7 = require("three");
|
|
1560
|
+
function applyElementRotation(rotation, geometry) {
|
|
1561
|
+
const origin = new import_three7.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1562
|
+
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1563
|
+
switch (rotation.axis) {
|
|
1564
|
+
case "X" /* X */:
|
|
1565
|
+
geometry.rotateX(toRadians(rotation.angle));
|
|
1566
|
+
break;
|
|
1567
|
+
case "y" /* Y */:
|
|
1568
|
+
geometry.rotateY(toRadians(rotation.angle));
|
|
1569
|
+
break;
|
|
1570
|
+
case "z" /* Z */:
|
|
1571
|
+
geometry.rotateZ(toRadians(rotation.angle));
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
if (rotation.rescale) {
|
|
1575
|
+
if (Math.abs(rotation.angle) === 22.5) {
|
|
1576
|
+
const s = 1 / Math.cos(0.39269909262657166);
|
|
1577
|
+
geometry.scale(s, 1, s);
|
|
1578
|
+
} else {
|
|
1579
|
+
const s = 1 / Math.cos(0.7853981852531433);
|
|
1580
|
+
geometry.scale(s, 1, s);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
geometry.translate(origin.x, origin.y, origin.z);
|
|
1584
|
+
}
|
|
1585
|
+
function applyModelPartRotation(modelPart, geometry) {
|
|
1586
|
+
const origin = new import_three7.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1587
|
+
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1588
|
+
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1589
|
+
geometry.rotateY(toRadians(modelPart.yaw));
|
|
1590
|
+
geometry.rotateZ(toRadians(modelPart.roll));
|
|
1591
|
+
geometry.translate(origin.x, origin.y, origin.z);
|
|
1592
|
+
}
|
|
1593
|
+
function applyGenericRotation(axis, rotation, obj) {
|
|
1594
|
+
switch (axis) {
|
|
1595
|
+
case "X" /* X */:
|
|
1596
|
+
obj.rotateOnAxis(new import_three7.Vector3(1, 0, 0), toRadians(rotation));
|
|
1597
|
+
break;
|
|
1598
|
+
case "y" /* Y */:
|
|
1599
|
+
obj.rotateOnAxis(new import_three7.Vector3(0, 1, 0), toRadians(rotation));
|
|
1600
|
+
break;
|
|
1601
|
+
case "z" /* Z */:
|
|
1602
|
+
obj.rotateOnAxis(new import_three7.Vector3(0, 0, 1), toRadians(rotation));
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1607
|
+
let size = new import_three7.Vector3();
|
|
1608
|
+
box.getSize(size);
|
|
1609
|
+
let boxGeo = new import_three7.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
1610
|
+
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1611
|
+
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1612
|
+
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1613
|
+
obj.add(wireframe);
|
|
1614
|
+
let axes = new import_three7.AxesHelper(1);
|
|
1615
|
+
obj.add(axes);
|
|
1616
|
+
}
|
|
1617
|
+
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
1618
|
+
let boxGeo = new import_three7.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
1619
|
+
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1620
|
+
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1621
|
+
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1622
|
+
obj.add(wireframe);
|
|
1623
|
+
let axes = new import_three7.AxesHelper(1);
|
|
1624
|
+
obj.add(axes);
|
|
1625
|
+
}
|
|
1626
|
+
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
1627
|
+
let wireGeo = new import_three7.EdgesGeometry(geo);
|
|
1628
|
+
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1629
|
+
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1630
|
+
mesh.add(wireframe);
|
|
1631
|
+
let axes = new import_three7.AxesHelper(1);
|
|
1632
|
+
mesh.add(axes);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// src/util/performance.ts
|
|
1636
|
+
function captureException(e, ...extra) {
|
|
1637
|
+
console.error(e, extra);
|
|
1638
|
+
}
|
|
1639
|
+
function timingStart(marker) {
|
|
1640
|
+
console.time(marker);
|
|
1641
|
+
}
|
|
1642
|
+
function timingEnd(marker) {
|
|
1643
|
+
console.timeEnd(marker);
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
// src/util/three.ts
|
|
1647
|
+
function isObject3D(obj) {
|
|
1648
|
+
return obj.isObject3D;
|
|
1649
|
+
}
|
|
1650
|
+
function isMesh(obj) {
|
|
1651
|
+
return obj.isMesh;
|
|
1652
|
+
}
|
|
1653
|
+
function isInstancedMesh(obj) {
|
|
1654
|
+
return obj.isInstancedMesh;
|
|
1655
|
+
}
|
|
1656
|
+
function isPerspectiveCamera(obj) {
|
|
1657
|
+
return obj.isPerspectiveCamera;
|
|
1658
|
+
}
|
|
1659
|
+
function isOrthographicCamera(obj) {
|
|
1660
|
+
return obj.isOrthographicCamera;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// src/nbt/NBTHelper.ts
|
|
1664
|
+
var NBTHelper = class {
|
|
1665
|
+
static async fromBuffer(buffer) {
|
|
1666
|
+
const prismarineNbt = await import("prismarine-nbt");
|
|
1667
|
+
const { parsed, type, metadata } = await prismarineNbt.parse(buffer);
|
|
1668
|
+
return parsed;
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
// src/assets/source/HostedAssetSource.ts
|
|
1673
|
+
var import_ts_deepmerge2 = __toESM(require_dist());
|
|
1674
|
+
var p3 = prefix("HostedAssetSource");
|
|
1675
|
+
var DEFAULT_OPTIONS = {
|
|
1676
|
+
retryDefaults: true
|
|
1677
|
+
};
|
|
1678
|
+
var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
|
|
1679
|
+
async loadOrRetryWithDefaults(key, parser) {
|
|
1680
|
+
const direct = await this.load(key, parser);
|
|
1681
|
+
if (typeof direct !== "undefined") {
|
|
1682
|
+
return direct;
|
|
1683
|
+
}
|
|
1684
|
+
if (key.namespace !== DEFAULT_NAMESPACE) {
|
|
1685
|
+
console.info(p3, "Retrying", key, "with default namespace");
|
|
1686
|
+
const namespaceKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, key.root);
|
|
1687
|
+
const namespaced = await this.load(namespaceKey, parser);
|
|
1688
|
+
if (typeof namespaced !== "undefined") {
|
|
1689
|
+
return namespaced;
|
|
1690
|
+
}
|
|
1691
|
+
if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
|
|
1692
|
+
console.info(p3, "Retrying", key, "with default root+namespace");
|
|
1693
|
+
const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
|
|
1694
|
+
const namespacedRooted = await this.load(namespacedRootedKey, parser);
|
|
1695
|
+
if (typeof namespacedRooted !== "undefined") {
|
|
1696
|
+
return namespacedRooted;
|
|
1592
1697
|
}
|
|
1593
1698
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1699
|
+
} else if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
|
|
1700
|
+
console.info(p3, "Retrying", key, "with default root");
|
|
1701
|
+
const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
|
|
1702
|
+
const rooted = await this.load(rootKey, parser);
|
|
1703
|
+
if (typeof rooted !== "undefined") {
|
|
1704
|
+
return rooted;
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
return void 0;
|
|
1708
|
+
}
|
|
1709
|
+
async load(key, parser) {
|
|
1710
|
+
console.info(p3, "Loading", key);
|
|
1711
|
+
const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1712
|
+
console.debug(p3, url);
|
|
1713
|
+
const request = { url };
|
|
1714
|
+
try {
|
|
1715
|
+
parser.config(request);
|
|
1716
|
+
let response;
|
|
1717
|
+
try {
|
|
1718
|
+
response = await Requests.mcAssetRequest(request);
|
|
1719
|
+
} catch (cause) {
|
|
1720
|
+
if (cause instanceof RequestError && cause.response?.status === 404) {
|
|
1600
1721
|
return void 0;
|
|
1601
1722
|
}
|
|
1723
|
+
throw cause;
|
|
1602
1724
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1725
|
+
if (response.data === void 0) {
|
|
1726
|
+
throw new Error("Asset response has no data");
|
|
1727
|
+
}
|
|
1728
|
+
return await parser.parse(response);
|
|
1729
|
+
} catch (cause) {
|
|
1730
|
+
throw new AssetLoadError(this, key, request.url, cause);
|
|
1731
|
+
}
|
|
1606
1732
|
}
|
|
1607
1733
|
assetBasePath(key) {
|
|
1608
1734
|
return `${key.root ?? this.root ?? AssetLoader.ROOT}/${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
|
|
@@ -1709,7 +1835,6 @@ var BrowserArchiveProxy = class {
|
|
|
1709
1835
|
};
|
|
1710
1836
|
|
|
1711
1837
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
1712
|
-
var p4 = prefix("ArchiveAssetSource");
|
|
1713
1838
|
var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
1714
1839
|
constructor(archiveProxy) {
|
|
1715
1840
|
super();
|
|
@@ -1728,74 +1853,31 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1728
1853
|
}
|
|
1729
1854
|
async get(key, parser) {
|
|
1730
1855
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
1731
|
-
|
|
1732
|
-
let entries = await this.getEntries();
|
|
1733
|
-
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1734
|
-
console.log(path);
|
|
1735
|
-
const entry = await this.getEntry(path);
|
|
1736
|
-
console.log(entry);
|
|
1737
|
-
if (!entry) {
|
|
1738
|
-
return void 0;
|
|
1739
|
-
}
|
|
1740
|
-
let blob = await entry.getData();
|
|
1741
|
-
const url = URL.createObjectURL(blob);
|
|
1742
|
-
console.log(url);
|
|
1743
|
-
let req = {
|
|
1744
|
-
url
|
|
1745
|
-
};
|
|
1746
|
-
responseParser.config(req);
|
|
1747
|
-
return Requests.genericRequest(req).then((response) => {
|
|
1748
|
-
if (response && response.data) {
|
|
1749
|
-
try {
|
|
1750
|
-
return responseParser.parse(response);
|
|
1751
|
-
} catch (e) {
|
|
1752
|
-
console.warn("Parser failed to process response", response, e);
|
|
1753
|
-
throw e;
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
return void 0;
|
|
1757
|
-
}).catch((err) => {
|
|
1758
|
-
if (err.response) {
|
|
1759
|
-
let response = err.response;
|
|
1760
|
-
if (response.status === 404) {
|
|
1761
|
-
console.debug(p4, key, "not found");
|
|
1762
|
-
return void 0;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
console.debug(p4, "Failed to load", key, err?.message);
|
|
1766
|
-
return void 0;
|
|
1767
|
-
});
|
|
1856
|
+
return this.load(key, responseParser);
|
|
1768
1857
|
}
|
|
1769
|
-
//TODO: abstract this
|
|
1770
1858
|
async load(key, parser) {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
parser.config(req);
|
|
1778
|
-
return await Requests.genericRequest(req).then((response) => {
|
|
1779
|
-
if (response && response.data) {
|
|
1780
|
-
try {
|
|
1781
|
-
return parser.parse(response);
|
|
1782
|
-
} catch (e) {
|
|
1783
|
-
console.warn("Parser failed to process response", response, e);
|
|
1784
|
-
throw e;
|
|
1785
|
-
}
|
|
1859
|
+
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1860
|
+
let url;
|
|
1861
|
+
try {
|
|
1862
|
+
const entry = await this.getEntry(path);
|
|
1863
|
+
if (!entry) {
|
|
1864
|
+
return void 0;
|
|
1786
1865
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
return void 0;
|
|
1794
|
-
}
|
|
1866
|
+
url = URL.createObjectURL(await entry.getData());
|
|
1867
|
+
const request = { url };
|
|
1868
|
+
parser.config(request);
|
|
1869
|
+
const response = await Requests.genericRequest(request);
|
|
1870
|
+
if (response.data === void 0) {
|
|
1871
|
+
throw new Error("Asset response has no data");
|
|
1795
1872
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1873
|
+
return await parser.parse(response);
|
|
1874
|
+
} catch (cause) {
|
|
1875
|
+
throw new AssetLoadError(this, key, path, cause);
|
|
1876
|
+
} finally {
|
|
1877
|
+
if (url !== void 0) {
|
|
1878
|
+
URL.revokeObjectURL(url);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1799
1881
|
}
|
|
1800
1882
|
assetBasePath(key) {
|
|
1801
1883
|
return `${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
|
|
@@ -1803,18 +1885,17 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1803
1885
|
};
|
|
1804
1886
|
|
|
1805
1887
|
// src/assets/AssetLoader.ts
|
|
1806
|
-
var
|
|
1807
|
-
var p5 = prefix("AssetLoader");
|
|
1888
|
+
var p4 = prefix("AssetLoader");
|
|
1808
1889
|
var _AssetLoader = class _AssetLoader {
|
|
1809
1890
|
static addSource(key, source, override = true) {
|
|
1810
1891
|
if (override) {
|
|
1811
1892
|
const existing = this.removeSource(key);
|
|
1812
1893
|
if (existing) {
|
|
1813
|
-
console.log(
|
|
1894
|
+
console.log(p4, "Removed existing AssetSource", key);
|
|
1814
1895
|
}
|
|
1815
1896
|
}
|
|
1816
1897
|
this._SOURCES.unshift({ key, source });
|
|
1817
|
-
console.log(
|
|
1898
|
+
console.log(p4, "Added AssetSource", key);
|
|
1818
1899
|
}
|
|
1819
1900
|
static removeSource(key) {
|
|
1820
1901
|
const index = this._SOURCES.findIndex((s) => s.key === key);
|
|
@@ -1827,7 +1908,6 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1827
1908
|
return void 0;
|
|
1828
1909
|
}
|
|
1829
1910
|
static async getAll(key, parser) {
|
|
1830
|
-
console.log(this._SOURCES);
|
|
1831
1911
|
let promises = [];
|
|
1832
1912
|
for (const source of this._SOURCES) {
|
|
1833
1913
|
promises.push(source.source.get(key, parser));
|
|
@@ -1836,24 +1916,16 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1836
1916
|
return results.filter((r) => r != void 0);
|
|
1837
1917
|
});
|
|
1838
1918
|
}
|
|
1919
|
+
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
1839
1920
|
static async get(key, parser) {
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
return Promise.all(promises).then((results) => {
|
|
1846
|
-
const fallback = results[results.length - 1];
|
|
1847
|
-
for (const result of results) {
|
|
1848
|
-
if (result) {
|
|
1849
|
-
if (fallback) {
|
|
1850
|
-
return (0, import_ts_deepmerge3.default)({}, fallback, result);
|
|
1851
|
-
}
|
|
1852
|
-
return result;
|
|
1853
|
-
}
|
|
1921
|
+
const sources = [...this._SOURCES];
|
|
1922
|
+
for (const source of sources) {
|
|
1923
|
+
const result = await source.source.get(key, parser);
|
|
1924
|
+
if (result !== void 0) {
|
|
1925
|
+
return result;
|
|
1854
1926
|
}
|
|
1855
|
-
|
|
1856
|
-
|
|
1927
|
+
}
|
|
1928
|
+
return void 0;
|
|
1857
1929
|
}
|
|
1858
1930
|
};
|
|
1859
1931
|
_AssetLoader.ROOT = DEFAULT_ROOT;
|
|
@@ -1868,11 +1940,21 @@ var ModelTextures = class {
|
|
|
1868
1940
|
return this._persistentMetaCache ?? (this._persistentMetaCache = PersistentCache.open("minerender-texturemeta"));
|
|
1869
1941
|
}
|
|
1870
1942
|
static async get(key) {
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1873
|
-
|
|
1943
|
+
const keyStr = key.serialize();
|
|
1944
|
+
const pending = this.preload(key);
|
|
1945
|
+
const cached = Caching.textureAssetCache.getIfPresent(keyStr);
|
|
1946
|
+
try {
|
|
1947
|
+
const asset = await pending;
|
|
1948
|
+
if (asset) {
|
|
1949
|
+
return await ImageLoader.infoToCanvasData(asset);
|
|
1950
|
+
}
|
|
1951
|
+
return void 0;
|
|
1952
|
+
} catch (err) {
|
|
1953
|
+
if (cached && Caching.textureAssetCache.getIfPresent(keyStr) === cached) {
|
|
1954
|
+
Caching.textureAssetCache.invalidate(keyStr);
|
|
1955
|
+
}
|
|
1956
|
+
throw err;
|
|
1874
1957
|
}
|
|
1875
|
-
return void 0;
|
|
1876
1958
|
}
|
|
1877
1959
|
static async preload(key) {
|
|
1878
1960
|
const keyStr = key.serialize();
|
|
@@ -2063,7 +2145,7 @@ var ModelGenerator = class {
|
|
|
2063
2145
|
ModelGenerator.ITEM_LAYERS = ["layer0", "layer1", "layer2", "layer3", "layer4"];
|
|
2064
2146
|
|
|
2065
2147
|
// src/UVMapper.ts
|
|
2066
|
-
var
|
|
2148
|
+
var p5 = prefix("UVMapper");
|
|
2067
2149
|
var DEFAULT_UV = [0, 0, 16, 16];
|
|
2068
2150
|
var X = 0;
|
|
2069
2151
|
var Y = 1;
|
|
@@ -2240,7 +2322,7 @@ var UVMapper = class {
|
|
|
2240
2322
|
const metaMap = {};
|
|
2241
2323
|
const model = { ...originalModel };
|
|
2242
2324
|
const isItemModel = !("elements" in model);
|
|
2243
|
-
console.debug(
|
|
2325
|
+
console.debug(p5, "Creating Atlas for", model.key);
|
|
2244
2326
|
if (model.textures) {
|
|
2245
2327
|
const promises = [];
|
|
2246
2328
|
const uniqueTextureNames = [];
|
|
@@ -2254,7 +2336,7 @@ var UVMapper = class {
|
|
|
2254
2336
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
2255
2337
|
promises.push(ModelTextures.get(assetKey).then((asset) => {
|
|
2256
2338
|
if (!asset) {
|
|
2257
|
-
console.warn(
|
|
2339
|
+
console.warn(p5, "Missing texture", assetKey);
|
|
2258
2340
|
return;
|
|
2259
2341
|
}
|
|
2260
2342
|
textureMap[textureKey] = new WrappedImage(asset);
|
|
@@ -2266,7 +2348,7 @@ var UVMapper = class {
|
|
|
2266
2348
|
}
|
|
2267
2349
|
await Promise.all(promises);
|
|
2268
2350
|
const textureCount = uniqueTextureNames.length;
|
|
2269
|
-
console.debug(
|
|
2351
|
+
console.debug(p5, "Creating Atlas for", textureCount, "textures");
|
|
2270
2352
|
this.fillMissingTextureKeys(model.textures, textureMap);
|
|
2271
2353
|
this.fillMissingTextureKeys(model.textures, metaMap);
|
|
2272
2354
|
const sizes = {};
|
|
@@ -2286,7 +2368,7 @@ var UVMapper = class {
|
|
|
2286
2368
|
this.fillMissingTextureKeys(model.textures, sizes);
|
|
2287
2369
|
const s = Math.ceil(Math.sqrt(textureCount + 1));
|
|
2288
2370
|
const size = Math.ceil(s * maxWidth);
|
|
2289
|
-
console.debug(
|
|
2371
|
+
console.debug(p5, "Atlas size:", size);
|
|
2290
2372
|
const squaredSize = size * size;
|
|
2291
2373
|
const missing = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC");
|
|
2292
2374
|
const empty = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA5JREFUKM9jGAWjgAIAAAJAAAFSSwuTAAAAAElFTkSuQmCC");
|
|
@@ -2341,10 +2423,10 @@ var UVMapper = class {
|
|
|
2341
2423
|
}
|
|
2342
2424
|
}
|
|
2343
2425
|
const atlasImageData = image.toDataURL();
|
|
2344
|
-
console.log(
|
|
2426
|
+
console.log(p5, "Atlas Image for", model.key, atlasImageData);
|
|
2345
2427
|
this.fillMissingTextureKeys(model.textures, positions);
|
|
2346
2428
|
if (isItemModel) {
|
|
2347
|
-
console.debug(
|
|
2429
|
+
console.debug(p5, "Generating item model for", model);
|
|
2348
2430
|
model.elements = [];
|
|
2349
2431
|
for (let layerName of ModelGenerator.ITEM_LAYERS) {
|
|
2350
2432
|
const textureImage = textureMap[layerName];
|
|
@@ -2352,7 +2434,7 @@ var UVMapper = class {
|
|
|
2352
2434
|
model.elements.push(...ModelGenerator.generateItemModel(textureImage.data, layerName));
|
|
2353
2435
|
}
|
|
2354
2436
|
}
|
|
2355
|
-
console.debug(
|
|
2437
|
+
console.debug(p5, "Item model elements", model.elements);
|
|
2356
2438
|
}
|
|
2357
2439
|
if (!model.elements) {
|
|
2358
2440
|
}
|
|
@@ -2412,7 +2494,7 @@ var UVMapper = class {
|
|
|
2412
2494
|
hasTransparency
|
|
2413
2495
|
);
|
|
2414
2496
|
} else {
|
|
2415
|
-
console.warn(
|
|
2497
|
+
console.warn(p5, "Model does not have any textures", model);
|
|
2416
2498
|
}
|
|
2417
2499
|
return void 0;
|
|
2418
2500
|
}
|
|
@@ -2550,17 +2632,20 @@ function shutdown() {
|
|
|
2550
2632
|
}
|
|
2551
2633
|
|
|
2552
2634
|
// src/assets/Entities.ts
|
|
2553
|
-
var import_typescript_memoize3 = require("typescript-memoize");
|
|
2554
2635
|
var Entities = class {
|
|
2555
2636
|
static async getBlockEntityModels() {
|
|
2556
2637
|
const key = AssetKey.parse("models", "minerender:blockEntityModels");
|
|
2557
2638
|
console.log(key);
|
|
2558
|
-
return
|
|
2639
|
+
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2640
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2641
|
+
});
|
|
2559
2642
|
}
|
|
2560
2643
|
static async getEntityModels() {
|
|
2561
2644
|
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
2562
2645
|
console.log(key);
|
|
2563
|
-
return
|
|
2646
|
+
return Caching.entityModelsCache.get(key.serialize(), () => {
|
|
2647
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2648
|
+
});
|
|
2564
2649
|
}
|
|
2565
2650
|
// BlockEntity names are hardcoded
|
|
2566
2651
|
static async getBlockList() {
|
|
@@ -2606,12 +2691,6 @@ var Entities = class {
|
|
|
2606
2691
|
};
|
|
2607
2692
|
}
|
|
2608
2693
|
};
|
|
2609
|
-
__decorateClass([
|
|
2610
|
-
(0, import_typescript_memoize3.Memoize)()
|
|
2611
|
-
], Entities, "getBlockEntityModels", 1);
|
|
2612
|
-
__decorateClass([
|
|
2613
|
-
(0, import_typescript_memoize3.Memoize)()
|
|
2614
|
-
], Entities, "getEntityModels", 1);
|
|
2615
2694
|
var EntityModels = class {
|
|
2616
2695
|
};
|
|
2617
2696
|
var BlockEntityModels = class {
|
|
@@ -2675,8 +2754,8 @@ var MineRenderError = class _MineRenderError extends Error {
|
|
|
2675
2754
|
};
|
|
2676
2755
|
|
|
2677
2756
|
// src/renderer/SceneObject.ts
|
|
2678
|
-
var
|
|
2679
|
-
var
|
|
2757
|
+
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
2758
|
+
var p6 = prefix("SceneObject");
|
|
2680
2759
|
var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
2681
2760
|
constructor(options) {
|
|
2682
2761
|
super();
|
|
@@ -2684,7 +2763,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2684
2763
|
this.materialCallbacks = {};
|
|
2685
2764
|
this._isInstanced = false;
|
|
2686
2765
|
this._instanceCounter = 0;
|
|
2687
|
-
this.options = (0,
|
|
2766
|
+
this.options = (0, import_ts_deepmerge3.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
2688
2767
|
console.log("SceneObject options", this.options);
|
|
2689
2768
|
}
|
|
2690
2769
|
set scene(scene) {
|
|
@@ -2855,9 +2934,9 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2855
2934
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2856
2935
|
const i = this._instanceCounter++;
|
|
2857
2936
|
this.setMatrixAt(i, new import_three9.Matrix4());
|
|
2858
|
-
console.debug(
|
|
2937
|
+
console.debug(p6, "nextInstance " + i);
|
|
2859
2938
|
if (i === this.options.maxInstanceCount) {
|
|
2860
|
-
console.warn(
|
|
2939
|
+
console.warn(p6, "Max instance count reached for " + this);
|
|
2861
2940
|
}
|
|
2862
2941
|
if (this.scene) {
|
|
2863
2942
|
this.scene.stats.instanceCount++;
|
|
@@ -3033,7 +3112,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3033
3112
|
}
|
|
3034
3113
|
//</editor-fold>
|
|
3035
3114
|
};
|
|
3036
|
-
_SceneObject.DEFAULT_OPTIONS = (0,
|
|
3115
|
+
_SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge3.default)({}, {
|
|
3037
3116
|
instanceMeshes: true,
|
|
3038
3117
|
maxInstanceCount: 50,
|
|
3039
3118
|
mergeMeshes: true,
|
|
@@ -3045,16 +3124,16 @@ function isSceneObject(obj) {
|
|
|
3045
3124
|
}
|
|
3046
3125
|
|
|
3047
3126
|
// src/entity/scene/EntityObject.ts
|
|
3048
|
-
var
|
|
3127
|
+
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
3049
3128
|
var import_three11 = require("three");
|
|
3050
|
-
var
|
|
3129
|
+
var THREE3 = __toESM(require("three"));
|
|
3051
3130
|
var EntityObject = class extends SceneObject {
|
|
3052
3131
|
constructor(entity, options) {
|
|
3053
3132
|
super();
|
|
3054
3133
|
this.entity = entity;
|
|
3055
3134
|
this.isEntityObject = true;
|
|
3056
3135
|
this.meshesCreated = false;
|
|
3057
|
-
this.options = (0,
|
|
3136
|
+
this.options = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
3058
3137
|
}
|
|
3059
3138
|
async init() {
|
|
3060
3139
|
this.createMeshes();
|
|
@@ -3063,8 +3142,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3063
3142
|
dispose() {
|
|
3064
3143
|
super.dispose();
|
|
3065
3144
|
}
|
|
3066
|
-
|
|
3067
|
-
|
|
3145
|
+
get textureKey() {
|
|
3146
|
+
return new AssetKey(
|
|
3068
3147
|
this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
|
|
3069
3148
|
this.entity.key.path,
|
|
3070
3149
|
//TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
|
|
@@ -3072,7 +3151,10 @@ var EntityObject = class extends SceneObject {
|
|
|
3072
3151
|
"entity",
|
|
3073
3152
|
"assets",
|
|
3074
3153
|
".png"
|
|
3075
|
-
)
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
async loadTextures() {
|
|
3157
|
+
this.imageData = await ModelTextures.get(this.textureKey);
|
|
3076
3158
|
}
|
|
3077
3159
|
//TODO: abstract this, since extracted model data can be used for entities, blocks, players
|
|
3078
3160
|
createMeshes(force = false) {
|
|
@@ -3091,8 +3173,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3091
3173
|
const l = cube.maxZ - cube.minZ;
|
|
3092
3174
|
const uv = texture.toUvArray(w, h, l);
|
|
3093
3175
|
const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
|
|
3094
|
-
cubeGeo.applyMatrix4(new
|
|
3095
|
-
cubeGeo.applyMatrix4(new
|
|
3176
|
+
cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
|
|
3177
|
+
cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
|
|
3096
3178
|
applyModelPartRotation(part, cubeGeo);
|
|
3097
3179
|
const mesh = this.createMesh(partName, cubeGeo, mat);
|
|
3098
3180
|
partAnchor.add(mesh);
|
|
@@ -3105,23 +3187,26 @@ var EntityObject = class extends SceneObject {
|
|
|
3105
3187
|
this.meshesCreated = true;
|
|
3106
3188
|
}
|
|
3107
3189
|
async applyTextures() {
|
|
3108
|
-
const
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3190
|
+
const assetKeyStr = this.textureKey.serialize();
|
|
3191
|
+
const keyStr = `entity:${assetKeyStr}`;
|
|
3192
|
+
let mat = Caching.materialCache.getIfPresent(keyStr);
|
|
3193
|
+
if (!mat) {
|
|
3194
|
+
const pending = this.loadTextures();
|
|
3195
|
+
const cachedAsset = Caching.textureAssetCache.getIfPresent(assetKeyStr);
|
|
3196
|
+
await pending;
|
|
3197
|
+
if (!this.imageData) return;
|
|
3198
|
+
const canvas = this.imageData.data.canvas;
|
|
3199
|
+
const createMaterial = () => Materials.createBasicCanvasMaterial(canvas);
|
|
3200
|
+
mat = cachedAsset && Caching.textureAssetCache.getIfPresent(assetKeyStr) === cachedAsset ? Caching.materialCache.get(keyStr, createMaterial) : createMaterial();
|
|
3201
|
+
this.imageData = void 0;
|
|
3202
|
+
}
|
|
3203
|
+
this.iterateAllMeshes((mesh) => {
|
|
3204
|
+
mesh.material = mat;
|
|
3205
|
+
});
|
|
3206
|
+
this.notifyDirty();
|
|
3122
3207
|
}
|
|
3123
3208
|
};
|
|
3124
|
-
EntityObject.DEFAULT_OPTIONS = (0,
|
|
3209
|
+
EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
3125
3210
|
function isEntityObject(obj) {
|
|
3126
3211
|
return obj.isEntityObject;
|
|
3127
3212
|
}
|
|
@@ -3133,7 +3218,7 @@ var GuiObject = class extends SceneObject {
|
|
|
3133
3218
|
|
|
3134
3219
|
// src/inspector/SceneInspector.ts
|
|
3135
3220
|
var import_three12 = require("three");
|
|
3136
|
-
var
|
|
3221
|
+
var p7 = prefix("SceneInspector");
|
|
3137
3222
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3138
3223
|
var SceneInspector = class {
|
|
3139
3224
|
constructor(renderer) {
|
|
@@ -3202,7 +3287,7 @@ var SceneInspector = class {
|
|
|
3202
3287
|
}
|
|
3203
3288
|
selectObject(targetObject, targetIntersection) {
|
|
3204
3289
|
this.selectedObject = targetObject;
|
|
3205
|
-
console.log(
|
|
3290
|
+
console.log(p7, "selected", targetObject);
|
|
3206
3291
|
this.redraw(targetObject, targetIntersection);
|
|
3207
3292
|
}
|
|
3208
3293
|
redraw(targetObject, targetIntersection) {
|
|
@@ -3500,7 +3585,7 @@ var SceneStatsDisplay = class {
|
|
|
3500
3585
|
};
|
|
3501
3586
|
|
|
3502
3587
|
// src/instance/InstanceManager.ts
|
|
3503
|
-
var
|
|
3588
|
+
var p8 = prefix("InstanceManager");
|
|
3504
3589
|
var InstanceManager = class {
|
|
3505
3590
|
constructor() {
|
|
3506
3591
|
this.isInstanceManager = true;
|
|
@@ -3508,7 +3593,7 @@ var InstanceManager = class {
|
|
|
3508
3593
|
}
|
|
3509
3594
|
async get(key) {
|
|
3510
3595
|
if (key in this.instanceCache) {
|
|
3511
|
-
console.debug(
|
|
3596
|
+
console.debug(p8, "key in cache", key);
|
|
3512
3597
|
return (await this.instanceCache[key]).nextInstance();
|
|
3513
3598
|
}
|
|
3514
3599
|
return void 0;
|
|
@@ -3517,13 +3602,17 @@ var InstanceManager = class {
|
|
|
3517
3602
|
if (key in this.instanceCache) {
|
|
3518
3603
|
return await this.get(key);
|
|
3519
3604
|
}
|
|
3520
|
-
console.debug(
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
})
|
|
3526
|
-
|
|
3605
|
+
console.debug(p8, "key not in cache", key);
|
|
3606
|
+
const pending = Promise.resolve().then(supplier).then((obj) => obj.nextInstance());
|
|
3607
|
+
this.instanceCache[key] = pending;
|
|
3608
|
+
try {
|
|
3609
|
+
return await pending;
|
|
3610
|
+
} catch (error) {
|
|
3611
|
+
if (this.instanceCache[key] === pending) {
|
|
3612
|
+
delete this.instanceCache[key];
|
|
3613
|
+
}
|
|
3614
|
+
throw error;
|
|
3615
|
+
}
|
|
3527
3616
|
}
|
|
3528
3617
|
reset() {
|
|
3529
3618
|
for (let instanceCacheKey in this.instanceCache) {
|
|
@@ -4112,15 +4201,15 @@ function computeMorphedAttributes(object) {
|
|
|
4112
4201
|
}
|
|
4113
4202
|
|
|
4114
4203
|
// src/model/scene/ModelObject.ts
|
|
4115
|
-
var
|
|
4116
|
-
var
|
|
4204
|
+
var import_ts_deepmerge5 = __toESM(require_dist());
|
|
4205
|
+
var p9 = prefix("ModelObject");
|
|
4117
4206
|
var _ModelObject = class _ModelObject extends SceneObject {
|
|
4118
4207
|
constructor(originalModel, options) {
|
|
4119
4208
|
super(options);
|
|
4120
4209
|
this.originalModel = originalModel;
|
|
4121
4210
|
this.isModelObject = true;
|
|
4122
4211
|
this.meshesCreated = false;
|
|
4123
|
-
this.options = (0,
|
|
4212
|
+
this.options = (0, import_ts_deepmerge5.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
|
|
4124
4213
|
console.log("ModelObject options", this.options);
|
|
4125
4214
|
}
|
|
4126
4215
|
async init() {
|
|
@@ -4163,10 +4252,10 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4163
4252
|
}
|
|
4164
4253
|
});
|
|
4165
4254
|
} else {
|
|
4166
|
-
console.debug(
|
|
4255
|
+
console.debug(p9, this.atlas.model, "has no elements");
|
|
4167
4256
|
}
|
|
4168
4257
|
} else {
|
|
4169
|
-
console.debug(
|
|
4258
|
+
console.debug(p9, "Missing atlas for", this);
|
|
4170
4259
|
}
|
|
4171
4260
|
if (this.options.mergeMeshes) {
|
|
4172
4261
|
let combinedGeo;
|
|
@@ -4218,16 +4307,16 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4218
4307
|
}
|
|
4219
4308
|
}
|
|
4220
4309
|
};
|
|
4221
|
-
_ModelObject.DEFAULT_OPTIONS = (0,
|
|
4310
|
+
_ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
4222
4311
|
var ModelObject = _ModelObject;
|
|
4223
4312
|
function isModelObject(obj) {
|
|
4224
4313
|
return obj.isModelObject;
|
|
4225
4314
|
}
|
|
4226
4315
|
|
|
4227
4316
|
// src/model/block/scene/BlockObject.ts
|
|
4228
|
-
var
|
|
4317
|
+
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4229
4318
|
var import_three16 = require("three");
|
|
4230
|
-
var
|
|
4319
|
+
var p10 = prefix("BlockObject");
|
|
4231
4320
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
4232
4321
|
constructor(blockState, options) {
|
|
4233
4322
|
super(options);
|
|
@@ -4241,11 +4330,11 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4241
4330
|
this._instanceModel = [];
|
|
4242
4331
|
this._variants = [];
|
|
4243
4332
|
this._models = [];
|
|
4244
|
-
this.options = (0,
|
|
4333
|
+
this.options = (0, import_ts_deepmerge6.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
4245
4334
|
}
|
|
4246
4335
|
async init() {
|
|
4247
4336
|
if (this.options.applyDefaultState) {
|
|
4248
|
-
const defaultState = this.blockState.key ? BlockStates.getDefaultState(this.blockState.key) : void 0;
|
|
4337
|
+
const defaultState = this.blockState.key ? await BlockStates.getDefaultState(this.blockState.key) : void 0;
|
|
4249
4338
|
if (defaultState && Object.keys(defaultState).length > 0) {
|
|
4250
4339
|
const state = {};
|
|
4251
4340
|
for (let k in defaultState) {
|
|
@@ -4321,7 +4410,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4321
4410
|
} else if (this.blockState.multipart) {
|
|
4322
4411
|
for (let part of this.blockState.multipart) {
|
|
4323
4412
|
if (!part.apply) {
|
|
4324
|
-
console.debug(
|
|
4413
|
+
console.debug(p10, "Missing apply for blockState part", part);
|
|
4325
4414
|
continue;
|
|
4326
4415
|
}
|
|
4327
4416
|
if (!part.when) {
|
|
@@ -4530,7 +4619,7 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4530
4619
|
//TODO: should override rotation + scale methods
|
|
4531
4620
|
//TODO
|
|
4532
4621
|
};
|
|
4533
|
-
_BlockObject.DEFAULT_OPTIONS = (0,
|
|
4622
|
+
_BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, ModelObject.DEFAULT_OPTIONS, {
|
|
4534
4623
|
applyDefaultState: true
|
|
4535
4624
|
});
|
|
4536
4625
|
var BlockObject = _BlockObject;
|
|
@@ -4580,7 +4669,7 @@ var StructureParser = class {
|
|
|
4580
4669
|
|
|
4581
4670
|
// src/renderer/MineRenderScene.ts
|
|
4582
4671
|
var import_three17 = require("three");
|
|
4583
|
-
var
|
|
4672
|
+
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
4584
4673
|
|
|
4585
4674
|
// src/skin/SkinPart.ts
|
|
4586
4675
|
var SkinPart = /* @__PURE__ */ ((SkinPart2) => {
|
|
@@ -5311,7 +5400,7 @@ var slimSkinGeometries = {
|
|
|
5311
5400
|
};
|
|
5312
5401
|
|
|
5313
5402
|
// src/skin/scene/SkinObject.ts
|
|
5314
|
-
var
|
|
5403
|
+
var import_ts_deepmerge7 = __toESM(require_dist());
|
|
5315
5404
|
var SkinObject = class extends SceneObject {
|
|
5316
5405
|
constructor(options) {
|
|
5317
5406
|
super();
|
|
@@ -5319,7 +5408,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5319
5408
|
this.legacy = false;
|
|
5320
5409
|
this.skinTextureWidth = 64;
|
|
5321
5410
|
this.skinTextureHeight = 64;
|
|
5322
|
-
this.options = (0,
|
|
5411
|
+
this.options = (0, import_ts_deepmerge7.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5323
5412
|
}
|
|
5324
5413
|
async init() {
|
|
5325
5414
|
this.createMeshes();
|
|
@@ -5430,24 +5519,54 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5430
5519
|
this.stats = new SceneStats();
|
|
5431
5520
|
this.instanceManager = new InstanceManager();
|
|
5432
5521
|
this.dirty = true;
|
|
5433
|
-
this.
|
|
5522
|
+
this.observedObjects = /* @__PURE__ */ new Set();
|
|
5523
|
+
this.onObjectChange = (event) => {
|
|
5524
|
+
if (event.target?.parent === this) {
|
|
5525
|
+
this.dirty = true;
|
|
5526
|
+
}
|
|
5527
|
+
};
|
|
5528
|
+
this.options = (0, import_ts_deepmerge8.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
5434
5529
|
}
|
|
5435
|
-
add(...
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5530
|
+
add(...objects) {
|
|
5531
|
+
for (const object of objects) {
|
|
5532
|
+
this.dirty = true;
|
|
5533
|
+
try {
|
|
5534
|
+
super.add(object);
|
|
5535
|
+
} finally {
|
|
5536
|
+
if (object?.isObject3D && object !== this) {
|
|
5537
|
+
this.updateObjectRegistration(object, object.parent === this);
|
|
5538
|
+
}
|
|
5441
5539
|
}
|
|
5442
|
-
obj.addEventListener("change", (event) => {
|
|
5443
|
-
this.dirty = true;
|
|
5444
|
-
});
|
|
5445
5540
|
}
|
|
5446
|
-
return
|
|
5541
|
+
return this;
|
|
5447
5542
|
}
|
|
5448
|
-
remove(...
|
|
5449
|
-
|
|
5450
|
-
|
|
5543
|
+
remove(...objects) {
|
|
5544
|
+
for (const object of objects) {
|
|
5545
|
+
if (!this.children.includes(object)) continue;
|
|
5546
|
+
this.dirty = true;
|
|
5547
|
+
this.updateObjectRegistration(object, false);
|
|
5548
|
+
try {
|
|
5549
|
+
super.remove(object);
|
|
5550
|
+
} finally {
|
|
5551
|
+
this.updateObjectRegistration(object, object.parent === this);
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
return this;
|
|
5555
|
+
}
|
|
5556
|
+
updateObjectRegistration(object, attached) {
|
|
5557
|
+
if (this.observedObjects.has(object) === attached) return;
|
|
5558
|
+
if (attached) {
|
|
5559
|
+
this.observedObjects.add(object);
|
|
5560
|
+
object.addEventListener("change", this.onObjectChange);
|
|
5561
|
+
} else {
|
|
5562
|
+
this.observedObjects.delete(object);
|
|
5563
|
+
object.removeEventListener("change", this.onObjectChange);
|
|
5564
|
+
}
|
|
5565
|
+
const change = attached ? 1 : -1;
|
|
5566
|
+
this.stats.objectCount += change;
|
|
5567
|
+
if (isSceneObject(object)) {
|
|
5568
|
+
this.stats.sceneObjectCount += change;
|
|
5569
|
+
}
|
|
5451
5570
|
}
|
|
5452
5571
|
async initAndAdd(...object) {
|
|
5453
5572
|
this.dirty = true;
|
|
@@ -5502,412 +5621,24 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5502
5621
|
return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
|
|
5503
5622
|
}
|
|
5504
5623
|
};
|
|
5505
|
-
_MineRenderScene.DEFAULT_OPTIONS = (0,
|
|
5624
|
+
_MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge8.default)({}, {});
|
|
5506
5625
|
var MineRenderScene = _MineRenderScene;
|
|
5507
5626
|
function isMineRenderScene(obj) {
|
|
5508
5627
|
return obj.isMineRenderScene;
|
|
5509
5628
|
}
|
|
5510
5629
|
|
|
5511
5630
|
// src/renderer/Renderer.ts
|
|
5512
|
-
var
|
|
5513
|
-
var
|
|
5631
|
+
var import_three19 = require("three");
|
|
5632
|
+
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
5514
5633
|
var import_stats = __toESM(require("stats.js"));
|
|
5515
5634
|
var import_postprocessing = require("postprocessing");
|
|
5516
|
-
var _Renderer = class _Renderer {
|
|
5517
|
-
constructor(options) {
|
|
5518
|
-
this._dirty = true;
|
|
5519
|
-
this._animationTimer = void 0;
|
|
5520
|
-
this._animationFrame = void 0;
|
|
5521
|
-
this._resizeListener = void 0;
|
|
5522
|
-
this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
|
|
5523
|
-
this._animationLoop = this.animate.bind(this);
|
|
5524
|
-
this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
|
|
5525
|
-
this._scene = this.createScene();
|
|
5526
|
-
this._camera = this.createCamera();
|
|
5527
|
-
this._renderer = this.createRenderer();
|
|
5528
|
-
this._composer = this.createComposer();
|
|
5529
|
-
if (this.options.render.stats) {
|
|
5530
|
-
this._stats = new import_stats.default();
|
|
5531
|
-
document.body.appendChild(this._stats.dom);
|
|
5532
|
-
}
|
|
5533
|
-
this.init();
|
|
5534
|
-
}
|
|
5535
|
-
//<editor-fold desc="INIT">
|
|
5536
|
-
createScene() {
|
|
5537
|
-
return new MineRenderScene();
|
|
5538
|
-
}
|
|
5539
|
-
createCamera() {
|
|
5540
|
-
switch (this.options.camera.type) {
|
|
5541
|
-
case "perspective":
|
|
5542
|
-
default:
|
|
5543
|
-
return new import_three18.PerspectiveCamera(
|
|
5544
|
-
this.options.camera.perspective.fov,
|
|
5545
|
-
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
5546
|
-
this.options.camera.near,
|
|
5547
|
-
this.options.camera.far
|
|
5548
|
-
);
|
|
5549
|
-
case "orthographic":
|
|
5550
|
-
return new import_three18.OrthographicCamera(
|
|
5551
|
-
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
5552
|
-
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
5553
|
-
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
5554
|
-
this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
|
|
5555
|
-
this.options.camera.near,
|
|
5556
|
-
this.options.camera.far
|
|
5557
|
-
);
|
|
5558
|
-
}
|
|
5559
|
-
}
|
|
5560
|
-
createRenderer() {
|
|
5561
|
-
const renderer = new import_three18.WebGLRenderer({
|
|
5562
|
-
antialias: this.options.render.antialias,
|
|
5563
|
-
alpha: true,
|
|
5564
|
-
powerPreference: "high-performance",
|
|
5565
|
-
depth: true
|
|
5566
|
-
});
|
|
5567
|
-
renderer.setClearColor(0, 0);
|
|
5568
|
-
renderer.shadowMap.enabled = true;
|
|
5569
|
-
renderer.shadowMap.type = import_three18.PCFSoftShadowMap;
|
|
5570
|
-
renderer.outputEncoding = import_three18.LinearEncoding;
|
|
5571
|
-
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
5572
|
-
return renderer;
|
|
5573
|
-
}
|
|
5574
|
-
createComposer() {
|
|
5575
|
-
const composer = new import_postprocessing.EffectComposer(this.renderer);
|
|
5576
|
-
if (!this.options.composer.enabled) return composer;
|
|
5577
|
-
composer.setSize(this.viewWidth, this.viewHeight);
|
|
5578
|
-
composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
|
|
5579
|
-
return composer;
|
|
5580
|
-
}
|
|
5581
|
-
//</editor-fold>
|
|
5582
|
-
init() {
|
|
5583
|
-
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
5584
|
-
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
5585
|
-
}
|
|
5586
|
-
if (this.options.debug.grid) {
|
|
5587
|
-
const gridHelper = new import_three18.GridHelper(128, 16);
|
|
5588
|
-
this.scene.add(gridHelper);
|
|
5589
|
-
const gridHelper2 = new import_three18.GridHelper(128, 16);
|
|
5590
|
-
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
5591
|
-
this.scene.add(gridHelper2);
|
|
5592
|
-
const gridHelper3 = new import_three18.GridHelper(128, 16);
|
|
5593
|
-
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
5594
|
-
this.scene.add(gridHelper3);
|
|
5595
|
-
}
|
|
5596
|
-
if (this.options.debug.axes) {
|
|
5597
|
-
const axesHelper = new import_three18.AxesHelper(64);
|
|
5598
|
-
this.scene.add(axesHelper);
|
|
5599
|
-
}
|
|
5600
|
-
if (this.options.camera.position) {
|
|
5601
|
-
if (isVector3(this.options.camera.position)) {
|
|
5602
|
-
this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
|
|
5603
|
-
} else if (isTripleArray(this.options.camera.position)) {
|
|
5604
|
-
this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
|
|
5605
|
-
}
|
|
5606
|
-
}
|
|
5607
|
-
if (this.options.camera.lookingAt) {
|
|
5608
|
-
if (isVector3(this.options.camera.lookingAt)) {
|
|
5609
|
-
this.camera.lookAt(this.options.camera.lookingAt);
|
|
5610
|
-
} else if (isTripleArray(this.options.camera.lookingAt)) {
|
|
5611
|
-
this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
|
|
5612
|
-
}
|
|
5613
|
-
}
|
|
5614
|
-
if (this.options.render.autoResize) {
|
|
5615
|
-
this._resizeListener = () => {
|
|
5616
|
-
this.resize(this.viewWidth, this.viewHeight);
|
|
5617
|
-
};
|
|
5618
|
-
window.addEventListener("resize", this._resizeListener);
|
|
5619
|
-
}
|
|
5620
|
-
}
|
|
5621
|
-
get element() {
|
|
5622
|
-
return this._element;
|
|
5623
|
-
}
|
|
5624
|
-
appendTo(element) {
|
|
5625
|
-
this._element = element;
|
|
5626
|
-
this._element.appendChild(this.renderer.domElement);
|
|
5627
|
-
if (this.viewWidth == 0) {
|
|
5628
|
-
console.warn("0 element width");
|
|
5629
|
-
}
|
|
5630
|
-
if (this.viewHeight == 0) {
|
|
5631
|
-
console.warn("0 element height");
|
|
5632
|
-
}
|
|
5633
|
-
this.resize(this.viewWidth, this.viewHeight);
|
|
5634
|
-
}
|
|
5635
|
-
/**
|
|
5636
|
-
* Register an EventDispatcher which may update the scene or renderer in order to redraw the scene
|
|
5637
|
-
*/
|
|
5638
|
-
registerEventDispatcher(dispatcher, changeEvent2 = "change") {
|
|
5639
|
-
dispatcher.addEventListener(changeEvent2, (event) => {
|
|
5640
|
-
this._dirty = true;
|
|
5641
|
-
});
|
|
5642
|
-
}
|
|
5643
|
-
resize(width, height) {
|
|
5644
|
-
if (isPerspectiveCamera(this.camera)) {
|
|
5645
|
-
this.camera.aspect = width / height;
|
|
5646
|
-
this.camera.updateProjectionMatrix();
|
|
5647
|
-
} else if (isOrthographicCamera(this.camera)) {
|
|
5648
|
-
this.camera.left = width / -2;
|
|
5649
|
-
this.camera.right = width / 2;
|
|
5650
|
-
this.camera.top = height / 2;
|
|
5651
|
-
this.camera.bottom = height / -2;
|
|
5652
|
-
this.camera.updateProjectionMatrix();
|
|
5653
|
-
}
|
|
5654
|
-
this.renderer.setSize(width, height);
|
|
5655
|
-
this.composer.setSize(width, height);
|
|
5656
|
-
}
|
|
5657
|
-
//<editor-fold desc="RENDER">
|
|
5658
|
-
get dirty() {
|
|
5659
|
-
return this._dirty || this.scene.dirty;
|
|
5660
|
-
}
|
|
5661
|
-
set dirty(dirty) {
|
|
5662
|
-
this._dirty = dirty;
|
|
5663
|
-
this.scene.dirty = dirty;
|
|
5664
|
-
}
|
|
5665
|
-
start() {
|
|
5666
|
-
stop();
|
|
5667
|
-
this.renderer.setAnimationLoop(this._animationLoop);
|
|
5668
|
-
}
|
|
5669
|
-
stop() {
|
|
5670
|
-
this.renderer.setAnimationLoop(null);
|
|
5671
|
-
if (this._animationTimer)
|
|
5672
|
-
clearTimeout(this._animationTimer);
|
|
5673
|
-
this._animationTimer = void 0;
|
|
5674
|
-
if (this._animationFrame)
|
|
5675
|
-
cancelAnimationFrame(this._animationFrame);
|
|
5676
|
-
this._animationFrame = void 0;
|
|
5677
|
-
}
|
|
5678
|
-
animate(t) {
|
|
5679
|
-
if (this._stats) {
|
|
5680
|
-
this._stats.begin();
|
|
5681
|
-
}
|
|
5682
|
-
if (this.dirty || this.options.render.renderAlways) {
|
|
5683
|
-
if (this.options.composer.enabled) {
|
|
5684
|
-
this.composer.render();
|
|
5685
|
-
} else {
|
|
5686
|
-
this.renderer.render(this.scene, this.camera);
|
|
5687
|
-
}
|
|
5688
|
-
}
|
|
5689
|
-
this.dirty = false;
|
|
5690
|
-
if (this._stats) {
|
|
5691
|
-
this._stats.end();
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5694
|
-
//</editor-fold>
|
|
5695
|
-
toImage() {
|
|
5696
|
-
return this.renderer.domElement.toDataURL();
|
|
5697
|
-
}
|
|
5698
|
-
///
|
|
5699
|
-
get attachedToBody() {
|
|
5700
|
-
return this.element === document.body;
|
|
5701
|
-
}
|
|
5702
|
-
get viewWidth() {
|
|
5703
|
-
return this.attachedToBody ? window.innerWidth : this.element?.offsetWidth || 0;
|
|
5704
|
-
}
|
|
5705
|
-
get viewHeight() {
|
|
5706
|
-
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
5707
|
-
}
|
|
5708
|
-
get scene() {
|
|
5709
|
-
return this._scene;
|
|
5710
|
-
}
|
|
5711
|
-
get camera() {
|
|
5712
|
-
return this._camera;
|
|
5713
|
-
}
|
|
5714
|
-
get renderer() {
|
|
5715
|
-
return this._renderer;
|
|
5716
|
-
}
|
|
5717
|
-
get composer() {
|
|
5718
|
-
return this._composer;
|
|
5719
|
-
}
|
|
5720
|
-
///
|
|
5721
|
-
};
|
|
5722
|
-
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
|
|
5723
|
-
camera: {
|
|
5724
|
-
type: "perspective",
|
|
5725
|
-
near: 1,
|
|
5726
|
-
far: 5e3,
|
|
5727
|
-
perspective: {
|
|
5728
|
-
aspect: void 0,
|
|
5729
|
-
fov: 50
|
|
5730
|
-
},
|
|
5731
|
-
orthographic: {
|
|
5732
|
-
left: void 0,
|
|
5733
|
-
right: void 0,
|
|
5734
|
-
top: void 0,
|
|
5735
|
-
bottom: void 0
|
|
5736
|
-
},
|
|
5737
|
-
position: new import_three18.Vector3(50, 50, 50),
|
|
5738
|
-
lookingAt: new import_three18.Vector3(0, 0, 0)
|
|
5739
|
-
},
|
|
5740
|
-
render: {
|
|
5741
|
-
fpsLimit: 60,
|
|
5742
|
-
stats: false,
|
|
5743
|
-
antialias: true,
|
|
5744
|
-
shade: true,
|
|
5745
|
-
autoResize: true,
|
|
5746
|
-
renderAlways: false
|
|
5747
|
-
},
|
|
5748
|
-
composer: {
|
|
5749
|
-
enabled: true
|
|
5750
|
-
},
|
|
5751
|
-
debug: {
|
|
5752
|
-
grid: false,
|
|
5753
|
-
axes: false
|
|
5754
|
-
}
|
|
5755
|
-
});
|
|
5756
|
-
var Renderer = _Renderer;
|
|
5757
|
-
|
|
5758
|
-
// src/skin/Skins.ts
|
|
5759
|
-
var Skins = class {
|
|
5760
|
-
//<editor-fold desc="Skins">
|
|
5761
|
-
static async fromUuidOrUsername(uuidOrUsername) {
|
|
5762
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
5763
|
-
return this.fromUuid(uuidOrUsername);
|
|
5764
|
-
}
|
|
5765
|
-
return this.fromUsername(uuidOrUsername);
|
|
5766
|
-
}
|
|
5767
|
-
static async fromUuid(uuid) {
|
|
5768
|
-
return this.getSkinProxySkinUrl(uuid);
|
|
5769
|
-
}
|
|
5770
|
-
static async fromUsername(username) {
|
|
5771
|
-
return this.usernameToUuid(username).then((uuid) => {
|
|
5772
|
-
if (uuid) {
|
|
5773
|
-
return this.fromUuid(uuid);
|
|
5774
|
-
}
|
|
5775
|
-
return void 0;
|
|
5776
|
-
});
|
|
5777
|
-
}
|
|
5778
|
-
static async fromMineSkin(mineskinId) {
|
|
5779
|
-
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
5780
|
-
if (mineskin) {
|
|
5781
|
-
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
5782
|
-
}
|
|
5783
|
-
return void 0;
|
|
5784
|
-
});
|
|
5785
|
-
}
|
|
5786
|
-
//</editor-fold>
|
|
5787
|
-
//<editor-fold desc="Capes">
|
|
5788
|
-
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
5789
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
5790
|
-
return this.capeFromUuid(uuidOrUsername);
|
|
5791
|
-
}
|
|
5792
|
-
return this.capeFromUsername(uuidOrUsername);
|
|
5793
|
-
}
|
|
5794
|
-
static async capeFromUuid(uuid) {
|
|
5795
|
-
return this.getSkinProxyCapeUrl(uuid);
|
|
5796
|
-
}
|
|
5797
|
-
static async capeFromUsername(username) {
|
|
5798
|
-
return this.usernameToUuid(username).then((uuid) => {
|
|
5799
|
-
if (uuid) {
|
|
5800
|
-
return this.capeFromUuid(uuid);
|
|
5801
|
-
}
|
|
5802
|
-
return void 0;
|
|
5803
|
-
});
|
|
5804
|
-
}
|
|
5805
|
-
static async capeFromCapesDev(uuid, capeType = "minecraft") {
|
|
5806
|
-
return this.getCapesDev(uuid, capeType).then((cape) => {
|
|
5807
|
-
if (cape) {
|
|
5808
|
-
return cape?.stillImageUrl;
|
|
5809
|
-
}
|
|
5810
|
-
return void 0;
|
|
5811
|
-
});
|
|
5812
|
-
}
|
|
5813
|
-
//</editor-fold>
|
|
5814
|
-
//<editor-fold desc="Helpers">
|
|
5815
|
-
static async usernameToUuid(username) {
|
|
5816
|
-
return this.usernameToUuidSkinProxy(username);
|
|
5817
|
-
}
|
|
5818
|
-
static async usernameToUuidSkinProxy(username) {
|
|
5819
|
-
return Requests.genericRequest({
|
|
5820
|
-
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
5821
|
-
url: "/uuid/" + username
|
|
5822
|
-
}).then((res) => {
|
|
5823
|
-
if (res.status === 200) {
|
|
5824
|
-
return res.data["id"];
|
|
5825
|
-
}
|
|
5826
|
-
return void 0;
|
|
5827
|
-
}).catch((err) => {
|
|
5828
|
-
console.warn(err);
|
|
5829
|
-
return void 0;
|
|
5830
|
-
});
|
|
5831
|
-
}
|
|
5832
|
-
static async usernameToUuidMineTools(username) {
|
|
5833
|
-
return Requests.genericRequest({
|
|
5834
|
-
baseURL: "https://api.minetools.eu",
|
|
5835
|
-
url: "/uuid/" + username
|
|
5836
|
-
}).then((res) => {
|
|
5837
|
-
if (res.status === 200) {
|
|
5838
|
-
return res.data["id"];
|
|
5839
|
-
}
|
|
5840
|
-
return void 0;
|
|
5841
|
-
}).catch((err) => {
|
|
5842
|
-
console.warn(err);
|
|
5843
|
-
return void 0;
|
|
5844
|
-
});
|
|
5845
|
-
}
|
|
5846
|
-
static async getProfileFromMinetools(uuid) {
|
|
5847
|
-
return Requests.genericRequest({
|
|
5848
|
-
baseURL: "https://api.minetools.eu",
|
|
5849
|
-
url: "/profile/" + uuid
|
|
5850
|
-
}).then((res) => {
|
|
5851
|
-
if (res.status === 200) {
|
|
5852
|
-
return res.data;
|
|
5853
|
-
}
|
|
5854
|
-
});
|
|
5855
|
-
}
|
|
5856
|
-
static async getMineSkin(mineskinId) {
|
|
5857
|
-
return Requests.genericRequest({
|
|
5858
|
-
baseURL: "https://api.mineskin.org",
|
|
5859
|
-
url: "/get/uuid/" + mineskinId
|
|
5860
|
-
}).then((res) => {
|
|
5861
|
-
if (res.status === 200) {
|
|
5862
|
-
return res.data;
|
|
5863
|
-
}
|
|
5864
|
-
return void 0;
|
|
5865
|
-
}).catch((err) => {
|
|
5866
|
-
console.warn(err);
|
|
5867
|
-
return void 0;
|
|
5868
|
-
});
|
|
5869
|
-
}
|
|
5870
|
-
static async getCapesDev(uuid, type = "all") {
|
|
5871
|
-
return Requests.genericRequest({
|
|
5872
|
-
baseURL: "https://api.capes.dev",
|
|
5873
|
-
url: "/load/" + uuid + "/" + type
|
|
5874
|
-
}).then((res) => {
|
|
5875
|
-
if (res.status === 200) {
|
|
5876
|
-
return res.data;
|
|
5877
|
-
}
|
|
5878
|
-
return void 0;
|
|
5879
|
-
}).catch((err) => {
|
|
5880
|
-
console.warn(err);
|
|
5881
|
-
return void 0;
|
|
5882
|
-
});
|
|
5883
|
-
}
|
|
5884
|
-
static getCrafatarSkinUrl(uuid) {
|
|
5885
|
-
return "https://crafatar.com/skins/" + uuid;
|
|
5886
|
-
}
|
|
5887
|
-
static getCrafatarCapeUrl(uuid) {
|
|
5888
|
-
return "https://crafatar.com/capes/" + uuid;
|
|
5889
|
-
}
|
|
5890
|
-
static getMcHeadsSkinUrl(uuid) {
|
|
5891
|
-
return "https://mc-heads.net/skin/" + uuid;
|
|
5892
|
-
}
|
|
5893
|
-
static getMineSkinPlayerSkinUrl(uuid) {
|
|
5894
|
-
return "https://mineskin.org/skin/player/" + uuid;
|
|
5895
|
-
}
|
|
5896
|
-
static getSkinProxySkinUrl(uuid) {
|
|
5897
|
-
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
5898
|
-
}
|
|
5899
|
-
static getSkinProxyCapeUrl(uuid) {
|
|
5900
|
-
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
5901
|
-
}
|
|
5902
|
-
//</editor-fold>
|
|
5903
|
-
};
|
|
5904
5635
|
|
|
5905
5636
|
// src/three/OrbitControls.js
|
|
5906
|
-
var
|
|
5637
|
+
var import_three18 = require("three");
|
|
5907
5638
|
var _changeEvent = { type: "change" };
|
|
5908
5639
|
var _startEvent = { type: "start" };
|
|
5909
5640
|
var _endEvent = { type: "end" };
|
|
5910
|
-
var OrbitControls = class extends
|
|
5641
|
+
var OrbitControls = class extends import_three18.EventDispatcher {
|
|
5911
5642
|
constructor(object, domElement) {
|
|
5912
5643
|
super();
|
|
5913
5644
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -5916,7 +5647,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
5916
5647
|
this.domElement = domElement;
|
|
5917
5648
|
this.domElement.style.touchAction = "none";
|
|
5918
5649
|
this.enabled = true;
|
|
5919
|
-
this.target = new
|
|
5650
|
+
this.target = new import_three18.Vector3();
|
|
5920
5651
|
this.minDistance = 0;
|
|
5921
5652
|
this.maxDistance = Infinity;
|
|
5922
5653
|
this.minZoom = 0;
|
|
@@ -5938,8 +5669,8 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
5938
5669
|
this.autoRotate = false;
|
|
5939
5670
|
this.autoRotateSpeed = 2;
|
|
5940
5671
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5941
|
-
this.mouseButtons = { LEFT:
|
|
5942
|
-
this.touches = { ONE:
|
|
5672
|
+
this.mouseButtons = { LEFT: import_three18.MOUSE.ROTATE, MIDDLE: import_three18.MOUSE.DOLLY, RIGHT: import_three18.MOUSE.PAN };
|
|
5673
|
+
this.touches = { ONE: import_three18.TOUCH.ROTATE, TWO: import_three18.TOUCH.DOLLY_PAN };
|
|
5943
5674
|
this.target0 = this.target.clone();
|
|
5944
5675
|
this.position0 = this.object.position.clone();
|
|
5945
5676
|
this.zoom0 = this.object.zoom;
|
|
@@ -5968,11 +5699,11 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
5968
5699
|
state = STATE.NONE;
|
|
5969
5700
|
};
|
|
5970
5701
|
this.update = function() {
|
|
5971
|
-
const offset = new
|
|
5972
|
-
const quat = new
|
|
5702
|
+
const offset = new import_three18.Vector3();
|
|
5703
|
+
const quat = new import_three18.Quaternion().setFromUnitVectors(object.up, new import_three18.Vector3(0, 1, 0));
|
|
5973
5704
|
const quatInverse = quat.clone().invert();
|
|
5974
|
-
const lastPosition = new
|
|
5975
|
-
const lastQuaternion = new
|
|
5705
|
+
const lastPosition = new import_three18.Vector3();
|
|
5706
|
+
const lastQuaternion = new import_three18.Quaternion();
|
|
5976
5707
|
const twoPI = 2 * Math.PI;
|
|
5977
5708
|
return function update() {
|
|
5978
5709
|
const position = scope.object.position;
|
|
@@ -6058,20 +5789,20 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6058
5789
|
};
|
|
6059
5790
|
let state = STATE.NONE;
|
|
6060
5791
|
const EPS = 1e-6;
|
|
6061
|
-
const spherical = new
|
|
6062
|
-
const sphericalDelta = new
|
|
5792
|
+
const spherical = new import_three18.Spherical();
|
|
5793
|
+
const sphericalDelta = new import_three18.Spherical();
|
|
6063
5794
|
let scale = 1;
|
|
6064
|
-
const panOffset = new
|
|
5795
|
+
const panOffset = new import_three18.Vector3();
|
|
6065
5796
|
let zoomChanged = false;
|
|
6066
|
-
const rotateStart = new
|
|
6067
|
-
const rotateEnd = new
|
|
6068
|
-
const rotateDelta = new
|
|
6069
|
-
const panStart = new
|
|
6070
|
-
const panEnd = new
|
|
6071
|
-
const panDelta = new
|
|
6072
|
-
const dollyStart = new
|
|
6073
|
-
const dollyEnd = new
|
|
6074
|
-
const dollyDelta = new
|
|
5797
|
+
const rotateStart = new import_three18.Vector2();
|
|
5798
|
+
const rotateEnd = new import_three18.Vector2();
|
|
5799
|
+
const rotateDelta = new import_three18.Vector2();
|
|
5800
|
+
const panStart = new import_three18.Vector2();
|
|
5801
|
+
const panEnd = new import_three18.Vector2();
|
|
5802
|
+
const panDelta = new import_three18.Vector2();
|
|
5803
|
+
const dollyStart = new import_three18.Vector2();
|
|
5804
|
+
const dollyEnd = new import_three18.Vector2();
|
|
5805
|
+
const dollyDelta = new import_three18.Vector2();
|
|
6075
5806
|
const pointers = [];
|
|
6076
5807
|
const pointerPositions = {};
|
|
6077
5808
|
function getAutoRotationAngle() {
|
|
@@ -6087,7 +5818,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6087
5818
|
sphericalDelta.phi -= angle;
|
|
6088
5819
|
}
|
|
6089
5820
|
const panLeft = function() {
|
|
6090
|
-
const v = new
|
|
5821
|
+
const v = new import_three18.Vector3();
|
|
6091
5822
|
return function panLeft2(distance, objectMatrix) {
|
|
6092
5823
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6093
5824
|
v.multiplyScalar(-distance);
|
|
@@ -6095,7 +5826,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6095
5826
|
};
|
|
6096
5827
|
}();
|
|
6097
5828
|
const panUp = function() {
|
|
6098
|
-
const v = new
|
|
5829
|
+
const v = new import_three18.Vector3();
|
|
6099
5830
|
return function panUp2(distance, objectMatrix) {
|
|
6100
5831
|
if (scope.screenSpacePanning === true) {
|
|
6101
5832
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -6108,7 +5839,7 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6108
5839
|
};
|
|
6109
5840
|
}();
|
|
6110
5841
|
const pan = function() {
|
|
6111
|
-
const offset = new
|
|
5842
|
+
const offset = new import_three18.Vector3();
|
|
6112
5843
|
return function pan2(deltaX, deltaY) {
|
|
6113
5844
|
const element = scope.domElement;
|
|
6114
5845
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -6177,371 +5908,853 @@ var OrbitControls = class extends import_three20.EventDispatcher {
|
|
|
6177
5908
|
} else if (dollyDelta.y < 0) {
|
|
6178
5909
|
dollyIn(getZoomScale());
|
|
6179
5910
|
}
|
|
6180
|
-
dollyStart.copy(dollyEnd);
|
|
6181
|
-
scope.update();
|
|
5911
|
+
dollyStart.copy(dollyEnd);
|
|
5912
|
+
scope.update();
|
|
5913
|
+
}
|
|
5914
|
+
function handleMouseMovePan(event) {
|
|
5915
|
+
panEnd.set(event.clientX, event.clientY);
|
|
5916
|
+
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
5917
|
+
pan(panDelta.x, panDelta.y);
|
|
5918
|
+
panStart.copy(panEnd);
|
|
5919
|
+
scope.update();
|
|
5920
|
+
}
|
|
5921
|
+
function handleMouseUp() {
|
|
5922
|
+
}
|
|
5923
|
+
function handleMouseWheel(event) {
|
|
5924
|
+
if (event.deltaY < 0) {
|
|
5925
|
+
dollyIn(getZoomScale());
|
|
5926
|
+
} else if (event.deltaY > 0) {
|
|
5927
|
+
dollyOut(getZoomScale());
|
|
5928
|
+
}
|
|
5929
|
+
scope.update();
|
|
5930
|
+
}
|
|
5931
|
+
function handleKeyDown(event) {
|
|
5932
|
+
let needsUpdate = false;
|
|
5933
|
+
switch (event.code) {
|
|
5934
|
+
case scope.keys.UP:
|
|
5935
|
+
pan(0, scope.keyPanSpeed);
|
|
5936
|
+
needsUpdate = true;
|
|
5937
|
+
break;
|
|
5938
|
+
case scope.keys.BOTTOM:
|
|
5939
|
+
pan(0, -scope.keyPanSpeed);
|
|
5940
|
+
needsUpdate = true;
|
|
5941
|
+
break;
|
|
5942
|
+
case scope.keys.LEFT:
|
|
5943
|
+
pan(scope.keyPanSpeed, 0);
|
|
5944
|
+
needsUpdate = true;
|
|
5945
|
+
break;
|
|
5946
|
+
case scope.keys.RIGHT:
|
|
5947
|
+
pan(-scope.keyPanSpeed, 0);
|
|
5948
|
+
needsUpdate = true;
|
|
5949
|
+
break;
|
|
5950
|
+
}
|
|
5951
|
+
if (needsUpdate) {
|
|
5952
|
+
event.preventDefault();
|
|
5953
|
+
scope.update();
|
|
5954
|
+
}
|
|
5955
|
+
}
|
|
5956
|
+
function handleTouchStartRotate() {
|
|
5957
|
+
if (pointers.length === 1) {
|
|
5958
|
+
rotateStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
5959
|
+
} else {
|
|
5960
|
+
const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
5961
|
+
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
5962
|
+
rotateStart.set(x, y);
|
|
5963
|
+
}
|
|
5964
|
+
}
|
|
5965
|
+
function handleTouchStartPan() {
|
|
5966
|
+
if (pointers.length === 1) {
|
|
5967
|
+
panStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
5968
|
+
} else {
|
|
5969
|
+
const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
5970
|
+
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
5971
|
+
panStart.set(x, y);
|
|
5972
|
+
}
|
|
5973
|
+
}
|
|
5974
|
+
function handleTouchStartDolly() {
|
|
5975
|
+
const dx = pointers[0].pageX - pointers[1].pageX;
|
|
5976
|
+
const dy = pointers[0].pageY - pointers[1].pageY;
|
|
5977
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
5978
|
+
dollyStart.set(0, distance);
|
|
5979
|
+
}
|
|
5980
|
+
function handleTouchStartDollyPan() {
|
|
5981
|
+
if (scope.enableZoom) handleTouchStartDolly();
|
|
5982
|
+
if (scope.enablePan) handleTouchStartPan();
|
|
5983
|
+
}
|
|
5984
|
+
function handleTouchStartDollyRotate() {
|
|
5985
|
+
if (scope.enableZoom) handleTouchStartDolly();
|
|
5986
|
+
if (scope.enableRotate) handleTouchStartRotate();
|
|
5987
|
+
}
|
|
5988
|
+
function handleTouchMoveRotate(event) {
|
|
5989
|
+
if (pointers.length == 1) {
|
|
5990
|
+
rotateEnd.set(event.pageX, event.pageY);
|
|
5991
|
+
} else {
|
|
5992
|
+
const position = getSecondPointerPosition(event);
|
|
5993
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
5994
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
5995
|
+
rotateEnd.set(x, y);
|
|
5996
|
+
}
|
|
5997
|
+
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
5998
|
+
const element = scope.domElement;
|
|
5999
|
+
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
6000
|
+
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
6001
|
+
rotateStart.copy(rotateEnd);
|
|
6002
|
+
}
|
|
6003
|
+
function handleTouchMovePan(event) {
|
|
6004
|
+
if (pointers.length === 1) {
|
|
6005
|
+
panEnd.set(event.pageX, event.pageY);
|
|
6006
|
+
} else {
|
|
6007
|
+
const position = getSecondPointerPosition(event);
|
|
6008
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
6009
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
6010
|
+
panEnd.set(x, y);
|
|
6011
|
+
}
|
|
6012
|
+
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
6013
|
+
pan(panDelta.x, panDelta.y);
|
|
6014
|
+
panStart.copy(panEnd);
|
|
6015
|
+
}
|
|
6016
|
+
function handleTouchMoveDolly(event) {
|
|
6017
|
+
const position = getSecondPointerPosition(event);
|
|
6018
|
+
const dx = event.pageX - position.x;
|
|
6019
|
+
const dy = event.pageY - position.y;
|
|
6020
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6021
|
+
dollyEnd.set(0, distance);
|
|
6022
|
+
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
6023
|
+
dollyOut(dollyDelta.y);
|
|
6024
|
+
dollyStart.copy(dollyEnd);
|
|
6025
|
+
}
|
|
6026
|
+
function handleTouchMoveDollyPan(event) {
|
|
6027
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6028
|
+
if (scope.enablePan) handleTouchMovePan(event);
|
|
6029
|
+
}
|
|
6030
|
+
function handleTouchMoveDollyRotate(event) {
|
|
6031
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6032
|
+
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
6033
|
+
}
|
|
6034
|
+
function handleTouchEnd() {
|
|
6035
|
+
}
|
|
6036
|
+
function onPointerDown(event) {
|
|
6037
|
+
if (scope.enabled === false) return;
|
|
6038
|
+
if (pointers.length === 0) {
|
|
6039
|
+
scope.domElement.setPointerCapture(event.pointerId);
|
|
6040
|
+
scope.domElement.addEventListener("pointermove", onPointerMove);
|
|
6041
|
+
scope.domElement.addEventListener("pointerup", onPointerUp);
|
|
6042
|
+
}
|
|
6043
|
+
addPointer(event);
|
|
6044
|
+
if (event.pointerType === "touch") {
|
|
6045
|
+
onTouchStart(event);
|
|
6046
|
+
} else {
|
|
6047
|
+
onMouseDown(event);
|
|
6048
|
+
}
|
|
6049
|
+
}
|
|
6050
|
+
function onPointerMove(event) {
|
|
6051
|
+
if (scope.enabled === false) return;
|
|
6052
|
+
if (event.pointerType === "touch") {
|
|
6053
|
+
onTouchMove(event);
|
|
6054
|
+
} else {
|
|
6055
|
+
onMouseMove(event);
|
|
6056
|
+
}
|
|
6057
|
+
}
|
|
6058
|
+
function onPointerUp(event) {
|
|
6059
|
+
if (scope.enabled === false) return;
|
|
6060
|
+
if (event.pointerType === "touch") {
|
|
6061
|
+
onTouchEnd();
|
|
6062
|
+
} else {
|
|
6063
|
+
onMouseUp(event);
|
|
6064
|
+
}
|
|
6065
|
+
removePointer(event);
|
|
6066
|
+
if (pointers.length === 0) {
|
|
6067
|
+
scope.domElement.releasePointerCapture(event.pointerId);
|
|
6068
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
6069
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
6070
|
+
}
|
|
6071
|
+
}
|
|
6072
|
+
function onPointerCancel(event) {
|
|
6073
|
+
removePointer(event);
|
|
6074
|
+
}
|
|
6075
|
+
function onMouseDown(event) {
|
|
6076
|
+
let mouseAction;
|
|
6077
|
+
switch (event.button) {
|
|
6078
|
+
case 0:
|
|
6079
|
+
mouseAction = scope.mouseButtons.LEFT;
|
|
6080
|
+
break;
|
|
6081
|
+
case 1:
|
|
6082
|
+
mouseAction = scope.mouseButtons.MIDDLE;
|
|
6083
|
+
break;
|
|
6084
|
+
case 2:
|
|
6085
|
+
mouseAction = scope.mouseButtons.RIGHT;
|
|
6086
|
+
break;
|
|
6087
|
+
default:
|
|
6088
|
+
mouseAction = -1;
|
|
6089
|
+
}
|
|
6090
|
+
switch (mouseAction) {
|
|
6091
|
+
case import_three18.MOUSE.DOLLY:
|
|
6092
|
+
if (scope.enableZoom === false) return;
|
|
6093
|
+
handleMouseDownDolly(event);
|
|
6094
|
+
state = STATE.DOLLY;
|
|
6095
|
+
break;
|
|
6096
|
+
case import_three18.MOUSE.ROTATE:
|
|
6097
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6098
|
+
if (scope.enablePan === false) return;
|
|
6099
|
+
handleMouseDownPan(event);
|
|
6100
|
+
state = STATE.PAN;
|
|
6101
|
+
} else {
|
|
6102
|
+
if (scope.enableRotate === false) return;
|
|
6103
|
+
handleMouseDownRotate(event);
|
|
6104
|
+
state = STATE.ROTATE;
|
|
6105
|
+
}
|
|
6106
|
+
break;
|
|
6107
|
+
case import_three18.MOUSE.PAN:
|
|
6108
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6109
|
+
if (scope.enableRotate === false) return;
|
|
6110
|
+
handleMouseDownRotate(event);
|
|
6111
|
+
state = STATE.ROTATE;
|
|
6112
|
+
} else {
|
|
6113
|
+
if (scope.enablePan === false) return;
|
|
6114
|
+
handleMouseDownPan(event);
|
|
6115
|
+
state = STATE.PAN;
|
|
6116
|
+
}
|
|
6117
|
+
break;
|
|
6118
|
+
default:
|
|
6119
|
+
state = STATE.NONE;
|
|
6120
|
+
}
|
|
6121
|
+
if (state !== STATE.NONE) {
|
|
6122
|
+
scope.dispatchEvent(_startEvent);
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
function onMouseMove(event) {
|
|
6126
|
+
if (scope.enabled === false) return;
|
|
6127
|
+
switch (state) {
|
|
6128
|
+
case STATE.ROTATE:
|
|
6129
|
+
if (scope.enableRotate === false) return;
|
|
6130
|
+
handleMouseMoveRotate(event);
|
|
6131
|
+
break;
|
|
6132
|
+
case STATE.DOLLY:
|
|
6133
|
+
if (scope.enableZoom === false) return;
|
|
6134
|
+
handleMouseMoveDolly(event);
|
|
6135
|
+
break;
|
|
6136
|
+
case STATE.PAN:
|
|
6137
|
+
if (scope.enablePan === false) return;
|
|
6138
|
+
handleMouseMovePan(event);
|
|
6139
|
+
break;
|
|
6140
|
+
}
|
|
6182
6141
|
}
|
|
6183
|
-
function
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
panStart.copy(panEnd);
|
|
6188
|
-
scope.update();
|
|
6142
|
+
function onMouseUp(event) {
|
|
6143
|
+
handleMouseUp(event);
|
|
6144
|
+
scope.dispatchEvent(_endEvent);
|
|
6145
|
+
state = STATE.NONE;
|
|
6189
6146
|
}
|
|
6190
|
-
function
|
|
6147
|
+
function onMouseWheel(event) {
|
|
6148
|
+
if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
|
|
6149
|
+
event.preventDefault();
|
|
6150
|
+
scope.dispatchEvent(_startEvent);
|
|
6151
|
+
handleMouseWheel(event);
|
|
6152
|
+
scope.dispatchEvent(_endEvent);
|
|
6191
6153
|
}
|
|
6192
|
-
function
|
|
6193
|
-
if (
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6154
|
+
function onKeyDown(event) {
|
|
6155
|
+
if (scope.enabled === false || scope.enablePan === false) return;
|
|
6156
|
+
handleKeyDown(event);
|
|
6157
|
+
}
|
|
6158
|
+
function onTouchStart(event) {
|
|
6159
|
+
trackPointer(event);
|
|
6160
|
+
switch (pointers.length) {
|
|
6161
|
+
case 1:
|
|
6162
|
+
switch (scope.touches.ONE) {
|
|
6163
|
+
case import_three18.TOUCH.ROTATE:
|
|
6164
|
+
if (scope.enableRotate === false) return;
|
|
6165
|
+
handleTouchStartRotate();
|
|
6166
|
+
state = STATE.TOUCH_ROTATE;
|
|
6167
|
+
break;
|
|
6168
|
+
case import_three18.TOUCH.PAN:
|
|
6169
|
+
if (scope.enablePan === false) return;
|
|
6170
|
+
handleTouchStartPan();
|
|
6171
|
+
state = STATE.TOUCH_PAN;
|
|
6172
|
+
break;
|
|
6173
|
+
default:
|
|
6174
|
+
state = STATE.NONE;
|
|
6175
|
+
}
|
|
6176
|
+
break;
|
|
6177
|
+
case 2:
|
|
6178
|
+
switch (scope.touches.TWO) {
|
|
6179
|
+
case import_three18.TOUCH.DOLLY_PAN:
|
|
6180
|
+
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6181
|
+
handleTouchStartDollyPan();
|
|
6182
|
+
state = STATE.TOUCH_DOLLY_PAN;
|
|
6183
|
+
break;
|
|
6184
|
+
case import_three18.TOUCH.DOLLY_ROTATE:
|
|
6185
|
+
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6186
|
+
handleTouchStartDollyRotate();
|
|
6187
|
+
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
6188
|
+
break;
|
|
6189
|
+
default:
|
|
6190
|
+
state = STATE.NONE;
|
|
6191
|
+
}
|
|
6192
|
+
break;
|
|
6193
|
+
default:
|
|
6194
|
+
state = STATE.NONE;
|
|
6195
|
+
}
|
|
6196
|
+
if (state !== STATE.NONE) {
|
|
6197
|
+
scope.dispatchEvent(_startEvent);
|
|
6197
6198
|
}
|
|
6198
|
-
scope.update();
|
|
6199
6199
|
}
|
|
6200
|
-
function
|
|
6201
|
-
|
|
6202
|
-
switch (
|
|
6203
|
-
case
|
|
6204
|
-
|
|
6205
|
-
|
|
6200
|
+
function onTouchMove(event) {
|
|
6201
|
+
trackPointer(event);
|
|
6202
|
+
switch (state) {
|
|
6203
|
+
case STATE.TOUCH_ROTATE:
|
|
6204
|
+
if (scope.enableRotate === false) return;
|
|
6205
|
+
handleTouchMoveRotate(event);
|
|
6206
|
+
scope.update();
|
|
6206
6207
|
break;
|
|
6207
|
-
case
|
|
6208
|
-
|
|
6209
|
-
|
|
6208
|
+
case STATE.TOUCH_PAN:
|
|
6209
|
+
if (scope.enablePan === false) return;
|
|
6210
|
+
handleTouchMovePan(event);
|
|
6211
|
+
scope.update();
|
|
6210
6212
|
break;
|
|
6211
|
-
case
|
|
6212
|
-
|
|
6213
|
-
|
|
6213
|
+
case STATE.TOUCH_DOLLY_PAN:
|
|
6214
|
+
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6215
|
+
handleTouchMoveDollyPan(event);
|
|
6216
|
+
scope.update();
|
|
6214
6217
|
break;
|
|
6215
|
-
case
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
+
case STATE.TOUCH_DOLLY_ROTATE:
|
|
6219
|
+
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6220
|
+
handleTouchMoveDollyRotate(event);
|
|
6221
|
+
scope.update();
|
|
6218
6222
|
break;
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
event.preventDefault();
|
|
6222
|
-
scope.update();
|
|
6223
|
+
default:
|
|
6224
|
+
state = STATE.NONE;
|
|
6223
6225
|
}
|
|
6224
6226
|
}
|
|
6225
|
-
function
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6227
|
+
function onTouchEnd(event) {
|
|
6228
|
+
handleTouchEnd(event);
|
|
6229
|
+
scope.dispatchEvent(_endEvent);
|
|
6230
|
+
state = STATE.NONE;
|
|
6231
|
+
}
|
|
6232
|
+
function onContextMenu(event) {
|
|
6233
|
+
if (scope.enabled === false) return;
|
|
6234
|
+
event.preventDefault();
|
|
6235
|
+
}
|
|
6236
|
+
function addPointer(event) {
|
|
6237
|
+
pointers.push(event);
|
|
6238
|
+
}
|
|
6239
|
+
function removePointer(event) {
|
|
6240
|
+
delete pointerPositions[event.pointerId];
|
|
6241
|
+
for (let i = 0; i < pointers.length; i++) {
|
|
6242
|
+
if (pointers[i].pointerId == event.pointerId) {
|
|
6243
|
+
pointers.splice(i, 1);
|
|
6244
|
+
return;
|
|
6245
|
+
}
|
|
6232
6246
|
}
|
|
6233
6247
|
}
|
|
6234
|
-
function
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
6240
|
-
panStart.set(x, y);
|
|
6248
|
+
function trackPointer(event) {
|
|
6249
|
+
let position = pointerPositions[event.pointerId];
|
|
6250
|
+
if (position === void 0) {
|
|
6251
|
+
position = new import_three18.Vector2();
|
|
6252
|
+
pointerPositions[event.pointerId] = position;
|
|
6241
6253
|
}
|
|
6254
|
+
position.set(event.pageX, event.pageY);
|
|
6242
6255
|
}
|
|
6243
|
-
function
|
|
6244
|
-
const
|
|
6245
|
-
|
|
6246
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6247
|
-
dollyStart.set(0, distance);
|
|
6256
|
+
function getSecondPointerPosition(event) {
|
|
6257
|
+
const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
|
|
6258
|
+
return pointerPositions[pointer.pointerId];
|
|
6248
6259
|
}
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6260
|
+
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
6261
|
+
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
6262
|
+
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
6263
|
+
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
6264
|
+
this.update();
|
|
6265
|
+
}
|
|
6266
|
+
};
|
|
6267
|
+
var MapControls = class extends OrbitControls {
|
|
6268
|
+
constructor(object, domElement) {
|
|
6269
|
+
super(object, domElement);
|
|
6270
|
+
this.screenSpacePanning = false;
|
|
6271
|
+
this.mouseButtons.LEFT = import_three18.MOUSE.PAN;
|
|
6272
|
+
this.mouseButtons.RIGHT = import_three18.MOUSE.ROTATE;
|
|
6273
|
+
this.touches.ONE = import_three18.TOUCH.PAN;
|
|
6274
|
+
this.touches.TWO = import_three18.TOUCH.DOLLY_ROTATE;
|
|
6275
|
+
}
|
|
6276
|
+
};
|
|
6277
|
+
|
|
6278
|
+
// src/renderer/Renderer.ts
|
|
6279
|
+
var _Renderer = class _Renderer {
|
|
6280
|
+
constructor(options) {
|
|
6281
|
+
this._dirty = true;
|
|
6282
|
+
this._resizeListener = void 0;
|
|
6283
|
+
this._disposed = false;
|
|
6284
|
+
this._debugHelpers = [];
|
|
6285
|
+
this._eventDispatchers = /* @__PURE__ */ new Map();
|
|
6286
|
+
this._changeListener = () => {
|
|
6287
|
+
this._dirty = true;
|
|
6288
|
+
};
|
|
6289
|
+
this.options = (0, import_ts_deepmerge9.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
|
|
6290
|
+
this._animationLoop = this.animate.bind(this);
|
|
6291
|
+
this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
|
|
6292
|
+
this._scene = this.createScene();
|
|
6293
|
+
this._camera = this.createCamera();
|
|
6294
|
+
this._renderer = this.createRenderer();
|
|
6295
|
+
this._composer = this.createComposer();
|
|
6296
|
+
if (this.options.render.stats) {
|
|
6297
|
+
this._stats = new import_stats.default();
|
|
6298
|
+
document.body.appendChild(this._stats.dom);
|
|
6252
6299
|
}
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6300
|
+
this.init();
|
|
6301
|
+
this._controls = this.createControls();
|
|
6302
|
+
}
|
|
6303
|
+
//<editor-fold desc="INIT">
|
|
6304
|
+
createScene() {
|
|
6305
|
+
return new MineRenderScene();
|
|
6306
|
+
}
|
|
6307
|
+
createCamera() {
|
|
6308
|
+
switch (this.options.camera.type) {
|
|
6309
|
+
case "perspective":
|
|
6310
|
+
default:
|
|
6311
|
+
return new import_three19.PerspectiveCamera(
|
|
6312
|
+
this.options.camera.perspective.fov,
|
|
6313
|
+
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
6314
|
+
this.options.camera.near,
|
|
6315
|
+
this.options.camera.far
|
|
6316
|
+
);
|
|
6317
|
+
case "orthographic":
|
|
6318
|
+
return new import_three19.OrthographicCamera(
|
|
6319
|
+
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
6320
|
+
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
6321
|
+
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
6322
|
+
this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
|
|
6323
|
+
this.options.camera.near,
|
|
6324
|
+
this.options.camera.far
|
|
6325
|
+
);
|
|
6256
6326
|
}
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6327
|
+
}
|
|
6328
|
+
createRenderer() {
|
|
6329
|
+
const renderer = new import_three19.WebGLRenderer({
|
|
6330
|
+
antialias: this.options.render.antialias,
|
|
6331
|
+
alpha: true,
|
|
6332
|
+
powerPreference: "high-performance",
|
|
6333
|
+
depth: true
|
|
6334
|
+
});
|
|
6335
|
+
renderer.setClearColor(0, 0);
|
|
6336
|
+
renderer.shadowMap.enabled = true;
|
|
6337
|
+
renderer.shadowMap.type = import_three19.PCFSoftShadowMap;
|
|
6338
|
+
renderer.outputColorSpace = import_three19.SRGBColorSpace;
|
|
6339
|
+
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6340
|
+
return renderer;
|
|
6341
|
+
}
|
|
6342
|
+
createComposer() {
|
|
6343
|
+
if (!this.options.composer.enabled) return void 0;
|
|
6344
|
+
const composer = new import_postprocessing.EffectComposer(this.renderer);
|
|
6345
|
+
composer.setSize(this.viewWidth, this.viewHeight);
|
|
6346
|
+
composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
|
|
6347
|
+
return composer;
|
|
6348
|
+
}
|
|
6349
|
+
createControls() {
|
|
6350
|
+
if (!this.options.controls?.enabled) return void 0;
|
|
6351
|
+
const position = this.camera.position.clone();
|
|
6352
|
+
const controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
6353
|
+
this.camera.position.copy(position);
|
|
6354
|
+
const target = this.options.camera.lookingAt;
|
|
6355
|
+
if (isVector3(target)) {
|
|
6356
|
+
controls.target.copy(target);
|
|
6357
|
+
} else if (isTripleArray(target)) {
|
|
6358
|
+
controls.target.set(target[0], target[1], target[2]);
|
|
6359
|
+
}
|
|
6360
|
+
controls.update();
|
|
6361
|
+
controls.saveState();
|
|
6362
|
+
this.registerEventDispatcher(controls);
|
|
6363
|
+
return controls;
|
|
6364
|
+
}
|
|
6365
|
+
//</editor-fold>
|
|
6366
|
+
init() {
|
|
6367
|
+
if (this._disposed) return;
|
|
6368
|
+
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
6369
|
+
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6370
|
+
}
|
|
6371
|
+
if (this.options.debug.grid) {
|
|
6372
|
+
const gridHelper = new import_three19.GridHelper(128, 16);
|
|
6373
|
+
this._debugHelpers.push(gridHelper);
|
|
6374
|
+
this.scene.add(gridHelper);
|
|
6375
|
+
const gridHelper2 = new import_three19.GridHelper(128, 16);
|
|
6376
|
+
this._debugHelpers.push(gridHelper2);
|
|
6377
|
+
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6378
|
+
this.scene.add(gridHelper2);
|
|
6379
|
+
const gridHelper3 = new import_three19.GridHelper(128, 16);
|
|
6380
|
+
this._debugHelpers.push(gridHelper3);
|
|
6381
|
+
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6382
|
+
this.scene.add(gridHelper3);
|
|
6383
|
+
}
|
|
6384
|
+
if (this.options.debug.axes) {
|
|
6385
|
+
const axesHelper = new import_three19.AxesHelper(64);
|
|
6386
|
+
this._debugHelpers.push(axesHelper);
|
|
6387
|
+
this.scene.add(axesHelper);
|
|
6388
|
+
}
|
|
6389
|
+
if (this.options.camera.position) {
|
|
6390
|
+
if (isVector3(this.options.camera.position)) {
|
|
6391
|
+
this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
|
|
6392
|
+
} else if (isTripleArray(this.options.camera.position)) {
|
|
6393
|
+
this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
|
|
6265
6394
|
}
|
|
6266
|
-
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
6267
|
-
const element = scope.domElement;
|
|
6268
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
6269
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
6270
|
-
rotateStart.copy(rotateEnd);
|
|
6271
6395
|
}
|
|
6272
|
-
|
|
6273
|
-
if (
|
|
6274
|
-
|
|
6275
|
-
} else {
|
|
6276
|
-
|
|
6277
|
-
const x = 0.5 * (event.pageX + position.x);
|
|
6278
|
-
const y = 0.5 * (event.pageY + position.y);
|
|
6279
|
-
panEnd.set(x, y);
|
|
6396
|
+
if (this.options.camera.lookingAt) {
|
|
6397
|
+
if (isVector3(this.options.camera.lookingAt)) {
|
|
6398
|
+
this.camera.lookAt(this.options.camera.lookingAt);
|
|
6399
|
+
} else if (isTripleArray(this.options.camera.lookingAt)) {
|
|
6400
|
+
this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
|
|
6280
6401
|
}
|
|
6281
|
-
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
6282
|
-
pan(panDelta.x, panDelta.y);
|
|
6283
|
-
panStart.copy(panEnd);
|
|
6284
6402
|
}
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
dollyEnd.set(0, distance);
|
|
6291
|
-
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
6292
|
-
dollyOut(dollyDelta.y);
|
|
6293
|
-
dollyStart.copy(dollyEnd);
|
|
6403
|
+
if (this.options.render.autoResize && !this._resizeListener) {
|
|
6404
|
+
this._resizeListener = () => {
|
|
6405
|
+
this.resize(this.viewWidth, this.viewHeight);
|
|
6406
|
+
};
|
|
6407
|
+
window.addEventListener("resize", this._resizeListener);
|
|
6294
6408
|
}
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6409
|
+
}
|
|
6410
|
+
get element() {
|
|
6411
|
+
return this._element;
|
|
6412
|
+
}
|
|
6413
|
+
appendTo(element) {
|
|
6414
|
+
if (this._disposed) return;
|
|
6415
|
+
this._element = element;
|
|
6416
|
+
this._element.appendChild(this.renderer.domElement);
|
|
6417
|
+
if (this.viewWidth == 0) {
|
|
6418
|
+
console.warn("0 element width");
|
|
6298
6419
|
}
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
6420
|
+
if (this.viewHeight == 0) {
|
|
6421
|
+
console.warn("0 element height");
|
|
6302
6422
|
}
|
|
6303
|
-
|
|
6423
|
+
this.resize(this.viewWidth, this.viewHeight);
|
|
6424
|
+
}
|
|
6425
|
+
/**
|
|
6426
|
+
* Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
|
|
6427
|
+
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
6428
|
+
*/
|
|
6429
|
+
registerEventDispatcher(dispatcher, changeEvent2 = "change") {
|
|
6430
|
+
if (this._disposed) return;
|
|
6431
|
+
let events = this._eventDispatchers.get(dispatcher);
|
|
6432
|
+
if (!events) {
|
|
6433
|
+
events = /* @__PURE__ */ new Set();
|
|
6434
|
+
this._eventDispatchers.set(dispatcher, events);
|
|
6304
6435
|
}
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6436
|
+
if (events.has(changeEvent2)) return;
|
|
6437
|
+
events.add(changeEvent2);
|
|
6438
|
+
dispatcher.addEventListener(changeEvent2, this._changeListener);
|
|
6439
|
+
}
|
|
6440
|
+
resize(width, height) {
|
|
6441
|
+
if (this._disposed) return;
|
|
6442
|
+
if (isPerspectiveCamera(this.camera)) {
|
|
6443
|
+
this.camera.aspect = width / height;
|
|
6444
|
+
this.camera.updateProjectionMatrix();
|
|
6445
|
+
} else if (isOrthographicCamera(this.camera)) {
|
|
6446
|
+
this.camera.left = width / -2;
|
|
6447
|
+
this.camera.right = width / 2;
|
|
6448
|
+
this.camera.top = height / 2;
|
|
6449
|
+
this.camera.bottom = height / -2;
|
|
6450
|
+
this.camera.updateProjectionMatrix();
|
|
6318
6451
|
}
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6452
|
+
this.renderer.setSize(width, height);
|
|
6453
|
+
this.composer?.setSize(width, height);
|
|
6454
|
+
this._dirty = true;
|
|
6455
|
+
}
|
|
6456
|
+
//<editor-fold desc="RENDER">
|
|
6457
|
+
get dirty() {
|
|
6458
|
+
return this._dirty || this.scene.dirty;
|
|
6459
|
+
}
|
|
6460
|
+
set dirty(dirty) {
|
|
6461
|
+
this._dirty = dirty;
|
|
6462
|
+
this.scene.dirty = dirty;
|
|
6463
|
+
}
|
|
6464
|
+
start() {
|
|
6465
|
+
if (this._disposed) return;
|
|
6466
|
+
this.stop();
|
|
6467
|
+
this.renderer.setAnimationLoop(this._animationLoop);
|
|
6468
|
+
}
|
|
6469
|
+
stop() {
|
|
6470
|
+
if (this._disposed) return;
|
|
6471
|
+
this.renderer.setAnimationLoop(null);
|
|
6472
|
+
this._nextFrameTime = void 0;
|
|
6473
|
+
}
|
|
6474
|
+
/**
|
|
6475
|
+
* Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
|
|
6476
|
+
* renderer cannot be restarted. Scene objects are detached; shared assets and caller-owned
|
|
6477
|
+
* controls must be managed by their owners.
|
|
6478
|
+
*/
|
|
6479
|
+
dispose() {
|
|
6480
|
+
if (this._disposed) return;
|
|
6481
|
+
this.stop();
|
|
6482
|
+
this._disposed = true;
|
|
6483
|
+
if (this._resizeListener) {
|
|
6484
|
+
window.removeEventListener("resize", this._resizeListener);
|
|
6485
|
+
this._resizeListener = void 0;
|
|
6486
|
+
}
|
|
6487
|
+
for (const [dispatcher, events] of this._eventDispatchers) {
|
|
6488
|
+
for (const event of events) {
|
|
6489
|
+
dispatcher.removeEventListener(event, this._changeListener);
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
this._eventDispatchers.clear();
|
|
6493
|
+
this._stats?.dom.remove();
|
|
6494
|
+
this._stats = void 0;
|
|
6495
|
+
this.renderer.domElement.remove();
|
|
6496
|
+
this._element = void 0;
|
|
6497
|
+
if (this._controls) {
|
|
6498
|
+
const controls = this._controls;
|
|
6499
|
+
this._controls = void 0;
|
|
6500
|
+
controls.enabled = false;
|
|
6501
|
+
controls.dispose();
|
|
6502
|
+
}
|
|
6503
|
+
this.scene.clear();
|
|
6504
|
+
for (const helper of this._debugHelpers) {
|
|
6505
|
+
helper.geometry.dispose();
|
|
6506
|
+
const materials = Array.isArray(helper.material) ? helper.material : [helper.material];
|
|
6507
|
+
for (const material of materials) {
|
|
6508
|
+
material.dispose();
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
this._debugHelpers.length = 0;
|
|
6512
|
+
this.composer?.dispose();
|
|
6513
|
+
this.renderer.dispose();
|
|
6514
|
+
this.renderer.forceContextLoss();
|
|
6515
|
+
}
|
|
6516
|
+
animate(t = performance.now()) {
|
|
6517
|
+
if (this._disposed) return;
|
|
6518
|
+
if (this._controls?.enabled) {
|
|
6519
|
+
this._controls.update();
|
|
6520
|
+
}
|
|
6521
|
+
if (this._disposed) return;
|
|
6522
|
+
if (!this.dirty && !this.options.render.renderAlways) return;
|
|
6523
|
+
const interval = this._frameInterval;
|
|
6524
|
+
if (interval) {
|
|
6525
|
+
const next = this._nextFrameTime;
|
|
6526
|
+
if (next !== void 0 && t + 0.1 < next) return;
|
|
6527
|
+
this._nextFrameTime = next !== void 0 && t - next < interval ? next + interval : t + interval;
|
|
6326
6528
|
}
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
if (event.pointerType === "touch") {
|
|
6330
|
-
onTouchEnd();
|
|
6331
|
-
} else {
|
|
6332
|
-
onMouseUp(event);
|
|
6333
|
-
}
|
|
6334
|
-
removePointer(event);
|
|
6335
|
-
if (pointers.length === 0) {
|
|
6336
|
-
scope.domElement.releasePointerCapture(event.pointerId);
|
|
6337
|
-
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
6338
|
-
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
6339
|
-
}
|
|
6529
|
+
if (this._stats) {
|
|
6530
|
+
this._stats.begin();
|
|
6340
6531
|
}
|
|
6341
|
-
|
|
6342
|
-
|
|
6532
|
+
if (this.options.composer.enabled && this.composer) {
|
|
6533
|
+
this.composer.render();
|
|
6534
|
+
} else {
|
|
6535
|
+
this.renderer.render(this.scene, this.camera);
|
|
6343
6536
|
}
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6537
|
+
this.dirty = false;
|
|
6538
|
+
if (this._stats) {
|
|
6539
|
+
this._stats.end();
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
//</editor-fold>
|
|
6543
|
+
toImage() {
|
|
6544
|
+
return this.renderer.domElement.toDataURL();
|
|
6545
|
+
}
|
|
6546
|
+
///
|
|
6547
|
+
get attachedToBody() {
|
|
6548
|
+
return this.element === document.body;
|
|
6549
|
+
}
|
|
6550
|
+
get viewWidth() {
|
|
6551
|
+
return this.attachedToBody ? window.innerWidth : this.element?.offsetWidth || 0;
|
|
6552
|
+
}
|
|
6553
|
+
get viewHeight() {
|
|
6554
|
+
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
6555
|
+
}
|
|
6556
|
+
get scene() {
|
|
6557
|
+
return this._scene;
|
|
6558
|
+
}
|
|
6559
|
+
get camera() {
|
|
6560
|
+
return this._camera;
|
|
6561
|
+
}
|
|
6562
|
+
get renderer() {
|
|
6563
|
+
return this._renderer;
|
|
6564
|
+
}
|
|
6565
|
+
get composer() {
|
|
6566
|
+
return this._composer;
|
|
6567
|
+
}
|
|
6568
|
+
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
6569
|
+
get controls() {
|
|
6570
|
+
return this._controls;
|
|
6571
|
+
}
|
|
6572
|
+
///
|
|
6573
|
+
};
|
|
6574
|
+
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
6575
|
+
camera: {
|
|
6576
|
+
type: "perspective",
|
|
6577
|
+
near: 1,
|
|
6578
|
+
far: 5e3,
|
|
6579
|
+
perspective: {
|
|
6580
|
+
aspect: void 0,
|
|
6581
|
+
fov: 50
|
|
6582
|
+
},
|
|
6583
|
+
orthographic: {
|
|
6584
|
+
left: void 0,
|
|
6585
|
+
right: void 0,
|
|
6586
|
+
top: void 0,
|
|
6587
|
+
bottom: void 0
|
|
6588
|
+
},
|
|
6589
|
+
position: new import_three19.Vector3(50, 50, 50),
|
|
6590
|
+
lookingAt: new import_three19.Vector3(0, 0, 0)
|
|
6591
|
+
},
|
|
6592
|
+
render: {
|
|
6593
|
+
fpsLimit: 60,
|
|
6594
|
+
stats: false,
|
|
6595
|
+
antialias: true,
|
|
6596
|
+
shade: true,
|
|
6597
|
+
autoResize: true,
|
|
6598
|
+
renderAlways: false
|
|
6599
|
+
},
|
|
6600
|
+
composer: {
|
|
6601
|
+
enabled: true
|
|
6602
|
+
},
|
|
6603
|
+
controls: {
|
|
6604
|
+
enabled: false
|
|
6605
|
+
},
|
|
6606
|
+
debug: {
|
|
6607
|
+
grid: false,
|
|
6608
|
+
axes: false
|
|
6609
|
+
}
|
|
6610
|
+
});
|
|
6611
|
+
var Renderer = _Renderer;
|
|
6612
|
+
|
|
6613
|
+
// src/skin/Skins.ts
|
|
6614
|
+
var Skins = class {
|
|
6615
|
+
//<editor-fold desc="Skins">
|
|
6616
|
+
static async fromUuidOrUsername(uuidOrUsername) {
|
|
6617
|
+
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
6618
|
+
return this.fromUuid(uuidOrUsername);
|
|
6619
|
+
}
|
|
6620
|
+
return this.fromUsername(uuidOrUsername);
|
|
6621
|
+
}
|
|
6622
|
+
static async fromUuid(uuid) {
|
|
6623
|
+
return this.getSkinProxySkinUrl(uuid);
|
|
6624
|
+
}
|
|
6625
|
+
static async fromUsername(username) {
|
|
6626
|
+
return this.usernameToUuid(username).then((uuid) => {
|
|
6627
|
+
if (uuid) {
|
|
6628
|
+
return this.fromUuid(uuid);
|
|
6389
6629
|
}
|
|
6390
|
-
|
|
6391
|
-
|
|
6630
|
+
return void 0;
|
|
6631
|
+
});
|
|
6632
|
+
}
|
|
6633
|
+
static async fromMineSkin(mineskinId) {
|
|
6634
|
+
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
6635
|
+
if (mineskin) {
|
|
6636
|
+
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
6392
6637
|
}
|
|
6638
|
+
return void 0;
|
|
6639
|
+
});
|
|
6640
|
+
}
|
|
6641
|
+
//</editor-fold>
|
|
6642
|
+
//<editor-fold desc="Capes">
|
|
6643
|
+
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
6644
|
+
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
6645
|
+
return this.capeFromUuid(uuidOrUsername);
|
|
6393
6646
|
}
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
handleMouseMoveDolly(event);
|
|
6404
|
-
break;
|
|
6405
|
-
case STATE.PAN:
|
|
6406
|
-
if (scope.enablePan === false) return;
|
|
6407
|
-
handleMouseMovePan(event);
|
|
6408
|
-
break;
|
|
6647
|
+
return this.capeFromUsername(uuidOrUsername);
|
|
6648
|
+
}
|
|
6649
|
+
static async capeFromUuid(uuid) {
|
|
6650
|
+
return this.getSkinProxyCapeUrl(uuid);
|
|
6651
|
+
}
|
|
6652
|
+
static async capeFromUsername(username) {
|
|
6653
|
+
return this.usernameToUuid(username).then((uuid) => {
|
|
6654
|
+
if (uuid) {
|
|
6655
|
+
return this.capeFromUuid(uuid);
|
|
6409
6656
|
}
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
|
|
6418
|
-
event.preventDefault();
|
|
6419
|
-
scope.dispatchEvent(_startEvent);
|
|
6420
|
-
handleMouseWheel(event);
|
|
6421
|
-
scope.dispatchEvent(_endEvent);
|
|
6422
|
-
}
|
|
6423
|
-
function onKeyDown(event) {
|
|
6424
|
-
if (scope.enabled === false || scope.enablePan === false) return;
|
|
6425
|
-
handleKeyDown(event);
|
|
6426
|
-
}
|
|
6427
|
-
function onTouchStart(event) {
|
|
6428
|
-
trackPointer(event);
|
|
6429
|
-
switch (pointers.length) {
|
|
6430
|
-
case 1:
|
|
6431
|
-
switch (scope.touches.ONE) {
|
|
6432
|
-
case import_three20.TOUCH.ROTATE:
|
|
6433
|
-
if (scope.enableRotate === false) return;
|
|
6434
|
-
handleTouchStartRotate();
|
|
6435
|
-
state = STATE.TOUCH_ROTATE;
|
|
6436
|
-
break;
|
|
6437
|
-
case import_three20.TOUCH.PAN:
|
|
6438
|
-
if (scope.enablePan === false) return;
|
|
6439
|
-
handleTouchStartPan();
|
|
6440
|
-
state = STATE.TOUCH_PAN;
|
|
6441
|
-
break;
|
|
6442
|
-
default:
|
|
6443
|
-
state = STATE.NONE;
|
|
6444
|
-
}
|
|
6445
|
-
break;
|
|
6446
|
-
case 2:
|
|
6447
|
-
switch (scope.touches.TWO) {
|
|
6448
|
-
case import_three20.TOUCH.DOLLY_PAN:
|
|
6449
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6450
|
-
handleTouchStartDollyPan();
|
|
6451
|
-
state = STATE.TOUCH_DOLLY_PAN;
|
|
6452
|
-
break;
|
|
6453
|
-
case import_three20.TOUCH.DOLLY_ROTATE:
|
|
6454
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6455
|
-
handleTouchStartDollyRotate();
|
|
6456
|
-
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
6457
|
-
break;
|
|
6458
|
-
default:
|
|
6459
|
-
state = STATE.NONE;
|
|
6460
|
-
}
|
|
6461
|
-
break;
|
|
6462
|
-
default:
|
|
6463
|
-
state = STATE.NONE;
|
|
6657
|
+
return void 0;
|
|
6658
|
+
});
|
|
6659
|
+
}
|
|
6660
|
+
static async capeFromCapesDev(uuid, capeType = "minecraft") {
|
|
6661
|
+
return this.getCapesDev(uuid, capeType).then((cape) => {
|
|
6662
|
+
if (cape) {
|
|
6663
|
+
return cape?.stillImageUrl;
|
|
6464
6664
|
}
|
|
6465
|
-
|
|
6466
|
-
|
|
6665
|
+
return void 0;
|
|
6666
|
+
});
|
|
6667
|
+
}
|
|
6668
|
+
//</editor-fold>
|
|
6669
|
+
//<editor-fold desc="Helpers">
|
|
6670
|
+
static async usernameToUuid(username) {
|
|
6671
|
+
return this.usernameToUuidSkinProxy(username);
|
|
6672
|
+
}
|
|
6673
|
+
static async usernameToUuidSkinProxy(username) {
|
|
6674
|
+
return Requests.genericRequest({
|
|
6675
|
+
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
6676
|
+
url: "/uuid/" + username
|
|
6677
|
+
}).then((res) => {
|
|
6678
|
+
if (res.status === 200) {
|
|
6679
|
+
return res.data["id"];
|
|
6467
6680
|
}
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
break;
|
|
6482
|
-
case STATE.TOUCH_DOLLY_PAN:
|
|
6483
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6484
|
-
handleTouchMoveDollyPan(event);
|
|
6485
|
-
scope.update();
|
|
6486
|
-
break;
|
|
6487
|
-
case STATE.TOUCH_DOLLY_ROTATE:
|
|
6488
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6489
|
-
handleTouchMoveDollyRotate(event);
|
|
6490
|
-
scope.update();
|
|
6491
|
-
break;
|
|
6492
|
-
default:
|
|
6493
|
-
state = STATE.NONE;
|
|
6681
|
+
return void 0;
|
|
6682
|
+
}).catch((err) => {
|
|
6683
|
+
console.warn(err);
|
|
6684
|
+
return void 0;
|
|
6685
|
+
});
|
|
6686
|
+
}
|
|
6687
|
+
static async usernameToUuidMineTools(username) {
|
|
6688
|
+
return Requests.genericRequest({
|
|
6689
|
+
baseURL: "https://api.minetools.eu",
|
|
6690
|
+
url: "/uuid/" + username
|
|
6691
|
+
}).then((res) => {
|
|
6692
|
+
if (res.status === 200) {
|
|
6693
|
+
return res.data["id"];
|
|
6494
6694
|
}
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
function removePointer(event) {
|
|
6509
|
-
delete pointerPositions[event.pointerId];
|
|
6510
|
-
for (let i = 0; i < pointers.length; i++) {
|
|
6511
|
-
if (pointers[i].pointerId == event.pointerId) {
|
|
6512
|
-
pointers.splice(i, 1);
|
|
6513
|
-
return;
|
|
6514
|
-
}
|
|
6695
|
+
return void 0;
|
|
6696
|
+
}).catch((err) => {
|
|
6697
|
+
console.warn(err);
|
|
6698
|
+
return void 0;
|
|
6699
|
+
});
|
|
6700
|
+
}
|
|
6701
|
+
static async getProfileFromMinetools(uuid) {
|
|
6702
|
+
return Requests.genericRequest({
|
|
6703
|
+
baseURL: "https://api.minetools.eu",
|
|
6704
|
+
url: "/profile/" + uuid
|
|
6705
|
+
}).then((res) => {
|
|
6706
|
+
if (res.status === 200) {
|
|
6707
|
+
return res.data;
|
|
6515
6708
|
}
|
|
6516
|
-
}
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6709
|
+
});
|
|
6710
|
+
}
|
|
6711
|
+
static async getMineSkin(mineskinId) {
|
|
6712
|
+
return Requests.genericRequest({
|
|
6713
|
+
baseURL: "https://api.mineskin.org",
|
|
6714
|
+
url: "/get/uuid/" + mineskinId
|
|
6715
|
+
}).then((res) => {
|
|
6716
|
+
if (res.status === 200) {
|
|
6717
|
+
return res.data;
|
|
6522
6718
|
}
|
|
6523
|
-
|
|
6524
|
-
}
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
}
|
|
6529
|
-
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
6530
|
-
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
6531
|
-
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
6532
|
-
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
6533
|
-
this.update();
|
|
6719
|
+
return void 0;
|
|
6720
|
+
}).catch((err) => {
|
|
6721
|
+
console.warn(err);
|
|
6722
|
+
return void 0;
|
|
6723
|
+
});
|
|
6534
6724
|
}
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6725
|
+
static async getCapesDev(uuid, type = "all") {
|
|
6726
|
+
return Requests.genericRequest({
|
|
6727
|
+
baseURL: "https://api.capes.dev",
|
|
6728
|
+
url: "/load/" + uuid + "/" + type
|
|
6729
|
+
}).then((res) => {
|
|
6730
|
+
if (res.status === 200) {
|
|
6731
|
+
return res.data;
|
|
6732
|
+
}
|
|
6733
|
+
return void 0;
|
|
6734
|
+
}).catch((err) => {
|
|
6735
|
+
console.warn(err);
|
|
6736
|
+
return void 0;
|
|
6737
|
+
});
|
|
6738
|
+
}
|
|
6739
|
+
static getCrafatarSkinUrl(uuid) {
|
|
6740
|
+
return "https://crafatar.com/skins/" + uuid;
|
|
6544
6741
|
}
|
|
6742
|
+
static getCrafatarCapeUrl(uuid) {
|
|
6743
|
+
return "https://crafatar.com/capes/" + uuid;
|
|
6744
|
+
}
|
|
6745
|
+
static getMcHeadsSkinUrl(uuid) {
|
|
6746
|
+
return "https://mc-heads.net/skin/" + uuid;
|
|
6747
|
+
}
|
|
6748
|
+
static getMineSkinPlayerSkinUrl(uuid) {
|
|
6749
|
+
return "https://mineskin.org/skin/player/" + uuid;
|
|
6750
|
+
}
|
|
6751
|
+
static getSkinProxySkinUrl(uuid) {
|
|
6752
|
+
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
6753
|
+
}
|
|
6754
|
+
static getSkinProxyCapeUrl(uuid) {
|
|
6755
|
+
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
6756
|
+
}
|
|
6757
|
+
//</editor-fold>
|
|
6545
6758
|
};
|
|
6546
6759
|
|
|
6547
6760
|
// src/world/Chunk.ts
|
|
@@ -6658,7 +6871,7 @@ var MineRenderWorld = class {
|
|
|
6658
6871
|
};
|
|
6659
6872
|
|
|
6660
6873
|
// src/world/Chunk.ts
|
|
6661
|
-
var
|
|
6874
|
+
var p11 = prefix("Chunk");
|
|
6662
6875
|
var Chunk = class _Chunk {
|
|
6663
6876
|
constructor(scene, x, y, z) {
|
|
6664
6877
|
this._blocks = [];
|
|
@@ -6710,7 +6923,7 @@ var Chunk = class _Chunk {
|
|
|
6710
6923
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
6711
6924
|
const current = this._blocks[index];
|
|
6712
6925
|
if (typeof current !== "undefined") {
|
|
6713
|
-
console.debug(
|
|
6926
|
+
console.debug(p11, "deleting existing block at", pos, worldPos, index);
|
|
6714
6927
|
current.object.removeFromScene();
|
|
6715
6928
|
delete this._blocks[index];
|
|
6716
6929
|
}
|