minerender 2.1.0-alpha.17 → 2.1.0-alpha.2
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 +0 -2
- package/dist/browser/index.d.mts +141 -193
- package/dist/browser/index.d.ts +141 -193
- package/dist/browser/index.js +1589 -1731
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1587 -1729
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +4968 -3520
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +140 -192
- package/dist/node/index.d.ts +140 -192
- package/dist/node/index.js +1710 -1921
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1703 -1912
- package/dist/node/index.mjs.map +1 -1
- package/package.json +9 -7
package/dist/browser/index.js
CHANGED
|
@@ -28,6 +28,14 @@ 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
|
+
};
|
|
31
39
|
|
|
32
40
|
// ../../node_modules/ts-deepmerge/dist/index.js
|
|
33
41
|
var require_dist = __commonJS({
|
|
@@ -37,8 +45,8 @@ var require_dist = __commonJS({
|
|
|
37
45
|
__assign = Object.assign || function(t) {
|
|
38
46
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
47
|
s = arguments[i];
|
|
40
|
-
for (var
|
|
41
|
-
t[
|
|
48
|
+
for (var p13 in s) if (Object.prototype.hasOwnProperty.call(s, p13))
|
|
49
|
+
t[p13] = s[p13];
|
|
42
50
|
}
|
|
43
51
|
return t;
|
|
44
52
|
};
|
|
@@ -82,7 +90,7 @@ var require_dist = __commonJS({
|
|
|
82
90
|
return false;
|
|
83
91
|
};
|
|
84
92
|
var PROTECTED_KEYS = ["__proto__"];
|
|
85
|
-
var
|
|
93
|
+
var merge11 = function() {
|
|
86
94
|
var objects = [];
|
|
87
95
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
88
96
|
objects[_i] = arguments[_i];
|
|
@@ -93,9 +101,9 @@ var require_dist = __commonJS({
|
|
|
93
101
|
return;
|
|
94
102
|
}
|
|
95
103
|
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
96
|
-
result[key] =
|
|
104
|
+
result[key] = merge11.options.mergeArrays ? Array.from(new Set(result[key].concat(current[key]))) : current[key];
|
|
97
105
|
} else if (isObject(result[key]) && isObject(current[key])) {
|
|
98
|
-
result[key] =
|
|
106
|
+
result[key] = merge11(result[key], current[key]);
|
|
99
107
|
} else {
|
|
100
108
|
result[key] = current[key];
|
|
101
109
|
}
|
|
@@ -106,18 +114,18 @@ var require_dist = __commonJS({
|
|
|
106
114
|
var defaultOptions = {
|
|
107
115
|
mergeArrays: true
|
|
108
116
|
};
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
merge11.options = defaultOptions;
|
|
118
|
+
merge11.withOptions = function(options) {
|
|
111
119
|
var objects = [];
|
|
112
120
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
113
121
|
objects[_i - 1] = arguments[_i];
|
|
114
122
|
}
|
|
115
|
-
|
|
116
|
-
var result =
|
|
117
|
-
|
|
123
|
+
merge11.options = __assign({ mergeArrays: true }, options);
|
|
124
|
+
var result = merge11.apply(void 0, __spreadArray([], __read(objects), false));
|
|
125
|
+
merge11.options = defaultOptions;
|
|
118
126
|
return result;
|
|
119
127
|
};
|
|
120
|
-
exports.default =
|
|
128
|
+
exports.default = merge11;
|
|
121
129
|
}
|
|
122
130
|
});
|
|
123
131
|
|
|
@@ -127,7 +135,6 @@ __export(index_browser_exports, {
|
|
|
127
135
|
AXES: () => AXES,
|
|
128
136
|
ArchiveAssetSource: () => ArchiveAssetSource,
|
|
129
137
|
AssetKey: () => AssetKey,
|
|
130
|
-
AssetLoadError: () => AssetLoadError,
|
|
131
138
|
AssetLoader: () => AssetLoader,
|
|
132
139
|
AssetParser: () => AssetParser,
|
|
133
140
|
AssetSource: () => AssetSource,
|
|
@@ -185,7 +192,6 @@ __export(index_browser_exports, {
|
|
|
185
192
|
OrbitControls: () => OrbitControls,
|
|
186
193
|
PersistentCache: () => PersistentCache,
|
|
187
194
|
Renderer: () => Renderer,
|
|
188
|
-
RequestError: () => RequestError,
|
|
189
195
|
Requests: () => Requests,
|
|
190
196
|
SKIN_PARTS: () => SKIN_PARTS,
|
|
191
197
|
SceneInspector: () => SceneInspector,
|
|
@@ -302,20 +308,17 @@ var _PersistentCache = class _PersistentCache {
|
|
|
302
308
|
static open(name) {
|
|
303
309
|
return Env.provider.openCache(name, _PersistentCache.VERSION);
|
|
304
310
|
}
|
|
305
|
-
/** Loads a missing entry and stores only non-nullish results. */
|
|
306
311
|
async getOrLoad(key, loader) {
|
|
307
312
|
let v = await this.get(key);
|
|
308
313
|
if (typeof v === "undefined" || v === null) {
|
|
309
314
|
v = await loader(key);
|
|
310
|
-
|
|
311
|
-
await this.put(key, v);
|
|
312
|
-
}
|
|
315
|
+
await this.put(key, v);
|
|
313
316
|
}
|
|
314
317
|
return v;
|
|
315
318
|
}
|
|
316
319
|
};
|
|
317
320
|
/** Bump to invalidate every persisted entry. */
|
|
318
|
-
_PersistentCache.VERSION =
|
|
321
|
+
_PersistentCache.VERSION = 1;
|
|
319
322
|
var PersistentCache = _PersistentCache;
|
|
320
323
|
|
|
321
324
|
// src/env/browser/BrowserCache.ts
|
|
@@ -416,8 +419,7 @@ var BrowserEnv = class {
|
|
|
416
419
|
}
|
|
417
420
|
openCache(name, version) {
|
|
418
421
|
return new BrowserCache(import_localforage.default.createInstance({
|
|
419
|
-
|
|
420
|
-
name: name + version,
|
|
422
|
+
name,
|
|
421
423
|
version
|
|
422
424
|
}));
|
|
423
425
|
}
|
|
@@ -434,7 +436,7 @@ registerBrowserEnv();
|
|
|
434
436
|
// src/Axis.ts
|
|
435
437
|
var import_three = require("three");
|
|
436
438
|
var Axis = /* @__PURE__ */ ((Axis3) => {
|
|
437
|
-
Axis3["X"] = "
|
|
439
|
+
Axis3["X"] = "X";
|
|
438
440
|
Axis3["Y"] = "y";
|
|
439
441
|
Axis3["Z"] = "z";
|
|
440
442
|
return Axis3;
|
|
@@ -442,7 +444,7 @@ var Axis = /* @__PURE__ */ ((Axis3) => {
|
|
|
442
444
|
var AXES = Object.values(Axis);
|
|
443
445
|
function axisToVec3(axis) {
|
|
444
446
|
switch (axis) {
|
|
445
|
-
case "
|
|
447
|
+
case "X" /* X */:
|
|
446
448
|
return new import_three.Vector3(1, 0, 0);
|
|
447
449
|
case "y" /* Y */:
|
|
448
450
|
return new import_three.Vector3(0, 1, 0);
|
|
@@ -545,10 +547,7 @@ function serializeMeshKey(key) {
|
|
|
545
547
|
// src/cache/Caching.ts
|
|
546
548
|
var import_loading_cache = require("@inventivetalent/loading-cache");
|
|
547
549
|
var import_time = require("@inventivetalent/time");
|
|
548
|
-
var
|
|
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
|
-
}
|
|
550
|
+
var Caching = class {
|
|
552
551
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
553
552
|
static get all() {
|
|
554
553
|
return [
|
|
@@ -565,10 +564,7 @@ var _Caching = class _Caching {
|
|
|
565
564
|
this.rawModelCache,
|
|
566
565
|
this.mergedModelCache,
|
|
567
566
|
this.modelTextureAtlasCache,
|
|
568
|
-
this.blockStateCache
|
|
569
|
-
this.listAssetCache,
|
|
570
|
-
this.defaultBlockStatesCache,
|
|
571
|
-
this.entityModelsCache
|
|
567
|
+
this.blockStateCache
|
|
572
568
|
];
|
|
573
569
|
}
|
|
574
570
|
static clear() {
|
|
@@ -579,8 +575,8 @@ var _Caching = class _Caching {
|
|
|
579
575
|
/**
|
|
580
576
|
* Clears every cache and stops its expiry timer.
|
|
581
577
|
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
578
|
+
* loading-cache reschedules that timer indefinitely, so a Node process will not exit until
|
|
579
|
+
* this is called - see {@link shutdown}.
|
|
584
580
|
*/
|
|
585
581
|
static end() {
|
|
586
582
|
for (const cache of this.all) {
|
|
@@ -594,24 +590,20 @@ var _Caching = class _Caching {
|
|
|
594
590
|
};
|
|
595
591
|
}
|
|
596
592
|
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
_Caching.listAssetCache = _Caching.createAssetCache();
|
|
612
|
-
_Caching.defaultBlockStatesCache = _Caching.createAssetCache();
|
|
613
|
-
_Caching.entityModelsCache = _Caching.createAssetCache();
|
|
614
|
-
var Caching = _Caching;
|
|
593
|
+
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();
|
|
594
|
+
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();
|
|
595
|
+
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();
|
|
596
|
+
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();
|
|
597
|
+
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();
|
|
598
|
+
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();
|
|
599
|
+
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();
|
|
600
|
+
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();
|
|
601
|
+
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();
|
|
602
|
+
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();
|
|
603
|
+
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();
|
|
604
|
+
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();
|
|
605
|
+
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();
|
|
606
|
+
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();
|
|
615
607
|
|
|
616
608
|
// src/Geometries.ts
|
|
617
609
|
var Geometries = class _Geometries {
|
|
@@ -632,14 +624,13 @@ var Geometries = class _Geometries {
|
|
|
632
624
|
};
|
|
633
625
|
|
|
634
626
|
// src/Materials.ts
|
|
635
|
-
var
|
|
627
|
+
var import_three6 = require("three");
|
|
636
628
|
|
|
637
629
|
// src/texture/Textures.ts
|
|
638
|
-
var
|
|
630
|
+
var import_three5 = require("three");
|
|
639
631
|
|
|
640
632
|
// src/texture/TextureLoader.ts
|
|
641
|
-
var
|
|
642
|
-
var THREE = __toESM(require("three"));
|
|
633
|
+
var import_three4 = require("three");
|
|
643
634
|
|
|
644
635
|
// src/canvas/CanvasCompat.ts
|
|
645
636
|
function createImage(width, height) {
|
|
@@ -650,7 +641,9 @@ function createCanvas(width, height) {
|
|
|
650
641
|
}
|
|
651
642
|
|
|
652
643
|
// src/request/Requests.ts
|
|
644
|
+
var import_axios = __toESM(require("axios"));
|
|
653
645
|
var import_jobqu = require("jobqu");
|
|
646
|
+
var import_time2 = require("@inventivetalent/time");
|
|
654
647
|
|
|
655
648
|
// src/util/log.ts
|
|
656
649
|
var Reset = "\x1B[0m";
|
|
@@ -660,170 +653,198 @@ function prefix(prefix2) {
|
|
|
660
653
|
return `${FgGreen}MR${BgBlack}${prefix2 ?? ""}${Reset}`;
|
|
661
654
|
}
|
|
662
655
|
|
|
663
|
-
// src/
|
|
664
|
-
var
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
this.
|
|
669
|
-
this.
|
|
670
|
-
this.name = "RequestError";
|
|
656
|
+
// src/util/BatchedExecutor.ts
|
|
657
|
+
var BatchedExecutor = class {
|
|
658
|
+
constructor(interval = 1, batch = 30) {
|
|
659
|
+
this.interval = interval;
|
|
660
|
+
this.batch = batch;
|
|
661
|
+
this.queue = [];
|
|
662
|
+
this.task = setInterval(() => this.run());
|
|
671
663
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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);
|
|
664
|
+
submit(task) {
|
|
665
|
+
this.queue.push(task);
|
|
666
|
+
}
|
|
667
|
+
run() {
|
|
668
|
+
for (let i = 0; i < this.batch; i++) {
|
|
669
|
+
this.runNext();
|
|
699
670
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
671
|
+
}
|
|
672
|
+
runNext() {
|
|
673
|
+
let next = this.queue.shift();
|
|
674
|
+
if (next) next();
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// src/util/model.ts
|
|
679
|
+
var import_three3 = require("three");
|
|
680
|
+
function applyElementRotation(rotation, geometry) {
|
|
681
|
+
const origin = new import_three3.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
682
|
+
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
683
|
+
switch (rotation.axis) {
|
|
684
|
+
case "X" /* X */:
|
|
685
|
+
geometry.rotateX(toRadians(rotation.angle));
|
|
686
|
+
break;
|
|
687
|
+
case "y" /* Y */:
|
|
688
|
+
geometry.rotateY(toRadians(rotation.angle));
|
|
689
|
+
break;
|
|
690
|
+
case "z" /* Z */:
|
|
691
|
+
geometry.rotateZ(toRadians(rotation.angle));
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
if (rotation.rescale) {
|
|
695
|
+
if (Math.abs(rotation.angle) === 22.5) {
|
|
696
|
+
const s = 1 / Math.cos(0.39269909262657166);
|
|
697
|
+
geometry.scale(s, 1, s);
|
|
698
|
+
} else {
|
|
699
|
+
const s = 1 / Math.cos(0.7853981852531433);
|
|
700
|
+
geometry.scale(s, 1, s);
|
|
707
701
|
}
|
|
708
|
-
throw error;
|
|
709
702
|
}
|
|
703
|
+
geometry.translate(origin.x, origin.y, origin.z);
|
|
710
704
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
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
|
+
}
|
|
713
|
+
function applyGenericRotation(axis, rotation, obj) {
|
|
714
|
+
switch (axis) {
|
|
715
|
+
case "X" /* X */:
|
|
716
|
+
obj.rotateOnAxis(new import_three3.Vector3(1, 0, 0), toRadians(rotation));
|
|
717
|
+
break;
|
|
718
|
+
case "y" /* Y */:
|
|
719
|
+
obj.rotateOnAxis(new import_three3.Vector3(0, 1, 0), toRadians(rotation));
|
|
720
|
+
break;
|
|
721
|
+
case "z" /* Z */:
|
|
722
|
+
obj.rotateOnAxis(new import_three3.Vector3(0, 0, 1), toRadians(rotation));
|
|
723
|
+
break;
|
|
723
724
|
}
|
|
724
725
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
726
|
+
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
727
|
+
let size = new import_three3.Vector3();
|
|
728
|
+
box.getSize(size);
|
|
729
|
+
let boxGeo = new import_three3.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
730
|
+
let wireGeo = new import_three3.EdgesGeometry(boxGeo);
|
|
731
|
+
let wireMat = new import_three3.LineBasicMaterial({ color, linewidth: w });
|
|
732
|
+
let wireframe = new import_three3.LineSegments(wireGeo, wireMat);
|
|
733
|
+
obj.add(wireframe);
|
|
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
|
+
});
|
|
733
798
|
}
|
|
734
|
-
|
|
735
|
-
this.
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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
|
+
});
|
|
804
|
+
}
|
|
805
|
+
static shouldRetry(e, request) {
|
|
806
|
+
if ("code" in e) {
|
|
807
|
+
if ("ECONNABORTED" === e.code) {
|
|
808
|
+
if ("minerenderRetry" in request) {
|
|
809
|
+
if (request["minerenderRetry"] > 0) {
|
|
810
|
+
request["minerenderRetry"]--;
|
|
811
|
+
return true;
|
|
747
812
|
}
|
|
748
|
-
|
|
813
|
+
} else {
|
|
814
|
+
request["minerenderRetry"] = 3;
|
|
815
|
+
return true;
|
|
749
816
|
}
|
|
750
817
|
}
|
|
751
|
-
} finally {
|
|
752
|
-
if (signal?.aborted) {
|
|
753
|
-
this.queue.remove(request);
|
|
754
|
-
}
|
|
755
|
-
this.pendingRequests--;
|
|
756
|
-
}
|
|
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
818
|
}
|
|
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);
|
|
819
|
+
return false;
|
|
804
820
|
}
|
|
805
821
|
static setMcAssetRoot(root) {
|
|
806
|
-
this.
|
|
822
|
+
this.mcAssetInstance.defaults.baseURL = root;
|
|
807
823
|
}
|
|
808
|
-
/** Counts unsettled calls, including retry delays and requests still running after shutdown. */
|
|
809
824
|
static get queueSizes() {
|
|
810
825
|
return {
|
|
811
|
-
generic: this.genericQueue.
|
|
812
|
-
mcAsset: this.mcAssetRequestQueue.
|
|
826
|
+
generic: this.genericQueue.size,
|
|
827
|
+
mcAsset: this.mcAssetRequestQueue.size
|
|
813
828
|
};
|
|
814
829
|
}
|
|
815
830
|
/**
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
* this cleanup. See {@link shutdown}.
|
|
831
|
+
* Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
|
|
832
|
+
* exit until this is called - see {@link shutdown}.
|
|
819
833
|
*/
|
|
820
834
|
static end() {
|
|
821
835
|
this.genericQueue.end();
|
|
822
836
|
this.mcAssetRequestQueue.end();
|
|
823
837
|
}
|
|
824
838
|
};
|
|
825
|
-
|
|
826
|
-
|
|
839
|
+
_Requests.axiosInstance = import_axios.default.create({
|
|
840
|
+
timeout: 5e3
|
|
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;
|
|
827
848
|
|
|
828
849
|
// src/WrappedImage.ts
|
|
829
850
|
var WrappedImage = class {
|
|
@@ -861,10 +882,10 @@ var WrappedImage = class {
|
|
|
861
882
|
return this.animated ? this.width : this.height;
|
|
862
883
|
}
|
|
863
884
|
get frameCount() {
|
|
864
|
-
return this.height / this.
|
|
885
|
+
return this.height / this.width;
|
|
865
886
|
}
|
|
866
887
|
getFrameY(frame) {
|
|
867
|
-
return this.
|
|
888
|
+
return this.height / this.frameCount * Math.max(0, Math.min(this.frameCount, frame));
|
|
868
889
|
}
|
|
869
890
|
getSectionData(sx, sy, sw, sh) {
|
|
870
891
|
return this.dta.data.getImageData(sx, sy, sw, sh);
|
|
@@ -874,7 +895,7 @@ var WrappedImage = class {
|
|
|
874
895
|
}
|
|
875
896
|
getFrameSectionData(frame) {
|
|
876
897
|
const y = this.getFrameY(frame);
|
|
877
|
-
return this.getSectionData(0, y, this.
|
|
898
|
+
return this.getSectionData(0, y, this.width, this.width + y);
|
|
878
899
|
}
|
|
879
900
|
};
|
|
880
901
|
|
|
@@ -888,41 +909,29 @@ var ImageLoader = class _ImageLoader {
|
|
|
888
909
|
static async loadAsync(src) {
|
|
889
910
|
return new Promise((resolve, reject) => {
|
|
890
911
|
const image = this._createImage();
|
|
891
|
-
image.onload = () => resolve(image);
|
|
892
|
-
image.onerror = (err) => reject(err instanceof Error ? err : new Error("Failed to decode image"));
|
|
893
912
|
image.src = src;
|
|
913
|
+
image.onload = () => resolve(image);
|
|
914
|
+
image.onerror = (err) => reject(err);
|
|
894
915
|
});
|
|
895
916
|
}
|
|
896
917
|
static loadElement(src, onload, onerr) {
|
|
897
918
|
const image = this._createImage();
|
|
919
|
+
image.src = src;
|
|
898
920
|
if (onload)
|
|
899
921
|
image.onload = onload;
|
|
900
922
|
if (onerr)
|
|
901
923
|
image.onerror = onerr;
|
|
902
|
-
image.src = src;
|
|
903
924
|
return image;
|
|
904
925
|
}
|
|
905
926
|
static async loadData(src) {
|
|
906
927
|
console.debug(p2, "loadData", src);
|
|
907
|
-
|
|
908
|
-
return image.data.getImageData(0, 0, image.width, image.height);
|
|
928
|
+
return await this.infoToData(await this.getInfo(src));
|
|
909
929
|
}
|
|
910
930
|
static async loadCanvasData(src) {
|
|
911
|
-
|
|
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
|
-
}
|
|
931
|
+
return await this.infoToCanvasData(await this.getInfo(src));
|
|
922
932
|
}
|
|
923
933
|
static async infoToCanvasData(info) {
|
|
924
|
-
const
|
|
925
|
-
const image = await _ImageLoader.loadAsync(`data:image/${type};base64,${info.data.toString("base64")}`);
|
|
934
|
+
const image = await _ImageLoader.loadAsync(info.src);
|
|
926
935
|
const canvas = createCanvas(info.width, info.height);
|
|
927
936
|
const context = canvas.getContext("2d");
|
|
928
937
|
context.drawImage(image, 0, 0);
|
|
@@ -933,8 +942,11 @@ var ImageLoader = class _ImageLoader {
|
|
|
933
942
|
};
|
|
934
943
|
}
|
|
935
944
|
static async infoToData(info) {
|
|
936
|
-
const image = await
|
|
937
|
-
|
|
945
|
+
const image = await _ImageLoader.loadAsync(info.src);
|
|
946
|
+
const canvas = createCanvas(info.width, info.height);
|
|
947
|
+
const context = canvas.getContext("2d");
|
|
948
|
+
context.drawImage(image, 0, 0);
|
|
949
|
+
return context.getImageData(0, 0, canvas.width, canvas.height);
|
|
938
950
|
}
|
|
939
951
|
static async getData(src) {
|
|
940
952
|
const keyStr = serializeImageKey({ src });
|
|
@@ -949,25 +961,38 @@ var ImageLoader = class _ImageLoader {
|
|
|
949
961
|
});
|
|
950
962
|
}
|
|
951
963
|
static async processResponse(response) {
|
|
952
|
-
const src = response.url;
|
|
964
|
+
const src = response.config.url;
|
|
953
965
|
const data = import_buffer.Buffer.from(response.data);
|
|
954
966
|
const { width, height, type } = Env.provider.imageSize(data);
|
|
955
|
-
if (!width || !height) {
|
|
956
|
-
throw new Error("Invalid or unsupported image dimensions");
|
|
957
|
-
}
|
|
958
967
|
return {
|
|
959
968
|
src,
|
|
960
|
-
width,
|
|
961
|
-
height,
|
|
969
|
+
width: width || 0,
|
|
970
|
+
height: height || 0,
|
|
962
971
|
type,
|
|
963
972
|
data
|
|
964
973
|
};
|
|
965
974
|
}
|
|
966
975
|
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
|
+
}
|
|
967
984
|
return Requests.genericRequest({
|
|
968
985
|
url: src,
|
|
969
986
|
responseType: "arraybuffer"
|
|
970
|
-
}).then(this.processResponse)
|
|
987
|
+
}).then(this.processResponse).catch((err) => {
|
|
988
|
+
return {
|
|
989
|
+
src,
|
|
990
|
+
width: 0,
|
|
991
|
+
height: 0,
|
|
992
|
+
type: void 0,
|
|
993
|
+
data: import_buffer.Buffer.from([0])
|
|
994
|
+
};
|
|
995
|
+
});
|
|
971
996
|
}
|
|
972
997
|
static async getInfo(src) {
|
|
973
998
|
const keyStr = serializeImageKey({ src });
|
|
@@ -989,50 +1014,38 @@ var ImageLoader = class _ImageLoader {
|
|
|
989
1014
|
|
|
990
1015
|
// src/texture/TextureLoader.ts
|
|
991
1016
|
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
|
-
}
|
|
996
1017
|
static createTexture() {
|
|
997
|
-
return new
|
|
1018
|
+
return new import_three4.Texture();
|
|
998
1019
|
}
|
|
999
|
-
static loadInBackground(src, format =
|
|
1020
|
+
static loadInBackground(src, format = import_three4.RGBAFormat, rotation = 0) {
|
|
1000
1021
|
const texture = this.createTexture();
|
|
1001
|
-
|
|
1002
|
-
|
|
1022
|
+
const image = ImageLoader.loadElement(src);
|
|
1023
|
+
image.onload = function() {
|
|
1003
1024
|
texture.needsUpdate = true;
|
|
1004
|
-
}
|
|
1005
|
-
this.failedTextures.add(texture);
|
|
1006
|
-
console.warn("Failed to load texture", src, error);
|
|
1007
|
-
});
|
|
1025
|
+
};
|
|
1008
1026
|
texture.image = image;
|
|
1009
1027
|
texture.format = format;
|
|
1010
1028
|
texture.rotation = rotation;
|
|
1011
1029
|
return Textures.initTextureProps(texture);
|
|
1012
1030
|
}
|
|
1013
|
-
static load(src, format =
|
|
1014
|
-
const texture = new
|
|
1015
|
-
texture.colorSpace = THREE.SRGBColorSpace;
|
|
1031
|
+
static load(src, format = import_three4.RGBAFormat, rotation = 0) {
|
|
1032
|
+
const texture = new import_three4.Texture();
|
|
1016
1033
|
ImageLoader.getData(src).then((image) => {
|
|
1017
|
-
texture.image = image;
|
|
1018
1034
|
texture.needsUpdate = true;
|
|
1019
|
-
|
|
1020
|
-
this.failedTextures.add(texture);
|
|
1021
|
-
console.warn("Failed to load texture", src, error);
|
|
1035
|
+
texture.image = image;
|
|
1022
1036
|
});
|
|
1023
1037
|
texture.format = format;
|
|
1024
1038
|
texture.rotation = rotation;
|
|
1025
1039
|
return Textures.initTextureProps(texture);
|
|
1026
1040
|
}
|
|
1027
1041
|
};
|
|
1028
|
-
TextureLoader.failedTextures = /* @__PURE__ */ new WeakSet();
|
|
1029
1042
|
|
|
1030
1043
|
// src/texture/Textures.ts
|
|
1031
|
-
var
|
|
1044
|
+
var THREE = __toESM(require("three"));
|
|
1032
1045
|
var Textures = class _Textures {
|
|
1033
1046
|
static initTextureProps(texture) {
|
|
1034
|
-
texture.magFilter =
|
|
1035
|
-
texture.minFilter =
|
|
1047
|
+
texture.magFilter = THREE.NearestFilter;
|
|
1048
|
+
texture.minFilter = THREE.NearestFilter;
|
|
1036
1049
|
texture.anisotropy = 0;
|
|
1037
1050
|
return texture;
|
|
1038
1051
|
}
|
|
@@ -1040,19 +1053,13 @@ var Textures = class _Textures {
|
|
|
1040
1053
|
return TextureLoader.load(key.src, key.format, key.rotation);
|
|
1041
1054
|
}
|
|
1042
1055
|
static createAsset(key) {
|
|
1043
|
-
return new
|
|
1056
|
+
return new import_three5.Texture();
|
|
1044
1057
|
}
|
|
1045
1058
|
static createCanvasTexture(canvas) {
|
|
1046
|
-
|
|
1047
|
-
texture.colorSpace = THREE2.SRGBColorSpace;
|
|
1048
|
-
return this.initTextureProps(texture);
|
|
1059
|
+
return this.initTextureProps(new import_three5.CanvasTexture(canvas));
|
|
1049
1060
|
}
|
|
1050
1061
|
static getImage(key) {
|
|
1051
1062
|
const keyStr = serializeTextureKey(key);
|
|
1052
|
-
const cached = Caching.textureCache.peek(keyStr);
|
|
1053
|
-
if (cached && TextureLoader.hasFailed(cached)) {
|
|
1054
|
-
Caching.textureCache.invalidate(keyStr);
|
|
1055
|
-
}
|
|
1056
1063
|
return Caching.textureCache.get(keyStr, (k) => {
|
|
1057
1064
|
return _Textures.createImage(key);
|
|
1058
1065
|
});
|
|
@@ -1068,26 +1075,26 @@ var _Materials = class _Materials {
|
|
|
1068
1075
|
}
|
|
1069
1076
|
static createImage(key) {
|
|
1070
1077
|
const transparent = key.transparent || false;
|
|
1071
|
-
return new
|
|
1078
|
+
return new import_three6.MeshBasicMaterial({
|
|
1072
1079
|
map: Textures.getImage(key.texture),
|
|
1073
1080
|
transparent,
|
|
1074
|
-
side: transparent ?
|
|
1081
|
+
side: transparent ? import_three6.DoubleSide : import_three6.FrontSide,
|
|
1075
1082
|
alphaTest: 0.5
|
|
1076
1083
|
});
|
|
1077
1084
|
}
|
|
1078
1085
|
static createBasicCanvasMaterial(canvas, transparent = false, shade = false) {
|
|
1079
1086
|
if (shade) {
|
|
1080
|
-
return new
|
|
1087
|
+
return new import_three6.MeshStandardMaterial({
|
|
1081
1088
|
map: Textures.createCanvasTexture(canvas),
|
|
1082
1089
|
transparent,
|
|
1083
|
-
side: transparent ?
|
|
1090
|
+
side: transparent ? import_three6.DoubleSide : import_three6.FrontSide,
|
|
1084
1091
|
alphaTest: 0.5
|
|
1085
1092
|
});
|
|
1086
1093
|
}
|
|
1087
|
-
return new
|
|
1094
|
+
return new import_three6.MeshBasicMaterial({
|
|
1088
1095
|
map: Textures.createCanvasTexture(canvas),
|
|
1089
1096
|
transparent,
|
|
1090
|
-
side: transparent ?
|
|
1097
|
+
side: transparent ? import_three6.DoubleSide : import_three6.FrontSide,
|
|
1091
1098
|
alphaTest: 0.5
|
|
1092
1099
|
});
|
|
1093
1100
|
}
|
|
@@ -1108,11 +1115,7 @@ var _Materials = class _Materials {
|
|
|
1108
1115
|
|
|
1109
1116
|
if (SHADE) {
|
|
1110
1117
|
|
|
1111
|
-
|
|
1112
|
-
vec3 N = vec3( modelMatrix * instanceMatrix * vec4(normal, 0.0) );
|
|
1113
|
-
#else
|
|
1114
|
-
vec3 N = vec3( modelMatrix * vec4(normal, 0.0) );
|
|
1115
|
-
#endif
|
|
1118
|
+
vec3 N = vec3( modelMatrix * instanceMatrix * vec4(normal, 0.0) );
|
|
1116
1119
|
|
|
1117
1120
|
float yLight = (1.0+N.y) * 0.5;
|
|
1118
1121
|
light = yLight * (1.0-AMBIENT) + N.x*N.x * XFAC + N.z*N.z * ZFAC + AMBIENT;
|
|
@@ -1170,19 +1173,16 @@ var _Materials = class _Materials {
|
|
|
1170
1173
|
gl_FragColor = vec4(lift + color.rgb * light2, 1.0);
|
|
1171
1174
|
|
|
1172
1175
|
}
|
|
1173
|
-
|
|
1174
|
-
#include <tonemapping_fragment>
|
|
1175
|
-
#include <colorspace_fragment>
|
|
1176
1176
|
}
|
|
1177
1177
|
`;
|
|
1178
1178
|
try {
|
|
1179
|
-
return new
|
|
1179
|
+
return new import_three6.ShaderMaterial({
|
|
1180
1180
|
uniforms: {
|
|
1181
1181
|
SHADE: { value: true },
|
|
1182
1182
|
BRIGHTNESS: { value: 1 },
|
|
1183
1183
|
EMISSIVE: { value: false },
|
|
1184
1184
|
base: {
|
|
1185
|
-
value: new
|
|
1185
|
+
value: new import_three6.Color(12698049)
|
|
1186
1186
|
/*TODO*/
|
|
1187
1187
|
},
|
|
1188
1188
|
map: { value: Textures.createCanvasTexture(canvas) }
|
|
@@ -1191,7 +1191,7 @@ var _Materials = class _Materials {
|
|
|
1191
1191
|
fragmentShader: fragShader,
|
|
1192
1192
|
vertexColors: true,
|
|
1193
1193
|
transparent,
|
|
1194
|
-
side: transparent ?
|
|
1194
|
+
side: transparent ? import_three6.DoubleSide : import_three6.FrontSide,
|
|
1195
1195
|
alphaTest: 0.5
|
|
1196
1196
|
});
|
|
1197
1197
|
} catch (e) {
|
|
@@ -1201,10 +1201,6 @@ var _Materials = class _Materials {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
static getImage(key) {
|
|
1203
1203
|
const keyStr = serializeMaterialKey(key);
|
|
1204
|
-
const map = Caching.materialCache.peek(keyStr)?.map;
|
|
1205
|
-
if (map && TextureLoader.hasFailed(map)) {
|
|
1206
|
-
Caching.materialCache.invalidate(keyStr);
|
|
1207
|
-
}
|
|
1208
1204
|
return Caching.materialCache.get(keyStr, (k) => {
|
|
1209
1205
|
return _Materials.createImage(key);
|
|
1210
1206
|
});
|
|
@@ -1229,10 +1225,10 @@ _Materials.MISSING_TEXTURE_SRC = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA
|
|
|
1229
1225
|
var Materials = _Materials;
|
|
1230
1226
|
|
|
1231
1227
|
// src/Meshes.ts
|
|
1232
|
-
var
|
|
1228
|
+
var import_three7 = require("three");
|
|
1233
1229
|
var Meshes = class _Meshes {
|
|
1234
1230
|
static createBox(key) {
|
|
1235
|
-
return new
|
|
1231
|
+
return new import_three7.Mesh(Geometries.getBox(key.geometry), Materials.getImage(key.material));
|
|
1236
1232
|
}
|
|
1237
1233
|
static getBox(key) {
|
|
1238
1234
|
const keyStr = serializeMeshKey(key);
|
|
@@ -1299,7 +1295,7 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1299
1295
|
}
|
|
1300
1296
|
toString() {
|
|
1301
1297
|
let a = [
|
|
1302
|
-
this.root ?? AssetLoader.ROOT,
|
|
1298
|
+
typeof this.root !== "undefined" || AssetLoader.ROOT !== DEFAULT_ROOT ? this.root ?? AssetLoader.ROOT : "__root__",
|
|
1303
1299
|
this.rootType ?? "__rootType__",
|
|
1304
1300
|
this.assetType ?? "__assetType__",
|
|
1305
1301
|
this.type ?? "__type__",
|
|
@@ -1309,12 +1305,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1309
1305
|
return a.join("/");
|
|
1310
1306
|
}
|
|
1311
1307
|
getFullPath() {
|
|
1312
|
-
let
|
|
1308
|
+
let p13 = [];
|
|
1313
1309
|
if (this.type) {
|
|
1314
|
-
|
|
1310
|
+
p13.push(this.type);
|
|
1315
1311
|
}
|
|
1316
|
-
|
|
1317
|
-
return
|
|
1312
|
+
p13.push(this.path);
|
|
1313
|
+
return p13.join("/");
|
|
1318
1314
|
}
|
|
1319
1315
|
toNamespacedString() {
|
|
1320
1316
|
return this.namespace + ":" + this.getFullPath();
|
|
@@ -1336,10 +1332,10 @@ var ModelMerger = class {
|
|
|
1336
1332
|
const models = await this.collectAllParents(model);
|
|
1337
1333
|
let merged = {};
|
|
1338
1334
|
for (let parentModel of models) {
|
|
1339
|
-
merged = import_ts_deepmerge.default
|
|
1335
|
+
merged = (0, import_ts_deepmerge.default)(merged, parentModel);
|
|
1340
1336
|
}
|
|
1341
|
-
merged = import_ts_deepmerge.default
|
|
1342
|
-
merged.hierarchy = models.map((m) => m.parent).filter((
|
|
1337
|
+
merged = (0, import_ts_deepmerge.default)(merged, model);
|
|
1338
|
+
merged.hierarchy = models.map((m) => m.parent).filter((p13) => `${p13}`);
|
|
1343
1339
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1344
1340
|
return merged;
|
|
1345
1341
|
}
|
|
@@ -1349,7 +1345,6 @@ var ModelMerger = class {
|
|
|
1349
1345
|
}
|
|
1350
1346
|
const models = [];
|
|
1351
1347
|
const parentKey = AssetKey.parse("models", model.parent);
|
|
1352
|
-
parentKey.root = model.key?.root;
|
|
1353
1348
|
const parentModel = await Models.getRaw(parentKey);
|
|
1354
1349
|
if (parentModel) {
|
|
1355
1350
|
models.unshift(parentModel);
|
|
@@ -1359,6 +1354,9 @@ var ModelMerger = class {
|
|
|
1359
1354
|
}
|
|
1360
1355
|
};
|
|
1361
1356
|
|
|
1357
|
+
// src/assets/Models.ts
|
|
1358
|
+
var import_typescript_memoize = require("typescript-memoize");
|
|
1359
|
+
|
|
1362
1360
|
// src/assets/source/parser/AssetParsers.ts
|
|
1363
1361
|
var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
1364
1362
|
AssetParser2["MODEL"] = "model";
|
|
@@ -1372,65 +1370,30 @@ var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
|
1372
1370
|
})(AssetParser || {});
|
|
1373
1371
|
|
|
1374
1372
|
// src/assets/Models.ts
|
|
1375
|
-
var
|
|
1373
|
+
var _Models = class _Models {
|
|
1376
1374
|
// opened lazily: touching the store at import time would hit IndexedDB/disk just for loading
|
|
1377
1375
|
// the library, and would require an EnvProvider before any entry has had a chance to register
|
|
1378
1376
|
static get PERSISTENT_CACHE() {
|
|
1379
1377
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-models"));
|
|
1380
1378
|
}
|
|
1381
1379
|
static async getItemList() {
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1380
|
+
return AssetLoader.get(new AssetKey(
|
|
1381
|
+
DEFAULT_NAMESPACE,
|
|
1382
|
+
"_list",
|
|
1383
|
+
"models",
|
|
1384
|
+
"item",
|
|
1385
|
+
"assets",
|
|
1386
|
+
".json",
|
|
1387
|
+
DEFAULT_ROOT
|
|
1388
|
+
), "list" /* LIST */).then((r) => r?.files ?? []);
|
|
1387
1389
|
}
|
|
1388
1390
|
static async loadAndMerge(key) {
|
|
1389
|
-
const model =
|
|
1391
|
+
const model = await this.getRaw(key);
|
|
1390
1392
|
if (!model) {
|
|
1391
1393
|
return void 0;
|
|
1392
1394
|
}
|
|
1393
1395
|
return ModelMerger.mergeWithParents(model);
|
|
1394
1396
|
}
|
|
1395
|
-
static async getItemModel(key) {
|
|
1396
|
-
const itemKey = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
1397
|
-
const model = await this.PERSISTENT_CACHE.getOrLoad(itemKey.serialize(), async () => {
|
|
1398
|
-
const result = await AssetLoader.getFirst([itemKey, key], "json" /* JSON */);
|
|
1399
|
-
if (!result) return void 0;
|
|
1400
|
-
if (result.key.assetType !== "items") return { ...result.asset, key };
|
|
1401
|
-
const reference = this.defaultItemModel(result.asset.model, key);
|
|
1402
|
-
const modelKey = AssetKey.parse("models", reference);
|
|
1403
|
-
modelKey.root = key.root;
|
|
1404
|
-
const model2 = await this.getRaw(modelKey);
|
|
1405
|
-
if (!model2) throw new Error(`Item ${key.toNamespacedString()} references missing model ${reference}`);
|
|
1406
|
-
return model2;
|
|
1407
|
-
});
|
|
1408
|
-
return model ? { ...model, key: Object.assign(new AssetKey("", ""), model.key) } : void 0;
|
|
1409
|
-
}
|
|
1410
|
-
// Item previews use the GUI context, false conditions, and zero numeric properties.
|
|
1411
|
-
static defaultItemModel(node, key) {
|
|
1412
|
-
if (!node || typeof node.type !== "string") {
|
|
1413
|
-
throw new Error(`Unsupported item model definition for ${key.toNamespacedString()}`);
|
|
1414
|
-
}
|
|
1415
|
-
switch (node.type.replace(/^minecraft:/, "")) {
|
|
1416
|
-
case "model":
|
|
1417
|
-
if (typeof node.model === "string" && node.model) return node.model;
|
|
1418
|
-
break;
|
|
1419
|
-
case "condition":
|
|
1420
|
-
return this.defaultItemModel(node.on_false, key);
|
|
1421
|
-
case "select": {
|
|
1422
|
-
const selected = node.property?.replace(/^minecraft:/, "") === "display_context" ? node.cases?.find((entry) => Array.isArray(entry.when) ? entry.when.includes("gui") : entry.when === "gui")?.model : void 0;
|
|
1423
|
-
return this.defaultItemModel(selected ?? node.fallback, key);
|
|
1424
|
-
}
|
|
1425
|
-
case "range_dispatch": {
|
|
1426
|
-
const selected = node.entries?.reduce((match, entry) => {
|
|
1427
|
-
return entry.threshold <= 0 && (!match || entry.threshold >= match.threshold) ? entry : match;
|
|
1428
|
-
}, void 0);
|
|
1429
|
-
return this.defaultItemModel(selected?.model ?? node.fallback, key);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
throw new Error(`Unsupported item model ${node?.type ?? "definition"} for ${key.toNamespacedString()}`);
|
|
1433
|
-
}
|
|
1434
1397
|
static async getRaw(key) {
|
|
1435
1398
|
if (!key.assetType) {
|
|
1436
1399
|
key.assetType = "models";
|
|
@@ -1469,15 +1432,19 @@ var Models = class _Models {
|
|
|
1469
1432
|
return this.PERSISTENT_CACHE.clear();
|
|
1470
1433
|
}
|
|
1471
1434
|
};
|
|
1435
|
+
__decorateClass([
|
|
1436
|
+
(0, import_typescript_memoize.Memoize)()
|
|
1437
|
+
], _Models, "getItemList", 1);
|
|
1438
|
+
var Models = _Models;
|
|
1472
1439
|
|
|
1473
1440
|
// src/assets/BlockStates.ts
|
|
1441
|
+
var import_typescript_memoize2 = require("typescript-memoize");
|
|
1474
1442
|
var BlockStates = class {
|
|
1475
1443
|
static get PERSISTENT_CACHE() {
|
|
1476
1444
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-blockstates"));
|
|
1477
1445
|
}
|
|
1478
|
-
// BlockState names are hardcoded
|
|
1479
1446
|
static async getList() {
|
|
1480
|
-
|
|
1447
|
+
return AssetLoader.get(new AssetKey(
|
|
1481
1448
|
DEFAULT_NAMESPACE,
|
|
1482
1449
|
"_list",
|
|
1483
1450
|
"blockstates",
|
|
@@ -1485,16 +1452,11 @@ var BlockStates = class {
|
|
|
1485
1452
|
"assets",
|
|
1486
1453
|
".json",
|
|
1487
1454
|
DEFAULT_ROOT
|
|
1488
|
-
);
|
|
1489
|
-
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1490
|
-
return AssetLoader.get(key, "list" /* LIST */);
|
|
1491
|
-
}).then((r) => r?.files ?? []);
|
|
1455
|
+
), "list" /* LIST */).then((r) => r?.files ?? []);
|
|
1492
1456
|
}
|
|
1493
1457
|
static async getDefaultStates() {
|
|
1494
1458
|
const key = AssetKey.parse("blockstates", "minerender:defaultBlockStates");
|
|
1495
|
-
return
|
|
1496
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
1497
|
-
});
|
|
1459
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
1498
1460
|
}
|
|
1499
1461
|
static async getDefaultState(key) {
|
|
1500
1462
|
const defaultStates = await this.getDefaultStates();
|
|
@@ -1533,11 +1495,17 @@ var BlockStates = class {
|
|
|
1533
1495
|
await this.PERSISTENT_CACHE.clear();
|
|
1534
1496
|
}
|
|
1535
1497
|
};
|
|
1498
|
+
__decorateClass([
|
|
1499
|
+
(0, import_typescript_memoize2.Memoize)()
|
|
1500
|
+
], BlockStates, "getList", 1);
|
|
1501
|
+
__decorateClass([
|
|
1502
|
+
(0, import_typescript_memoize2.Memoize)()
|
|
1503
|
+
], BlockStates, "getDefaultStates", 1);
|
|
1536
1504
|
var DefaultBlockStates = class {
|
|
1537
1505
|
};
|
|
1538
1506
|
|
|
1539
1507
|
// src/assets/Assets.ts
|
|
1540
|
-
var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.
|
|
1508
|
+
var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.17.1";
|
|
1541
1509
|
var DEFAULT_NAMESPACE = "minecraft";
|
|
1542
1510
|
var Assets = class {
|
|
1543
1511
|
/**
|
|
@@ -1559,150 +1527,13 @@ var AssetSource = class {
|
|
|
1559
1527
|
constructor() {
|
|
1560
1528
|
}
|
|
1561
1529
|
};
|
|
1562
|
-
var AssetLoadError = class extends Error {
|
|
1563
|
-
constructor(source, key, path, cause) {
|
|
1564
|
-
super(`Failed to load ${key.toNamespacedString()} from ${path}${cause instanceof Error ? `: ${cause.message}` : ""}`);
|
|
1565
|
-
this.source = source;
|
|
1566
|
-
this.key = key;
|
|
1567
|
-
this.path = path;
|
|
1568
|
-
this.cause = cause;
|
|
1569
|
-
this.name = "AssetLoadError";
|
|
1570
|
-
}
|
|
1571
|
-
};
|
|
1572
1530
|
|
|
1573
|
-
// src/
|
|
1574
|
-
var
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
this.task = setInterval(() => this.run());
|
|
1580
|
-
}
|
|
1581
|
-
submit(task) {
|
|
1582
|
-
this.queue.push(task);
|
|
1583
|
-
}
|
|
1584
|
-
run() {
|
|
1585
|
-
for (let i = 0; i < this.batch; i++) {
|
|
1586
|
-
this.runNext();
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
runNext() {
|
|
1590
|
-
let next = this.queue.shift();
|
|
1591
|
-
if (next) next();
|
|
1592
|
-
}
|
|
1593
|
-
};
|
|
1594
|
-
|
|
1595
|
-
// src/util/model.ts
|
|
1596
|
-
var import_three7 = require("three");
|
|
1597
|
-
function applyElementRotation(rotation, geometry) {
|
|
1598
|
-
const origin = new import_three7.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1599
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1600
|
-
switch (rotation.axis) {
|
|
1601
|
-
case "x" /* X */:
|
|
1602
|
-
geometry.rotateX(toRadians(rotation.angle));
|
|
1603
|
-
break;
|
|
1604
|
-
case "y" /* Y */:
|
|
1605
|
-
geometry.rotateY(toRadians(rotation.angle));
|
|
1606
|
-
break;
|
|
1607
|
-
case "z" /* Z */:
|
|
1608
|
-
geometry.rotateZ(toRadians(rotation.angle));
|
|
1609
|
-
break;
|
|
1610
|
-
}
|
|
1611
|
-
if (rotation.rescale) {
|
|
1612
|
-
if (Math.abs(rotation.angle) === 22.5) {
|
|
1613
|
-
const s = 1 / Math.cos(0.39269909262657166);
|
|
1614
|
-
geometry.scale(s, 1, s);
|
|
1615
|
-
} else {
|
|
1616
|
-
const s = 1 / Math.cos(0.7853981852531433);
|
|
1617
|
-
geometry.scale(s, 1, s);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
1621
|
-
}
|
|
1622
|
-
function applyModelPartRotation(modelPart, geometry) {
|
|
1623
|
-
const origin = new import_three7.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1624
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1625
|
-
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1626
|
-
geometry.rotateY(toRadians(modelPart.yaw));
|
|
1627
|
-
geometry.rotateZ(toRadians(modelPart.roll));
|
|
1628
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
1629
|
-
}
|
|
1630
|
-
function applyGenericRotation(axis, rotation, obj) {
|
|
1631
|
-
switch (axis) {
|
|
1632
|
-
case "x" /* X */:
|
|
1633
|
-
obj.rotateOnAxis(new import_three7.Vector3(1, 0, 0), toRadians(rotation));
|
|
1634
|
-
break;
|
|
1635
|
-
case "y" /* Y */:
|
|
1636
|
-
obj.rotateOnAxis(new import_three7.Vector3(0, 1, 0), toRadians(rotation));
|
|
1637
|
-
break;
|
|
1638
|
-
case "z" /* Z */:
|
|
1639
|
-
obj.rotateOnAxis(new import_three7.Vector3(0, 0, 1), toRadians(rotation));
|
|
1640
|
-
break;
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1644
|
-
let size = new import_three7.Vector3();
|
|
1645
|
-
box.getSize(size);
|
|
1646
|
-
let boxGeo = new import_three7.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
1647
|
-
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1648
|
-
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1649
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1650
|
-
obj.add(wireframe);
|
|
1651
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1652
|
-
obj.add(axes);
|
|
1653
|
-
}
|
|
1654
|
-
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
1655
|
-
let boxGeo = new import_three7.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
1656
|
-
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1657
|
-
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1658
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1659
|
-
obj.add(wireframe);
|
|
1660
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1661
|
-
obj.add(axes);
|
|
1662
|
-
}
|
|
1663
|
-
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
1664
|
-
let wireGeo = new import_three7.EdgesGeometry(geo);
|
|
1665
|
-
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1666
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1667
|
-
mesh.add(wireframe);
|
|
1668
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1669
|
-
mesh.add(axes);
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
|
-
// src/util/performance.ts
|
|
1673
|
-
function captureException(e, ...extra) {
|
|
1674
|
-
console.error(e, extra);
|
|
1675
|
-
}
|
|
1676
|
-
function timingStart(marker) {
|
|
1677
|
-
console.time(marker);
|
|
1678
|
-
}
|
|
1679
|
-
function timingEnd(marker) {
|
|
1680
|
-
console.timeEnd(marker);
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
// src/util/three.ts
|
|
1684
|
-
function isObject3D(obj) {
|
|
1685
|
-
return obj.isObject3D;
|
|
1686
|
-
}
|
|
1687
|
-
function isMesh(obj) {
|
|
1688
|
-
return obj.isMesh;
|
|
1689
|
-
}
|
|
1690
|
-
function isInstancedMesh(obj) {
|
|
1691
|
-
return obj.isInstancedMesh;
|
|
1692
|
-
}
|
|
1693
|
-
function isPerspectiveCamera(obj) {
|
|
1694
|
-
return obj.isPerspectiveCamera;
|
|
1695
|
-
}
|
|
1696
|
-
function isOrthographicCamera(obj) {
|
|
1697
|
-
return obj.isOrthographicCamera;
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
// src/nbt/NBTHelper.ts
|
|
1701
|
-
var NBTHelper = class {
|
|
1702
|
-
static async fromBuffer(buffer) {
|
|
1703
|
-
const prismarineNbt = await import("prismarine-nbt");
|
|
1704
|
-
const { parsed, type, metadata } = await prismarineNbt.parse(buffer);
|
|
1705
|
-
return parsed;
|
|
1531
|
+
// src/nbt/NBTHelper.ts
|
|
1532
|
+
var NBTHelper = class {
|
|
1533
|
+
static async fromBuffer(buffer) {
|
|
1534
|
+
const prismarineNbt = await import("prismarine-nbt");
|
|
1535
|
+
const { parsed, type, metadata } = await prismarineNbt.parse(buffer);
|
|
1536
|
+
return parsed;
|
|
1706
1537
|
}
|
|
1707
1538
|
};
|
|
1708
1539
|
|
|
@@ -1747,25 +1578,31 @@ var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
|
|
|
1747
1578
|
console.info(p3, "Loading", key);
|
|
1748
1579
|
const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1749
1580
|
console.debug(p3, url);
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1581
|
+
let req = {
|
|
1582
|
+
url
|
|
1583
|
+
};
|
|
1584
|
+
parser.config(req);
|
|
1585
|
+
return await Requests.mcAssetRequest(req).then((response) => {
|
|
1586
|
+
if (response && response.data) {
|
|
1587
|
+
try {
|
|
1588
|
+
return parser.parse(response);
|
|
1589
|
+
} catch (e) {
|
|
1590
|
+
console.warn("Parser failed to process response", response, e);
|
|
1591
|
+
throw e;
|
|
1759
1592
|
}
|
|
1760
|
-
throw cause;
|
|
1761
1593
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1594
|
+
return void 0;
|
|
1595
|
+
}).catch((err) => {
|
|
1596
|
+
if (err.response) {
|
|
1597
|
+
let response = err.response;
|
|
1598
|
+
if (response.status === 404) {
|
|
1599
|
+
console.debug(p3, key, "not found");
|
|
1600
|
+
return void 0;
|
|
1601
|
+
}
|
|
1764
1602
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
}
|
|
1603
|
+
console.debug(p3, "Failed to load", key, err?.message);
|
|
1604
|
+
return void 0;
|
|
1605
|
+
});
|
|
1769
1606
|
}
|
|
1770
1607
|
assetBasePath(key) {
|
|
1771
1608
|
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 + "/" : ""}`;
|
|
@@ -1872,6 +1709,7 @@ var BrowserArchiveProxy = class {
|
|
|
1872
1709
|
};
|
|
1873
1710
|
|
|
1874
1711
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
1712
|
+
var p4 = prefix("ArchiveAssetSource");
|
|
1875
1713
|
var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
1876
1714
|
constructor(archiveProxy) {
|
|
1877
1715
|
super();
|
|
@@ -1890,31 +1728,74 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1890
1728
|
}
|
|
1891
1729
|
async get(key, parser) {
|
|
1892
1730
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
async load(key, parser) {
|
|
1731
|
+
console.log("ArchiveAssetSource.get", key, parser);
|
|
1732
|
+
let entries = await this.getEntries();
|
|
1896
1733
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
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
|
+
}
|
|
1902
1764
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1765
|
+
console.debug(p4, "Failed to load", key, err?.message);
|
|
1766
|
+
return void 0;
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
//TODO: abstract this
|
|
1770
|
+
async load(key, parser) {
|
|
1771
|
+
console.info(p4, "Loading", key);
|
|
1772
|
+
const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1773
|
+
console.debug(p4, url);
|
|
1774
|
+
let req = {
|
|
1775
|
+
url
|
|
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
|
+
}
|
|
1909
1786
|
}
|
|
1910
|
-
return
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1787
|
+
return void 0;
|
|
1788
|
+
}).catch((err) => {
|
|
1789
|
+
if (err.response) {
|
|
1790
|
+
let response = err.response;
|
|
1791
|
+
if (response.status === 404) {
|
|
1792
|
+
console.debug(p4, key, "not found");
|
|
1793
|
+
return void 0;
|
|
1794
|
+
}
|
|
1916
1795
|
}
|
|
1917
|
-
|
|
1796
|
+
console.debug(p4, "Failed to load", key, err?.message);
|
|
1797
|
+
return void 0;
|
|
1798
|
+
});
|
|
1918
1799
|
}
|
|
1919
1800
|
assetBasePath(key) {
|
|
1920
1801
|
return `${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
|
|
@@ -1922,17 +1803,18 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1922
1803
|
};
|
|
1923
1804
|
|
|
1924
1805
|
// src/assets/AssetLoader.ts
|
|
1925
|
-
var
|
|
1806
|
+
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
1807
|
+
var p5 = prefix("AssetLoader");
|
|
1926
1808
|
var _AssetLoader = class _AssetLoader {
|
|
1927
1809
|
static addSource(key, source, override = true) {
|
|
1928
1810
|
if (override) {
|
|
1929
1811
|
const existing = this.removeSource(key);
|
|
1930
1812
|
if (existing) {
|
|
1931
|
-
console.log(
|
|
1813
|
+
console.log(p5, "Removed existing AssetSource", key);
|
|
1932
1814
|
}
|
|
1933
1815
|
}
|
|
1934
1816
|
this._SOURCES.unshift({ key, source });
|
|
1935
|
-
console.log(
|
|
1817
|
+
console.log(p5, "Added AssetSource", key);
|
|
1936
1818
|
}
|
|
1937
1819
|
static removeSource(key) {
|
|
1938
1820
|
const index = this._SOURCES.findIndex((s) => s.key === key);
|
|
@@ -1945,6 +1827,7 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1945
1827
|
return void 0;
|
|
1946
1828
|
}
|
|
1947
1829
|
static async getAll(key, parser) {
|
|
1830
|
+
console.log(this._SOURCES);
|
|
1948
1831
|
let promises = [];
|
|
1949
1832
|
for (const source of this._SOURCES) {
|
|
1950
1833
|
promises.push(source.source.get(key, parser));
|
|
@@ -1953,34 +1836,24 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1953
1836
|
return results.filter((r) => r != void 0);
|
|
1954
1837
|
});
|
|
1955
1838
|
}
|
|
1956
|
-
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
1957
1839
|
static async get(key, parser) {
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
}
|
|
1972
|
-
/** Tries each path within a source before considering lower-priority sources. */
|
|
1973
|
-
static async getFirst(keys, parser) {
|
|
1974
|
-
const sources = [...this._SOURCES];
|
|
1975
|
-
for (const source of sources) {
|
|
1976
|
-
for (const key of keys) {
|
|
1977
|
-
const result = await source.source.get(key, parser);
|
|
1978
|
-
if (result !== void 0) {
|
|
1979
|
-
return { key, asset: result };
|
|
1840
|
+
console.log(this._SOURCES);
|
|
1841
|
+
let promises = [];
|
|
1842
|
+
for (const source of this._SOURCES) {
|
|
1843
|
+
promises.push(source.source.get(key, parser));
|
|
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;
|
|
1980
1853
|
}
|
|
1981
1854
|
}
|
|
1982
|
-
|
|
1983
|
-
|
|
1855
|
+
return void 0;
|
|
1856
|
+
});
|
|
1984
1857
|
}
|
|
1985
1858
|
};
|
|
1986
1859
|
_AssetLoader.ROOT = DEFAULT_ROOT;
|
|
@@ -1995,21 +1868,11 @@ var ModelTextures = class {
|
|
|
1995
1868
|
return this._persistentMetaCache ?? (this._persistentMetaCache = PersistentCache.open("minerender-texturemeta"));
|
|
1996
1869
|
}
|
|
1997
1870
|
static async get(key) {
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
try {
|
|
2002
|
-
const asset = await pending;
|
|
2003
|
-
if (asset) {
|
|
2004
|
-
return await ImageLoader.infoToCanvasData(asset);
|
|
2005
|
-
}
|
|
2006
|
-
return void 0;
|
|
2007
|
-
} catch (err) {
|
|
2008
|
-
if (cached && Caching.textureAssetCache.getIfPresent(keyStr) === cached) {
|
|
2009
|
-
Caching.textureAssetCache.invalidate(keyStr);
|
|
2010
|
-
}
|
|
2011
|
-
throw err;
|
|
1871
|
+
const asset = await this.preload(key);
|
|
1872
|
+
if (asset) {
|
|
1873
|
+
return ImageLoader.infoToCanvasData(asset);
|
|
2012
1874
|
}
|
|
1875
|
+
return void 0;
|
|
2013
1876
|
}
|
|
2014
1877
|
static async preload(key) {
|
|
2015
1878
|
const keyStr = key.serialize();
|
|
@@ -2200,7 +2063,7 @@ var ModelGenerator = class {
|
|
|
2200
2063
|
ModelGenerator.ITEM_LAYERS = ["layer0", "layer1", "layer2", "layer3", "layer4"];
|
|
2201
2064
|
|
|
2202
2065
|
// src/UVMapper.ts
|
|
2203
|
-
var
|
|
2066
|
+
var p6 = prefix("UVMapper");
|
|
2204
2067
|
var DEFAULT_UV = [0, 0, 16, 16];
|
|
2205
2068
|
var X = 0;
|
|
2206
2069
|
var Y = 1;
|
|
@@ -2377,7 +2240,7 @@ var UVMapper = class {
|
|
|
2377
2240
|
const metaMap = {};
|
|
2378
2241
|
const model = { ...originalModel };
|
|
2379
2242
|
const isItemModel = !("elements" in model);
|
|
2380
|
-
console.debug(
|
|
2243
|
+
console.debug(p6, "Creating Atlas for", model.key);
|
|
2381
2244
|
if (model.textures) {
|
|
2382
2245
|
const promises = [];
|
|
2383
2246
|
const uniqueTextureNames = [];
|
|
@@ -2391,7 +2254,7 @@ var UVMapper = class {
|
|
|
2391
2254
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
2392
2255
|
promises.push(ModelTextures.get(assetKey).then((asset) => {
|
|
2393
2256
|
if (!asset) {
|
|
2394
|
-
console.warn(
|
|
2257
|
+
console.warn(p6, "Missing texture", assetKey);
|
|
2395
2258
|
return;
|
|
2396
2259
|
}
|
|
2397
2260
|
textureMap[textureKey] = new WrappedImage(asset);
|
|
@@ -2403,7 +2266,7 @@ var UVMapper = class {
|
|
|
2403
2266
|
}
|
|
2404
2267
|
await Promise.all(promises);
|
|
2405
2268
|
const textureCount = uniqueTextureNames.length;
|
|
2406
|
-
console.debug(
|
|
2269
|
+
console.debug(p6, "Creating Atlas for", textureCount, "textures");
|
|
2407
2270
|
this.fillMissingTextureKeys(model.textures, textureMap);
|
|
2408
2271
|
this.fillMissingTextureKeys(model.textures, metaMap);
|
|
2409
2272
|
const sizes = {};
|
|
@@ -2423,7 +2286,7 @@ var UVMapper = class {
|
|
|
2423
2286
|
this.fillMissingTextureKeys(model.textures, sizes);
|
|
2424
2287
|
const s = Math.ceil(Math.sqrt(textureCount + 1));
|
|
2425
2288
|
const size = Math.ceil(s * maxWidth);
|
|
2426
|
-
console.debug(
|
|
2289
|
+
console.debug(p6, "Atlas size:", size);
|
|
2427
2290
|
const squaredSize = size * size;
|
|
2428
2291
|
const missing = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC");
|
|
2429
2292
|
const empty = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA5JREFUKM9jGAWjgAIAAAJAAAFSSwuTAAAAAElFTkSuQmCC");
|
|
@@ -2478,10 +2341,10 @@ var UVMapper = class {
|
|
|
2478
2341
|
}
|
|
2479
2342
|
}
|
|
2480
2343
|
const atlasImageData = image.toDataURL();
|
|
2481
|
-
console.log(
|
|
2344
|
+
console.log(p6, "Atlas Image for", model.key, atlasImageData);
|
|
2482
2345
|
this.fillMissingTextureKeys(model.textures, positions);
|
|
2483
2346
|
if (isItemModel) {
|
|
2484
|
-
console.debug(
|
|
2347
|
+
console.debug(p6, "Generating item model for", model);
|
|
2485
2348
|
model.elements = [];
|
|
2486
2349
|
for (let layerName of ModelGenerator.ITEM_LAYERS) {
|
|
2487
2350
|
const textureImage = textureMap[layerName];
|
|
@@ -2489,7 +2352,7 @@ var UVMapper = class {
|
|
|
2489
2352
|
model.elements.push(...ModelGenerator.generateItemModel(textureImage.data, layerName));
|
|
2490
2353
|
}
|
|
2491
2354
|
}
|
|
2492
|
-
console.debug(
|
|
2355
|
+
console.debug(p6, "Item model elements", model.elements);
|
|
2493
2356
|
}
|
|
2494
2357
|
if (!model.elements) {
|
|
2495
2358
|
}
|
|
@@ -2507,13 +2370,17 @@ var UVMapper = class {
|
|
|
2507
2370
|
this.setCubeFaceUvInArray(uv, faceIndex * 4, [0, 1, 8 / size, (size - 8) / size]);
|
|
2508
2371
|
continue;
|
|
2509
2372
|
}
|
|
2510
|
-
if (!face.texture) continue;
|
|
2511
2373
|
if (!face.uv) {
|
|
2512
2374
|
face.uv = this.getFallbackUv(element, faceName);
|
|
2513
2375
|
}
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2376
|
+
let faceTexture = face.texture;
|
|
2377
|
+
let texPosition;
|
|
2378
|
+
let texSize;
|
|
2379
|
+
if (faceTexture) {
|
|
2380
|
+
faceTexture = faceTexture.substr(1);
|
|
2381
|
+
texPosition = positions[faceTexture] || [0, 0];
|
|
2382
|
+
texSize = sizes[faceTexture] || [16, 16];
|
|
2383
|
+
}
|
|
2517
2384
|
let texPosV = new import_three8.Vector2(texPosition[0], texPosition[1]);
|
|
2518
2385
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
2519
2386
|
tl.add(texPosV);
|
|
@@ -2545,7 +2412,7 @@ var UVMapper = class {
|
|
|
2545
2412
|
hasTransparency
|
|
2546
2413
|
);
|
|
2547
2414
|
} else {
|
|
2548
|
-
console.warn(
|
|
2415
|
+
console.warn(p6, "Model does not have any textures", model);
|
|
2549
2416
|
}
|
|
2550
2417
|
return void 0;
|
|
2551
2418
|
}
|
|
@@ -2683,20 +2550,17 @@ function shutdown() {
|
|
|
2683
2550
|
}
|
|
2684
2551
|
|
|
2685
2552
|
// src/assets/Entities.ts
|
|
2553
|
+
var import_typescript_memoize3 = require("typescript-memoize");
|
|
2686
2554
|
var Entities = class {
|
|
2687
2555
|
static async getBlockEntityModels() {
|
|
2688
2556
|
const key = AssetKey.parse("models", "minerender:blockEntityModels");
|
|
2689
2557
|
console.log(key);
|
|
2690
|
-
return
|
|
2691
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
2692
|
-
});
|
|
2558
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2693
2559
|
}
|
|
2694
2560
|
static async getEntityModels() {
|
|
2695
2561
|
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
2696
2562
|
console.log(key);
|
|
2697
|
-
return
|
|
2698
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
2699
|
-
});
|
|
2563
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2700
2564
|
}
|
|
2701
2565
|
// BlockEntity names are hardcoded
|
|
2702
2566
|
static async getBlockList() {
|
|
@@ -2742,6 +2606,12 @@ var Entities = class {
|
|
|
2742
2606
|
};
|
|
2743
2607
|
}
|
|
2744
2608
|
};
|
|
2609
|
+
__decorateClass([
|
|
2610
|
+
(0, import_typescript_memoize3.Memoize)()
|
|
2611
|
+
], Entities, "getBlockEntityModels", 1);
|
|
2612
|
+
__decorateClass([
|
|
2613
|
+
(0, import_typescript_memoize3.Memoize)()
|
|
2614
|
+
], Entities, "getEntityModels", 1);
|
|
2745
2615
|
var EntityModels = class {
|
|
2746
2616
|
};
|
|
2747
2617
|
var BlockEntityModels = class {
|
|
@@ -2805,8 +2675,8 @@ var MineRenderError = class _MineRenderError extends Error {
|
|
|
2805
2675
|
};
|
|
2806
2676
|
|
|
2807
2677
|
// src/renderer/SceneObject.ts
|
|
2808
|
-
var
|
|
2809
|
-
var
|
|
2678
|
+
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
2679
|
+
var p7 = prefix("SceneObject");
|
|
2810
2680
|
var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
2811
2681
|
constructor(options) {
|
|
2812
2682
|
super();
|
|
@@ -2814,7 +2684,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2814
2684
|
this.materialCallbacks = {};
|
|
2815
2685
|
this._isInstanced = false;
|
|
2816
2686
|
this._instanceCounter = 0;
|
|
2817
|
-
this.options = (0,
|
|
2687
|
+
this.options = (0, import_ts_deepmerge4.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
2818
2688
|
console.log("SceneObject options", this.options);
|
|
2819
2689
|
}
|
|
2820
2690
|
set scene(scene) {
|
|
@@ -2985,9 +2855,9 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2985
2855
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2986
2856
|
const i = this._instanceCounter++;
|
|
2987
2857
|
this.setMatrixAt(i, new import_three9.Matrix4());
|
|
2988
|
-
console.debug(
|
|
2858
|
+
console.debug(p7, "nextInstance " + i);
|
|
2989
2859
|
if (i === this.options.maxInstanceCount) {
|
|
2990
|
-
console.warn(
|
|
2860
|
+
console.warn(p7, "Max instance count reached for " + this);
|
|
2991
2861
|
}
|
|
2992
2862
|
if (this.scene) {
|
|
2993
2863
|
this.scene.stats.instanceCount++;
|
|
@@ -3163,7 +3033,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3163
3033
|
}
|
|
3164
3034
|
//</editor-fold>
|
|
3165
3035
|
};
|
|
3166
|
-
_SceneObject.DEFAULT_OPTIONS = (0,
|
|
3036
|
+
_SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, {
|
|
3167
3037
|
instanceMeshes: true,
|
|
3168
3038
|
maxInstanceCount: 50,
|
|
3169
3039
|
mergeMeshes: true,
|
|
@@ -3175,16 +3045,16 @@ function isSceneObject(obj) {
|
|
|
3175
3045
|
}
|
|
3176
3046
|
|
|
3177
3047
|
// src/entity/scene/EntityObject.ts
|
|
3178
|
-
var
|
|
3048
|
+
var import_ts_deepmerge5 = __toESM(require_dist());
|
|
3179
3049
|
var import_three11 = require("three");
|
|
3180
|
-
var
|
|
3050
|
+
var THREE2 = __toESM(require("three"));
|
|
3181
3051
|
var EntityObject = class extends SceneObject {
|
|
3182
3052
|
constructor(entity, options) {
|
|
3183
3053
|
super();
|
|
3184
3054
|
this.entity = entity;
|
|
3185
3055
|
this.isEntityObject = true;
|
|
3186
3056
|
this.meshesCreated = false;
|
|
3187
|
-
this.options = (0,
|
|
3057
|
+
this.options = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
3188
3058
|
}
|
|
3189
3059
|
async init() {
|
|
3190
3060
|
this.createMeshes();
|
|
@@ -3193,8 +3063,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3193
3063
|
dispose() {
|
|
3194
3064
|
super.dispose();
|
|
3195
3065
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3066
|
+
async loadTextures() {
|
|
3067
|
+
this.imageData = await ModelTextures.get(new AssetKey(
|
|
3198
3068
|
this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
|
|
3199
3069
|
this.entity.key.path,
|
|
3200
3070
|
//TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
|
|
@@ -3202,10 +3072,7 @@ var EntityObject = class extends SceneObject {
|
|
|
3202
3072
|
"entity",
|
|
3203
3073
|
"assets",
|
|
3204
3074
|
".png"
|
|
3205
|
-
);
|
|
3206
|
-
}
|
|
3207
|
-
async loadTextures() {
|
|
3208
|
-
this.imageData = await ModelTextures.get(this.textureKey);
|
|
3075
|
+
));
|
|
3209
3076
|
}
|
|
3210
3077
|
//TODO: abstract this, since extracted model data can be used for entities, blocks, players
|
|
3211
3078
|
createMeshes(force = false) {
|
|
@@ -3224,8 +3091,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3224
3091
|
const l = cube.maxZ - cube.minZ;
|
|
3225
3092
|
const uv = texture.toUvArray(w, h, l);
|
|
3226
3093
|
const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
|
|
3227
|
-
cubeGeo.applyMatrix4(new
|
|
3228
|
-
cubeGeo.applyMatrix4(new
|
|
3094
|
+
cubeGeo.applyMatrix4(new THREE2.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
|
|
3095
|
+
cubeGeo.applyMatrix4(new THREE2.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
|
|
3229
3096
|
applyModelPartRotation(part, cubeGeo);
|
|
3230
3097
|
const mesh = this.createMesh(partName, cubeGeo, mat);
|
|
3231
3098
|
partAnchor.add(mesh);
|
|
@@ -3238,26 +3105,23 @@ var EntityObject = class extends SceneObject {
|
|
|
3238
3105
|
this.meshesCreated = true;
|
|
3239
3106
|
}
|
|
3240
3107
|
async applyTextures() {
|
|
3241
|
-
const
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
mesh.material = mat;
|
|
3256
|
-
});
|
|
3257
|
-
this.notifyDirty();
|
|
3108
|
+
const textureAsset = await ModelTextures.preload(new AssetKey(
|
|
3109
|
+
this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
|
|
3110
|
+
this.entity.key.path,
|
|
3111
|
+
"textures",
|
|
3112
|
+
"entity",
|
|
3113
|
+
"assets",
|
|
3114
|
+
".png"
|
|
3115
|
+
));
|
|
3116
|
+
if (textureAsset) {
|
|
3117
|
+
let mat = Materials.getImage({ texture: { src: textureAsset.src } });
|
|
3118
|
+
this.iterateAllMeshes((mesh) => {
|
|
3119
|
+
mesh.material = mat;
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3258
3122
|
}
|
|
3259
3123
|
};
|
|
3260
|
-
EntityObject.DEFAULT_OPTIONS = (0,
|
|
3124
|
+
EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
3261
3125
|
function isEntityObject(obj) {
|
|
3262
3126
|
return obj.isEntityObject;
|
|
3263
3127
|
}
|
|
@@ -3269,7 +3133,7 @@ var GuiObject = class extends SceneObject {
|
|
|
3269
3133
|
|
|
3270
3134
|
// src/inspector/SceneInspector.ts
|
|
3271
3135
|
var import_three12 = require("three");
|
|
3272
|
-
var
|
|
3136
|
+
var p8 = prefix("SceneInspector");
|
|
3273
3137
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3274
3138
|
var SceneInspector = class {
|
|
3275
3139
|
constructor(renderer) {
|
|
@@ -3338,7 +3202,7 @@ var SceneInspector = class {
|
|
|
3338
3202
|
}
|
|
3339
3203
|
selectObject(targetObject, targetIntersection) {
|
|
3340
3204
|
this.selectedObject = targetObject;
|
|
3341
|
-
console.log(
|
|
3205
|
+
console.log(p8, "selected", targetObject);
|
|
3342
3206
|
this.redraw(targetObject, targetIntersection);
|
|
3343
3207
|
}
|
|
3344
3208
|
redraw(targetObject, targetIntersection) {
|
|
@@ -3636,7 +3500,7 @@ var SceneStatsDisplay = class {
|
|
|
3636
3500
|
};
|
|
3637
3501
|
|
|
3638
3502
|
// src/instance/InstanceManager.ts
|
|
3639
|
-
var
|
|
3503
|
+
var p9 = prefix("InstanceManager");
|
|
3640
3504
|
var InstanceManager = class {
|
|
3641
3505
|
constructor() {
|
|
3642
3506
|
this.isInstanceManager = true;
|
|
@@ -3644,7 +3508,7 @@ var InstanceManager = class {
|
|
|
3644
3508
|
}
|
|
3645
3509
|
async get(key) {
|
|
3646
3510
|
if (key in this.instanceCache) {
|
|
3647
|
-
console.debug(
|
|
3511
|
+
console.debug(p9, "key in cache", key);
|
|
3648
3512
|
return (await this.instanceCache[key]).nextInstance();
|
|
3649
3513
|
}
|
|
3650
3514
|
return void 0;
|
|
@@ -3653,17 +3517,13 @@ var InstanceManager = class {
|
|
|
3653
3517
|
if (key in this.instanceCache) {
|
|
3654
3518
|
return await this.get(key);
|
|
3655
3519
|
}
|
|
3656
|
-
console.debug(
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
}
|
|
3662
|
-
|
|
3663
|
-
delete this.instanceCache[key];
|
|
3664
|
-
}
|
|
3665
|
-
throw error;
|
|
3666
|
-
}
|
|
3520
|
+
console.debug(p9, "key not in cache", key);
|
|
3521
|
+
this.instanceCache[key] = new Promise(async (resolve) => {
|
|
3522
|
+
const obj = await supplier();
|
|
3523
|
+
const instance = obj.nextInstance();
|
|
3524
|
+
resolve(instance);
|
|
3525
|
+
});
|
|
3526
|
+
return await this.instanceCache[key];
|
|
3667
3527
|
}
|
|
3668
3528
|
reset() {
|
|
3669
3529
|
for (let instanceCacheKey in this.instanceCache) {
|
|
@@ -4252,15 +4112,15 @@ function computeMorphedAttributes(object) {
|
|
|
4252
4112
|
}
|
|
4253
4113
|
|
|
4254
4114
|
// src/model/scene/ModelObject.ts
|
|
4255
|
-
var
|
|
4256
|
-
var
|
|
4115
|
+
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4116
|
+
var p10 = prefix("ModelObject");
|
|
4257
4117
|
var _ModelObject = class _ModelObject extends SceneObject {
|
|
4258
4118
|
constructor(originalModel, options) {
|
|
4259
4119
|
super(options);
|
|
4260
4120
|
this.originalModel = originalModel;
|
|
4261
4121
|
this.isModelObject = true;
|
|
4262
4122
|
this.meshesCreated = false;
|
|
4263
|
-
this.options = (0,
|
|
4123
|
+
this.options = (0, import_ts_deepmerge6.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
|
|
4264
4124
|
console.log("ModelObject options", this.options);
|
|
4265
4125
|
}
|
|
4266
4126
|
async init() {
|
|
@@ -4303,10 +4163,10 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4303
4163
|
}
|
|
4304
4164
|
});
|
|
4305
4165
|
} else {
|
|
4306
|
-
console.debug(
|
|
4166
|
+
console.debug(p10, this.atlas.model, "has no elements");
|
|
4307
4167
|
}
|
|
4308
4168
|
} else {
|
|
4309
|
-
console.debug(
|
|
4169
|
+
console.debug(p10, "Missing atlas for", this);
|
|
4310
4170
|
}
|
|
4311
4171
|
if (this.options.mergeMeshes) {
|
|
4312
4172
|
let combinedGeo;
|
|
@@ -4358,26 +4218,16 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4358
4218
|
}
|
|
4359
4219
|
}
|
|
4360
4220
|
};
|
|
4361
|
-
_ModelObject.DEFAULT_OPTIONS = (0,
|
|
4221
|
+
_ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
4362
4222
|
var ModelObject = _ModelObject;
|
|
4363
4223
|
function isModelObject(obj) {
|
|
4364
4224
|
return obj.isModelObject;
|
|
4365
4225
|
}
|
|
4366
4226
|
|
|
4367
4227
|
// src/model/block/scene/BlockObject.ts
|
|
4368
|
-
var
|
|
4228
|
+
var import_ts_deepmerge7 = __toESM(require_dist());
|
|
4369
4229
|
var import_three16 = require("three");
|
|
4370
|
-
var
|
|
4371
|
-
function matchesCondition(condition, state) {
|
|
4372
|
-
return Object.entries(condition).every(([key, value]) => {
|
|
4373
|
-
if (Array.isArray(value)) {
|
|
4374
|
-
if (key === "OR") return value.some((child) => matchesCondition(child, state));
|
|
4375
|
-
if (key === "AND") return value.every((child) => matchesCondition(child, state));
|
|
4376
|
-
return false;
|
|
4377
|
-
}
|
|
4378
|
-
return typeof value === "string" && state[key] !== void 0 && value.split("|").includes(`${state[key]}`);
|
|
4379
|
-
});
|
|
4380
|
-
}
|
|
4230
|
+
var p11 = prefix("BlockObject");
|
|
4381
4231
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
4382
4232
|
constructor(blockState, options) {
|
|
4383
4233
|
super(options);
|
|
@@ -4391,11 +4241,11 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4391
4241
|
this._instanceModel = [];
|
|
4392
4242
|
this._variants = [];
|
|
4393
4243
|
this._models = [];
|
|
4394
|
-
this.options = (0,
|
|
4244
|
+
this.options = (0, import_ts_deepmerge7.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
4395
4245
|
}
|
|
4396
4246
|
async init() {
|
|
4397
4247
|
if (this.options.applyDefaultState) {
|
|
4398
|
-
const defaultState = this.blockState.key ?
|
|
4248
|
+
const defaultState = this.blockState.key ? BlockStates.getDefaultState(this.blockState.key) : void 0;
|
|
4399
4249
|
if (defaultState && Object.keys(defaultState).length > 0) {
|
|
4400
4250
|
const state = {};
|
|
4401
4251
|
for (let k in defaultState) {
|
|
@@ -4406,9 +4256,15 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4406
4256
|
if (this.blockState.variants) {
|
|
4407
4257
|
await this.setState(Object.keys(this.blockState.variants)[0]);
|
|
4408
4258
|
} else if (this.blockState.multipart) {
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4259
|
+
for (let part of this.blockState.multipart) {
|
|
4260
|
+
if (part.when && !("OR" in part.when)) {
|
|
4261
|
+
const k = Object.keys(part.when)[0];
|
|
4262
|
+
if (k) {
|
|
4263
|
+
await this.setState(k, part.when[k].split("|")[0]);
|
|
4264
|
+
break;
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4412
4268
|
}
|
|
4413
4269
|
}
|
|
4414
4270
|
} else {
|
|
@@ -4465,11 +4321,55 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4465
4321
|
} else if (this.blockState.multipart) {
|
|
4466
4322
|
for (let part of this.blockState.multipart) {
|
|
4467
4323
|
if (!part.apply) {
|
|
4468
|
-
console.debug(
|
|
4324
|
+
console.debug(p11, "Missing apply for blockState part", part);
|
|
4469
4325
|
continue;
|
|
4470
4326
|
}
|
|
4471
|
-
if (!part.when
|
|
4327
|
+
if (!part.when) {
|
|
4472
4328
|
out.push(this.getSingleVariant(part.apply));
|
|
4329
|
+
} else {
|
|
4330
|
+
let matches = true;
|
|
4331
|
+
if ("OR" in part.when) {
|
|
4332
|
+
const or = part.when.OR;
|
|
4333
|
+
let anyMatch = false;
|
|
4334
|
+
for (let o of or) {
|
|
4335
|
+
for (let k in o) {
|
|
4336
|
+
const split = o[k].split("|");
|
|
4337
|
+
let m = false;
|
|
4338
|
+
for (let s of split) {
|
|
4339
|
+
if (`${state[k]}` === `${s}`) {
|
|
4340
|
+
m = true;
|
|
4341
|
+
break;
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
if (m) {
|
|
4345
|
+
anyMatch = true;
|
|
4346
|
+
break;
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
if (!anyMatch) {
|
|
4351
|
+
matches = false;
|
|
4352
|
+
}
|
|
4353
|
+
} else {
|
|
4354
|
+
for (let k in part.when) {
|
|
4355
|
+
const split = part.when[k].split("|");
|
|
4356
|
+
let m = false;
|
|
4357
|
+
for (let s of split) {
|
|
4358
|
+
if (`${state[k]}` === `${s}`) {
|
|
4359
|
+
m = true;
|
|
4360
|
+
break;
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
if (!m) {
|
|
4364
|
+
matches = false;
|
|
4365
|
+
break;
|
|
4366
|
+
}
|
|
4367
|
+
}
|
|
4368
|
+
}
|
|
4369
|
+
if (matches) {
|
|
4370
|
+
const variants = part.apply;
|
|
4371
|
+
out.push(this.getSingleVariant(variants));
|
|
4372
|
+
}
|
|
4473
4373
|
}
|
|
4474
4374
|
}
|
|
4475
4375
|
}
|
|
@@ -4499,21 +4399,11 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4499
4399
|
}
|
|
4500
4400
|
}
|
|
4501
4401
|
getSingleVariant(variants) {
|
|
4502
|
-
if (
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
throw new MineRenderError(`Invalid blockstate variant weight: ${weight}`);
|
|
4508
|
-
}
|
|
4509
|
-
return sum + weight;
|
|
4510
|
-
}, 0);
|
|
4511
|
-
let choice = Math.random() * total;
|
|
4512
|
-
for (const variant of variants) {
|
|
4513
|
-
choice -= variant.weight ?? 1;
|
|
4514
|
-
if (choice < 0) return variant;
|
|
4515
|
-
}
|
|
4516
|
-
return variants[variants.length - 1];
|
|
4402
|
+
if (Array.isArray(variants)) {
|
|
4403
|
+
return variants[0];
|
|
4404
|
+
} else {
|
|
4405
|
+
return variants;
|
|
4406
|
+
}
|
|
4517
4407
|
}
|
|
4518
4408
|
// @deprecated
|
|
4519
4409
|
async createAVariant(variants, instanceInfo) {
|
|
@@ -4539,6 +4429,9 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4539
4429
|
}
|
|
4540
4430
|
}
|
|
4541
4431
|
obj.setRotation(rotation);
|
|
4432
|
+
setTimeout(() => {
|
|
4433
|
+
obj.setRotation(rotation);
|
|
4434
|
+
}, 150);
|
|
4542
4435
|
console.log(obj);
|
|
4543
4436
|
return obj;
|
|
4544
4437
|
}
|
|
@@ -4629,16 +4522,15 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4629
4522
|
}
|
|
4630
4523
|
}
|
|
4631
4524
|
setPosition(position) {
|
|
4632
|
-
|
|
4525
|
+
super.setPosition(position);
|
|
4633
4526
|
for (let model of this._models) {
|
|
4634
4527
|
model.setPosition(position);
|
|
4635
4528
|
}
|
|
4636
|
-
this.notifyDirty();
|
|
4637
4529
|
}
|
|
4638
4530
|
//TODO: should override rotation + scale methods
|
|
4639
4531
|
//TODO
|
|
4640
4532
|
};
|
|
4641
|
-
_BlockObject.DEFAULT_OPTIONS = (0,
|
|
4533
|
+
_BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge7.default)({}, ModelObject.DEFAULT_OPTIONS, {
|
|
4642
4534
|
applyDefaultState: true
|
|
4643
4535
|
});
|
|
4644
4536
|
var BlockObject = _BlockObject;
|
|
@@ -4688,7 +4580,7 @@ var StructureParser = class {
|
|
|
4688
4580
|
|
|
4689
4581
|
// src/renderer/MineRenderScene.ts
|
|
4690
4582
|
var import_three17 = require("three");
|
|
4691
|
-
var
|
|
4583
|
+
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
4692
4584
|
|
|
4693
4585
|
// src/skin/SkinPart.ts
|
|
4694
4586
|
var SkinPart = /* @__PURE__ */ ((SkinPart2) => {
|
|
@@ -5419,7 +5311,7 @@ var slimSkinGeometries = {
|
|
|
5419
5311
|
};
|
|
5420
5312
|
|
|
5421
5313
|
// src/skin/scene/SkinObject.ts
|
|
5422
|
-
var
|
|
5314
|
+
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
5423
5315
|
var SkinObject = class extends SceneObject {
|
|
5424
5316
|
constructor(options) {
|
|
5425
5317
|
super();
|
|
@@ -5427,7 +5319,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5427
5319
|
this.legacy = false;
|
|
5428
5320
|
this.skinTextureWidth = 64;
|
|
5429
5321
|
this.skinTextureHeight = 64;
|
|
5430
|
-
this.options = (0,
|
|
5322
|
+
this.options = (0, import_ts_deepmerge8.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5431
5323
|
}
|
|
5432
5324
|
async init() {
|
|
5433
5325
|
this.createMeshes();
|
|
@@ -5544,7 +5436,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5544
5436
|
this.dirty = true;
|
|
5545
5437
|
}
|
|
5546
5438
|
};
|
|
5547
|
-
this.options = (0,
|
|
5439
|
+
this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
5548
5440
|
}
|
|
5549
5441
|
add(...objects) {
|
|
5550
5442
|
for (const object of objects) {
|
|
@@ -5640,1140 +5532,1106 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5640
5532
|
return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
|
|
5641
5533
|
}
|
|
5642
5534
|
};
|
|
5643
|
-
_MineRenderScene.DEFAULT_OPTIONS = (0,
|
|
5535
|
+
_MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {});
|
|
5644
5536
|
var MineRenderScene = _MineRenderScene;
|
|
5645
5537
|
function isMineRenderScene(obj) {
|
|
5646
5538
|
return obj.isMineRenderScene;
|
|
5647
5539
|
}
|
|
5648
5540
|
|
|
5649
5541
|
// src/renderer/Renderer.ts
|
|
5650
|
-
var
|
|
5651
|
-
var
|
|
5542
|
+
var import_three18 = require("three");
|
|
5543
|
+
var import_ts_deepmerge10 = __toESM(require_dist());
|
|
5652
5544
|
var import_stats = __toESM(require("stats.js"));
|
|
5653
5545
|
var import_postprocessing = require("postprocessing");
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
this.object = object;
|
|
5666
|
-
this.domElement = domElement;
|
|
5667
|
-
this.domElement.style.touchAction = "none";
|
|
5668
|
-
this.enabled = true;
|
|
5669
|
-
this.target = new import_three18.Vector3();
|
|
5670
|
-
this.minDistance = 0;
|
|
5671
|
-
this.maxDistance = Infinity;
|
|
5672
|
-
this.minZoom = 0;
|
|
5673
|
-
this.maxZoom = Infinity;
|
|
5674
|
-
this.minPolarAngle = 0;
|
|
5675
|
-
this.maxPolarAngle = Math.PI;
|
|
5676
|
-
this.minAzimuthAngle = -Infinity;
|
|
5677
|
-
this.maxAzimuthAngle = Infinity;
|
|
5678
|
-
this.enableDamping = false;
|
|
5679
|
-
this.dampingFactor = 0.05;
|
|
5680
|
-
this.enableZoom = true;
|
|
5681
|
-
this.zoomSpeed = 1;
|
|
5682
|
-
this.enableRotate = true;
|
|
5683
|
-
this.rotateSpeed = 1;
|
|
5684
|
-
this.enablePan = true;
|
|
5685
|
-
this.panSpeed = 1;
|
|
5686
|
-
this.screenSpacePanning = true;
|
|
5687
|
-
this.keyPanSpeed = 7;
|
|
5688
|
-
this.autoRotate = false;
|
|
5689
|
-
this.autoRotateSpeed = 2;
|
|
5690
|
-
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5691
|
-
this.mouseButtons = { LEFT: import_three18.MOUSE.ROTATE, MIDDLE: import_three18.MOUSE.DOLLY, RIGHT: import_three18.MOUSE.PAN };
|
|
5692
|
-
this.touches = { ONE: import_three18.TOUCH.ROTATE, TWO: import_three18.TOUCH.DOLLY_PAN };
|
|
5693
|
-
this.target0 = this.target.clone();
|
|
5694
|
-
this.position0 = this.object.position.clone();
|
|
5695
|
-
this.zoom0 = this.object.zoom;
|
|
5696
|
-
this._domElementKeyEvents = null;
|
|
5697
|
-
this.getPolarAngle = function() {
|
|
5698
|
-
return spherical.phi;
|
|
5699
|
-
};
|
|
5700
|
-
this.getAzimuthalAngle = function() {
|
|
5701
|
-
return spherical.theta;
|
|
5702
|
-
};
|
|
5703
|
-
this.getDistance = function() {
|
|
5704
|
-
return this.object.position.distanceTo(this.target);
|
|
5546
|
+
var _Renderer = class _Renderer {
|
|
5547
|
+
constructor(options) {
|
|
5548
|
+
this._dirty = true;
|
|
5549
|
+
this._animationTimer = void 0;
|
|
5550
|
+
this._animationFrame = void 0;
|
|
5551
|
+
this._resizeListener = void 0;
|
|
5552
|
+
this._disposed = false;
|
|
5553
|
+
this._debugHelpers = [];
|
|
5554
|
+
this._eventDispatchers = /* @__PURE__ */ new Map();
|
|
5555
|
+
this._changeListener = () => {
|
|
5556
|
+
this._dirty = true;
|
|
5705
5557
|
};
|
|
5706
|
-
this.
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
this.
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
scope.dispatchEvent(_changeEvent);
|
|
5717
|
-
scope.update();
|
|
5718
|
-
state = STATE.NONE;
|
|
5719
|
-
};
|
|
5720
|
-
this.update = function() {
|
|
5721
|
-
const offset = new import_three18.Vector3();
|
|
5722
|
-
const quat = new import_three18.Quaternion().setFromUnitVectors(object.up, new import_three18.Vector3(0, 1, 0));
|
|
5723
|
-
const quatInverse = quat.clone().invert();
|
|
5724
|
-
const lastPosition = new import_three18.Vector3();
|
|
5725
|
-
const lastQuaternion = new import_three18.Quaternion();
|
|
5726
|
-
const twoPI = 2 * Math.PI;
|
|
5727
|
-
return function update() {
|
|
5728
|
-
const position = scope.object.position;
|
|
5729
|
-
offset.copy(position).sub(scope.target);
|
|
5730
|
-
offset.applyQuaternion(quat);
|
|
5731
|
-
spherical.setFromVector3(offset);
|
|
5732
|
-
if (scope.autoRotate && state === STATE.NONE) {
|
|
5733
|
-
rotateLeft(getAutoRotationAngle());
|
|
5734
|
-
}
|
|
5735
|
-
if (scope.enableDamping) {
|
|
5736
|
-
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
5737
|
-
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
5738
|
-
} else {
|
|
5739
|
-
spherical.theta += sphericalDelta.theta;
|
|
5740
|
-
spherical.phi += sphericalDelta.phi;
|
|
5741
|
-
}
|
|
5742
|
-
let min = scope.minAzimuthAngle;
|
|
5743
|
-
let max = scope.maxAzimuthAngle;
|
|
5744
|
-
if (isFinite(min) && isFinite(max)) {
|
|
5745
|
-
if (min < -Math.PI) min += twoPI;
|
|
5746
|
-
else if (min > Math.PI) min -= twoPI;
|
|
5747
|
-
if (max < -Math.PI) max += twoPI;
|
|
5748
|
-
else if (max > Math.PI) max -= twoPI;
|
|
5749
|
-
if (min <= max) {
|
|
5750
|
-
spherical.theta = Math.max(min, Math.min(max, spherical.theta));
|
|
5751
|
-
} else {
|
|
5752
|
-
spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
|
|
5753
|
-
}
|
|
5754
|
-
}
|
|
5755
|
-
spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
|
|
5756
|
-
spherical.makeSafe();
|
|
5757
|
-
spherical.radius *= scale;
|
|
5758
|
-
spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
|
|
5759
|
-
if (scope.enableDamping === true) {
|
|
5760
|
-
scope.target.addScaledVector(panOffset, scope.dampingFactor);
|
|
5761
|
-
} else {
|
|
5762
|
-
scope.target.add(panOffset);
|
|
5763
|
-
}
|
|
5764
|
-
offset.setFromSpherical(spherical);
|
|
5765
|
-
offset.applyQuaternion(quatInverse);
|
|
5766
|
-
position.copy(scope.target).add(offset);
|
|
5767
|
-
scope.object.lookAt(scope.target);
|
|
5768
|
-
if (scope.enableDamping === true) {
|
|
5769
|
-
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
5770
|
-
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
5771
|
-
panOffset.multiplyScalar(1 - scope.dampingFactor);
|
|
5772
|
-
} else {
|
|
5773
|
-
sphericalDelta.set(0, 0, 0);
|
|
5774
|
-
panOffset.set(0, 0, 0);
|
|
5775
|
-
}
|
|
5776
|
-
scale = 1;
|
|
5777
|
-
if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
|
|
5778
|
-
scope.dispatchEvent(_changeEvent);
|
|
5779
|
-
lastPosition.copy(scope.object.position);
|
|
5780
|
-
lastQuaternion.copy(scope.object.quaternion);
|
|
5781
|
-
zoomChanged = false;
|
|
5782
|
-
return true;
|
|
5783
|
-
}
|
|
5784
|
-
return false;
|
|
5785
|
-
};
|
|
5786
|
-
}();
|
|
5787
|
-
this.dispose = function() {
|
|
5788
|
-
scope.domElement.removeEventListener("contextmenu", onContextMenu);
|
|
5789
|
-
scope.domElement.removeEventListener("pointerdown", onPointerDown);
|
|
5790
|
-
scope.domElement.removeEventListener("pointercancel", onPointerCancel);
|
|
5791
|
-
scope.domElement.removeEventListener("wheel", onMouseWheel);
|
|
5792
|
-
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
5793
|
-
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
5794
|
-
if (scope._domElementKeyEvents !== null) {
|
|
5795
|
-
scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
|
|
5796
|
-
}
|
|
5797
|
-
};
|
|
5798
|
-
const scope = this;
|
|
5799
|
-
const STATE = {
|
|
5800
|
-
NONE: -1,
|
|
5801
|
-
ROTATE: 0,
|
|
5802
|
-
DOLLY: 1,
|
|
5803
|
-
PAN: 2,
|
|
5804
|
-
TOUCH_ROTATE: 3,
|
|
5805
|
-
TOUCH_PAN: 4,
|
|
5806
|
-
TOUCH_DOLLY_PAN: 5,
|
|
5807
|
-
TOUCH_DOLLY_ROTATE: 6
|
|
5808
|
-
};
|
|
5809
|
-
let state = STATE.NONE;
|
|
5810
|
-
const EPS = 1e-6;
|
|
5811
|
-
const spherical = new import_three18.Spherical();
|
|
5812
|
-
const sphericalDelta = new import_three18.Spherical();
|
|
5813
|
-
let scale = 1;
|
|
5814
|
-
const panOffset = new import_three18.Vector3();
|
|
5815
|
-
let zoomChanged = false;
|
|
5816
|
-
const rotateStart = new import_three18.Vector2();
|
|
5817
|
-
const rotateEnd = new import_three18.Vector2();
|
|
5818
|
-
const rotateDelta = new import_three18.Vector2();
|
|
5819
|
-
const panStart = new import_three18.Vector2();
|
|
5820
|
-
const panEnd = new import_three18.Vector2();
|
|
5821
|
-
const panDelta = new import_three18.Vector2();
|
|
5822
|
-
const dollyStart = new import_three18.Vector2();
|
|
5823
|
-
const dollyEnd = new import_three18.Vector2();
|
|
5824
|
-
const dollyDelta = new import_three18.Vector2();
|
|
5825
|
-
const pointers = [];
|
|
5826
|
-
const pointerPositions = {};
|
|
5827
|
-
function getAutoRotationAngle() {
|
|
5828
|
-
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
5558
|
+
this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
|
|
5559
|
+
this._animationLoop = this.animate.bind(this);
|
|
5560
|
+
this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
|
|
5561
|
+
this._scene = this.createScene();
|
|
5562
|
+
this._camera = this.createCamera();
|
|
5563
|
+
this._renderer = this.createRenderer();
|
|
5564
|
+
this._composer = this.createComposer();
|
|
5565
|
+
if (this.options.render.stats) {
|
|
5566
|
+
this._stats = new import_stats.default();
|
|
5567
|
+
document.body.appendChild(this._stats.dom);
|
|
5829
5568
|
}
|
|
5830
|
-
|
|
5831
|
-
|
|
5569
|
+
this.init();
|
|
5570
|
+
}
|
|
5571
|
+
//<editor-fold desc="INIT">
|
|
5572
|
+
createScene() {
|
|
5573
|
+
return new MineRenderScene();
|
|
5574
|
+
}
|
|
5575
|
+
createCamera() {
|
|
5576
|
+
switch (this.options.camera.type) {
|
|
5577
|
+
case "perspective":
|
|
5578
|
+
default:
|
|
5579
|
+
return new import_three18.PerspectiveCamera(
|
|
5580
|
+
this.options.camera.perspective.fov,
|
|
5581
|
+
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
5582
|
+
this.options.camera.near,
|
|
5583
|
+
this.options.camera.far
|
|
5584
|
+
);
|
|
5585
|
+
case "orthographic":
|
|
5586
|
+
return new import_three18.OrthographicCamera(
|
|
5587
|
+
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
5588
|
+
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
5589
|
+
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
5590
|
+
this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
|
|
5591
|
+
this.options.camera.near,
|
|
5592
|
+
this.options.camera.far
|
|
5593
|
+
);
|
|
5832
5594
|
}
|
|
5833
|
-
|
|
5834
|
-
|
|
5595
|
+
}
|
|
5596
|
+
createRenderer() {
|
|
5597
|
+
const renderer = new import_three18.WebGLRenderer({
|
|
5598
|
+
antialias: this.options.render.antialias,
|
|
5599
|
+
alpha: true,
|
|
5600
|
+
powerPreference: "high-performance",
|
|
5601
|
+
depth: true
|
|
5602
|
+
});
|
|
5603
|
+
renderer.setClearColor(0, 0);
|
|
5604
|
+
renderer.shadowMap.enabled = true;
|
|
5605
|
+
renderer.shadowMap.type = import_three18.PCFSoftShadowMap;
|
|
5606
|
+
renderer.outputEncoding = import_three18.LinearEncoding;
|
|
5607
|
+
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
5608
|
+
return renderer;
|
|
5609
|
+
}
|
|
5610
|
+
createComposer() {
|
|
5611
|
+
const composer = new import_postprocessing.EffectComposer(this.renderer);
|
|
5612
|
+
if (!this.options.composer.enabled) return composer;
|
|
5613
|
+
composer.setSize(this.viewWidth, this.viewHeight);
|
|
5614
|
+
composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
|
|
5615
|
+
return composer;
|
|
5616
|
+
}
|
|
5617
|
+
//</editor-fold>
|
|
5618
|
+
init() {
|
|
5619
|
+
if (this._disposed) return;
|
|
5620
|
+
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
5621
|
+
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
5835
5622
|
}
|
|
5836
|
-
|
|
5837
|
-
|
|
5623
|
+
if (this.options.debug.grid) {
|
|
5624
|
+
const gridHelper = new import_three18.GridHelper(128, 16);
|
|
5625
|
+
this._debugHelpers.push(gridHelper);
|
|
5626
|
+
this.scene.add(gridHelper);
|
|
5627
|
+
const gridHelper2 = new import_three18.GridHelper(128, 16);
|
|
5628
|
+
this._debugHelpers.push(gridHelper2);
|
|
5629
|
+
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
5630
|
+
this.scene.add(gridHelper2);
|
|
5631
|
+
const gridHelper3 = new import_three18.GridHelper(128, 16);
|
|
5632
|
+
this._debugHelpers.push(gridHelper3);
|
|
5633
|
+
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
5634
|
+
this.scene.add(gridHelper3);
|
|
5838
5635
|
}
|
|
5839
|
-
|
|
5840
|
-
const
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
v.multiplyScalar(-distance);
|
|
5844
|
-
panOffset.add(v);
|
|
5845
|
-
};
|
|
5846
|
-
}();
|
|
5847
|
-
const panUp = function() {
|
|
5848
|
-
const v = new import_three18.Vector3();
|
|
5849
|
-
return function panUp2(distance, objectMatrix) {
|
|
5850
|
-
if (scope.screenSpacePanning === true) {
|
|
5851
|
-
v.setFromMatrixColumn(objectMatrix, 1);
|
|
5852
|
-
} else {
|
|
5853
|
-
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5854
|
-
v.crossVectors(scope.object.up, v);
|
|
5855
|
-
}
|
|
5856
|
-
v.multiplyScalar(distance);
|
|
5857
|
-
panOffset.add(v);
|
|
5858
|
-
};
|
|
5859
|
-
}();
|
|
5860
|
-
const pan = function() {
|
|
5861
|
-
const offset = new import_three18.Vector3();
|
|
5862
|
-
return function pan2(deltaX, deltaY) {
|
|
5863
|
-
const element = scope.domElement;
|
|
5864
|
-
if (scope.object.isPerspectiveCamera) {
|
|
5865
|
-
const position = scope.object.position;
|
|
5866
|
-
offset.copy(position).sub(scope.target);
|
|
5867
|
-
let targetDistance = offset.length();
|
|
5868
|
-
targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
|
|
5869
|
-
panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
|
|
5870
|
-
panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
|
|
5871
|
-
} else if (scope.object.isOrthographicCamera) {
|
|
5872
|
-
panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
|
|
5873
|
-
panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
|
|
5874
|
-
} else {
|
|
5875
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
|
|
5876
|
-
scope.enablePan = false;
|
|
5877
|
-
}
|
|
5878
|
-
};
|
|
5879
|
-
}();
|
|
5880
|
-
function dollyOut(dollyScale) {
|
|
5881
|
-
if (scope.object.isPerspectiveCamera) {
|
|
5882
|
-
scale /= dollyScale;
|
|
5883
|
-
} else if (scope.object.isOrthographicCamera) {
|
|
5884
|
-
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
|
|
5885
|
-
scope.object.updateProjectionMatrix();
|
|
5886
|
-
zoomChanged = true;
|
|
5887
|
-
} else {
|
|
5888
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
5889
|
-
scope.enableZoom = false;
|
|
5890
|
-
}
|
|
5636
|
+
if (this.options.debug.axes) {
|
|
5637
|
+
const axesHelper = new import_three18.AxesHelper(64);
|
|
5638
|
+
this._debugHelpers.push(axesHelper);
|
|
5639
|
+
this.scene.add(axesHelper);
|
|
5891
5640
|
}
|
|
5892
|
-
|
|
5893
|
-
if (
|
|
5894
|
-
|
|
5895
|
-
} else if (
|
|
5896
|
-
|
|
5897
|
-
scope.object.updateProjectionMatrix();
|
|
5898
|
-
zoomChanged = true;
|
|
5899
|
-
} else {
|
|
5900
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
5901
|
-
scope.enableZoom = false;
|
|
5641
|
+
if (this.options.camera.position) {
|
|
5642
|
+
if (isVector3(this.options.camera.position)) {
|
|
5643
|
+
this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
|
|
5644
|
+
} else if (isTripleArray(this.options.camera.position)) {
|
|
5645
|
+
this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
|
|
5902
5646
|
}
|
|
5903
5647
|
}
|
|
5904
|
-
|
|
5905
|
-
|
|
5648
|
+
if (this.options.camera.lookingAt) {
|
|
5649
|
+
if (isVector3(this.options.camera.lookingAt)) {
|
|
5650
|
+
this.camera.lookAt(this.options.camera.lookingAt);
|
|
5651
|
+
} else if (isTripleArray(this.options.camera.lookingAt)) {
|
|
5652
|
+
this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
|
|
5653
|
+
}
|
|
5906
5654
|
}
|
|
5907
|
-
|
|
5908
|
-
|
|
5655
|
+
if (this.options.render.autoResize && !this._resizeListener) {
|
|
5656
|
+
this._resizeListener = () => {
|
|
5657
|
+
this.resize(this.viewWidth, this.viewHeight);
|
|
5658
|
+
};
|
|
5659
|
+
window.addEventListener("resize", this._resizeListener);
|
|
5909
5660
|
}
|
|
5910
|
-
|
|
5911
|
-
|
|
5661
|
+
}
|
|
5662
|
+
get element() {
|
|
5663
|
+
return this._element;
|
|
5664
|
+
}
|
|
5665
|
+
appendTo(element) {
|
|
5666
|
+
if (this._disposed) return;
|
|
5667
|
+
this._element = element;
|
|
5668
|
+
this._element.appendChild(this.renderer.domElement);
|
|
5669
|
+
if (this.viewWidth == 0) {
|
|
5670
|
+
console.warn("0 element width");
|
|
5912
5671
|
}
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
5916
|
-
const element = scope.domElement;
|
|
5917
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
5918
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
5919
|
-
rotateStart.copy(rotateEnd);
|
|
5920
|
-
scope.update();
|
|
5672
|
+
if (this.viewHeight == 0) {
|
|
5673
|
+
console.warn("0 element height");
|
|
5921
5674
|
}
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5675
|
+
this.resize(this.viewWidth, this.viewHeight);
|
|
5676
|
+
}
|
|
5677
|
+
/**
|
|
5678
|
+
* Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
|
|
5679
|
+
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
5680
|
+
*/
|
|
5681
|
+
registerEventDispatcher(dispatcher, changeEvent2 = "change") {
|
|
5682
|
+
if (this._disposed) return;
|
|
5683
|
+
let events = this._eventDispatchers.get(dispatcher);
|
|
5684
|
+
if (!events) {
|
|
5685
|
+
events = /* @__PURE__ */ new Set();
|
|
5686
|
+
this._eventDispatchers.set(dispatcher, events);
|
|
5932
5687
|
}
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5688
|
+
if (events.has(changeEvent2)) return;
|
|
5689
|
+
events.add(changeEvent2);
|
|
5690
|
+
dispatcher.addEventListener(changeEvent2, this._changeListener);
|
|
5691
|
+
}
|
|
5692
|
+
resize(width, height) {
|
|
5693
|
+
if (this._disposed) return;
|
|
5694
|
+
if (isPerspectiveCamera(this.camera)) {
|
|
5695
|
+
this.camera.aspect = width / height;
|
|
5696
|
+
this.camera.updateProjectionMatrix();
|
|
5697
|
+
} else if (isOrthographicCamera(this.camera)) {
|
|
5698
|
+
this.camera.left = width / -2;
|
|
5699
|
+
this.camera.right = width / 2;
|
|
5700
|
+
this.camera.top = height / 2;
|
|
5701
|
+
this.camera.bottom = height / -2;
|
|
5702
|
+
this.camera.updateProjectionMatrix();
|
|
5939
5703
|
}
|
|
5940
|
-
|
|
5704
|
+
this.renderer.setSize(width, height);
|
|
5705
|
+
this.composer.setSize(width, height);
|
|
5706
|
+
this._dirty = true;
|
|
5707
|
+
}
|
|
5708
|
+
//<editor-fold desc="RENDER">
|
|
5709
|
+
get dirty() {
|
|
5710
|
+
return this._dirty || this.scene.dirty;
|
|
5711
|
+
}
|
|
5712
|
+
set dirty(dirty) {
|
|
5713
|
+
this._dirty = dirty;
|
|
5714
|
+
this.scene.dirty = dirty;
|
|
5715
|
+
}
|
|
5716
|
+
start() {
|
|
5717
|
+
if (this._disposed) return;
|
|
5718
|
+
this.stop();
|
|
5719
|
+
this.renderer.setAnimationLoop(this._animationLoop);
|
|
5720
|
+
}
|
|
5721
|
+
stop() {
|
|
5722
|
+
if (this._disposed) return;
|
|
5723
|
+
this.renderer.setAnimationLoop(null);
|
|
5724
|
+
if (this._animationTimer)
|
|
5725
|
+
clearTimeout(this._animationTimer);
|
|
5726
|
+
this._animationTimer = void 0;
|
|
5727
|
+
if (this._animationFrame)
|
|
5728
|
+
cancelAnimationFrame(this._animationFrame);
|
|
5729
|
+
this._animationFrame = void 0;
|
|
5730
|
+
}
|
|
5731
|
+
/**
|
|
5732
|
+
* Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
|
|
5733
|
+
* renderer cannot be restarted. Scene objects are detached; shared assets and caller-owned
|
|
5734
|
+
* controls must be managed by their owners.
|
|
5735
|
+
*/
|
|
5736
|
+
dispose() {
|
|
5737
|
+
if (this._disposed) return;
|
|
5738
|
+
this.stop();
|
|
5739
|
+
this._disposed = true;
|
|
5740
|
+
if (this._resizeListener) {
|
|
5741
|
+
window.removeEventListener("resize", this._resizeListener);
|
|
5742
|
+
this._resizeListener = void 0;
|
|
5941
5743
|
}
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
} else if (event.deltaY > 0) {
|
|
5946
|
-
dollyOut(getZoomScale());
|
|
5744
|
+
for (const [dispatcher, events] of this._eventDispatchers) {
|
|
5745
|
+
for (const event of events) {
|
|
5746
|
+
dispatcher.removeEventListener(event, this._changeListener);
|
|
5947
5747
|
}
|
|
5948
|
-
scope.update();
|
|
5949
5748
|
}
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
case scope.keys.LEFT:
|
|
5962
|
-
pan(scope.keyPanSpeed, 0);
|
|
5963
|
-
needsUpdate = true;
|
|
5964
|
-
break;
|
|
5965
|
-
case scope.keys.RIGHT:
|
|
5966
|
-
pan(-scope.keyPanSpeed, 0);
|
|
5967
|
-
needsUpdate = true;
|
|
5968
|
-
break;
|
|
5969
|
-
}
|
|
5970
|
-
if (needsUpdate) {
|
|
5971
|
-
event.preventDefault();
|
|
5972
|
-
scope.update();
|
|
5749
|
+
this._eventDispatchers.clear();
|
|
5750
|
+
this._stats?.dom.remove();
|
|
5751
|
+
this._stats = void 0;
|
|
5752
|
+
this.renderer.domElement.remove();
|
|
5753
|
+
this._element = void 0;
|
|
5754
|
+
this.scene.clear();
|
|
5755
|
+
for (const helper of this._debugHelpers) {
|
|
5756
|
+
helper.geometry.dispose();
|
|
5757
|
+
const materials = Array.isArray(helper.material) ? helper.material : [helper.material];
|
|
5758
|
+
for (const material of materials) {
|
|
5759
|
+
material.dispose();
|
|
5973
5760
|
}
|
|
5974
5761
|
}
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5762
|
+
this._debugHelpers.length = 0;
|
|
5763
|
+
this.composer.dispose();
|
|
5764
|
+
this.renderer.dispose();
|
|
5765
|
+
this.renderer.forceContextLoss();
|
|
5766
|
+
}
|
|
5767
|
+
animate(t) {
|
|
5768
|
+
if (this._disposed) return;
|
|
5769
|
+
if (this._stats) {
|
|
5770
|
+
this._stats.begin();
|
|
5983
5771
|
}
|
|
5984
|
-
|
|
5985
|
-
if (
|
|
5986
|
-
|
|
5772
|
+
if (this.dirty || this.options.render.renderAlways) {
|
|
5773
|
+
if (this.options.composer.enabled) {
|
|
5774
|
+
this.composer.render();
|
|
5987
5775
|
} else {
|
|
5988
|
-
|
|
5989
|
-
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
5990
|
-
panStart.set(x, y);
|
|
5776
|
+
this.renderer.render(this.scene, this.camera);
|
|
5991
5777
|
}
|
|
5992
5778
|
}
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
5997
|
-
dollyStart.set(0, distance);
|
|
5998
|
-
}
|
|
5999
|
-
function handleTouchStartDollyPan() {
|
|
6000
|
-
if (scope.enableZoom) handleTouchStartDolly();
|
|
6001
|
-
if (scope.enablePan) handleTouchStartPan();
|
|
5779
|
+
this.dirty = false;
|
|
5780
|
+
if (this._stats) {
|
|
5781
|
+
this._stats.end();
|
|
6002
5782
|
}
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
5783
|
+
}
|
|
5784
|
+
//</editor-fold>
|
|
5785
|
+
toImage() {
|
|
5786
|
+
return this.renderer.domElement.toDataURL();
|
|
5787
|
+
}
|
|
5788
|
+
///
|
|
5789
|
+
get attachedToBody() {
|
|
5790
|
+
return this.element === document.body;
|
|
5791
|
+
}
|
|
5792
|
+
get viewWidth() {
|
|
5793
|
+
return this.attachedToBody ? window.innerWidth : this.element?.offsetWidth || 0;
|
|
5794
|
+
}
|
|
5795
|
+
get viewHeight() {
|
|
5796
|
+
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
5797
|
+
}
|
|
5798
|
+
get scene() {
|
|
5799
|
+
return this._scene;
|
|
5800
|
+
}
|
|
5801
|
+
get camera() {
|
|
5802
|
+
return this._camera;
|
|
5803
|
+
}
|
|
5804
|
+
get renderer() {
|
|
5805
|
+
return this._renderer;
|
|
5806
|
+
}
|
|
5807
|
+
get composer() {
|
|
5808
|
+
return this._composer;
|
|
5809
|
+
}
|
|
5810
|
+
///
|
|
5811
|
+
};
|
|
5812
|
+
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
|
|
5813
|
+
camera: {
|
|
5814
|
+
type: "perspective",
|
|
5815
|
+
near: 1,
|
|
5816
|
+
far: 5e3,
|
|
5817
|
+
perspective: {
|
|
5818
|
+
aspect: void 0,
|
|
5819
|
+
fov: 50
|
|
5820
|
+
},
|
|
5821
|
+
orthographic: {
|
|
5822
|
+
left: void 0,
|
|
5823
|
+
right: void 0,
|
|
5824
|
+
top: void 0,
|
|
5825
|
+
bottom: void 0
|
|
5826
|
+
},
|
|
5827
|
+
position: new import_three18.Vector3(50, 50, 50),
|
|
5828
|
+
lookingAt: new import_three18.Vector3(0, 0, 0)
|
|
5829
|
+
},
|
|
5830
|
+
render: {
|
|
5831
|
+
fpsLimit: 60,
|
|
5832
|
+
stats: false,
|
|
5833
|
+
antialias: true,
|
|
5834
|
+
shade: true,
|
|
5835
|
+
autoResize: true,
|
|
5836
|
+
renderAlways: false
|
|
5837
|
+
},
|
|
5838
|
+
composer: {
|
|
5839
|
+
enabled: true
|
|
5840
|
+
},
|
|
5841
|
+
debug: {
|
|
5842
|
+
grid: false,
|
|
5843
|
+
axes: false
|
|
5844
|
+
}
|
|
5845
|
+
});
|
|
5846
|
+
var Renderer = _Renderer;
|
|
5847
|
+
|
|
5848
|
+
// src/skin/Skins.ts
|
|
5849
|
+
var Skins = class {
|
|
5850
|
+
//<editor-fold desc="Skins">
|
|
5851
|
+
static async fromUuidOrUsername(uuidOrUsername) {
|
|
5852
|
+
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
5853
|
+
return this.fromUuid(uuidOrUsername);
|
|
6006
5854
|
}
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
6017
|
-
const element = scope.domElement;
|
|
6018
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
6019
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
6020
|
-
rotateStart.copy(rotateEnd);
|
|
6021
|
-
}
|
|
6022
|
-
function handleTouchMovePan(event) {
|
|
6023
|
-
if (pointers.length === 1) {
|
|
6024
|
-
panEnd.set(event.pageX, event.pageY);
|
|
6025
|
-
} else {
|
|
6026
|
-
const position = getSecondPointerPosition(event);
|
|
6027
|
-
const x = 0.5 * (event.pageX + position.x);
|
|
6028
|
-
const y = 0.5 * (event.pageY + position.y);
|
|
6029
|
-
panEnd.set(x, y);
|
|
6030
|
-
}
|
|
6031
|
-
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
6032
|
-
pan(panDelta.x, panDelta.y);
|
|
6033
|
-
panStart.copy(panEnd);
|
|
6034
|
-
}
|
|
6035
|
-
function handleTouchMoveDolly(event) {
|
|
6036
|
-
const position = getSecondPointerPosition(event);
|
|
6037
|
-
const dx = event.pageX - position.x;
|
|
6038
|
-
const dy = event.pageY - position.y;
|
|
6039
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6040
|
-
dollyEnd.set(0, distance);
|
|
6041
|
-
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
6042
|
-
dollyOut(dollyDelta.y);
|
|
6043
|
-
dollyStart.copy(dollyEnd);
|
|
6044
|
-
}
|
|
6045
|
-
function handleTouchMoveDollyPan(event) {
|
|
6046
|
-
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6047
|
-
if (scope.enablePan) handleTouchMovePan(event);
|
|
6048
|
-
}
|
|
6049
|
-
function handleTouchMoveDollyRotate(event) {
|
|
6050
|
-
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6051
|
-
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
6052
|
-
}
|
|
6053
|
-
function handleTouchEnd() {
|
|
6054
|
-
}
|
|
6055
|
-
function onPointerDown(event) {
|
|
6056
|
-
if (scope.enabled === false) return;
|
|
6057
|
-
if (pointers.length === 0) {
|
|
6058
|
-
scope.domElement.setPointerCapture(event.pointerId);
|
|
6059
|
-
scope.domElement.addEventListener("pointermove", onPointerMove);
|
|
6060
|
-
scope.domElement.addEventListener("pointerup", onPointerUp);
|
|
5855
|
+
return this.fromUsername(uuidOrUsername);
|
|
5856
|
+
}
|
|
5857
|
+
static async fromUuid(uuid) {
|
|
5858
|
+
return this.getSkinProxySkinUrl(uuid);
|
|
5859
|
+
}
|
|
5860
|
+
static async fromUsername(username) {
|
|
5861
|
+
return this.usernameToUuid(username).then((uuid) => {
|
|
5862
|
+
if (uuid) {
|
|
5863
|
+
return this.fromUuid(uuid);
|
|
6061
5864
|
}
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
5865
|
+
return void 0;
|
|
5866
|
+
});
|
|
5867
|
+
}
|
|
5868
|
+
static async fromMineSkin(mineskinId) {
|
|
5869
|
+
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
5870
|
+
if (mineskin) {
|
|
5871
|
+
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
6067
5872
|
}
|
|
5873
|
+
return void 0;
|
|
5874
|
+
});
|
|
5875
|
+
}
|
|
5876
|
+
//</editor-fold>
|
|
5877
|
+
//<editor-fold desc="Capes">
|
|
5878
|
+
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
5879
|
+
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
5880
|
+
return this.capeFromUuid(uuidOrUsername);
|
|
6068
5881
|
}
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
5882
|
+
return this.capeFromUsername(uuidOrUsername);
|
|
5883
|
+
}
|
|
5884
|
+
static async capeFromUuid(uuid) {
|
|
5885
|
+
return this.getSkinProxyCapeUrl(uuid);
|
|
5886
|
+
}
|
|
5887
|
+
static async capeFromUsername(username) {
|
|
5888
|
+
return this.usernameToUuid(username).then((uuid) => {
|
|
5889
|
+
if (uuid) {
|
|
5890
|
+
return this.capeFromUuid(uuid);
|
|
6075
5891
|
}
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
5892
|
+
return void 0;
|
|
5893
|
+
});
|
|
5894
|
+
}
|
|
5895
|
+
static async capeFromCapesDev(uuid, capeType = "minecraft") {
|
|
5896
|
+
return this.getCapesDev(uuid, capeType).then((cape) => {
|
|
5897
|
+
if (cape) {
|
|
5898
|
+
return cape?.stillImageUrl;
|
|
6083
5899
|
}
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
5900
|
+
return void 0;
|
|
5901
|
+
});
|
|
5902
|
+
}
|
|
5903
|
+
//</editor-fold>
|
|
5904
|
+
//<editor-fold desc="Helpers">
|
|
5905
|
+
static async usernameToUuid(username) {
|
|
5906
|
+
return this.usernameToUuidSkinProxy(username);
|
|
5907
|
+
}
|
|
5908
|
+
static async usernameToUuidSkinProxy(username) {
|
|
5909
|
+
return Requests.genericRequest({
|
|
5910
|
+
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
5911
|
+
url: "/uuid/" + username
|
|
5912
|
+
}).then((res) => {
|
|
5913
|
+
if (res.status === 200) {
|
|
5914
|
+
return res.data["id"];
|
|
6089
5915
|
}
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
case 2:
|
|
6104
|
-
mouseAction = scope.mouseButtons.RIGHT;
|
|
6105
|
-
break;
|
|
6106
|
-
default:
|
|
6107
|
-
mouseAction = -1;
|
|
5916
|
+
return void 0;
|
|
5917
|
+
}).catch((err) => {
|
|
5918
|
+
console.warn(err);
|
|
5919
|
+
return void 0;
|
|
5920
|
+
});
|
|
5921
|
+
}
|
|
5922
|
+
static async usernameToUuidMineTools(username) {
|
|
5923
|
+
return Requests.genericRequest({
|
|
5924
|
+
baseURL: "https://api.minetools.eu",
|
|
5925
|
+
url: "/uuid/" + username
|
|
5926
|
+
}).then((res) => {
|
|
5927
|
+
if (res.status === 200) {
|
|
5928
|
+
return res.data["id"];
|
|
6108
5929
|
}
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
handleMouseDownRotate(event);
|
|
6123
|
-
state = STATE.ROTATE;
|
|
6124
|
-
}
|
|
6125
|
-
break;
|
|
6126
|
-
case import_three18.MOUSE.PAN:
|
|
6127
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6128
|
-
if (scope.enableRotate === false) return;
|
|
6129
|
-
handleMouseDownRotate(event);
|
|
6130
|
-
state = STATE.ROTATE;
|
|
6131
|
-
} else {
|
|
6132
|
-
if (scope.enablePan === false) return;
|
|
6133
|
-
handleMouseDownPan(event);
|
|
6134
|
-
state = STATE.PAN;
|
|
6135
|
-
}
|
|
6136
|
-
break;
|
|
6137
|
-
default:
|
|
6138
|
-
state = STATE.NONE;
|
|
5930
|
+
return void 0;
|
|
5931
|
+
}).catch((err) => {
|
|
5932
|
+
console.warn(err);
|
|
5933
|
+
return void 0;
|
|
5934
|
+
});
|
|
5935
|
+
}
|
|
5936
|
+
static async getProfileFromMinetools(uuid) {
|
|
5937
|
+
return Requests.genericRequest({
|
|
5938
|
+
baseURL: "https://api.minetools.eu",
|
|
5939
|
+
url: "/profile/" + uuid
|
|
5940
|
+
}).then((res) => {
|
|
5941
|
+
if (res.status === 200) {
|
|
5942
|
+
return res.data;
|
|
6139
5943
|
}
|
|
6140
|
-
|
|
6141
|
-
|
|
5944
|
+
});
|
|
5945
|
+
}
|
|
5946
|
+
static async getMineSkin(mineskinId) {
|
|
5947
|
+
return Requests.genericRequest({
|
|
5948
|
+
baseURL: "https://api.mineskin.org",
|
|
5949
|
+
url: "/get/uuid/" + mineskinId
|
|
5950
|
+
}).then((res) => {
|
|
5951
|
+
if (res.status === 200) {
|
|
5952
|
+
return res.data;
|
|
6142
5953
|
}
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
if (scope.enablePan === false) return;
|
|
6157
|
-
handleMouseMovePan(event);
|
|
6158
|
-
break;
|
|
5954
|
+
return void 0;
|
|
5955
|
+
}).catch((err) => {
|
|
5956
|
+
console.warn(err);
|
|
5957
|
+
return void 0;
|
|
5958
|
+
});
|
|
5959
|
+
}
|
|
5960
|
+
static async getCapesDev(uuid, type = "all") {
|
|
5961
|
+
return Requests.genericRequest({
|
|
5962
|
+
baseURL: "https://api.capes.dev",
|
|
5963
|
+
url: "/load/" + uuid + "/" + type
|
|
5964
|
+
}).then((res) => {
|
|
5965
|
+
if (res.status === 200) {
|
|
5966
|
+
return res.data;
|
|
6159
5967
|
}
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
}
|
|
6166
|
-
function onMouseWheel(event) {
|
|
6167
|
-
if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
|
|
6168
|
-
event.preventDefault();
|
|
6169
|
-
scope.dispatchEvent(_startEvent);
|
|
6170
|
-
handleMouseWheel(event);
|
|
6171
|
-
scope.dispatchEvent(_endEvent);
|
|
6172
|
-
}
|
|
6173
|
-
function onKeyDown(event) {
|
|
6174
|
-
if (scope.enabled === false || scope.enablePan === false) return;
|
|
6175
|
-
handleKeyDown(event);
|
|
6176
|
-
}
|
|
6177
|
-
function onTouchStart(event) {
|
|
6178
|
-
trackPointer(event);
|
|
6179
|
-
switch (pointers.length) {
|
|
6180
|
-
case 1:
|
|
6181
|
-
switch (scope.touches.ONE) {
|
|
6182
|
-
case import_three18.TOUCH.ROTATE:
|
|
6183
|
-
if (scope.enableRotate === false) return;
|
|
6184
|
-
handleTouchStartRotate();
|
|
6185
|
-
state = STATE.TOUCH_ROTATE;
|
|
6186
|
-
break;
|
|
6187
|
-
case import_three18.TOUCH.PAN:
|
|
6188
|
-
if (scope.enablePan === false) return;
|
|
6189
|
-
handleTouchStartPan();
|
|
6190
|
-
state = STATE.TOUCH_PAN;
|
|
6191
|
-
break;
|
|
6192
|
-
default:
|
|
6193
|
-
state = STATE.NONE;
|
|
6194
|
-
}
|
|
6195
|
-
break;
|
|
6196
|
-
case 2:
|
|
6197
|
-
switch (scope.touches.TWO) {
|
|
6198
|
-
case import_three18.TOUCH.DOLLY_PAN:
|
|
6199
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6200
|
-
handleTouchStartDollyPan();
|
|
6201
|
-
state = STATE.TOUCH_DOLLY_PAN;
|
|
6202
|
-
break;
|
|
6203
|
-
case import_three18.TOUCH.DOLLY_ROTATE:
|
|
6204
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6205
|
-
handleTouchStartDollyRotate();
|
|
6206
|
-
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
6207
|
-
break;
|
|
6208
|
-
default:
|
|
6209
|
-
state = STATE.NONE;
|
|
6210
|
-
}
|
|
6211
|
-
break;
|
|
6212
|
-
default:
|
|
6213
|
-
state = STATE.NONE;
|
|
6214
|
-
}
|
|
6215
|
-
if (state !== STATE.NONE) {
|
|
6216
|
-
scope.dispatchEvent(_startEvent);
|
|
6217
|
-
}
|
|
6218
|
-
}
|
|
6219
|
-
function onTouchMove(event) {
|
|
6220
|
-
trackPointer(event);
|
|
6221
|
-
switch (state) {
|
|
6222
|
-
case STATE.TOUCH_ROTATE:
|
|
6223
|
-
if (scope.enableRotate === false) return;
|
|
6224
|
-
handleTouchMoveRotate(event);
|
|
6225
|
-
scope.update();
|
|
6226
|
-
break;
|
|
6227
|
-
case STATE.TOUCH_PAN:
|
|
6228
|
-
if (scope.enablePan === false) return;
|
|
6229
|
-
handleTouchMovePan(event);
|
|
6230
|
-
scope.update();
|
|
6231
|
-
break;
|
|
6232
|
-
case STATE.TOUCH_DOLLY_PAN:
|
|
6233
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6234
|
-
handleTouchMoveDollyPan(event);
|
|
6235
|
-
scope.update();
|
|
6236
|
-
break;
|
|
6237
|
-
case STATE.TOUCH_DOLLY_ROTATE:
|
|
6238
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6239
|
-
handleTouchMoveDollyRotate(event);
|
|
6240
|
-
scope.update();
|
|
6241
|
-
break;
|
|
6242
|
-
default:
|
|
6243
|
-
state = STATE.NONE;
|
|
6244
|
-
}
|
|
6245
|
-
}
|
|
6246
|
-
function onTouchEnd(event) {
|
|
6247
|
-
handleTouchEnd(event);
|
|
6248
|
-
scope.dispatchEvent(_endEvent);
|
|
6249
|
-
state = STATE.NONE;
|
|
6250
|
-
}
|
|
6251
|
-
function onContextMenu(event) {
|
|
6252
|
-
if (scope.enabled === false) return;
|
|
6253
|
-
event.preventDefault();
|
|
6254
|
-
}
|
|
6255
|
-
function addPointer(event) {
|
|
6256
|
-
pointers.push(event);
|
|
6257
|
-
}
|
|
6258
|
-
function removePointer(event) {
|
|
6259
|
-
delete pointerPositions[event.pointerId];
|
|
6260
|
-
for (let i = 0; i < pointers.length; i++) {
|
|
6261
|
-
if (pointers[i].pointerId == event.pointerId) {
|
|
6262
|
-
pointers.splice(i, 1);
|
|
6263
|
-
return;
|
|
6264
|
-
}
|
|
6265
|
-
}
|
|
6266
|
-
}
|
|
6267
|
-
function trackPointer(event) {
|
|
6268
|
-
let position = pointerPositions[event.pointerId];
|
|
6269
|
-
if (position === void 0) {
|
|
6270
|
-
position = new import_three18.Vector2();
|
|
6271
|
-
pointerPositions[event.pointerId] = position;
|
|
6272
|
-
}
|
|
6273
|
-
position.set(event.pageX, event.pageY);
|
|
6274
|
-
}
|
|
6275
|
-
function getSecondPointerPosition(event) {
|
|
6276
|
-
const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
|
|
6277
|
-
return pointerPositions[pointer.pointerId];
|
|
6278
|
-
}
|
|
6279
|
-
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
6280
|
-
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
6281
|
-
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
6282
|
-
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
6283
|
-
this.update();
|
|
5968
|
+
return void 0;
|
|
5969
|
+
}).catch((err) => {
|
|
5970
|
+
console.warn(err);
|
|
5971
|
+
return void 0;
|
|
5972
|
+
});
|
|
6284
5973
|
}
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
constructor(object, domElement) {
|
|
6288
|
-
super(object, domElement);
|
|
6289
|
-
this.screenSpacePanning = false;
|
|
6290
|
-
this.mouseButtons.LEFT = import_three18.MOUSE.PAN;
|
|
6291
|
-
this.mouseButtons.RIGHT = import_three18.MOUSE.ROTATE;
|
|
6292
|
-
this.touches.ONE = import_three18.TOUCH.PAN;
|
|
6293
|
-
this.touches.TWO = import_three18.TOUCH.DOLLY_ROTATE;
|
|
5974
|
+
static getCrafatarSkinUrl(uuid) {
|
|
5975
|
+
return "https://crafatar.com/skins/" + uuid;
|
|
6294
5976
|
}
|
|
5977
|
+
static getCrafatarCapeUrl(uuid) {
|
|
5978
|
+
return "https://crafatar.com/capes/" + uuid;
|
|
5979
|
+
}
|
|
5980
|
+
static getMcHeadsSkinUrl(uuid) {
|
|
5981
|
+
return "https://mc-heads.net/skin/" + uuid;
|
|
5982
|
+
}
|
|
5983
|
+
static getMineSkinPlayerSkinUrl(uuid) {
|
|
5984
|
+
return "https://mineskin.org/skin/player/" + uuid;
|
|
5985
|
+
}
|
|
5986
|
+
static getSkinProxySkinUrl(uuid) {
|
|
5987
|
+
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
5988
|
+
}
|
|
5989
|
+
static getSkinProxyCapeUrl(uuid) {
|
|
5990
|
+
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
5991
|
+
}
|
|
5992
|
+
//</editor-fold>
|
|
6295
5993
|
};
|
|
6296
5994
|
|
|
6297
|
-
// src/
|
|
6298
|
-
var
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
5995
|
+
// src/three/OrbitControls.js
|
|
5996
|
+
var import_three20 = require("three");
|
|
5997
|
+
var _changeEvent = { type: "change" };
|
|
5998
|
+
var _startEvent = { type: "start" };
|
|
5999
|
+
var _endEvent = { type: "end" };
|
|
6000
|
+
var OrbitControls = class extends import_three20.EventDispatcher {
|
|
6001
|
+
constructor(object, domElement) {
|
|
6002
|
+
super();
|
|
6003
|
+
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
6004
|
+
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
6005
|
+
this.object = object;
|
|
6006
|
+
this.domElement = domElement;
|
|
6007
|
+
this.domElement.style.touchAction = "none";
|
|
6008
|
+
this.enabled = true;
|
|
6009
|
+
this.target = new import_three20.Vector3();
|
|
6010
|
+
this.minDistance = 0;
|
|
6011
|
+
this.maxDistance = Infinity;
|
|
6012
|
+
this.minZoom = 0;
|
|
6013
|
+
this.maxZoom = Infinity;
|
|
6014
|
+
this.minPolarAngle = 0;
|
|
6015
|
+
this.maxPolarAngle = Math.PI;
|
|
6016
|
+
this.minAzimuthAngle = -Infinity;
|
|
6017
|
+
this.maxAzimuthAngle = Infinity;
|
|
6018
|
+
this.enableDamping = false;
|
|
6019
|
+
this.dampingFactor = 0.05;
|
|
6020
|
+
this.enableZoom = true;
|
|
6021
|
+
this.zoomSpeed = 1;
|
|
6022
|
+
this.enableRotate = true;
|
|
6023
|
+
this.rotateSpeed = 1;
|
|
6024
|
+
this.enablePan = true;
|
|
6025
|
+
this.panSpeed = 1;
|
|
6026
|
+
this.screenSpacePanning = true;
|
|
6027
|
+
this.keyPanSpeed = 7;
|
|
6028
|
+
this.autoRotate = false;
|
|
6029
|
+
this.autoRotateSpeed = 2;
|
|
6030
|
+
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
6031
|
+
this.mouseButtons = { LEFT: import_three20.MOUSE.ROTATE, MIDDLE: import_three20.MOUSE.DOLLY, RIGHT: import_three20.MOUSE.PAN };
|
|
6032
|
+
this.touches = { ONE: import_three20.TOUCH.ROTATE, TWO: import_three20.TOUCH.DOLLY_PAN };
|
|
6033
|
+
this.target0 = this.target.clone();
|
|
6034
|
+
this.position0 = this.object.position.clone();
|
|
6035
|
+
this.zoom0 = this.object.zoom;
|
|
6036
|
+
this._domElementKeyEvents = null;
|
|
6037
|
+
this.getPolarAngle = function() {
|
|
6038
|
+
return spherical.phi;
|
|
6307
6039
|
};
|
|
6308
|
-
this.
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
this.
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
this.
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
}
|
|
6319
|
-
this.
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6040
|
+
this.getAzimuthalAngle = function() {
|
|
6041
|
+
return spherical.theta;
|
|
6042
|
+
};
|
|
6043
|
+
this.getDistance = function() {
|
|
6044
|
+
return this.object.position.distanceTo(this.target);
|
|
6045
|
+
};
|
|
6046
|
+
this.saveState = function() {
|
|
6047
|
+
scope.target0.copy(scope.target);
|
|
6048
|
+
scope.position0.copy(scope.object.position);
|
|
6049
|
+
scope.zoom0 = scope.object.zoom;
|
|
6050
|
+
};
|
|
6051
|
+
this.reset = function() {
|
|
6052
|
+
scope.target.copy(scope.target0);
|
|
6053
|
+
scope.object.position.copy(scope.position0);
|
|
6054
|
+
scope.object.zoom = scope.zoom0;
|
|
6055
|
+
scope.object.updateProjectionMatrix();
|
|
6056
|
+
scope.dispatchEvent(_changeEvent);
|
|
6057
|
+
scope.update();
|
|
6058
|
+
state = STATE.NONE;
|
|
6059
|
+
};
|
|
6060
|
+
this.update = function() {
|
|
6061
|
+
const offset = new import_three20.Vector3();
|
|
6062
|
+
const quat = new import_three20.Quaternion().setFromUnitVectors(object.up, new import_three20.Vector3(0, 1, 0));
|
|
6063
|
+
const quatInverse = quat.clone().invert();
|
|
6064
|
+
const lastPosition = new import_three20.Vector3();
|
|
6065
|
+
const lastQuaternion = new import_three20.Quaternion();
|
|
6066
|
+
const twoPI = 2 * Math.PI;
|
|
6067
|
+
return function update() {
|
|
6068
|
+
const position = scope.object.position;
|
|
6069
|
+
offset.copy(position).sub(scope.target);
|
|
6070
|
+
offset.applyQuaternion(quat);
|
|
6071
|
+
spherical.setFromVector3(offset);
|
|
6072
|
+
if (scope.autoRotate && state === STATE.NONE) {
|
|
6073
|
+
rotateLeft(getAutoRotationAngle());
|
|
6074
|
+
}
|
|
6075
|
+
if (scope.enableDamping) {
|
|
6076
|
+
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
6077
|
+
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
6078
|
+
} else {
|
|
6079
|
+
spherical.theta += sphericalDelta.theta;
|
|
6080
|
+
spherical.phi += sphericalDelta.phi;
|
|
6081
|
+
}
|
|
6082
|
+
let min = scope.minAzimuthAngle;
|
|
6083
|
+
let max = scope.maxAzimuthAngle;
|
|
6084
|
+
if (isFinite(min) && isFinite(max)) {
|
|
6085
|
+
if (min < -Math.PI) min += twoPI;
|
|
6086
|
+
else if (min > Math.PI) min -= twoPI;
|
|
6087
|
+
if (max < -Math.PI) max += twoPI;
|
|
6088
|
+
else if (max > Math.PI) max -= twoPI;
|
|
6089
|
+
if (min <= max) {
|
|
6090
|
+
spherical.theta = Math.max(min, Math.min(max, spherical.theta));
|
|
6091
|
+
} else {
|
|
6092
|
+
spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6095
|
+
spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
|
|
6096
|
+
spherical.makeSafe();
|
|
6097
|
+
spherical.radius *= scale;
|
|
6098
|
+
spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
|
|
6099
|
+
if (scope.enableDamping === true) {
|
|
6100
|
+
scope.target.addScaledVector(panOffset, scope.dampingFactor);
|
|
6101
|
+
} else {
|
|
6102
|
+
scope.target.add(panOffset);
|
|
6103
|
+
}
|
|
6104
|
+
offset.setFromSpherical(spherical);
|
|
6105
|
+
offset.applyQuaternion(quatInverse);
|
|
6106
|
+
position.copy(scope.target).add(offset);
|
|
6107
|
+
scope.object.lookAt(scope.target);
|
|
6108
|
+
if (scope.enableDamping === true) {
|
|
6109
|
+
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
6110
|
+
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
6111
|
+
panOffset.multiplyScalar(1 - scope.dampingFactor);
|
|
6112
|
+
} else {
|
|
6113
|
+
sphericalDelta.set(0, 0, 0);
|
|
6114
|
+
panOffset.set(0, 0, 0);
|
|
6115
|
+
}
|
|
6116
|
+
scale = 1;
|
|
6117
|
+
if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
|
|
6118
|
+
scope.dispatchEvent(_changeEvent);
|
|
6119
|
+
lastPosition.copy(scope.object.position);
|
|
6120
|
+
lastQuaternion.copy(scope.object.quaternion);
|
|
6121
|
+
zoomChanged = false;
|
|
6122
|
+
return true;
|
|
6123
|
+
}
|
|
6124
|
+
return false;
|
|
6125
|
+
};
|
|
6126
|
+
}();
|
|
6127
|
+
this.dispose = function() {
|
|
6128
|
+
scope.domElement.removeEventListener("contextmenu", onContextMenu);
|
|
6129
|
+
scope.domElement.removeEventListener("pointerdown", onPointerDown);
|
|
6130
|
+
scope.domElement.removeEventListener("pointercancel", onPointerCancel);
|
|
6131
|
+
scope.domElement.removeEventListener("wheel", onMouseWheel);
|
|
6132
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
6133
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
6134
|
+
if (scope._domElementKeyEvents !== null) {
|
|
6135
|
+
scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
|
|
6136
|
+
}
|
|
6137
|
+
};
|
|
6138
|
+
const scope = this;
|
|
6139
|
+
const STATE = {
|
|
6140
|
+
NONE: -1,
|
|
6141
|
+
ROTATE: 0,
|
|
6142
|
+
DOLLY: 1,
|
|
6143
|
+
PAN: 2,
|
|
6144
|
+
TOUCH_ROTATE: 3,
|
|
6145
|
+
TOUCH_PAN: 4,
|
|
6146
|
+
TOUCH_DOLLY_PAN: 5,
|
|
6147
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
6148
|
+
};
|
|
6149
|
+
let state = STATE.NONE;
|
|
6150
|
+
const EPS = 1e-6;
|
|
6151
|
+
const spherical = new import_three20.Spherical();
|
|
6152
|
+
const sphericalDelta = new import_three20.Spherical();
|
|
6153
|
+
let scale = 1;
|
|
6154
|
+
const panOffset = new import_three20.Vector3();
|
|
6155
|
+
let zoomChanged = false;
|
|
6156
|
+
const rotateStart = new import_three20.Vector2();
|
|
6157
|
+
const rotateEnd = new import_three20.Vector2();
|
|
6158
|
+
const rotateDelta = new import_three20.Vector2();
|
|
6159
|
+
const panStart = new import_three20.Vector2();
|
|
6160
|
+
const panEnd = new import_three20.Vector2();
|
|
6161
|
+
const panDelta = new import_three20.Vector2();
|
|
6162
|
+
const dollyStart = new import_three20.Vector2();
|
|
6163
|
+
const dollyEnd = new import_three20.Vector2();
|
|
6164
|
+
const dollyDelta = new import_three20.Vector2();
|
|
6165
|
+
const pointers = [];
|
|
6166
|
+
const pointerPositions = {};
|
|
6167
|
+
function getAutoRotationAngle() {
|
|
6168
|
+
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
6345
6169
|
}
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
const renderer = new import_three19.WebGLRenderer({
|
|
6349
|
-
antialias: this.options.render.antialias,
|
|
6350
|
-
alpha: true,
|
|
6351
|
-
powerPreference: "high-performance",
|
|
6352
|
-
depth: true
|
|
6353
|
-
});
|
|
6354
|
-
renderer.setClearColor(0, 0);
|
|
6355
|
-
renderer.shadowMap.enabled = true;
|
|
6356
|
-
renderer.shadowMap.type = import_three19.PCFSoftShadowMap;
|
|
6357
|
-
renderer.outputColorSpace = import_three19.SRGBColorSpace;
|
|
6358
|
-
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6359
|
-
return renderer;
|
|
6360
|
-
}
|
|
6361
|
-
createComposer() {
|
|
6362
|
-
if (!this.options.composer.enabled) return void 0;
|
|
6363
|
-
const composer = new import_postprocessing.EffectComposer(this.renderer);
|
|
6364
|
-
composer.setSize(this.viewWidth, this.viewHeight);
|
|
6365
|
-
composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
|
|
6366
|
-
return composer;
|
|
6367
|
-
}
|
|
6368
|
-
createControls() {
|
|
6369
|
-
if (!this.options.controls?.enabled) return void 0;
|
|
6370
|
-
const position = this.camera.position.clone();
|
|
6371
|
-
const controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
6372
|
-
this.camera.position.copy(position);
|
|
6373
|
-
const target = this.options.camera.lookingAt;
|
|
6374
|
-
if (isVector3(target)) {
|
|
6375
|
-
controls.target.copy(target);
|
|
6376
|
-
} else if (isTripleArray(target)) {
|
|
6377
|
-
controls.target.set(target[0], target[1], target[2]);
|
|
6378
|
-
}
|
|
6379
|
-
controls.update();
|
|
6380
|
-
controls.saveState();
|
|
6381
|
-
this.registerEventDispatcher(controls);
|
|
6382
|
-
return controls;
|
|
6383
|
-
}
|
|
6384
|
-
//</editor-fold>
|
|
6385
|
-
init() {
|
|
6386
|
-
if (this._disposed) return;
|
|
6387
|
-
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
6388
|
-
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6170
|
+
function getZoomScale() {
|
|
6171
|
+
return Math.pow(0.95, scope.zoomSpeed);
|
|
6389
6172
|
}
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
this._debugHelpers.push(gridHelper);
|
|
6393
|
-
this.scene.add(gridHelper);
|
|
6394
|
-
const gridHelper2 = new import_three19.GridHelper(128, 16);
|
|
6395
|
-
this._debugHelpers.push(gridHelper2);
|
|
6396
|
-
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6397
|
-
this.scene.add(gridHelper2);
|
|
6398
|
-
const gridHelper3 = new import_three19.GridHelper(128, 16);
|
|
6399
|
-
this._debugHelpers.push(gridHelper3);
|
|
6400
|
-
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6401
|
-
this.scene.add(gridHelper3);
|
|
6173
|
+
function rotateLeft(angle) {
|
|
6174
|
+
sphericalDelta.theta -= angle;
|
|
6402
6175
|
}
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
this._debugHelpers.push(axesHelper);
|
|
6406
|
-
this.scene.add(axesHelper);
|
|
6176
|
+
function rotateUp(angle) {
|
|
6177
|
+
sphericalDelta.phi -= angle;
|
|
6407
6178
|
}
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6179
|
+
const panLeft = function() {
|
|
6180
|
+
const v = new import_three20.Vector3();
|
|
6181
|
+
return function panLeft2(distance, objectMatrix) {
|
|
6182
|
+
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6183
|
+
v.multiplyScalar(-distance);
|
|
6184
|
+
panOffset.add(v);
|
|
6185
|
+
};
|
|
6186
|
+
}();
|
|
6187
|
+
const panUp = function() {
|
|
6188
|
+
const v = new import_three20.Vector3();
|
|
6189
|
+
return function panUp2(distance, objectMatrix) {
|
|
6190
|
+
if (scope.screenSpacePanning === true) {
|
|
6191
|
+
v.setFromMatrixColumn(objectMatrix, 1);
|
|
6192
|
+
} else {
|
|
6193
|
+
v.setFromMatrixColumn(objectMatrix, 0);
|
|
6194
|
+
v.crossVectors(scope.object.up, v);
|
|
6195
|
+
}
|
|
6196
|
+
v.multiplyScalar(distance);
|
|
6197
|
+
panOffset.add(v);
|
|
6198
|
+
};
|
|
6199
|
+
}();
|
|
6200
|
+
const pan = function() {
|
|
6201
|
+
const offset = new import_three20.Vector3();
|
|
6202
|
+
return function pan2(deltaX, deltaY) {
|
|
6203
|
+
const element = scope.domElement;
|
|
6204
|
+
if (scope.object.isPerspectiveCamera) {
|
|
6205
|
+
const position = scope.object.position;
|
|
6206
|
+
offset.copy(position).sub(scope.target);
|
|
6207
|
+
let targetDistance = offset.length();
|
|
6208
|
+
targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
|
|
6209
|
+
panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
|
|
6210
|
+
panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
|
|
6211
|
+
} else if (scope.object.isOrthographicCamera) {
|
|
6212
|
+
panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
|
|
6213
|
+
panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
|
|
6214
|
+
} else {
|
|
6215
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
|
|
6216
|
+
scope.enablePan = false;
|
|
6217
|
+
}
|
|
6218
|
+
};
|
|
6219
|
+
}();
|
|
6220
|
+
function dollyOut(dollyScale) {
|
|
6221
|
+
if (scope.object.isPerspectiveCamera) {
|
|
6222
|
+
scale /= dollyScale;
|
|
6223
|
+
} else if (scope.object.isOrthographicCamera) {
|
|
6224
|
+
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
|
|
6225
|
+
scope.object.updateProjectionMatrix();
|
|
6226
|
+
zoomChanged = true;
|
|
6227
|
+
} else {
|
|
6228
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
6229
|
+
scope.enableZoom = false;
|
|
6413
6230
|
}
|
|
6414
6231
|
}
|
|
6415
|
-
|
|
6416
|
-
if (
|
|
6417
|
-
|
|
6418
|
-
} else if (
|
|
6419
|
-
|
|
6232
|
+
function dollyIn(dollyScale) {
|
|
6233
|
+
if (scope.object.isPerspectiveCamera) {
|
|
6234
|
+
scale *= dollyScale;
|
|
6235
|
+
} else if (scope.object.isOrthographicCamera) {
|
|
6236
|
+
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
|
|
6237
|
+
scope.object.updateProjectionMatrix();
|
|
6238
|
+
zoomChanged = true;
|
|
6239
|
+
} else {
|
|
6240
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
6241
|
+
scope.enableZoom = false;
|
|
6420
6242
|
}
|
|
6421
6243
|
}
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
this.resize(this.viewWidth, this.viewHeight);
|
|
6425
|
-
};
|
|
6426
|
-
window.addEventListener("resize", this._resizeListener);
|
|
6244
|
+
function handleMouseDownRotate(event) {
|
|
6245
|
+
rotateStart.set(event.clientX, event.clientY);
|
|
6427
6246
|
}
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
return this._element;
|
|
6431
|
-
}
|
|
6432
|
-
appendTo(element) {
|
|
6433
|
-
if (this._disposed) return;
|
|
6434
|
-
this._element = element;
|
|
6435
|
-
this._element.appendChild(this.renderer.domElement);
|
|
6436
|
-
if (this.viewWidth == 0) {
|
|
6437
|
-
console.warn("0 element width");
|
|
6247
|
+
function handleMouseDownDolly(event) {
|
|
6248
|
+
dollyStart.set(event.clientX, event.clientY);
|
|
6438
6249
|
}
|
|
6439
|
-
|
|
6440
|
-
|
|
6250
|
+
function handleMouseDownPan(event) {
|
|
6251
|
+
panStart.set(event.clientX, event.clientY);
|
|
6441
6252
|
}
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
let events = this._eventDispatchers.get(dispatcher);
|
|
6451
|
-
if (!events) {
|
|
6452
|
-
events = /* @__PURE__ */ new Set();
|
|
6453
|
-
this._eventDispatchers.set(dispatcher, events);
|
|
6253
|
+
function handleMouseMoveRotate(event) {
|
|
6254
|
+
rotateEnd.set(event.clientX, event.clientY);
|
|
6255
|
+
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
6256
|
+
const element = scope.domElement;
|
|
6257
|
+
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
6258
|
+
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
6259
|
+
rotateStart.copy(rotateEnd);
|
|
6260
|
+
scope.update();
|
|
6454
6261
|
}
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
this.camera.left = width / -2;
|
|
6466
|
-
this.camera.right = width / 2;
|
|
6467
|
-
this.camera.top = height / 2;
|
|
6468
|
-
this.camera.bottom = height / -2;
|
|
6469
|
-
this.camera.updateProjectionMatrix();
|
|
6262
|
+
function handleMouseMoveDolly(event) {
|
|
6263
|
+
dollyEnd.set(event.clientX, event.clientY);
|
|
6264
|
+
dollyDelta.subVectors(dollyEnd, dollyStart);
|
|
6265
|
+
if (dollyDelta.y > 0) {
|
|
6266
|
+
dollyOut(getZoomScale());
|
|
6267
|
+
} else if (dollyDelta.y < 0) {
|
|
6268
|
+
dollyIn(getZoomScale());
|
|
6269
|
+
}
|
|
6270
|
+
dollyStart.copy(dollyEnd);
|
|
6271
|
+
scope.update();
|
|
6470
6272
|
}
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6273
|
+
function handleMouseMovePan(event) {
|
|
6274
|
+
panEnd.set(event.clientX, event.clientY);
|
|
6275
|
+
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
6276
|
+
pan(panDelta.x, panDelta.y);
|
|
6277
|
+
panStart.copy(panEnd);
|
|
6278
|
+
scope.update();
|
|
6279
|
+
}
|
|
6280
|
+
function handleMouseUp() {
|
|
6281
|
+
}
|
|
6282
|
+
function handleMouseWheel(event) {
|
|
6283
|
+
if (event.deltaY < 0) {
|
|
6284
|
+
dollyIn(getZoomScale());
|
|
6285
|
+
} else if (event.deltaY > 0) {
|
|
6286
|
+
dollyOut(getZoomScale());
|
|
6287
|
+
}
|
|
6288
|
+
scope.update();
|
|
6289
|
+
}
|
|
6290
|
+
function handleKeyDown(event) {
|
|
6291
|
+
let needsUpdate = false;
|
|
6292
|
+
switch (event.code) {
|
|
6293
|
+
case scope.keys.UP:
|
|
6294
|
+
pan(0, scope.keyPanSpeed);
|
|
6295
|
+
needsUpdate = true;
|
|
6296
|
+
break;
|
|
6297
|
+
case scope.keys.BOTTOM:
|
|
6298
|
+
pan(0, -scope.keyPanSpeed);
|
|
6299
|
+
needsUpdate = true;
|
|
6300
|
+
break;
|
|
6301
|
+
case scope.keys.LEFT:
|
|
6302
|
+
pan(scope.keyPanSpeed, 0);
|
|
6303
|
+
needsUpdate = true;
|
|
6304
|
+
break;
|
|
6305
|
+
case scope.keys.RIGHT:
|
|
6306
|
+
pan(-scope.keyPanSpeed, 0);
|
|
6307
|
+
needsUpdate = true;
|
|
6308
|
+
break;
|
|
6309
|
+
}
|
|
6310
|
+
if (needsUpdate) {
|
|
6311
|
+
event.preventDefault();
|
|
6312
|
+
scope.update();
|
|
6313
|
+
}
|
|
6505
6314
|
}
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6315
|
+
function handleTouchStartRotate() {
|
|
6316
|
+
if (pointers.length === 1) {
|
|
6317
|
+
rotateStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
6318
|
+
} else {
|
|
6319
|
+
const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
6320
|
+
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
6321
|
+
rotateStart.set(x, y);
|
|
6509
6322
|
}
|
|
6510
6323
|
}
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
controls.enabled = false;
|
|
6520
|
-
controls.dispose();
|
|
6324
|
+
function handleTouchStartPan() {
|
|
6325
|
+
if (pointers.length === 1) {
|
|
6326
|
+
panStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
6327
|
+
} else {
|
|
6328
|
+
const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
6329
|
+
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
6330
|
+
panStart.set(x, y);
|
|
6331
|
+
}
|
|
6521
6332
|
}
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
const
|
|
6526
|
-
|
|
6527
|
-
|
|
6333
|
+
function handleTouchStartDolly() {
|
|
6334
|
+
const dx = pointers[0].pageX - pointers[1].pageX;
|
|
6335
|
+
const dy = pointers[0].pageY - pointers[1].pageY;
|
|
6336
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6337
|
+
dollyStart.set(0, distance);
|
|
6338
|
+
}
|
|
6339
|
+
function handleTouchStartDollyPan() {
|
|
6340
|
+
if (scope.enableZoom) handleTouchStartDolly();
|
|
6341
|
+
if (scope.enablePan) handleTouchStartPan();
|
|
6342
|
+
}
|
|
6343
|
+
function handleTouchStartDollyRotate() {
|
|
6344
|
+
if (scope.enableZoom) handleTouchStartDolly();
|
|
6345
|
+
if (scope.enableRotate) handleTouchStartRotate();
|
|
6346
|
+
}
|
|
6347
|
+
function handleTouchMoveRotate(event) {
|
|
6348
|
+
if (pointers.length == 1) {
|
|
6349
|
+
rotateEnd.set(event.pageX, event.pageY);
|
|
6350
|
+
} else {
|
|
6351
|
+
const position = getSecondPointerPosition(event);
|
|
6352
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
6353
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
6354
|
+
rotateEnd.set(x, y);
|
|
6528
6355
|
}
|
|
6356
|
+
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
6357
|
+
const element = scope.domElement;
|
|
6358
|
+
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
6359
|
+
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
6360
|
+
rotateStart.copy(rotateEnd);
|
|
6529
6361
|
}
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6362
|
+
function handleTouchMovePan(event) {
|
|
6363
|
+
if (pointers.length === 1) {
|
|
6364
|
+
panEnd.set(event.pageX, event.pageY);
|
|
6365
|
+
} else {
|
|
6366
|
+
const position = getSecondPointerPosition(event);
|
|
6367
|
+
const x = 0.5 * (event.pageX + position.x);
|
|
6368
|
+
const y = 0.5 * (event.pageY + position.y);
|
|
6369
|
+
panEnd.set(x, y);
|
|
6370
|
+
}
|
|
6371
|
+
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
6372
|
+
pan(panDelta.x, panDelta.y);
|
|
6373
|
+
panStart.copy(panEnd);
|
|
6539
6374
|
}
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
const
|
|
6545
|
-
|
|
6546
|
-
|
|
6375
|
+
function handleTouchMoveDolly(event) {
|
|
6376
|
+
const position = getSecondPointerPosition(event);
|
|
6377
|
+
const dx = event.pageX - position.x;
|
|
6378
|
+
const dy = event.pageY - position.y;
|
|
6379
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6380
|
+
dollyEnd.set(0, distance);
|
|
6381
|
+
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
6382
|
+
dollyOut(dollyDelta.y);
|
|
6383
|
+
dollyStart.copy(dollyEnd);
|
|
6547
6384
|
}
|
|
6548
|
-
|
|
6549
|
-
|
|
6385
|
+
function handleTouchMoveDollyPan(event) {
|
|
6386
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6387
|
+
if (scope.enablePan) handleTouchMovePan(event);
|
|
6550
6388
|
}
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
this.renderer.render(this.scene, this.camera);
|
|
6389
|
+
function handleTouchMoveDollyRotate(event) {
|
|
6390
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6391
|
+
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
6555
6392
|
}
|
|
6556
|
-
|
|
6557
|
-
if (this._stats) {
|
|
6558
|
-
this._stats.end();
|
|
6393
|
+
function handleTouchEnd() {
|
|
6559
6394
|
}
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
6574
|
-
}
|
|
6575
|
-
get scene() {
|
|
6576
|
-
return this._scene;
|
|
6577
|
-
}
|
|
6578
|
-
get camera() {
|
|
6579
|
-
return this._camera;
|
|
6580
|
-
}
|
|
6581
|
-
get renderer() {
|
|
6582
|
-
return this._renderer;
|
|
6583
|
-
}
|
|
6584
|
-
get composer() {
|
|
6585
|
-
return this._composer;
|
|
6586
|
-
}
|
|
6587
|
-
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
6588
|
-
get controls() {
|
|
6589
|
-
return this._controls;
|
|
6590
|
-
}
|
|
6591
|
-
///
|
|
6592
|
-
};
|
|
6593
|
-
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
6594
|
-
camera: {
|
|
6595
|
-
type: "perspective",
|
|
6596
|
-
near: 1,
|
|
6597
|
-
far: 5e3,
|
|
6598
|
-
perspective: {
|
|
6599
|
-
aspect: void 0,
|
|
6600
|
-
fov: 50
|
|
6601
|
-
},
|
|
6602
|
-
orthographic: {
|
|
6603
|
-
left: void 0,
|
|
6604
|
-
right: void 0,
|
|
6605
|
-
top: void 0,
|
|
6606
|
-
bottom: void 0
|
|
6607
|
-
},
|
|
6608
|
-
position: new import_three19.Vector3(50, 50, 50),
|
|
6609
|
-
lookingAt: new import_three19.Vector3(0, 0, 0)
|
|
6610
|
-
},
|
|
6611
|
-
render: {
|
|
6612
|
-
fpsLimit: 60,
|
|
6613
|
-
stats: false,
|
|
6614
|
-
antialias: true,
|
|
6615
|
-
shade: true,
|
|
6616
|
-
autoResize: true,
|
|
6617
|
-
renderAlways: false
|
|
6618
|
-
},
|
|
6619
|
-
composer: {
|
|
6620
|
-
enabled: true
|
|
6621
|
-
},
|
|
6622
|
-
controls: {
|
|
6623
|
-
enabled: false
|
|
6624
|
-
},
|
|
6625
|
-
debug: {
|
|
6626
|
-
grid: false,
|
|
6627
|
-
axes: false
|
|
6628
|
-
}
|
|
6629
|
-
});
|
|
6630
|
-
var Renderer = _Renderer;
|
|
6631
|
-
|
|
6632
|
-
// src/skin/Skins.ts
|
|
6633
|
-
var Skins = class {
|
|
6634
|
-
//<editor-fold desc="Skins">
|
|
6635
|
-
static async fromUuidOrUsername(uuidOrUsername) {
|
|
6636
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
6637
|
-
return this.fromUuid(uuidOrUsername);
|
|
6395
|
+
function onPointerDown(event) {
|
|
6396
|
+
if (scope.enabled === false) return;
|
|
6397
|
+
if (pointers.length === 0) {
|
|
6398
|
+
scope.domElement.setPointerCapture(event.pointerId);
|
|
6399
|
+
scope.domElement.addEventListener("pointermove", onPointerMove);
|
|
6400
|
+
scope.domElement.addEventListener("pointerup", onPointerUp);
|
|
6401
|
+
}
|
|
6402
|
+
addPointer(event);
|
|
6403
|
+
if (event.pointerType === "touch") {
|
|
6404
|
+
onTouchStart(event);
|
|
6405
|
+
} else {
|
|
6406
|
+
onMouseDown(event);
|
|
6407
|
+
}
|
|
6638
6408
|
}
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6409
|
+
function onPointerMove(event) {
|
|
6410
|
+
if (scope.enabled === false) return;
|
|
6411
|
+
if (event.pointerType === "touch") {
|
|
6412
|
+
onTouchMove(event);
|
|
6413
|
+
} else {
|
|
6414
|
+
onMouseMove(event);
|
|
6415
|
+
}
|
|
6416
|
+
}
|
|
6417
|
+
function onPointerUp(event) {
|
|
6418
|
+
if (scope.enabled === false) return;
|
|
6419
|
+
if (event.pointerType === "touch") {
|
|
6420
|
+
onTouchEnd();
|
|
6421
|
+
} else {
|
|
6422
|
+
onMouseUp(event);
|
|
6423
|
+
}
|
|
6424
|
+
removePointer(event);
|
|
6425
|
+
if (pointers.length === 0) {
|
|
6426
|
+
scope.domElement.releasePointerCapture(event.pointerId);
|
|
6427
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
6428
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6431
|
+
function onPointerCancel(event) {
|
|
6432
|
+
removePointer(event);
|
|
6433
|
+
}
|
|
6434
|
+
function onMouseDown(event) {
|
|
6435
|
+
let mouseAction;
|
|
6436
|
+
switch (event.button) {
|
|
6437
|
+
case 0:
|
|
6438
|
+
mouseAction = scope.mouseButtons.LEFT;
|
|
6439
|
+
break;
|
|
6440
|
+
case 1:
|
|
6441
|
+
mouseAction = scope.mouseButtons.MIDDLE;
|
|
6442
|
+
break;
|
|
6443
|
+
case 2:
|
|
6444
|
+
mouseAction = scope.mouseButtons.RIGHT;
|
|
6445
|
+
break;
|
|
6446
|
+
default:
|
|
6447
|
+
mouseAction = -1;
|
|
6448
|
+
}
|
|
6449
|
+
switch (mouseAction) {
|
|
6450
|
+
case import_three20.MOUSE.DOLLY:
|
|
6451
|
+
if (scope.enableZoom === false) return;
|
|
6452
|
+
handleMouseDownDolly(event);
|
|
6453
|
+
state = STATE.DOLLY;
|
|
6454
|
+
break;
|
|
6455
|
+
case import_three20.MOUSE.ROTATE:
|
|
6456
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6457
|
+
if (scope.enablePan === false) return;
|
|
6458
|
+
handleMouseDownPan(event);
|
|
6459
|
+
state = STATE.PAN;
|
|
6460
|
+
} else {
|
|
6461
|
+
if (scope.enableRotate === false) return;
|
|
6462
|
+
handleMouseDownRotate(event);
|
|
6463
|
+
state = STATE.ROTATE;
|
|
6464
|
+
}
|
|
6465
|
+
break;
|
|
6466
|
+
case import_three20.MOUSE.PAN:
|
|
6467
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6468
|
+
if (scope.enableRotate === false) return;
|
|
6469
|
+
handleMouseDownRotate(event);
|
|
6470
|
+
state = STATE.ROTATE;
|
|
6471
|
+
} else {
|
|
6472
|
+
if (scope.enablePan === false) return;
|
|
6473
|
+
handleMouseDownPan(event);
|
|
6474
|
+
state = STATE.PAN;
|
|
6475
|
+
}
|
|
6476
|
+
break;
|
|
6477
|
+
default:
|
|
6478
|
+
state = STATE.NONE;
|
|
6648
6479
|
}
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
}
|
|
6652
|
-
static async fromMineSkin(mineskinId) {
|
|
6653
|
-
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
6654
|
-
if (mineskin) {
|
|
6655
|
-
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
6480
|
+
if (state !== STATE.NONE) {
|
|
6481
|
+
scope.dispatchEvent(_startEvent);
|
|
6656
6482
|
}
|
|
6657
|
-
return void 0;
|
|
6658
|
-
});
|
|
6659
|
-
}
|
|
6660
|
-
//</editor-fold>
|
|
6661
|
-
//<editor-fold desc="Capes">
|
|
6662
|
-
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
6663
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
6664
|
-
return this.capeFromUuid(uuidOrUsername);
|
|
6665
6483
|
}
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
if (cape) {
|
|
6682
|
-
return cape?.stillImageUrl;
|
|
6484
|
+
function onMouseMove(event) {
|
|
6485
|
+
if (scope.enabled === false) return;
|
|
6486
|
+
switch (state) {
|
|
6487
|
+
case STATE.ROTATE:
|
|
6488
|
+
if (scope.enableRotate === false) return;
|
|
6489
|
+
handleMouseMoveRotate(event);
|
|
6490
|
+
break;
|
|
6491
|
+
case STATE.DOLLY:
|
|
6492
|
+
if (scope.enableZoom === false) return;
|
|
6493
|
+
handleMouseMoveDolly(event);
|
|
6494
|
+
break;
|
|
6495
|
+
case STATE.PAN:
|
|
6496
|
+
if (scope.enablePan === false) return;
|
|
6497
|
+
handleMouseMovePan(event);
|
|
6498
|
+
break;
|
|
6683
6499
|
}
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
}
|
|
6697
|
-
|
|
6698
|
-
|
|
6500
|
+
}
|
|
6501
|
+
function onMouseUp(event) {
|
|
6502
|
+
handleMouseUp(event);
|
|
6503
|
+
scope.dispatchEvent(_endEvent);
|
|
6504
|
+
state = STATE.NONE;
|
|
6505
|
+
}
|
|
6506
|
+
function onMouseWheel(event) {
|
|
6507
|
+
if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
|
|
6508
|
+
event.preventDefault();
|
|
6509
|
+
scope.dispatchEvent(_startEvent);
|
|
6510
|
+
handleMouseWheel(event);
|
|
6511
|
+
scope.dispatchEvent(_endEvent);
|
|
6512
|
+
}
|
|
6513
|
+
function onKeyDown(event) {
|
|
6514
|
+
if (scope.enabled === false || scope.enablePan === false) return;
|
|
6515
|
+
handleKeyDown(event);
|
|
6516
|
+
}
|
|
6517
|
+
function onTouchStart(event) {
|
|
6518
|
+
trackPointer(event);
|
|
6519
|
+
switch (pointers.length) {
|
|
6520
|
+
case 1:
|
|
6521
|
+
switch (scope.touches.ONE) {
|
|
6522
|
+
case import_three20.TOUCH.ROTATE:
|
|
6523
|
+
if (scope.enableRotate === false) return;
|
|
6524
|
+
handleTouchStartRotate();
|
|
6525
|
+
state = STATE.TOUCH_ROTATE;
|
|
6526
|
+
break;
|
|
6527
|
+
case import_three20.TOUCH.PAN:
|
|
6528
|
+
if (scope.enablePan === false) return;
|
|
6529
|
+
handleTouchStartPan();
|
|
6530
|
+
state = STATE.TOUCH_PAN;
|
|
6531
|
+
break;
|
|
6532
|
+
default:
|
|
6533
|
+
state = STATE.NONE;
|
|
6534
|
+
}
|
|
6535
|
+
break;
|
|
6536
|
+
case 2:
|
|
6537
|
+
switch (scope.touches.TWO) {
|
|
6538
|
+
case import_three20.TOUCH.DOLLY_PAN:
|
|
6539
|
+
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6540
|
+
handleTouchStartDollyPan();
|
|
6541
|
+
state = STATE.TOUCH_DOLLY_PAN;
|
|
6542
|
+
break;
|
|
6543
|
+
case import_three20.TOUCH.DOLLY_ROTATE:
|
|
6544
|
+
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6545
|
+
handleTouchStartDollyRotate();
|
|
6546
|
+
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
6547
|
+
break;
|
|
6548
|
+
default:
|
|
6549
|
+
state = STATE.NONE;
|
|
6550
|
+
}
|
|
6551
|
+
break;
|
|
6552
|
+
default:
|
|
6553
|
+
state = STATE.NONE;
|
|
6699
6554
|
}
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
console.warn(err);
|
|
6703
|
-
return void 0;
|
|
6704
|
-
});
|
|
6705
|
-
}
|
|
6706
|
-
static async usernameToUuidMineTools(username) {
|
|
6707
|
-
return Requests.genericRequest({
|
|
6708
|
-
baseURL: "https://api.minetools.eu",
|
|
6709
|
-
url: "/uuid/" + username
|
|
6710
|
-
}).then((res) => {
|
|
6711
|
-
if (res.status === 200) {
|
|
6712
|
-
return res.data["id"];
|
|
6555
|
+
if (state !== STATE.NONE) {
|
|
6556
|
+
scope.dispatchEvent(_startEvent);
|
|
6713
6557
|
}
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6558
|
+
}
|
|
6559
|
+
function onTouchMove(event) {
|
|
6560
|
+
trackPointer(event);
|
|
6561
|
+
switch (state) {
|
|
6562
|
+
case STATE.TOUCH_ROTATE:
|
|
6563
|
+
if (scope.enableRotate === false) return;
|
|
6564
|
+
handleTouchMoveRotate(event);
|
|
6565
|
+
scope.update();
|
|
6566
|
+
break;
|
|
6567
|
+
case STATE.TOUCH_PAN:
|
|
6568
|
+
if (scope.enablePan === false) return;
|
|
6569
|
+
handleTouchMovePan(event);
|
|
6570
|
+
scope.update();
|
|
6571
|
+
break;
|
|
6572
|
+
case STATE.TOUCH_DOLLY_PAN:
|
|
6573
|
+
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6574
|
+
handleTouchMoveDollyPan(event);
|
|
6575
|
+
scope.update();
|
|
6576
|
+
break;
|
|
6577
|
+
case STATE.TOUCH_DOLLY_ROTATE:
|
|
6578
|
+
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6579
|
+
handleTouchMoveDollyRotate(event);
|
|
6580
|
+
scope.update();
|
|
6581
|
+
break;
|
|
6582
|
+
default:
|
|
6583
|
+
state = STATE.NONE;
|
|
6727
6584
|
}
|
|
6728
|
-
}
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
if (
|
|
6736
|
-
|
|
6585
|
+
}
|
|
6586
|
+
function onTouchEnd(event) {
|
|
6587
|
+
handleTouchEnd(event);
|
|
6588
|
+
scope.dispatchEvent(_endEvent);
|
|
6589
|
+
state = STATE.NONE;
|
|
6590
|
+
}
|
|
6591
|
+
function onContextMenu(event) {
|
|
6592
|
+
if (scope.enabled === false) return;
|
|
6593
|
+
event.preventDefault();
|
|
6594
|
+
}
|
|
6595
|
+
function addPointer(event) {
|
|
6596
|
+
pointers.push(event);
|
|
6597
|
+
}
|
|
6598
|
+
function removePointer(event) {
|
|
6599
|
+
delete pointerPositions[event.pointerId];
|
|
6600
|
+
for (let i = 0; i < pointers.length; i++) {
|
|
6601
|
+
if (pointers[i].pointerId == event.pointerId) {
|
|
6602
|
+
pointers.splice(i, 1);
|
|
6603
|
+
return;
|
|
6604
|
+
}
|
|
6737
6605
|
}
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
static async getCapesDev(uuid, type = "all") {
|
|
6745
|
-
return Requests.genericRequest({
|
|
6746
|
-
baseURL: "https://api.capes.dev",
|
|
6747
|
-
url: "/load/" + uuid + "/" + type
|
|
6748
|
-
}).then((res) => {
|
|
6749
|
-
if (res.status === 200) {
|
|
6750
|
-
return res.data;
|
|
6606
|
+
}
|
|
6607
|
+
function trackPointer(event) {
|
|
6608
|
+
let position = pointerPositions[event.pointerId];
|
|
6609
|
+
if (position === void 0) {
|
|
6610
|
+
position = new import_three20.Vector2();
|
|
6611
|
+
pointerPositions[event.pointerId] = position;
|
|
6751
6612
|
}
|
|
6752
|
-
|
|
6753
|
-
}
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
}
|
|
6764
|
-
static getMcHeadsSkinUrl(uuid) {
|
|
6765
|
-
return "https://mc-heads.net/skin/" + uuid;
|
|
6766
|
-
}
|
|
6767
|
-
static getMineSkinPlayerSkinUrl(uuid) {
|
|
6768
|
-
return "https://mineskin.org/skin/player/" + uuid;
|
|
6769
|
-
}
|
|
6770
|
-
static getSkinProxySkinUrl(uuid) {
|
|
6771
|
-
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
6613
|
+
position.set(event.pageX, event.pageY);
|
|
6614
|
+
}
|
|
6615
|
+
function getSecondPointerPosition(event) {
|
|
6616
|
+
const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
|
|
6617
|
+
return pointerPositions[pointer.pointerId];
|
|
6618
|
+
}
|
|
6619
|
+
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
6620
|
+
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
6621
|
+
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
6622
|
+
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
6623
|
+
this.update();
|
|
6772
6624
|
}
|
|
6773
|
-
|
|
6774
|
-
|
|
6625
|
+
};
|
|
6626
|
+
var MapControls = class extends OrbitControls {
|
|
6627
|
+
constructor(object, domElement) {
|
|
6628
|
+
super(object, domElement);
|
|
6629
|
+
this.screenSpacePanning = false;
|
|
6630
|
+
this.mouseButtons.LEFT = import_three20.MOUSE.PAN;
|
|
6631
|
+
this.mouseButtons.RIGHT = import_three20.MOUSE.ROTATE;
|
|
6632
|
+
this.touches.ONE = import_three20.TOUCH.PAN;
|
|
6633
|
+
this.touches.TWO = import_three20.TOUCH.DOLLY_ROTATE;
|
|
6775
6634
|
}
|
|
6776
|
-
//</editor-fold>
|
|
6777
6635
|
};
|
|
6778
6636
|
|
|
6779
6637
|
// src/world/Chunk.ts
|
|
@@ -6890,7 +6748,7 @@ var MineRenderWorld = class {
|
|
|
6890
6748
|
};
|
|
6891
6749
|
|
|
6892
6750
|
// src/world/Chunk.ts
|
|
6893
|
-
var
|
|
6751
|
+
var p12 = prefix("Chunk");
|
|
6894
6752
|
var Chunk = class _Chunk {
|
|
6895
6753
|
constructor(scene, x, y, z) {
|
|
6896
6754
|
this._blocks = [];
|
|
@@ -6942,7 +6800,7 @@ var Chunk = class _Chunk {
|
|
|
6942
6800
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
6943
6801
|
const current = this._blocks[index];
|
|
6944
6802
|
if (typeof current !== "undefined") {
|
|
6945
|
-
console.debug(
|
|
6803
|
+
console.debug(p12, "deleting existing block at", pos, worldPos, index);
|
|
6946
6804
|
current.object.removeFromScene();
|
|
6947
6805
|
delete this._blocks[index];
|
|
6948
6806
|
}
|