minerender 2.1.0-alpha.18 → 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 -194
- package/dist/browser/index.d.ts +141 -194
- package/dist/browser/index.js +1592 -1738
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1590 -1736
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +4971 -3527
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +140 -193
- package/dist/node/index.d.ts +140 -193
- package/dist/node/index.js +1711 -1926
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1705 -1918
- 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);
|
|
@@ -1279,7 +1275,6 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1279
1275
|
this.rootType = rootType;
|
|
1280
1276
|
this.extension = extension;
|
|
1281
1277
|
this.root = root;
|
|
1282
|
-
this.isAssetKey = true;
|
|
1283
1278
|
}
|
|
1284
1279
|
static parse(assetType, str, origin) {
|
|
1285
1280
|
let namespace = origin?.namespace || DEFAULT_NAMESPACE;
|
|
@@ -1295,15 +1290,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1295
1290
|
split.shift();
|
|
1296
1291
|
}
|
|
1297
1292
|
let path = split.join("/");
|
|
1298
|
-
|
|
1299
|
-
if (extension && path.endsWith(extension)) {
|
|
1300
|
-
path = path.slice(0, -extension.length);
|
|
1301
|
-
}
|
|
1293
|
+
let extension = assetType === "textures" ? ".png" : origin?.assetType || ".json";
|
|
1302
1294
|
return new _AssetKey(namespace, path, assetType, type, "assets", extension, origin?.root);
|
|
1303
1295
|
}
|
|
1304
1296
|
toString() {
|
|
1305
1297
|
let a = [
|
|
1306
|
-
this.root ?? AssetLoader.ROOT,
|
|
1298
|
+
typeof this.root !== "undefined" || AssetLoader.ROOT !== DEFAULT_ROOT ? this.root ?? AssetLoader.ROOT : "__root__",
|
|
1307
1299
|
this.rootType ?? "__rootType__",
|
|
1308
1300
|
this.assetType ?? "__assetType__",
|
|
1309
1301
|
this.type ?? "__type__",
|
|
@@ -1313,12 +1305,12 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1313
1305
|
return a.join("/");
|
|
1314
1306
|
}
|
|
1315
1307
|
getFullPath() {
|
|
1316
|
-
let
|
|
1308
|
+
let p13 = [];
|
|
1317
1309
|
if (this.type) {
|
|
1318
|
-
|
|
1310
|
+
p13.push(this.type);
|
|
1319
1311
|
}
|
|
1320
|
-
|
|
1321
|
-
return
|
|
1312
|
+
p13.push(this.path);
|
|
1313
|
+
return p13.join("/");
|
|
1322
1314
|
}
|
|
1323
1315
|
toNamespacedString() {
|
|
1324
1316
|
return this.namespace + ":" + this.getFullPath();
|
|
@@ -1328,10 +1320,10 @@ var AssetKey = class _AssetKey extends BasicAssetKey {
|
|
|
1328
1320
|
}
|
|
1329
1321
|
};
|
|
1330
1322
|
function isBasicAssetKey(obj) {
|
|
1331
|
-
return
|
|
1323
|
+
return "namespace" in obj && "path" in obj;
|
|
1332
1324
|
}
|
|
1333
1325
|
function isAssetKey(obj) {
|
|
1334
|
-
return isBasicAssetKey(obj) &&
|
|
1326
|
+
return isBasicAssetKey(obj) && "parse" in obj;
|
|
1335
1327
|
}
|
|
1336
1328
|
|
|
1337
1329
|
// src/model/ModelMerger.ts
|
|
@@ -1340,10 +1332,10 @@ var ModelMerger = class {
|
|
|
1340
1332
|
const models = await this.collectAllParents(model);
|
|
1341
1333
|
let merged = {};
|
|
1342
1334
|
for (let parentModel of models) {
|
|
1343
|
-
merged = import_ts_deepmerge.default
|
|
1335
|
+
merged = (0, import_ts_deepmerge.default)(merged, parentModel);
|
|
1344
1336
|
}
|
|
1345
|
-
merged = import_ts_deepmerge.default
|
|
1346
|
-
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}`);
|
|
1347
1339
|
merged.hierarchy.push(`${merged.parent}`);
|
|
1348
1340
|
return merged;
|
|
1349
1341
|
}
|
|
@@ -1353,7 +1345,6 @@ var ModelMerger = class {
|
|
|
1353
1345
|
}
|
|
1354
1346
|
const models = [];
|
|
1355
1347
|
const parentKey = AssetKey.parse("models", model.parent);
|
|
1356
|
-
parentKey.root = model.key?.root;
|
|
1357
1348
|
const parentModel = await Models.getRaw(parentKey);
|
|
1358
1349
|
if (parentModel) {
|
|
1359
1350
|
models.unshift(parentModel);
|
|
@@ -1363,6 +1354,9 @@ var ModelMerger = class {
|
|
|
1363
1354
|
}
|
|
1364
1355
|
};
|
|
1365
1356
|
|
|
1357
|
+
// src/assets/Models.ts
|
|
1358
|
+
var import_typescript_memoize = require("typescript-memoize");
|
|
1359
|
+
|
|
1366
1360
|
// src/assets/source/parser/AssetParsers.ts
|
|
1367
1361
|
var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
1368
1362
|
AssetParser2["MODEL"] = "model";
|
|
@@ -1376,65 +1370,30 @@ var AssetParser = /* @__PURE__ */ ((AssetParser2) => {
|
|
|
1376
1370
|
})(AssetParser || {});
|
|
1377
1371
|
|
|
1378
1372
|
// src/assets/Models.ts
|
|
1379
|
-
var
|
|
1373
|
+
var _Models = class _Models {
|
|
1380
1374
|
// opened lazily: touching the store at import time would hit IndexedDB/disk just for loading
|
|
1381
1375
|
// the library, and would require an EnvProvider before any entry has had a chance to register
|
|
1382
1376
|
static get PERSISTENT_CACHE() {
|
|
1383
1377
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-models"));
|
|
1384
1378
|
}
|
|
1385
1379
|
static async getItemList() {
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
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 ?? []);
|
|
1391
1389
|
}
|
|
1392
1390
|
static async loadAndMerge(key) {
|
|
1393
|
-
const model =
|
|
1391
|
+
const model = await this.getRaw(key);
|
|
1394
1392
|
if (!model) {
|
|
1395
1393
|
return void 0;
|
|
1396
1394
|
}
|
|
1397
1395
|
return ModelMerger.mergeWithParents(model);
|
|
1398
1396
|
}
|
|
1399
|
-
static async getItemModel(key) {
|
|
1400
|
-
const itemKey = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
1401
|
-
const model = await this.PERSISTENT_CACHE.getOrLoad(itemKey.serialize(), async () => {
|
|
1402
|
-
const result = await AssetLoader.getFirst([itemKey, key], "json" /* JSON */);
|
|
1403
|
-
if (!result) return void 0;
|
|
1404
|
-
if (result.key.assetType !== "items") return { ...result.asset, key };
|
|
1405
|
-
const reference = this.defaultItemModel(result.asset.model, key);
|
|
1406
|
-
const modelKey = AssetKey.parse("models", reference);
|
|
1407
|
-
modelKey.root = key.root;
|
|
1408
|
-
const model2 = await this.getRaw(modelKey);
|
|
1409
|
-
if (!model2) throw new Error(`Item ${key.toNamespacedString()} references missing model ${reference}`);
|
|
1410
|
-
return model2;
|
|
1411
|
-
});
|
|
1412
|
-
return model ? { ...model, key: Object.assign(new AssetKey("", ""), model.key) } : void 0;
|
|
1413
|
-
}
|
|
1414
|
-
// Item previews use the GUI context, false conditions, and zero numeric properties.
|
|
1415
|
-
static defaultItemModel(node, key) {
|
|
1416
|
-
if (!node || typeof node.type !== "string") {
|
|
1417
|
-
throw new Error(`Unsupported item model definition for ${key.toNamespacedString()}`);
|
|
1418
|
-
}
|
|
1419
|
-
switch (node.type.replace(/^minecraft:/, "")) {
|
|
1420
|
-
case "model":
|
|
1421
|
-
if (typeof node.model === "string" && node.model) return node.model;
|
|
1422
|
-
break;
|
|
1423
|
-
case "condition":
|
|
1424
|
-
return this.defaultItemModel(node.on_false, key);
|
|
1425
|
-
case "select": {
|
|
1426
|
-
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;
|
|
1427
|
-
return this.defaultItemModel(selected ?? node.fallback, key);
|
|
1428
|
-
}
|
|
1429
|
-
case "range_dispatch": {
|
|
1430
|
-
const selected = node.entries?.reduce((match, entry) => {
|
|
1431
|
-
return entry.threshold <= 0 && (!match || entry.threshold >= match.threshold) ? entry : match;
|
|
1432
|
-
}, void 0);
|
|
1433
|
-
return this.defaultItemModel(selected?.model ?? node.fallback, key);
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
throw new Error(`Unsupported item model ${node?.type ?? "definition"} for ${key.toNamespacedString()}`);
|
|
1437
|
-
}
|
|
1438
1397
|
static async getRaw(key) {
|
|
1439
1398
|
if (!key.assetType) {
|
|
1440
1399
|
key.assetType = "models";
|
|
@@ -1473,15 +1432,19 @@ var Models = class _Models {
|
|
|
1473
1432
|
return this.PERSISTENT_CACHE.clear();
|
|
1474
1433
|
}
|
|
1475
1434
|
};
|
|
1435
|
+
__decorateClass([
|
|
1436
|
+
(0, import_typescript_memoize.Memoize)()
|
|
1437
|
+
], _Models, "getItemList", 1);
|
|
1438
|
+
var Models = _Models;
|
|
1476
1439
|
|
|
1477
1440
|
// src/assets/BlockStates.ts
|
|
1441
|
+
var import_typescript_memoize2 = require("typescript-memoize");
|
|
1478
1442
|
var BlockStates = class {
|
|
1479
1443
|
static get PERSISTENT_CACHE() {
|
|
1480
1444
|
return this._persistentCache ?? (this._persistentCache = PersistentCache.open("minerender-blockstates"));
|
|
1481
1445
|
}
|
|
1482
|
-
// BlockState names are hardcoded
|
|
1483
1446
|
static async getList() {
|
|
1484
|
-
|
|
1447
|
+
return AssetLoader.get(new AssetKey(
|
|
1485
1448
|
DEFAULT_NAMESPACE,
|
|
1486
1449
|
"_list",
|
|
1487
1450
|
"blockstates",
|
|
@@ -1489,16 +1452,11 @@ var BlockStates = class {
|
|
|
1489
1452
|
"assets",
|
|
1490
1453
|
".json",
|
|
1491
1454
|
DEFAULT_ROOT
|
|
1492
|
-
);
|
|
1493
|
-
return Caching.listAssetCache.get(key.serialize(), () => {
|
|
1494
|
-
return AssetLoader.get(key, "list" /* LIST */);
|
|
1495
|
-
}).then((r) => r?.files ?? []);
|
|
1455
|
+
), "list" /* LIST */).then((r) => r?.files ?? []);
|
|
1496
1456
|
}
|
|
1497
1457
|
static async getDefaultStates() {
|
|
1498
1458
|
const key = AssetKey.parse("blockstates", "minerender:defaultBlockStates");
|
|
1499
|
-
return
|
|
1500
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
1501
|
-
});
|
|
1459
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
1502
1460
|
}
|
|
1503
1461
|
static async getDefaultState(key) {
|
|
1504
1462
|
const defaultStates = await this.getDefaultStates();
|
|
@@ -1537,11 +1495,17 @@ var BlockStates = class {
|
|
|
1537
1495
|
await this.PERSISTENT_CACHE.clear();
|
|
1538
1496
|
}
|
|
1539
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);
|
|
1540
1504
|
var DefaultBlockStates = class {
|
|
1541
1505
|
};
|
|
1542
1506
|
|
|
1543
1507
|
// src/assets/Assets.ts
|
|
1544
|
-
var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.
|
|
1508
|
+
var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.17.1";
|
|
1545
1509
|
var DEFAULT_NAMESPACE = "minecraft";
|
|
1546
1510
|
var Assets = class {
|
|
1547
1511
|
/**
|
|
@@ -1563,150 +1527,13 @@ var AssetSource = class {
|
|
|
1563
1527
|
constructor() {
|
|
1564
1528
|
}
|
|
1565
1529
|
};
|
|
1566
|
-
var AssetLoadError = class extends Error {
|
|
1567
|
-
constructor(source, key, path, cause) {
|
|
1568
|
-
super(`Failed to load ${key.toNamespacedString()} from ${path}${cause instanceof Error ? `: ${cause.message}` : ""}`);
|
|
1569
|
-
this.source = source;
|
|
1570
|
-
this.key = key;
|
|
1571
|
-
this.path = path;
|
|
1572
|
-
this.cause = cause;
|
|
1573
|
-
this.name = "AssetLoadError";
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
1530
|
|
|
1577
|
-
// src/
|
|
1578
|
-
var
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
this.task = setInterval(() => this.run());
|
|
1584
|
-
}
|
|
1585
|
-
submit(task) {
|
|
1586
|
-
this.queue.push(task);
|
|
1587
|
-
}
|
|
1588
|
-
run() {
|
|
1589
|
-
for (let i = 0; i < this.batch; i++) {
|
|
1590
|
-
this.runNext();
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
runNext() {
|
|
1594
|
-
let next = this.queue.shift();
|
|
1595
|
-
if (next) next();
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
|
|
1599
|
-
// src/util/model.ts
|
|
1600
|
-
var import_three7 = require("three");
|
|
1601
|
-
function applyElementRotation(rotation, geometry) {
|
|
1602
|
-
const origin = new import_three7.Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);
|
|
1603
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1604
|
-
switch (rotation.axis) {
|
|
1605
|
-
case "x" /* X */:
|
|
1606
|
-
geometry.rotateX(toRadians(rotation.angle));
|
|
1607
|
-
break;
|
|
1608
|
-
case "y" /* Y */:
|
|
1609
|
-
geometry.rotateY(toRadians(rotation.angle));
|
|
1610
|
-
break;
|
|
1611
|
-
case "z" /* Z */:
|
|
1612
|
-
geometry.rotateZ(toRadians(rotation.angle));
|
|
1613
|
-
break;
|
|
1614
|
-
}
|
|
1615
|
-
if (rotation.rescale) {
|
|
1616
|
-
if (Math.abs(rotation.angle) === 22.5) {
|
|
1617
|
-
const s = 1 / Math.cos(0.39269909262657166);
|
|
1618
|
-
geometry.scale(s, 1, s);
|
|
1619
|
-
} else {
|
|
1620
|
-
const s = 1 / Math.cos(0.7853981852531433);
|
|
1621
|
-
geometry.scale(s, 1, s);
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
1625
|
-
}
|
|
1626
|
-
function applyModelPartRotation(modelPart, geometry) {
|
|
1627
|
-
const origin = new import_three7.Vector3(modelPart.pivotX, modelPart.pivotY, modelPart.pivotZ);
|
|
1628
|
-
geometry.translate(-origin.x, -origin.y, -origin.z);
|
|
1629
|
-
geometry.rotateX(toRadians(modelPart.pitch));
|
|
1630
|
-
geometry.rotateY(toRadians(modelPart.yaw));
|
|
1631
|
-
geometry.rotateZ(toRadians(modelPart.roll));
|
|
1632
|
-
geometry.translate(origin.x, origin.y, origin.z);
|
|
1633
|
-
}
|
|
1634
|
-
function applyGenericRotation(axis, rotation, obj) {
|
|
1635
|
-
switch (axis) {
|
|
1636
|
-
case "x" /* X */:
|
|
1637
|
-
obj.rotateOnAxis(new import_three7.Vector3(1, 0, 0), toRadians(rotation));
|
|
1638
|
-
break;
|
|
1639
|
-
case "y" /* Y */:
|
|
1640
|
-
obj.rotateOnAxis(new import_three7.Vector3(0, 1, 0), toRadians(rotation));
|
|
1641
|
-
break;
|
|
1642
|
-
case "z" /* Z */:
|
|
1643
|
-
obj.rotateOnAxis(new import_three7.Vector3(0, 0, 1), toRadians(rotation));
|
|
1644
|
-
break;
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
function addBox3WireframeToObject(box, obj, color = 16777215, w = 2) {
|
|
1648
|
-
let size = new import_three7.Vector3();
|
|
1649
|
-
box.getSize(size);
|
|
1650
|
-
let boxGeo = new import_three7.BoxGeometry(size.x, size.y, size.z, 1, 1, 1);
|
|
1651
|
-
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1652
|
-
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1653
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1654
|
-
obj.add(wireframe);
|
|
1655
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1656
|
-
obj.add(axes);
|
|
1657
|
-
}
|
|
1658
|
-
function addWireframeToObject(obj, color = 16777215, w = 2) {
|
|
1659
|
-
let boxGeo = new import_three7.BoxGeometry(16, 16, 16, 1, 1, 1);
|
|
1660
|
-
let wireGeo = new import_three7.EdgesGeometry(boxGeo);
|
|
1661
|
-
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1662
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1663
|
-
obj.add(wireframe);
|
|
1664
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1665
|
-
obj.add(axes);
|
|
1666
|
-
}
|
|
1667
|
-
function addWireframeToMesh(geo, mesh, color = 16777215, w = 2) {
|
|
1668
|
-
let wireGeo = new import_three7.EdgesGeometry(geo);
|
|
1669
|
-
let wireMat = new import_three7.LineBasicMaterial({ color, linewidth: w });
|
|
1670
|
-
let wireframe = new import_three7.LineSegments(wireGeo, wireMat);
|
|
1671
|
-
mesh.add(wireframe);
|
|
1672
|
-
let axes = new import_three7.AxesHelper(1);
|
|
1673
|
-
mesh.add(axes);
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
// src/util/performance.ts
|
|
1677
|
-
function captureException(e, ...extra) {
|
|
1678
|
-
console.error(e, extra);
|
|
1679
|
-
}
|
|
1680
|
-
function timingStart(marker) {
|
|
1681
|
-
console.time(marker);
|
|
1682
|
-
}
|
|
1683
|
-
function timingEnd(marker) {
|
|
1684
|
-
console.timeEnd(marker);
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
// src/util/three.ts
|
|
1688
|
-
function isObject3D(obj) {
|
|
1689
|
-
return obj.isObject3D;
|
|
1690
|
-
}
|
|
1691
|
-
function isMesh(obj) {
|
|
1692
|
-
return obj.isMesh;
|
|
1693
|
-
}
|
|
1694
|
-
function isInstancedMesh(obj) {
|
|
1695
|
-
return obj.isInstancedMesh;
|
|
1696
|
-
}
|
|
1697
|
-
function isPerspectiveCamera(obj) {
|
|
1698
|
-
return obj.isPerspectiveCamera;
|
|
1699
|
-
}
|
|
1700
|
-
function isOrthographicCamera(obj) {
|
|
1701
|
-
return obj.isOrthographicCamera;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// src/nbt/NBTHelper.ts
|
|
1705
|
-
var NBTHelper = class {
|
|
1706
|
-
static async fromBuffer(buffer) {
|
|
1707
|
-
const prismarineNbt = await import("prismarine-nbt");
|
|
1708
|
-
const { parsed, type, metadata } = await prismarineNbt.parse(buffer);
|
|
1709
|
-
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;
|
|
1710
1537
|
}
|
|
1711
1538
|
};
|
|
1712
1539
|
|
|
@@ -1751,25 +1578,31 @@ var _HostedAssetSource = class _HostedAssetSource extends AssetSource {
|
|
|
1751
1578
|
console.info(p3, "Loading", key);
|
|
1752
1579
|
const url = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1753
1580
|
console.debug(p3, url);
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
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;
|
|
1763
1592
|
}
|
|
1764
|
-
throw cause;
|
|
1765
1593
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
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
|
+
}
|
|
1768
1602
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1603
|
+
console.debug(p3, "Failed to load", key, err?.message);
|
|
1604
|
+
return void 0;
|
|
1605
|
+
});
|
|
1773
1606
|
}
|
|
1774
1607
|
assetBasePath(key) {
|
|
1775
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 + "/" : ""}`;
|
|
@@ -1876,6 +1709,7 @@ var BrowserArchiveProxy = class {
|
|
|
1876
1709
|
};
|
|
1877
1710
|
|
|
1878
1711
|
// src/assets/source/archive/ArchiveAssetSource.ts
|
|
1712
|
+
var p4 = prefix("ArchiveAssetSource");
|
|
1879
1713
|
var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
1880
1714
|
constructor(archiveProxy) {
|
|
1881
1715
|
super();
|
|
@@ -1894,31 +1728,74 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1894
1728
|
}
|
|
1895
1729
|
async get(key, parser) {
|
|
1896
1730
|
const responseParser = HostedAssetSource.PARSER_MAP.get(parser);
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
async load(key, parser) {
|
|
1731
|
+
console.log("ArchiveAssetSource.get", key, parser);
|
|
1732
|
+
let entries = await this.getEntries();
|
|
1900
1733
|
const path = `${this.assetBasePath(key)}${key.type !== void 0 ? key.type + "/" : ""}${key.path}${key.extension}`;
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
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
|
+
}
|
|
1906
1764
|
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
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
|
+
}
|
|
1913
1786
|
}
|
|
1914
|
-
return
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
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
|
+
}
|
|
1920
1795
|
}
|
|
1921
|
-
|
|
1796
|
+
console.debug(p4, "Failed to load", key, err?.message);
|
|
1797
|
+
return void 0;
|
|
1798
|
+
});
|
|
1922
1799
|
}
|
|
1923
1800
|
assetBasePath(key) {
|
|
1924
1801
|
return `${key.rootType !== void 0 ? key.rootType + "/" : ""}${key.namespace !== void 0 ? key.namespace + "/" : ""}${key.assetType !== void 0 ? key.assetType + "/" : ""}`;
|
|
@@ -1926,17 +1803,18 @@ var ArchiveAssetSource = class _ArchiveAssetSource extends AssetSource {
|
|
|
1926
1803
|
};
|
|
1927
1804
|
|
|
1928
1805
|
// src/assets/AssetLoader.ts
|
|
1929
|
-
var
|
|
1806
|
+
var import_ts_deepmerge3 = __toESM(require_dist());
|
|
1807
|
+
var p5 = prefix("AssetLoader");
|
|
1930
1808
|
var _AssetLoader = class _AssetLoader {
|
|
1931
1809
|
static addSource(key, source, override = true) {
|
|
1932
1810
|
if (override) {
|
|
1933
1811
|
const existing = this.removeSource(key);
|
|
1934
1812
|
if (existing) {
|
|
1935
|
-
console.log(
|
|
1813
|
+
console.log(p5, "Removed existing AssetSource", key);
|
|
1936
1814
|
}
|
|
1937
1815
|
}
|
|
1938
1816
|
this._SOURCES.unshift({ key, source });
|
|
1939
|
-
console.log(
|
|
1817
|
+
console.log(p5, "Added AssetSource", key);
|
|
1940
1818
|
}
|
|
1941
1819
|
static removeSource(key) {
|
|
1942
1820
|
const index = this._SOURCES.findIndex((s) => s.key === key);
|
|
@@ -1949,6 +1827,7 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1949
1827
|
return void 0;
|
|
1950
1828
|
}
|
|
1951
1829
|
static async getAll(key, parser) {
|
|
1830
|
+
console.log(this._SOURCES);
|
|
1952
1831
|
let promises = [];
|
|
1953
1832
|
for (const source of this._SOURCES) {
|
|
1954
1833
|
promises.push(source.source.get(key, parser));
|
|
@@ -1957,34 +1836,24 @@ var _AssetLoader = class _AssetLoader {
|
|
|
1957
1836
|
return results.filter((r) => r != void 0);
|
|
1958
1837
|
});
|
|
1959
1838
|
}
|
|
1960
|
-
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
1961
1839
|
static async get(key, parser) {
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
}
|
|
1976
|
-
/** Tries each path within a source before considering lower-priority sources. */
|
|
1977
|
-
static async getFirst(keys, parser) {
|
|
1978
|
-
const sources = [...this._SOURCES];
|
|
1979
|
-
for (const source of sources) {
|
|
1980
|
-
for (const key of keys) {
|
|
1981
|
-
const result = await source.source.get(key, parser);
|
|
1982
|
-
if (result !== void 0) {
|
|
1983
|
-
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;
|
|
1984
1853
|
}
|
|
1985
1854
|
}
|
|
1986
|
-
|
|
1987
|
-
|
|
1855
|
+
return void 0;
|
|
1856
|
+
});
|
|
1988
1857
|
}
|
|
1989
1858
|
};
|
|
1990
1859
|
_AssetLoader.ROOT = DEFAULT_ROOT;
|
|
@@ -1999,21 +1868,11 @@ var ModelTextures = class {
|
|
|
1999
1868
|
return this._persistentMetaCache ?? (this._persistentMetaCache = PersistentCache.open("minerender-texturemeta"));
|
|
2000
1869
|
}
|
|
2001
1870
|
static async get(key) {
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
try {
|
|
2006
|
-
const asset = await pending;
|
|
2007
|
-
if (asset) {
|
|
2008
|
-
return await ImageLoader.infoToCanvasData(asset);
|
|
2009
|
-
}
|
|
2010
|
-
return void 0;
|
|
2011
|
-
} catch (err) {
|
|
2012
|
-
if (cached && Caching.textureAssetCache.getIfPresent(keyStr) === cached) {
|
|
2013
|
-
Caching.textureAssetCache.invalidate(keyStr);
|
|
2014
|
-
}
|
|
2015
|
-
throw err;
|
|
1871
|
+
const asset = await this.preload(key);
|
|
1872
|
+
if (asset) {
|
|
1873
|
+
return ImageLoader.infoToCanvasData(asset);
|
|
2016
1874
|
}
|
|
1875
|
+
return void 0;
|
|
2017
1876
|
}
|
|
2018
1877
|
static async preload(key) {
|
|
2019
1878
|
const keyStr = key.serialize();
|
|
@@ -2204,7 +2063,7 @@ var ModelGenerator = class {
|
|
|
2204
2063
|
ModelGenerator.ITEM_LAYERS = ["layer0", "layer1", "layer2", "layer3", "layer4"];
|
|
2205
2064
|
|
|
2206
2065
|
// src/UVMapper.ts
|
|
2207
|
-
var
|
|
2066
|
+
var p6 = prefix("UVMapper");
|
|
2208
2067
|
var DEFAULT_UV = [0, 0, 16, 16];
|
|
2209
2068
|
var X = 0;
|
|
2210
2069
|
var Y = 1;
|
|
@@ -2381,7 +2240,7 @@ var UVMapper = class {
|
|
|
2381
2240
|
const metaMap = {};
|
|
2382
2241
|
const model = { ...originalModel };
|
|
2383
2242
|
const isItemModel = !("elements" in model);
|
|
2384
|
-
console.debug(
|
|
2243
|
+
console.debug(p6, "Creating Atlas for", model.key);
|
|
2385
2244
|
if (model.textures) {
|
|
2386
2245
|
const promises = [];
|
|
2387
2246
|
const uniqueTextureNames = [];
|
|
@@ -2395,7 +2254,7 @@ var UVMapper = class {
|
|
|
2395
2254
|
const assetKey = AssetKey.parse("textures", textureValue, model.key);
|
|
2396
2255
|
promises.push(ModelTextures.get(assetKey).then((asset) => {
|
|
2397
2256
|
if (!asset) {
|
|
2398
|
-
console.warn(
|
|
2257
|
+
console.warn(p6, "Missing texture", assetKey);
|
|
2399
2258
|
return;
|
|
2400
2259
|
}
|
|
2401
2260
|
textureMap[textureKey] = new WrappedImage(asset);
|
|
@@ -2407,7 +2266,7 @@ var UVMapper = class {
|
|
|
2407
2266
|
}
|
|
2408
2267
|
await Promise.all(promises);
|
|
2409
2268
|
const textureCount = uniqueTextureNames.length;
|
|
2410
|
-
console.debug(
|
|
2269
|
+
console.debug(p6, "Creating Atlas for", textureCount, "textures");
|
|
2411
2270
|
this.fillMissingTextureKeys(model.textures, textureMap);
|
|
2412
2271
|
this.fillMissingTextureKeys(model.textures, metaMap);
|
|
2413
2272
|
const sizes = {};
|
|
@@ -2427,7 +2286,7 @@ var UVMapper = class {
|
|
|
2427
2286
|
this.fillMissingTextureKeys(model.textures, sizes);
|
|
2428
2287
|
const s = Math.ceil(Math.sqrt(textureCount + 1));
|
|
2429
2288
|
const size = Math.ceil(s * maxWidth);
|
|
2430
|
-
console.debug(
|
|
2289
|
+
console.debug(p6, "Atlas size:", size);
|
|
2431
2290
|
const squaredSize = size * size;
|
|
2432
2291
|
const missing = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABlBMVEX/AP8AAACfphTyAAAAFUlEQVQoz2MIhQKGVVAwKjIqQrwIAHRz/wFI17TEAAAAAElFTkSuQmCC");
|
|
2433
2292
|
const empty = await ImageLoader.getData("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAA5JREFUKM9jGAWjgAIAAAJAAAFSSwuTAAAAAElFTkSuQmCC");
|
|
@@ -2482,10 +2341,10 @@ var UVMapper = class {
|
|
|
2482
2341
|
}
|
|
2483
2342
|
}
|
|
2484
2343
|
const atlasImageData = image.toDataURL();
|
|
2485
|
-
console.log(
|
|
2344
|
+
console.log(p6, "Atlas Image for", model.key, atlasImageData);
|
|
2486
2345
|
this.fillMissingTextureKeys(model.textures, positions);
|
|
2487
2346
|
if (isItemModel) {
|
|
2488
|
-
console.debug(
|
|
2347
|
+
console.debug(p6, "Generating item model for", model);
|
|
2489
2348
|
model.elements = [];
|
|
2490
2349
|
for (let layerName of ModelGenerator.ITEM_LAYERS) {
|
|
2491
2350
|
const textureImage = textureMap[layerName];
|
|
@@ -2493,7 +2352,7 @@ var UVMapper = class {
|
|
|
2493
2352
|
model.elements.push(...ModelGenerator.generateItemModel(textureImage.data, layerName));
|
|
2494
2353
|
}
|
|
2495
2354
|
}
|
|
2496
|
-
console.debug(
|
|
2355
|
+
console.debug(p6, "Item model elements", model.elements);
|
|
2497
2356
|
}
|
|
2498
2357
|
if (!model.elements) {
|
|
2499
2358
|
}
|
|
@@ -2511,13 +2370,17 @@ var UVMapper = class {
|
|
|
2511
2370
|
this.setCubeFaceUvInArray(uv, faceIndex * 4, [0, 1, 8 / size, (size - 8) / size]);
|
|
2512
2371
|
continue;
|
|
2513
2372
|
}
|
|
2514
|
-
if (!face.texture) continue;
|
|
2515
2373
|
if (!face.uv) {
|
|
2516
2374
|
face.uv = this.getFallbackUv(element, faceName);
|
|
2517
2375
|
}
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
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
|
+
}
|
|
2521
2384
|
let texPosV = new import_three8.Vector2(texPosition[0], texPosition[1]);
|
|
2522
2385
|
const [tl, tr, bl, br] = this.expandAndRotateMcUvs(face.uv, face.rotation, texSize[0], texSize[1]);
|
|
2523
2386
|
tl.add(texPosV);
|
|
@@ -2549,7 +2412,7 @@ var UVMapper = class {
|
|
|
2549
2412
|
hasTransparency
|
|
2550
2413
|
);
|
|
2551
2414
|
} else {
|
|
2552
|
-
console.warn(
|
|
2415
|
+
console.warn(p6, "Model does not have any textures", model);
|
|
2553
2416
|
}
|
|
2554
2417
|
return void 0;
|
|
2555
2418
|
}
|
|
@@ -2687,20 +2550,17 @@ function shutdown() {
|
|
|
2687
2550
|
}
|
|
2688
2551
|
|
|
2689
2552
|
// src/assets/Entities.ts
|
|
2553
|
+
var import_typescript_memoize3 = require("typescript-memoize");
|
|
2690
2554
|
var Entities = class {
|
|
2691
2555
|
static async getBlockEntityModels() {
|
|
2692
2556
|
const key = AssetKey.parse("models", "minerender:blockEntityModels");
|
|
2693
2557
|
console.log(key);
|
|
2694
|
-
return
|
|
2695
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
2696
|
-
});
|
|
2558
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2697
2559
|
}
|
|
2698
2560
|
static async getEntityModels() {
|
|
2699
2561
|
const key = AssetKey.parse("models", "minerender:entityModels");
|
|
2700
2562
|
console.log(key);
|
|
2701
|
-
return
|
|
2702
|
-
return AssetLoader.get(key, "json" /* JSON */);
|
|
2703
|
-
});
|
|
2563
|
+
return AssetLoader.get(key, "json" /* JSON */);
|
|
2704
2564
|
}
|
|
2705
2565
|
// BlockEntity names are hardcoded
|
|
2706
2566
|
static async getBlockList() {
|
|
@@ -2746,6 +2606,12 @@ var Entities = class {
|
|
|
2746
2606
|
};
|
|
2747
2607
|
}
|
|
2748
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);
|
|
2749
2615
|
var EntityModels = class {
|
|
2750
2616
|
};
|
|
2751
2617
|
var BlockEntityModels = class {
|
|
@@ -2809,8 +2675,8 @@ var MineRenderError = class _MineRenderError extends Error {
|
|
|
2809
2675
|
};
|
|
2810
2676
|
|
|
2811
2677
|
// src/renderer/SceneObject.ts
|
|
2812
|
-
var
|
|
2813
|
-
var
|
|
2678
|
+
var import_ts_deepmerge4 = __toESM(require_dist());
|
|
2679
|
+
var p7 = prefix("SceneObject");
|
|
2814
2680
|
var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
2815
2681
|
constructor(options) {
|
|
2816
2682
|
super();
|
|
@@ -2818,7 +2684,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2818
2684
|
this.materialCallbacks = {};
|
|
2819
2685
|
this._isInstanced = false;
|
|
2820
2686
|
this._instanceCounter = 0;
|
|
2821
|
-
this.options = (0,
|
|
2687
|
+
this.options = (0, import_ts_deepmerge4.default)({}, _SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
2822
2688
|
console.log("SceneObject options", this.options);
|
|
2823
2689
|
}
|
|
2824
2690
|
set scene(scene) {
|
|
@@ -2989,9 +2855,9 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
2989
2855
|
if (!this.isInstanced) throw new MineRenderError("Object is not instanced");
|
|
2990
2856
|
const i = this._instanceCounter++;
|
|
2991
2857
|
this.setMatrixAt(i, new import_three9.Matrix4());
|
|
2992
|
-
console.debug(
|
|
2858
|
+
console.debug(p7, "nextInstance " + i);
|
|
2993
2859
|
if (i === this.options.maxInstanceCount) {
|
|
2994
|
-
console.warn(
|
|
2860
|
+
console.warn(p7, "Max instance count reached for " + this);
|
|
2995
2861
|
}
|
|
2996
2862
|
if (this.scene) {
|
|
2997
2863
|
this.scene.stats.instanceCount++;
|
|
@@ -3167,7 +3033,7 @@ var _SceneObject = class _SceneObject extends import_three9.Object3D {
|
|
|
3167
3033
|
}
|
|
3168
3034
|
//</editor-fold>
|
|
3169
3035
|
};
|
|
3170
|
-
_SceneObject.DEFAULT_OPTIONS = (0,
|
|
3036
|
+
_SceneObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge4.default)({}, {
|
|
3171
3037
|
instanceMeshes: true,
|
|
3172
3038
|
maxInstanceCount: 50,
|
|
3173
3039
|
mergeMeshes: true,
|
|
@@ -3179,16 +3045,16 @@ function isSceneObject(obj) {
|
|
|
3179
3045
|
}
|
|
3180
3046
|
|
|
3181
3047
|
// src/entity/scene/EntityObject.ts
|
|
3182
|
-
var
|
|
3048
|
+
var import_ts_deepmerge5 = __toESM(require_dist());
|
|
3183
3049
|
var import_three11 = require("three");
|
|
3184
|
-
var
|
|
3050
|
+
var THREE2 = __toESM(require("three"));
|
|
3185
3051
|
var EntityObject = class extends SceneObject {
|
|
3186
3052
|
constructor(entity, options) {
|
|
3187
3053
|
super();
|
|
3188
3054
|
this.entity = entity;
|
|
3189
3055
|
this.isEntityObject = true;
|
|
3190
3056
|
this.meshesCreated = false;
|
|
3191
|
-
this.options = (0,
|
|
3057
|
+
this.options = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
3192
3058
|
}
|
|
3193
3059
|
async init() {
|
|
3194
3060
|
this.createMeshes();
|
|
@@ -3197,8 +3063,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3197
3063
|
dispose() {
|
|
3198
3064
|
super.dispose();
|
|
3199
3065
|
}
|
|
3200
|
-
|
|
3201
|
-
|
|
3066
|
+
async loadTextures() {
|
|
3067
|
+
this.imageData = await ModelTextures.get(new AssetKey(
|
|
3202
3068
|
this.entity.key?.namespace ?? DEFAULT_NAMESPACE,
|
|
3203
3069
|
this.entity.key.path,
|
|
3204
3070
|
//TODO: texture may differ from entity name; most of them are in subdirectories for multiple variants etc.
|
|
@@ -3206,10 +3072,7 @@ var EntityObject = class extends SceneObject {
|
|
|
3206
3072
|
"entity",
|
|
3207
3073
|
"assets",
|
|
3208
3074
|
".png"
|
|
3209
|
-
);
|
|
3210
|
-
}
|
|
3211
|
-
async loadTextures() {
|
|
3212
|
-
this.imageData = await ModelTextures.get(this.textureKey);
|
|
3075
|
+
));
|
|
3213
3076
|
}
|
|
3214
3077
|
//TODO: abstract this, since extracted model data can be used for entities, blocks, players
|
|
3215
3078
|
createMeshes(force = false) {
|
|
@@ -3228,8 +3091,8 @@ var EntityObject = class extends SceneObject {
|
|
|
3228
3091
|
const l = cube.maxZ - cube.minZ;
|
|
3229
3092
|
const uv = texture.toUvArray(w, h, l);
|
|
3230
3093
|
const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
|
|
3231
|
-
cubeGeo.applyMatrix4(new
|
|
3232
|
-
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));
|
|
3233
3096
|
applyModelPartRotation(part, cubeGeo);
|
|
3234
3097
|
const mesh = this.createMesh(partName, cubeGeo, mat);
|
|
3235
3098
|
partAnchor.add(mesh);
|
|
@@ -3242,26 +3105,23 @@ var EntityObject = class extends SceneObject {
|
|
|
3242
3105
|
this.meshesCreated = true;
|
|
3243
3106
|
}
|
|
3244
3107
|
async applyTextures() {
|
|
3245
|
-
const
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
mesh.material = mat;
|
|
3260
|
-
});
|
|
3261
|
-
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
|
+
}
|
|
3262
3122
|
}
|
|
3263
3123
|
};
|
|
3264
|
-
EntityObject.DEFAULT_OPTIONS = (0,
|
|
3124
|
+
EntityObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge5.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
3265
3125
|
function isEntityObject(obj) {
|
|
3266
3126
|
return obj.isEntityObject;
|
|
3267
3127
|
}
|
|
@@ -3273,7 +3133,7 @@ var GuiObject = class extends SceneObject {
|
|
|
3273
3133
|
|
|
3274
3134
|
// src/inspector/SceneInspector.ts
|
|
3275
3135
|
var import_three12 = require("three");
|
|
3276
|
-
var
|
|
3136
|
+
var p8 = prefix("SceneInspector");
|
|
3277
3137
|
var help = "<span>Ctrl+Click to Select<br/></span><br/>";
|
|
3278
3138
|
var SceneInspector = class {
|
|
3279
3139
|
constructor(renderer) {
|
|
@@ -3342,7 +3202,7 @@ var SceneInspector = class {
|
|
|
3342
3202
|
}
|
|
3343
3203
|
selectObject(targetObject, targetIntersection) {
|
|
3344
3204
|
this.selectedObject = targetObject;
|
|
3345
|
-
console.log(
|
|
3205
|
+
console.log(p8, "selected", targetObject);
|
|
3346
3206
|
this.redraw(targetObject, targetIntersection);
|
|
3347
3207
|
}
|
|
3348
3208
|
redraw(targetObject, targetIntersection) {
|
|
@@ -3640,7 +3500,7 @@ var SceneStatsDisplay = class {
|
|
|
3640
3500
|
};
|
|
3641
3501
|
|
|
3642
3502
|
// src/instance/InstanceManager.ts
|
|
3643
|
-
var
|
|
3503
|
+
var p9 = prefix("InstanceManager");
|
|
3644
3504
|
var InstanceManager = class {
|
|
3645
3505
|
constructor() {
|
|
3646
3506
|
this.isInstanceManager = true;
|
|
@@ -3648,7 +3508,7 @@ var InstanceManager = class {
|
|
|
3648
3508
|
}
|
|
3649
3509
|
async get(key) {
|
|
3650
3510
|
if (key in this.instanceCache) {
|
|
3651
|
-
console.debug(
|
|
3511
|
+
console.debug(p9, "key in cache", key);
|
|
3652
3512
|
return (await this.instanceCache[key]).nextInstance();
|
|
3653
3513
|
}
|
|
3654
3514
|
return void 0;
|
|
@@ -3657,17 +3517,13 @@ var InstanceManager = class {
|
|
|
3657
3517
|
if (key in this.instanceCache) {
|
|
3658
3518
|
return await this.get(key);
|
|
3659
3519
|
}
|
|
3660
|
-
console.debug(
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
}
|
|
3666
|
-
|
|
3667
|
-
delete this.instanceCache[key];
|
|
3668
|
-
}
|
|
3669
|
-
throw error;
|
|
3670
|
-
}
|
|
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];
|
|
3671
3527
|
}
|
|
3672
3528
|
reset() {
|
|
3673
3529
|
for (let instanceCacheKey in this.instanceCache) {
|
|
@@ -4256,15 +4112,15 @@ function computeMorphedAttributes(object) {
|
|
|
4256
4112
|
}
|
|
4257
4113
|
|
|
4258
4114
|
// src/model/scene/ModelObject.ts
|
|
4259
|
-
var
|
|
4260
|
-
var
|
|
4115
|
+
var import_ts_deepmerge6 = __toESM(require_dist());
|
|
4116
|
+
var p10 = prefix("ModelObject");
|
|
4261
4117
|
var _ModelObject = class _ModelObject extends SceneObject {
|
|
4262
4118
|
constructor(originalModel, options) {
|
|
4263
4119
|
super(options);
|
|
4264
4120
|
this.originalModel = originalModel;
|
|
4265
4121
|
this.isModelObject = true;
|
|
4266
4122
|
this.meshesCreated = false;
|
|
4267
|
-
this.options = (0,
|
|
4123
|
+
this.options = (0, import_ts_deepmerge6.default)({}, _ModelObject.DEFAULT_OPTIONS, options ?? {});
|
|
4268
4124
|
console.log("ModelObject options", this.options);
|
|
4269
4125
|
}
|
|
4270
4126
|
async init() {
|
|
@@ -4307,10 +4163,10 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4307
4163
|
}
|
|
4308
4164
|
});
|
|
4309
4165
|
} else {
|
|
4310
|
-
console.debug(
|
|
4166
|
+
console.debug(p10, this.atlas.model, "has no elements");
|
|
4311
4167
|
}
|
|
4312
4168
|
} else {
|
|
4313
|
-
console.debug(
|
|
4169
|
+
console.debug(p10, "Missing atlas for", this);
|
|
4314
4170
|
}
|
|
4315
4171
|
if (this.options.mergeMeshes) {
|
|
4316
4172
|
let combinedGeo;
|
|
@@ -4362,26 +4218,16 @@ var _ModelObject = class _ModelObject extends SceneObject {
|
|
|
4362
4218
|
}
|
|
4363
4219
|
}
|
|
4364
4220
|
};
|
|
4365
|
-
_ModelObject.DEFAULT_OPTIONS = (0,
|
|
4221
|
+
_ModelObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge6.default)({}, SceneObject.DEFAULT_OPTIONS, {});
|
|
4366
4222
|
var ModelObject = _ModelObject;
|
|
4367
4223
|
function isModelObject(obj) {
|
|
4368
4224
|
return obj.isModelObject;
|
|
4369
4225
|
}
|
|
4370
4226
|
|
|
4371
4227
|
// src/model/block/scene/BlockObject.ts
|
|
4372
|
-
var
|
|
4228
|
+
var import_ts_deepmerge7 = __toESM(require_dist());
|
|
4373
4229
|
var import_three16 = require("three");
|
|
4374
|
-
var
|
|
4375
|
-
function matchesCondition(condition, state) {
|
|
4376
|
-
return Object.entries(condition).every(([key, value]) => {
|
|
4377
|
-
if (Array.isArray(value)) {
|
|
4378
|
-
if (key === "OR") return value.some((child) => matchesCondition(child, state));
|
|
4379
|
-
if (key === "AND") return value.every((child) => matchesCondition(child, state));
|
|
4380
|
-
return false;
|
|
4381
|
-
}
|
|
4382
|
-
return typeof value === "string" && state[key] !== void 0 && value.split("|").includes(`${state[key]}`);
|
|
4383
|
-
});
|
|
4384
|
-
}
|
|
4230
|
+
var p11 = prefix("BlockObject");
|
|
4385
4231
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
4386
4232
|
constructor(blockState, options) {
|
|
4387
4233
|
super(options);
|
|
@@ -4395,11 +4241,11 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4395
4241
|
this._instanceModel = [];
|
|
4396
4242
|
this._variants = [];
|
|
4397
4243
|
this._models = [];
|
|
4398
|
-
this.options = (0,
|
|
4244
|
+
this.options = (0, import_ts_deepmerge7.default)({}, _BlockObject.DEFAULT_OPTIONS, options ?? {});
|
|
4399
4245
|
}
|
|
4400
4246
|
async init() {
|
|
4401
4247
|
if (this.options.applyDefaultState) {
|
|
4402
|
-
const defaultState = this.blockState.key ?
|
|
4248
|
+
const defaultState = this.blockState.key ? BlockStates.getDefaultState(this.blockState.key) : void 0;
|
|
4403
4249
|
if (defaultState && Object.keys(defaultState).length > 0) {
|
|
4404
4250
|
const state = {};
|
|
4405
4251
|
for (let k in defaultState) {
|
|
@@ -4410,9 +4256,15 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4410
4256
|
if (this.blockState.variants) {
|
|
4411
4257
|
await this.setState(Object.keys(this.blockState.variants)[0]);
|
|
4412
4258
|
} else if (this.blockState.multipart) {
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
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
|
+
}
|
|
4416
4268
|
}
|
|
4417
4269
|
}
|
|
4418
4270
|
} else {
|
|
@@ -4469,11 +4321,55 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4469
4321
|
} else if (this.blockState.multipart) {
|
|
4470
4322
|
for (let part of this.blockState.multipart) {
|
|
4471
4323
|
if (!part.apply) {
|
|
4472
|
-
console.debug(
|
|
4324
|
+
console.debug(p11, "Missing apply for blockState part", part);
|
|
4473
4325
|
continue;
|
|
4474
4326
|
}
|
|
4475
|
-
if (!part.when
|
|
4327
|
+
if (!part.when) {
|
|
4476
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
|
+
}
|
|
4477
4373
|
}
|
|
4478
4374
|
}
|
|
4479
4375
|
}
|
|
@@ -4503,21 +4399,11 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4503
4399
|
}
|
|
4504
4400
|
}
|
|
4505
4401
|
getSingleVariant(variants) {
|
|
4506
|
-
if (
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
throw new MineRenderError(`Invalid blockstate variant weight: ${weight}`);
|
|
4512
|
-
}
|
|
4513
|
-
return sum + weight;
|
|
4514
|
-
}, 0);
|
|
4515
|
-
let choice = Math.random() * total;
|
|
4516
|
-
for (const variant of variants) {
|
|
4517
|
-
choice -= variant.weight ?? 1;
|
|
4518
|
-
if (choice < 0) return variant;
|
|
4519
|
-
}
|
|
4520
|
-
return variants[variants.length - 1];
|
|
4402
|
+
if (Array.isArray(variants)) {
|
|
4403
|
+
return variants[0];
|
|
4404
|
+
} else {
|
|
4405
|
+
return variants;
|
|
4406
|
+
}
|
|
4521
4407
|
}
|
|
4522
4408
|
// @deprecated
|
|
4523
4409
|
async createAVariant(variants, instanceInfo) {
|
|
@@ -4543,6 +4429,9 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4543
4429
|
}
|
|
4544
4430
|
}
|
|
4545
4431
|
obj.setRotation(rotation);
|
|
4432
|
+
setTimeout(() => {
|
|
4433
|
+
obj.setRotation(rotation);
|
|
4434
|
+
}, 150);
|
|
4546
4435
|
console.log(obj);
|
|
4547
4436
|
return obj;
|
|
4548
4437
|
}
|
|
@@ -4633,16 +4522,15 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
4633
4522
|
}
|
|
4634
4523
|
}
|
|
4635
4524
|
setPosition(position) {
|
|
4636
|
-
|
|
4525
|
+
super.setPosition(position);
|
|
4637
4526
|
for (let model of this._models) {
|
|
4638
4527
|
model.setPosition(position);
|
|
4639
4528
|
}
|
|
4640
|
-
this.notifyDirty();
|
|
4641
4529
|
}
|
|
4642
4530
|
//TODO: should override rotation + scale methods
|
|
4643
4531
|
//TODO
|
|
4644
4532
|
};
|
|
4645
|
-
_BlockObject.DEFAULT_OPTIONS = (0,
|
|
4533
|
+
_BlockObject.DEFAULT_OPTIONS = (0, import_ts_deepmerge7.default)({}, ModelObject.DEFAULT_OPTIONS, {
|
|
4646
4534
|
applyDefaultState: true
|
|
4647
4535
|
});
|
|
4648
4536
|
var BlockObject = _BlockObject;
|
|
@@ -4692,7 +4580,7 @@ var StructureParser = class {
|
|
|
4692
4580
|
|
|
4693
4581
|
// src/renderer/MineRenderScene.ts
|
|
4694
4582
|
var import_three17 = require("three");
|
|
4695
|
-
var
|
|
4583
|
+
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
4696
4584
|
|
|
4697
4585
|
// src/skin/SkinPart.ts
|
|
4698
4586
|
var SkinPart = /* @__PURE__ */ ((SkinPart2) => {
|
|
@@ -5423,7 +5311,7 @@ var slimSkinGeometries = {
|
|
|
5423
5311
|
};
|
|
5424
5312
|
|
|
5425
5313
|
// src/skin/scene/SkinObject.ts
|
|
5426
|
-
var
|
|
5314
|
+
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
5427
5315
|
var SkinObject = class extends SceneObject {
|
|
5428
5316
|
constructor(options) {
|
|
5429
5317
|
super();
|
|
@@ -5431,7 +5319,7 @@ var SkinObject = class extends SceneObject {
|
|
|
5431
5319
|
this.legacy = false;
|
|
5432
5320
|
this.skinTextureWidth = 64;
|
|
5433
5321
|
this.skinTextureHeight = 64;
|
|
5434
|
-
this.options = (0,
|
|
5322
|
+
this.options = (0, import_ts_deepmerge8.default)({}, SceneObject.DEFAULT_OPTIONS, options ?? {});
|
|
5435
5323
|
}
|
|
5436
5324
|
async init() {
|
|
5437
5325
|
this.createMeshes();
|
|
@@ -5548,7 +5436,7 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5548
5436
|
this.dirty = true;
|
|
5549
5437
|
}
|
|
5550
5438
|
};
|
|
5551
|
-
this.options = (0,
|
|
5439
|
+
this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
5552
5440
|
}
|
|
5553
5441
|
add(...objects) {
|
|
5554
5442
|
for (const object of objects) {
|
|
@@ -5644,1140 +5532,1106 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
|
|
|
5644
5532
|
return this.addSceneObject(entity, () => new EntityObject(entity, options), options, parent);
|
|
5645
5533
|
}
|
|
5646
5534
|
};
|
|
5647
|
-
_MineRenderScene.DEFAULT_OPTIONS = (0,
|
|
5535
|
+
_MineRenderScene.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {});
|
|
5648
5536
|
var MineRenderScene = _MineRenderScene;
|
|
5649
5537
|
function isMineRenderScene(obj) {
|
|
5650
5538
|
return obj.isMineRenderScene;
|
|
5651
5539
|
}
|
|
5652
5540
|
|
|
5653
5541
|
// src/renderer/Renderer.ts
|
|
5654
|
-
var
|
|
5655
|
-
var
|
|
5542
|
+
var import_three18 = require("three");
|
|
5543
|
+
var import_ts_deepmerge10 = __toESM(require_dist());
|
|
5656
5544
|
var import_stats = __toESM(require("stats.js"));
|
|
5657
5545
|
var import_postprocessing = require("postprocessing");
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
this.object = object;
|
|
5670
|
-
this.domElement = domElement;
|
|
5671
|
-
this.domElement.style.touchAction = "none";
|
|
5672
|
-
this.enabled = true;
|
|
5673
|
-
this.target = new import_three18.Vector3();
|
|
5674
|
-
this.minDistance = 0;
|
|
5675
|
-
this.maxDistance = Infinity;
|
|
5676
|
-
this.minZoom = 0;
|
|
5677
|
-
this.maxZoom = Infinity;
|
|
5678
|
-
this.minPolarAngle = 0;
|
|
5679
|
-
this.maxPolarAngle = Math.PI;
|
|
5680
|
-
this.minAzimuthAngle = -Infinity;
|
|
5681
|
-
this.maxAzimuthAngle = Infinity;
|
|
5682
|
-
this.enableDamping = false;
|
|
5683
|
-
this.dampingFactor = 0.05;
|
|
5684
|
-
this.enableZoom = true;
|
|
5685
|
-
this.zoomSpeed = 1;
|
|
5686
|
-
this.enableRotate = true;
|
|
5687
|
-
this.rotateSpeed = 1;
|
|
5688
|
-
this.enablePan = true;
|
|
5689
|
-
this.panSpeed = 1;
|
|
5690
|
-
this.screenSpacePanning = true;
|
|
5691
|
-
this.keyPanSpeed = 7;
|
|
5692
|
-
this.autoRotate = false;
|
|
5693
|
-
this.autoRotateSpeed = 2;
|
|
5694
|
-
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
5695
|
-
this.mouseButtons = { LEFT: import_three18.MOUSE.ROTATE, MIDDLE: import_three18.MOUSE.DOLLY, RIGHT: import_three18.MOUSE.PAN };
|
|
5696
|
-
this.touches = { ONE: import_three18.TOUCH.ROTATE, TWO: import_three18.TOUCH.DOLLY_PAN };
|
|
5697
|
-
this.target0 = this.target.clone();
|
|
5698
|
-
this.position0 = this.object.position.clone();
|
|
5699
|
-
this.zoom0 = this.object.zoom;
|
|
5700
|
-
this._domElementKeyEvents = null;
|
|
5701
|
-
this.getPolarAngle = function() {
|
|
5702
|
-
return spherical.phi;
|
|
5703
|
-
};
|
|
5704
|
-
this.getAzimuthalAngle = function() {
|
|
5705
|
-
return spherical.theta;
|
|
5706
|
-
};
|
|
5707
|
-
this.getDistance = function() {
|
|
5708
|
-
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;
|
|
5709
5557
|
};
|
|
5710
|
-
this.
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
this.
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
scope.dispatchEvent(_changeEvent);
|
|
5721
|
-
scope.update();
|
|
5722
|
-
state = STATE.NONE;
|
|
5723
|
-
};
|
|
5724
|
-
this.update = function() {
|
|
5725
|
-
const offset = new import_three18.Vector3();
|
|
5726
|
-
const quat = new import_three18.Quaternion().setFromUnitVectors(object.up, new import_three18.Vector3(0, 1, 0));
|
|
5727
|
-
const quatInverse = quat.clone().invert();
|
|
5728
|
-
const lastPosition = new import_three18.Vector3();
|
|
5729
|
-
const lastQuaternion = new import_three18.Quaternion();
|
|
5730
|
-
const twoPI = 2 * Math.PI;
|
|
5731
|
-
return function update() {
|
|
5732
|
-
const position = scope.object.position;
|
|
5733
|
-
offset.copy(position).sub(scope.target);
|
|
5734
|
-
offset.applyQuaternion(quat);
|
|
5735
|
-
spherical.setFromVector3(offset);
|
|
5736
|
-
if (scope.autoRotate && state === STATE.NONE) {
|
|
5737
|
-
rotateLeft(getAutoRotationAngle());
|
|
5738
|
-
}
|
|
5739
|
-
if (scope.enableDamping) {
|
|
5740
|
-
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
5741
|
-
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
5742
|
-
} else {
|
|
5743
|
-
spherical.theta += sphericalDelta.theta;
|
|
5744
|
-
spherical.phi += sphericalDelta.phi;
|
|
5745
|
-
}
|
|
5746
|
-
let min = scope.minAzimuthAngle;
|
|
5747
|
-
let max = scope.maxAzimuthAngle;
|
|
5748
|
-
if (isFinite(min) && isFinite(max)) {
|
|
5749
|
-
if (min < -Math.PI) min += twoPI;
|
|
5750
|
-
else if (min > Math.PI) min -= twoPI;
|
|
5751
|
-
if (max < -Math.PI) max += twoPI;
|
|
5752
|
-
else if (max > Math.PI) max -= twoPI;
|
|
5753
|
-
if (min <= max) {
|
|
5754
|
-
spherical.theta = Math.max(min, Math.min(max, spherical.theta));
|
|
5755
|
-
} else {
|
|
5756
|
-
spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
|
|
5757
|
-
}
|
|
5758
|
-
}
|
|
5759
|
-
spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
|
|
5760
|
-
spherical.makeSafe();
|
|
5761
|
-
spherical.radius *= scale;
|
|
5762
|
-
spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
|
|
5763
|
-
if (scope.enableDamping === true) {
|
|
5764
|
-
scope.target.addScaledVector(panOffset, scope.dampingFactor);
|
|
5765
|
-
} else {
|
|
5766
|
-
scope.target.add(panOffset);
|
|
5767
|
-
}
|
|
5768
|
-
offset.setFromSpherical(spherical);
|
|
5769
|
-
offset.applyQuaternion(quatInverse);
|
|
5770
|
-
position.copy(scope.target).add(offset);
|
|
5771
|
-
scope.object.lookAt(scope.target);
|
|
5772
|
-
if (scope.enableDamping === true) {
|
|
5773
|
-
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
5774
|
-
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
5775
|
-
panOffset.multiplyScalar(1 - scope.dampingFactor);
|
|
5776
|
-
} else {
|
|
5777
|
-
sphericalDelta.set(0, 0, 0);
|
|
5778
|
-
panOffset.set(0, 0, 0);
|
|
5779
|
-
}
|
|
5780
|
-
scale = 1;
|
|
5781
|
-
if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
|
|
5782
|
-
scope.dispatchEvent(_changeEvent);
|
|
5783
|
-
lastPosition.copy(scope.object.position);
|
|
5784
|
-
lastQuaternion.copy(scope.object.quaternion);
|
|
5785
|
-
zoomChanged = false;
|
|
5786
|
-
return true;
|
|
5787
|
-
}
|
|
5788
|
-
return false;
|
|
5789
|
-
};
|
|
5790
|
-
}();
|
|
5791
|
-
this.dispose = function() {
|
|
5792
|
-
scope.domElement.removeEventListener("contextmenu", onContextMenu);
|
|
5793
|
-
scope.domElement.removeEventListener("pointerdown", onPointerDown);
|
|
5794
|
-
scope.domElement.removeEventListener("pointercancel", onPointerCancel);
|
|
5795
|
-
scope.domElement.removeEventListener("wheel", onMouseWheel);
|
|
5796
|
-
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
5797
|
-
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
5798
|
-
if (scope._domElementKeyEvents !== null) {
|
|
5799
|
-
scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
|
|
5800
|
-
}
|
|
5801
|
-
};
|
|
5802
|
-
const scope = this;
|
|
5803
|
-
const STATE = {
|
|
5804
|
-
NONE: -1,
|
|
5805
|
-
ROTATE: 0,
|
|
5806
|
-
DOLLY: 1,
|
|
5807
|
-
PAN: 2,
|
|
5808
|
-
TOUCH_ROTATE: 3,
|
|
5809
|
-
TOUCH_PAN: 4,
|
|
5810
|
-
TOUCH_DOLLY_PAN: 5,
|
|
5811
|
-
TOUCH_DOLLY_ROTATE: 6
|
|
5812
|
-
};
|
|
5813
|
-
let state = STATE.NONE;
|
|
5814
|
-
const EPS = 1e-6;
|
|
5815
|
-
const spherical = new import_three18.Spherical();
|
|
5816
|
-
const sphericalDelta = new import_three18.Spherical();
|
|
5817
|
-
let scale = 1;
|
|
5818
|
-
const panOffset = new import_three18.Vector3();
|
|
5819
|
-
let zoomChanged = false;
|
|
5820
|
-
const rotateStart = new import_three18.Vector2();
|
|
5821
|
-
const rotateEnd = new import_three18.Vector2();
|
|
5822
|
-
const rotateDelta = new import_three18.Vector2();
|
|
5823
|
-
const panStart = new import_three18.Vector2();
|
|
5824
|
-
const panEnd = new import_three18.Vector2();
|
|
5825
|
-
const panDelta = new import_three18.Vector2();
|
|
5826
|
-
const dollyStart = new import_three18.Vector2();
|
|
5827
|
-
const dollyEnd = new import_three18.Vector2();
|
|
5828
|
-
const dollyDelta = new import_three18.Vector2();
|
|
5829
|
-
const pointers = [];
|
|
5830
|
-
const pointerPositions = {};
|
|
5831
|
-
function getAutoRotationAngle() {
|
|
5832
|
-
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);
|
|
5833
5568
|
}
|
|
5834
|
-
|
|
5835
|
-
|
|
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
|
+
);
|
|
5836
5594
|
}
|
|
5837
|
-
|
|
5838
|
-
|
|
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 }));
|
|
5839
5622
|
}
|
|
5840
|
-
|
|
5841
|
-
|
|
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);
|
|
5842
5635
|
}
|
|
5843
|
-
|
|
5844
|
-
const
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
v.multiplyScalar(-distance);
|
|
5848
|
-
panOffset.add(v);
|
|
5849
|
-
};
|
|
5850
|
-
}();
|
|
5851
|
-
const panUp = function() {
|
|
5852
|
-
const v = new import_three18.Vector3();
|
|
5853
|
-
return function panUp2(distance, objectMatrix) {
|
|
5854
|
-
if (scope.screenSpacePanning === true) {
|
|
5855
|
-
v.setFromMatrixColumn(objectMatrix, 1);
|
|
5856
|
-
} else {
|
|
5857
|
-
v.setFromMatrixColumn(objectMatrix, 0);
|
|
5858
|
-
v.crossVectors(scope.object.up, v);
|
|
5859
|
-
}
|
|
5860
|
-
v.multiplyScalar(distance);
|
|
5861
|
-
panOffset.add(v);
|
|
5862
|
-
};
|
|
5863
|
-
}();
|
|
5864
|
-
const pan = function() {
|
|
5865
|
-
const offset = new import_three18.Vector3();
|
|
5866
|
-
return function pan2(deltaX, deltaY) {
|
|
5867
|
-
const element = scope.domElement;
|
|
5868
|
-
if (scope.object.isPerspectiveCamera) {
|
|
5869
|
-
const position = scope.object.position;
|
|
5870
|
-
offset.copy(position).sub(scope.target);
|
|
5871
|
-
let targetDistance = offset.length();
|
|
5872
|
-
targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
|
|
5873
|
-
panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
|
|
5874
|
-
panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
|
|
5875
|
-
} else if (scope.object.isOrthographicCamera) {
|
|
5876
|
-
panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
|
|
5877
|
-
panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
|
|
5878
|
-
} else {
|
|
5879
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
|
|
5880
|
-
scope.enablePan = false;
|
|
5881
|
-
}
|
|
5882
|
-
};
|
|
5883
|
-
}();
|
|
5884
|
-
function dollyOut(dollyScale) {
|
|
5885
|
-
if (scope.object.isPerspectiveCamera) {
|
|
5886
|
-
scale /= dollyScale;
|
|
5887
|
-
} else if (scope.object.isOrthographicCamera) {
|
|
5888
|
-
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
|
|
5889
|
-
scope.object.updateProjectionMatrix();
|
|
5890
|
-
zoomChanged = true;
|
|
5891
|
-
} else {
|
|
5892
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
5893
|
-
scope.enableZoom = false;
|
|
5894
|
-
}
|
|
5636
|
+
if (this.options.debug.axes) {
|
|
5637
|
+
const axesHelper = new import_three18.AxesHelper(64);
|
|
5638
|
+
this._debugHelpers.push(axesHelper);
|
|
5639
|
+
this.scene.add(axesHelper);
|
|
5895
5640
|
}
|
|
5896
|
-
|
|
5897
|
-
if (
|
|
5898
|
-
|
|
5899
|
-
} else if (
|
|
5900
|
-
|
|
5901
|
-
scope.object.updateProjectionMatrix();
|
|
5902
|
-
zoomChanged = true;
|
|
5903
|
-
} else {
|
|
5904
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
5905
|
-
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]);
|
|
5906
5646
|
}
|
|
5907
5647
|
}
|
|
5908
|
-
|
|
5909
|
-
|
|
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
|
+
}
|
|
5910
5654
|
}
|
|
5911
|
-
|
|
5912
|
-
|
|
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);
|
|
5913
5660
|
}
|
|
5914
|
-
|
|
5915
|
-
|
|
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");
|
|
5916
5671
|
}
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
5920
|
-
const element = scope.domElement;
|
|
5921
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
5922
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
5923
|
-
rotateStart.copy(rotateEnd);
|
|
5924
|
-
scope.update();
|
|
5672
|
+
if (this.viewHeight == 0) {
|
|
5673
|
+
console.warn("0 element height");
|
|
5925
5674
|
}
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
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);
|
|
5936
5687
|
}
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
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();
|
|
5943
5703
|
}
|
|
5944
|
-
|
|
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;
|
|
5945
5743
|
}
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
} else if (event.deltaY > 0) {
|
|
5950
|
-
dollyOut(getZoomScale());
|
|
5744
|
+
for (const [dispatcher, events] of this._eventDispatchers) {
|
|
5745
|
+
for (const event of events) {
|
|
5746
|
+
dispatcher.removeEventListener(event, this._changeListener);
|
|
5951
5747
|
}
|
|
5952
|
-
scope.update();
|
|
5953
5748
|
}
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
case scope.keys.LEFT:
|
|
5966
|
-
pan(scope.keyPanSpeed, 0);
|
|
5967
|
-
needsUpdate = true;
|
|
5968
|
-
break;
|
|
5969
|
-
case scope.keys.RIGHT:
|
|
5970
|
-
pan(-scope.keyPanSpeed, 0);
|
|
5971
|
-
needsUpdate = true;
|
|
5972
|
-
break;
|
|
5973
|
-
}
|
|
5974
|
-
if (needsUpdate) {
|
|
5975
|
-
event.preventDefault();
|
|
5976
|
-
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();
|
|
5977
5760
|
}
|
|
5978
5761
|
}
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
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();
|
|
5987
5771
|
}
|
|
5988
|
-
|
|
5989
|
-
if (
|
|
5990
|
-
|
|
5772
|
+
if (this.dirty || this.options.render.renderAlways) {
|
|
5773
|
+
if (this.options.composer.enabled) {
|
|
5774
|
+
this.composer.render();
|
|
5991
5775
|
} else {
|
|
5992
|
-
|
|
5993
|
-
const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
5994
|
-
panStart.set(x, y);
|
|
5776
|
+
this.renderer.render(this.scene, this.camera);
|
|
5995
5777
|
}
|
|
5996
5778
|
}
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6001
|
-
dollyStart.set(0, distance);
|
|
6002
|
-
}
|
|
6003
|
-
function handleTouchStartDollyPan() {
|
|
6004
|
-
if (scope.enableZoom) handleTouchStartDolly();
|
|
6005
|
-
if (scope.enablePan) handleTouchStartPan();
|
|
5779
|
+
this.dirty = false;
|
|
5780
|
+
if (this._stats) {
|
|
5781
|
+
this._stats.end();
|
|
6006
5782
|
}
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
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);
|
|
6010
5854
|
}
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
6021
|
-
const element = scope.domElement;
|
|
6022
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
6023
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
6024
|
-
rotateStart.copy(rotateEnd);
|
|
6025
|
-
}
|
|
6026
|
-
function handleTouchMovePan(event) {
|
|
6027
|
-
if (pointers.length === 1) {
|
|
6028
|
-
panEnd.set(event.pageX, event.pageY);
|
|
6029
|
-
} else {
|
|
6030
|
-
const position = getSecondPointerPosition(event);
|
|
6031
|
-
const x = 0.5 * (event.pageX + position.x);
|
|
6032
|
-
const y = 0.5 * (event.pageY + position.y);
|
|
6033
|
-
panEnd.set(x, y);
|
|
6034
|
-
}
|
|
6035
|
-
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
6036
|
-
pan(panDelta.x, panDelta.y);
|
|
6037
|
-
panStart.copy(panEnd);
|
|
6038
|
-
}
|
|
6039
|
-
function handleTouchMoveDolly(event) {
|
|
6040
|
-
const position = getSecondPointerPosition(event);
|
|
6041
|
-
const dx = event.pageX - position.x;
|
|
6042
|
-
const dy = event.pageY - position.y;
|
|
6043
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
6044
|
-
dollyEnd.set(0, distance);
|
|
6045
|
-
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
6046
|
-
dollyOut(dollyDelta.y);
|
|
6047
|
-
dollyStart.copy(dollyEnd);
|
|
6048
|
-
}
|
|
6049
|
-
function handleTouchMoveDollyPan(event) {
|
|
6050
|
-
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6051
|
-
if (scope.enablePan) handleTouchMovePan(event);
|
|
6052
|
-
}
|
|
6053
|
-
function handleTouchMoveDollyRotate(event) {
|
|
6054
|
-
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6055
|
-
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
6056
|
-
}
|
|
6057
|
-
function handleTouchEnd() {
|
|
6058
|
-
}
|
|
6059
|
-
function onPointerDown(event) {
|
|
6060
|
-
if (scope.enabled === false) return;
|
|
6061
|
-
if (pointers.length === 0) {
|
|
6062
|
-
scope.domElement.setPointerCapture(event.pointerId);
|
|
6063
|
-
scope.domElement.addEventListener("pointermove", onPointerMove);
|
|
6064
|
-
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);
|
|
6065
5864
|
}
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
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"];
|
|
6071
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);
|
|
6072
5881
|
}
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
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);
|
|
6079
5891
|
}
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
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;
|
|
6087
5899
|
}
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
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"];
|
|
6093
5915
|
}
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
case 2:
|
|
6108
|
-
mouseAction = scope.mouseButtons.RIGHT;
|
|
6109
|
-
break;
|
|
6110
|
-
default:
|
|
6111
|
-
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"];
|
|
6112
5929
|
}
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
handleMouseDownRotate(event);
|
|
6127
|
-
state = STATE.ROTATE;
|
|
6128
|
-
}
|
|
6129
|
-
break;
|
|
6130
|
-
case import_three18.MOUSE.PAN:
|
|
6131
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
6132
|
-
if (scope.enableRotate === false) return;
|
|
6133
|
-
handleMouseDownRotate(event);
|
|
6134
|
-
state = STATE.ROTATE;
|
|
6135
|
-
} else {
|
|
6136
|
-
if (scope.enablePan === false) return;
|
|
6137
|
-
handleMouseDownPan(event);
|
|
6138
|
-
state = STATE.PAN;
|
|
6139
|
-
}
|
|
6140
|
-
break;
|
|
6141
|
-
default:
|
|
6142
|
-
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;
|
|
6143
5943
|
}
|
|
6144
|
-
|
|
6145
|
-
|
|
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;
|
|
6146
5953
|
}
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
if (scope.enablePan === false) return;
|
|
6161
|
-
handleMouseMovePan(event);
|
|
6162
|
-
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;
|
|
6163
5967
|
}
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
}
|
|
6170
|
-
function onMouseWheel(event) {
|
|
6171
|
-
if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
|
|
6172
|
-
event.preventDefault();
|
|
6173
|
-
scope.dispatchEvent(_startEvent);
|
|
6174
|
-
handleMouseWheel(event);
|
|
6175
|
-
scope.dispatchEvent(_endEvent);
|
|
6176
|
-
}
|
|
6177
|
-
function onKeyDown(event) {
|
|
6178
|
-
if (scope.enabled === false || scope.enablePan === false) return;
|
|
6179
|
-
handleKeyDown(event);
|
|
6180
|
-
}
|
|
6181
|
-
function onTouchStart(event) {
|
|
6182
|
-
trackPointer(event);
|
|
6183
|
-
switch (pointers.length) {
|
|
6184
|
-
case 1:
|
|
6185
|
-
switch (scope.touches.ONE) {
|
|
6186
|
-
case import_three18.TOUCH.ROTATE:
|
|
6187
|
-
if (scope.enableRotate === false) return;
|
|
6188
|
-
handleTouchStartRotate();
|
|
6189
|
-
state = STATE.TOUCH_ROTATE;
|
|
6190
|
-
break;
|
|
6191
|
-
case import_three18.TOUCH.PAN:
|
|
6192
|
-
if (scope.enablePan === false) return;
|
|
6193
|
-
handleTouchStartPan();
|
|
6194
|
-
state = STATE.TOUCH_PAN;
|
|
6195
|
-
break;
|
|
6196
|
-
default:
|
|
6197
|
-
state = STATE.NONE;
|
|
6198
|
-
}
|
|
6199
|
-
break;
|
|
6200
|
-
case 2:
|
|
6201
|
-
switch (scope.touches.TWO) {
|
|
6202
|
-
case import_three18.TOUCH.DOLLY_PAN:
|
|
6203
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6204
|
-
handleTouchStartDollyPan();
|
|
6205
|
-
state = STATE.TOUCH_DOLLY_PAN;
|
|
6206
|
-
break;
|
|
6207
|
-
case import_three18.TOUCH.DOLLY_ROTATE:
|
|
6208
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6209
|
-
handleTouchStartDollyRotate();
|
|
6210
|
-
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
6211
|
-
break;
|
|
6212
|
-
default:
|
|
6213
|
-
state = STATE.NONE;
|
|
6214
|
-
}
|
|
6215
|
-
break;
|
|
6216
|
-
default:
|
|
6217
|
-
state = STATE.NONE;
|
|
6218
|
-
}
|
|
6219
|
-
if (state !== STATE.NONE) {
|
|
6220
|
-
scope.dispatchEvent(_startEvent);
|
|
6221
|
-
}
|
|
6222
|
-
}
|
|
6223
|
-
function onTouchMove(event) {
|
|
6224
|
-
trackPointer(event);
|
|
6225
|
-
switch (state) {
|
|
6226
|
-
case STATE.TOUCH_ROTATE:
|
|
6227
|
-
if (scope.enableRotate === false) return;
|
|
6228
|
-
handleTouchMoveRotate(event);
|
|
6229
|
-
scope.update();
|
|
6230
|
-
break;
|
|
6231
|
-
case STATE.TOUCH_PAN:
|
|
6232
|
-
if (scope.enablePan === false) return;
|
|
6233
|
-
handleTouchMovePan(event);
|
|
6234
|
-
scope.update();
|
|
6235
|
-
break;
|
|
6236
|
-
case STATE.TOUCH_DOLLY_PAN:
|
|
6237
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
6238
|
-
handleTouchMoveDollyPan(event);
|
|
6239
|
-
scope.update();
|
|
6240
|
-
break;
|
|
6241
|
-
case STATE.TOUCH_DOLLY_ROTATE:
|
|
6242
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
6243
|
-
handleTouchMoveDollyRotate(event);
|
|
6244
|
-
scope.update();
|
|
6245
|
-
break;
|
|
6246
|
-
default:
|
|
6247
|
-
state = STATE.NONE;
|
|
6248
|
-
}
|
|
6249
|
-
}
|
|
6250
|
-
function onTouchEnd(event) {
|
|
6251
|
-
handleTouchEnd(event);
|
|
6252
|
-
scope.dispatchEvent(_endEvent);
|
|
6253
|
-
state = STATE.NONE;
|
|
6254
|
-
}
|
|
6255
|
-
function onContextMenu(event) {
|
|
6256
|
-
if (scope.enabled === false) return;
|
|
6257
|
-
event.preventDefault();
|
|
6258
|
-
}
|
|
6259
|
-
function addPointer(event) {
|
|
6260
|
-
pointers.push(event);
|
|
6261
|
-
}
|
|
6262
|
-
function removePointer(event) {
|
|
6263
|
-
delete pointerPositions[event.pointerId];
|
|
6264
|
-
for (let i = 0; i < pointers.length; i++) {
|
|
6265
|
-
if (pointers[i].pointerId == event.pointerId) {
|
|
6266
|
-
pointers.splice(i, 1);
|
|
6267
|
-
return;
|
|
6268
|
-
}
|
|
6269
|
-
}
|
|
6270
|
-
}
|
|
6271
|
-
function trackPointer(event) {
|
|
6272
|
-
let position = pointerPositions[event.pointerId];
|
|
6273
|
-
if (position === void 0) {
|
|
6274
|
-
position = new import_three18.Vector2();
|
|
6275
|
-
pointerPositions[event.pointerId] = position;
|
|
6276
|
-
}
|
|
6277
|
-
position.set(event.pageX, event.pageY);
|
|
6278
|
-
}
|
|
6279
|
-
function getSecondPointerPosition(event) {
|
|
6280
|
-
const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
|
|
6281
|
-
return pointerPositions[pointer.pointerId];
|
|
6282
|
-
}
|
|
6283
|
-
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
6284
|
-
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
6285
|
-
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
6286
|
-
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
6287
|
-
this.update();
|
|
5968
|
+
return void 0;
|
|
5969
|
+
}).catch((err) => {
|
|
5970
|
+
console.warn(err);
|
|
5971
|
+
return void 0;
|
|
5972
|
+
});
|
|
6288
5973
|
}
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
constructor(object, domElement) {
|
|
6292
|
-
super(object, domElement);
|
|
6293
|
-
this.screenSpacePanning = false;
|
|
6294
|
-
this.mouseButtons.LEFT = import_three18.MOUSE.PAN;
|
|
6295
|
-
this.mouseButtons.RIGHT = import_three18.MOUSE.ROTATE;
|
|
6296
|
-
this.touches.ONE = import_three18.TOUCH.PAN;
|
|
6297
|
-
this.touches.TWO = import_three18.TOUCH.DOLLY_ROTATE;
|
|
5974
|
+
static getCrafatarSkinUrl(uuid) {
|
|
5975
|
+
return "https://crafatar.com/skins/" + uuid;
|
|
6298
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>
|
|
6299
5993
|
};
|
|
6300
5994
|
|
|
6301
|
-
// src/
|
|
6302
|
-
var
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
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;
|
|
6311
6039
|
};
|
|
6312
|
-
this.
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
this.
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
this.
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
}
|
|
6323
|
-
this.
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
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;
|
|
6349
6169
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
const renderer = new import_three19.WebGLRenderer({
|
|
6353
|
-
antialias: this.options.render.antialias,
|
|
6354
|
-
alpha: true,
|
|
6355
|
-
powerPreference: "high-performance",
|
|
6356
|
-
depth: true
|
|
6357
|
-
});
|
|
6358
|
-
renderer.setClearColor(0, 0);
|
|
6359
|
-
renderer.shadowMap.enabled = true;
|
|
6360
|
-
renderer.shadowMap.type = import_three19.PCFSoftShadowMap;
|
|
6361
|
-
renderer.outputColorSpace = import_three19.SRGBColorSpace;
|
|
6362
|
-
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6363
|
-
return renderer;
|
|
6364
|
-
}
|
|
6365
|
-
createComposer() {
|
|
6366
|
-
if (!this.options.composer.enabled) return void 0;
|
|
6367
|
-
const composer = new import_postprocessing.EffectComposer(this.renderer);
|
|
6368
|
-
composer.setSize(this.viewWidth, this.viewHeight);
|
|
6369
|
-
composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
|
|
6370
|
-
return composer;
|
|
6371
|
-
}
|
|
6372
|
-
createControls() {
|
|
6373
|
-
if (!this.options.controls?.enabled) return void 0;
|
|
6374
|
-
const position = this.camera.position.clone();
|
|
6375
|
-
const controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
6376
|
-
this.camera.position.copy(position);
|
|
6377
|
-
const target = this.options.camera.lookingAt;
|
|
6378
|
-
if (isVector3(target)) {
|
|
6379
|
-
controls.target.copy(target);
|
|
6380
|
-
} else if (isTripleArray(target)) {
|
|
6381
|
-
controls.target.set(target[0], target[1], target[2]);
|
|
6382
|
-
}
|
|
6383
|
-
controls.update();
|
|
6384
|
-
controls.saveState();
|
|
6385
|
-
this.registerEventDispatcher(controls);
|
|
6386
|
-
return controls;
|
|
6387
|
-
}
|
|
6388
|
-
//</editor-fold>
|
|
6389
|
-
init() {
|
|
6390
|
-
if (this._disposed) return;
|
|
6391
|
-
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
6392
|
-
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
6170
|
+
function getZoomScale() {
|
|
6171
|
+
return Math.pow(0.95, scope.zoomSpeed);
|
|
6393
6172
|
}
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
this._debugHelpers.push(gridHelper);
|
|
6397
|
-
this.scene.add(gridHelper);
|
|
6398
|
-
const gridHelper2 = new import_three19.GridHelper(128, 16);
|
|
6399
|
-
this._debugHelpers.push(gridHelper2);
|
|
6400
|
-
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
6401
|
-
this.scene.add(gridHelper2);
|
|
6402
|
-
const gridHelper3 = new import_three19.GridHelper(128, 16);
|
|
6403
|
-
this._debugHelpers.push(gridHelper3);
|
|
6404
|
-
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
6405
|
-
this.scene.add(gridHelper3);
|
|
6173
|
+
function rotateLeft(angle) {
|
|
6174
|
+
sphericalDelta.theta -= angle;
|
|
6406
6175
|
}
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
this._debugHelpers.push(axesHelper);
|
|
6410
|
-
this.scene.add(axesHelper);
|
|
6176
|
+
function rotateUp(angle) {
|
|
6177
|
+
sphericalDelta.phi -= angle;
|
|
6411
6178
|
}
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
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;
|
|
6417
6230
|
}
|
|
6418
6231
|
}
|
|
6419
|
-
|
|
6420
|
-
if (
|
|
6421
|
-
|
|
6422
|
-
} else if (
|
|
6423
|
-
|
|
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;
|
|
6424
6242
|
}
|
|
6425
6243
|
}
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
this.resize(this.viewWidth, this.viewHeight);
|
|
6429
|
-
};
|
|
6430
|
-
window.addEventListener("resize", this._resizeListener);
|
|
6244
|
+
function handleMouseDownRotate(event) {
|
|
6245
|
+
rotateStart.set(event.clientX, event.clientY);
|
|
6431
6246
|
}
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
return this._element;
|
|
6435
|
-
}
|
|
6436
|
-
appendTo(element) {
|
|
6437
|
-
if (this._disposed) return;
|
|
6438
|
-
this._element = element;
|
|
6439
|
-
this._element.appendChild(this.renderer.domElement);
|
|
6440
|
-
if (this.viewWidth == 0) {
|
|
6441
|
-
console.warn("0 element width");
|
|
6247
|
+
function handleMouseDownDolly(event) {
|
|
6248
|
+
dollyStart.set(event.clientX, event.clientY);
|
|
6442
6249
|
}
|
|
6443
|
-
|
|
6444
|
-
|
|
6250
|
+
function handleMouseDownPan(event) {
|
|
6251
|
+
panStart.set(event.clientX, event.clientY);
|
|
6445
6252
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
let events = this._eventDispatchers.get(dispatcher);
|
|
6455
|
-
if (!events) {
|
|
6456
|
-
events = /* @__PURE__ */ new Set();
|
|
6457
|
-
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();
|
|
6458
6261
|
}
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
this.camera.left = width / -2;
|
|
6470
|
-
this.camera.right = width / 2;
|
|
6471
|
-
this.camera.top = height / 2;
|
|
6472
|
-
this.camera.bottom = height / -2;
|
|
6473
|
-
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();
|
|
6474
6272
|
}
|
|
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
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
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
|
+
}
|
|
6509
6314
|
}
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
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);
|
|
6513
6322
|
}
|
|
6514
6323
|
}
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
controls.enabled = false;
|
|
6524
|
-
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
|
+
}
|
|
6525
6332
|
}
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
const
|
|
6530
|
-
|
|
6531
|
-
|
|
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);
|
|
6532
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);
|
|
6533
6361
|
}
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
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);
|
|
6543
6374
|
}
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
const
|
|
6549
|
-
|
|
6550
|
-
|
|
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);
|
|
6551
6384
|
}
|
|
6552
|
-
|
|
6553
|
-
|
|
6385
|
+
function handleTouchMoveDollyPan(event) {
|
|
6386
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6387
|
+
if (scope.enablePan) handleTouchMovePan(event);
|
|
6554
6388
|
}
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
this.renderer.render(this.scene, this.camera);
|
|
6389
|
+
function handleTouchMoveDollyRotate(event) {
|
|
6390
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
6391
|
+
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
6559
6392
|
}
|
|
6560
|
-
|
|
6561
|
-
if (this._stats) {
|
|
6562
|
-
this._stats.end();
|
|
6393
|
+
function handleTouchEnd() {
|
|
6563
6394
|
}
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
6578
|
-
}
|
|
6579
|
-
get scene() {
|
|
6580
|
-
return this._scene;
|
|
6581
|
-
}
|
|
6582
|
-
get camera() {
|
|
6583
|
-
return this._camera;
|
|
6584
|
-
}
|
|
6585
|
-
get renderer() {
|
|
6586
|
-
return this._renderer;
|
|
6587
|
-
}
|
|
6588
|
-
get composer() {
|
|
6589
|
-
return this._composer;
|
|
6590
|
-
}
|
|
6591
|
-
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
6592
|
-
get controls() {
|
|
6593
|
-
return this._controls;
|
|
6594
|
-
}
|
|
6595
|
-
///
|
|
6596
|
-
};
|
|
6597
|
-
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge9.default)({}, {
|
|
6598
|
-
camera: {
|
|
6599
|
-
type: "perspective",
|
|
6600
|
-
near: 1,
|
|
6601
|
-
far: 5e3,
|
|
6602
|
-
perspective: {
|
|
6603
|
-
aspect: void 0,
|
|
6604
|
-
fov: 50
|
|
6605
|
-
},
|
|
6606
|
-
orthographic: {
|
|
6607
|
-
left: void 0,
|
|
6608
|
-
right: void 0,
|
|
6609
|
-
top: void 0,
|
|
6610
|
-
bottom: void 0
|
|
6611
|
-
},
|
|
6612
|
-
position: new import_three19.Vector3(50, 50, 50),
|
|
6613
|
-
lookingAt: new import_three19.Vector3(0, 0, 0)
|
|
6614
|
-
},
|
|
6615
|
-
render: {
|
|
6616
|
-
fpsLimit: 60,
|
|
6617
|
-
stats: false,
|
|
6618
|
-
antialias: true,
|
|
6619
|
-
shade: true,
|
|
6620
|
-
autoResize: true,
|
|
6621
|
-
renderAlways: false
|
|
6622
|
-
},
|
|
6623
|
-
composer: {
|
|
6624
|
-
enabled: true
|
|
6625
|
-
},
|
|
6626
|
-
controls: {
|
|
6627
|
-
enabled: false
|
|
6628
|
-
},
|
|
6629
|
-
debug: {
|
|
6630
|
-
grid: false,
|
|
6631
|
-
axes: false
|
|
6632
|
-
}
|
|
6633
|
-
});
|
|
6634
|
-
var Renderer = _Renderer;
|
|
6635
|
-
|
|
6636
|
-
// src/skin/Skins.ts
|
|
6637
|
-
var Skins = class {
|
|
6638
|
-
//<editor-fold desc="Skins">
|
|
6639
|
-
static async fromUuidOrUsername(uuidOrUsername) {
|
|
6640
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
6641
|
-
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
|
+
}
|
|
6642
6408
|
}
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
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;
|
|
6652
6479
|
}
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
}
|
|
6656
|
-
static async fromMineSkin(mineskinId) {
|
|
6657
|
-
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
6658
|
-
if (mineskin) {
|
|
6659
|
-
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
6480
|
+
if (state !== STATE.NONE) {
|
|
6481
|
+
scope.dispatchEvent(_startEvent);
|
|
6660
6482
|
}
|
|
6661
|
-
return void 0;
|
|
6662
|
-
});
|
|
6663
|
-
}
|
|
6664
|
-
//</editor-fold>
|
|
6665
|
-
//<editor-fold desc="Capes">
|
|
6666
|
-
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
6667
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
6668
|
-
return this.capeFromUuid(uuidOrUsername);
|
|
6669
6483
|
}
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
if (cape) {
|
|
6686
|
-
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;
|
|
6687
6499
|
}
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
}
|
|
6701
|
-
|
|
6702
|
-
|
|
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;
|
|
6703
6554
|
}
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
console.warn(err);
|
|
6707
|
-
return void 0;
|
|
6708
|
-
});
|
|
6709
|
-
}
|
|
6710
|
-
static async usernameToUuidMineTools(username) {
|
|
6711
|
-
return Requests.genericRequest({
|
|
6712
|
-
baseURL: "https://api.minetools.eu",
|
|
6713
|
-
url: "/uuid/" + username
|
|
6714
|
-
}).then((res) => {
|
|
6715
|
-
if (res.status === 200) {
|
|
6716
|
-
return res.data["id"];
|
|
6555
|
+
if (state !== STATE.NONE) {
|
|
6556
|
+
scope.dispatchEvent(_startEvent);
|
|
6717
6557
|
}
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
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;
|
|
6731
6584
|
}
|
|
6732
|
-
}
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
if (
|
|
6740
|
-
|
|
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
|
+
}
|
|
6741
6605
|
}
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
static async getCapesDev(uuid, type = "all") {
|
|
6749
|
-
return Requests.genericRequest({
|
|
6750
|
-
baseURL: "https://api.capes.dev",
|
|
6751
|
-
url: "/load/" + uuid + "/" + type
|
|
6752
|
-
}).then((res) => {
|
|
6753
|
-
if (res.status === 200) {
|
|
6754
|
-
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;
|
|
6755
6612
|
}
|
|
6756
|
-
|
|
6757
|
-
}
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
}
|
|
6768
|
-
static getMcHeadsSkinUrl(uuid) {
|
|
6769
|
-
return "https://mc-heads.net/skin/" + uuid;
|
|
6770
|
-
}
|
|
6771
|
-
static getMineSkinPlayerSkinUrl(uuid) {
|
|
6772
|
-
return "https://mineskin.org/skin/player/" + uuid;
|
|
6773
|
-
}
|
|
6774
|
-
static getSkinProxySkinUrl(uuid) {
|
|
6775
|
-
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();
|
|
6776
6624
|
}
|
|
6777
|
-
|
|
6778
|
-
|
|
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;
|
|
6779
6634
|
}
|
|
6780
|
-
//</editor-fold>
|
|
6781
6635
|
};
|
|
6782
6636
|
|
|
6783
6637
|
// src/world/Chunk.ts
|
|
@@ -6894,7 +6748,7 @@ var MineRenderWorld = class {
|
|
|
6894
6748
|
};
|
|
6895
6749
|
|
|
6896
6750
|
// src/world/Chunk.ts
|
|
6897
|
-
var
|
|
6751
|
+
var p12 = prefix("Chunk");
|
|
6898
6752
|
var Chunk = class _Chunk {
|
|
6899
6753
|
constructor(scene, x, y, z) {
|
|
6900
6754
|
this._blocks = [];
|
|
@@ -6946,7 +6800,7 @@ var Chunk = class _Chunk {
|
|
|
6946
6800
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
6947
6801
|
const current = this._blocks[index];
|
|
6948
6802
|
if (typeof current !== "undefined") {
|
|
6949
|
-
console.debug(
|
|
6803
|
+
console.debug(p12, "deleting existing block at", pos, worldPos, index);
|
|
6950
6804
|
current.object.removeFromScene();
|
|
6951
6805
|
delete this._blocks[index];
|
|
6952
6806
|
}
|