minerender 2.1.0-alpha.0 → 2.1.0-alpha.3

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.
Files changed (94) hide show
  1. package/README.md +0 -2
  2. package/dist/browser/index.d.mts +106 -84
  3. package/dist/browser/index.d.ts +106 -84
  4. package/dist/browser/index.js +1094 -968
  5. package/dist/browser/index.js.map +1 -1
  6. package/dist/browser/index.mjs +1107 -981
  7. package/dist/browser/index.mjs.map +1 -1
  8. package/dist/bundle.js +1045 -921
  9. package/dist/bundle.js.map +1 -1
  10. package/dist/node/index.d.mts +106 -84
  11. package/dist/node/index.d.ts +106 -84
  12. package/dist/node/index.js +1100 -970
  13. package/dist/node/index.js.map +1 -1
  14. package/dist/node/index.mjs +1112 -982
  15. package/dist/node/index.mjs.map +1 -1
  16. package/package.json +5 -5
  17. package/.worktrees/jobqu-review/LICENSE +0 -21
  18. package/.worktrees/jobqu-review/README.md +0 -176
  19. package/.worktrees/v2-asset-sources/LICENSE +0 -21
  20. package/.worktrees/v2-asset-sources/README.md +0 -30
  21. package/.worktrees/v2-asset-sources/examples/script-tag/README.md +0 -13
  22. package/.worktrees/v2-asset-sources/examples/vite/README.md +0 -13
  23. package/.worktrees/v2-asset-sources/packages/minerender/LICENSE +0 -21
  24. package/.worktrees/v2-asset-sources/packages/minerender/README.md +0 -24
  25. package/.worktrees/v2-brightness/LICENSE +0 -21
  26. package/.worktrees/v2-brightness/README.md +0 -30
  27. package/.worktrees/v2-brightness/examples/script-tag/README.md +0 -13
  28. package/.worktrees/v2-brightness/examples/vite/README.md +0 -13
  29. package/.worktrees/v2-brightness/packages/minerender/LICENSE +0 -21
  30. package/.worktrees/v2-brightness/packages/minerender/README.md +0 -24
  31. package/.worktrees/v2-cache-recovery/LICENSE +0 -21
  32. package/.worktrees/v2-cache-recovery/README.md +0 -30
  33. package/.worktrees/v2-cache-recovery/examples/script-tag/README.md +0 -13
  34. package/.worktrees/v2-cache-recovery/examples/vite/README.md +0 -13
  35. package/.worktrees/v2-cache-recovery/packages/minerender/LICENSE +0 -21
  36. package/.worktrees/v2-cache-recovery/packages/minerender/README.md +0 -24
  37. package/.worktrees/v2-ci-stack/LICENSE +0 -21
  38. package/.worktrees/v2-ci-stack/README.md +0 -109
  39. package/.worktrees/v2-ci-stack/examples/script-tag/README.md +0 -15
  40. package/.worktrees/v2-ci-stack/examples/vite/README.md +0 -15
  41. package/.worktrees/v2-ci-stack/packages/minerender/LICENSE +0 -21
  42. package/.worktrees/v2-ci-stack/packages/minerender/README.md +0 -11
  43. package/.worktrees/v2-ci-typescript/LICENSE +0 -21
  44. package/.worktrees/v2-ci-typescript/README.md +0 -11
  45. package/.worktrees/v2-controls/LICENSE +0 -21
  46. package/.worktrees/v2-controls/README.md +0 -30
  47. package/.worktrees/v2-controls/examples/script-tag/README.md +0 -13
  48. package/.worktrees/v2-controls/examples/vite/README.md +0 -13
  49. package/.worktrees/v2-controls/packages/minerender/LICENSE +0 -21
  50. package/.worktrees/v2-controls/packages/minerender/README.md +0 -24
  51. package/.worktrees/v2-dependencies/LICENSE +0 -21
  52. package/.worktrees/v2-dependencies/README.md +0 -30
  53. package/.worktrees/v2-dependencies/examples/script-tag/README.md +0 -13
  54. package/.worktrees/v2-dependencies/examples/vite/README.md +0 -13
  55. package/.worktrees/v2-dependencies/packages/minerender/LICENSE +0 -21
  56. package/.worktrees/v2-dependencies/packages/minerender/README.md +0 -24
  57. package/.worktrees/v2-frame-limit/LICENSE +0 -21
  58. package/.worktrees/v2-frame-limit/README.md +0 -30
  59. package/.worktrees/v2-frame-limit/examples/script-tag/README.md +0 -13
  60. package/.worktrees/v2-frame-limit/examples/vite/README.md +0 -13
  61. package/.worktrees/v2-frame-limit/packages/minerender/LICENSE +0 -21
  62. package/.worktrees/v2-frame-limit/packages/minerender/README.md +0 -24
  63. package/.worktrees/v2-images/LICENSE +0 -21
  64. package/.worktrees/v2-images/README.md +0 -30
  65. package/.worktrees/v2-images/examples/script-tag/README.md +0 -13
  66. package/.worktrees/v2-images/examples/vite/README.md +0 -13
  67. package/.worktrees/v2-images/packages/minerender/LICENSE +0 -21
  68. package/.worktrees/v2-images/packages/minerender/README.md +0 -24
  69. package/.worktrees/v2-lifecycle/LICENSE +0 -21
  70. package/.worktrees/v2-lifecycle/README.md +0 -30
  71. package/.worktrees/v2-lifecycle/examples/script-tag/README.md +0 -13
  72. package/.worktrees/v2-lifecycle/examples/vite/README.md +0 -13
  73. package/.worktrees/v2-lifecycle/packages/minerender/LICENSE +0 -21
  74. package/.worktrees/v2-lifecycle/packages/minerender/README.md +0 -24
  75. package/.worktrees/v2-main-conflicts/LICENSE +0 -21
  76. package/.worktrees/v2-main-conflicts/README.md +0 -11
  77. package/.worktrees/v2-monorepo/LICENSE +0 -21
  78. package/.worktrees/v2-monorepo/README.md +0 -30
  79. package/.worktrees/v2-monorepo/examples/script-tag/README.md +0 -13
  80. package/.worktrees/v2-monorepo/examples/vite/README.md +0 -13
  81. package/.worktrees/v2-monorepo/packages/minerender/LICENSE +0 -21
  82. package/.worktrees/v2-monorepo/packages/minerender/README.md +0 -24
  83. package/.worktrees/v2-requests/LICENSE +0 -21
  84. package/.worktrees/v2-requests/README.md +0 -30
  85. package/.worktrees/v2-requests/examples/script-tag/README.md +0 -13
  86. package/.worktrees/v2-requests/examples/vite/README.md +0 -13
  87. package/.worktrees/v2-requests/packages/minerender/LICENSE +0 -21
  88. package/.worktrees/v2-requests/packages/minerender/README.md +0 -26
  89. package/.worktrees/v2-source-errors/LICENSE +0 -21
  90. package/.worktrees/v2-source-errors/README.md +0 -30
  91. package/.worktrees/v2-source-errors/examples/script-tag/README.md +0 -13
  92. package/.worktrees/v2-source-errors/examples/vite/README.md +0 -13
  93. package/.worktrees/v2-source-errors/packages/minerender/LICENSE +0 -21
  94. package/.worktrees/v2-source-errors/packages/minerender/README.md +0 -26
@@ -37,9 +37,9 @@ var __decorateClass = (decorators, target, key, kind) => {
37
37
  return result;
38
38
  };
39
39
 
40
- // node_modules/ts-deepmerge/dist/index.js
40
+ // ../../node_modules/ts-deepmerge/dist/index.js
41
41
  var require_dist = __commonJS({
42
- "node_modules/ts-deepmerge/dist/index.js"(exports2) {
42
+ "../../node_modules/ts-deepmerge/dist/index.js"(exports2) {
43
43
  "use strict";
44
44
  var __assign = exports2 && exports2.__assign || function() {
45
45
  __assign = Object.assign || function(t) {
@@ -1468,7 +1468,7 @@ var DefaultBlockStates = class {
1468
1468
  };
1469
1469
 
1470
1470
  // src/assets/Assets.ts
1471
- var DEFAULT_ROOT = "https://cdn.mcasset.cloud/file/minecraft-assets/1.17.1";
1471
+ var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.17.1";
1472
1472
  var DEFAULT_NAMESPACE = "minecraft";
1473
1473
  var Assets = class {
1474
1474
  /**
@@ -1821,8 +1821,8 @@ var _AssetLoader = class _AssetLoader {
1821
1821
  };
1822
1822
  _AssetLoader.ROOT = DEFAULT_ROOT;
1823
1823
  _AssetLoader._SOURCES = [];
1824
- _AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master"));
1825
- _AssetLoader.addSource("mcassets", new HostedAssetSource(DEFAULT_ROOT));
1824
+ _AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
1825
+ _AssetLoader.addSource("mcassets", new HostedAssetSource(DEFAULT_ROOT, { retryDefaults: false }));
1826
1826
  var AssetLoader = _AssetLoader;
1827
1827
 
1828
1828
  // src/assets/ModelTextures.ts
@@ -5402,24 +5402,55 @@ var _MineRenderScene = class _MineRenderScene extends import_three17.Scene {
5402
5402
  this.stats = new SceneStats();
5403
5403
  this.instanceManager = new InstanceManager();
5404
5404
  this.dirty = true;
5405
+ this.observedObjects = /* @__PURE__ */ new Set();
5406
+ this.onObjectChange = (event) => {
5407
+ var _a;
5408
+ if (((_a = event.target) == null ? void 0 : _a.parent) === this) {
5409
+ this.dirty = true;
5410
+ }
5411
+ };
5405
5412
  this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
5406
5413
  }
5407
- add(...object) {
5408
- this.dirty = true;
5409
- this.stats.objectCount += object.length;
5410
- for (let obj of object) {
5411
- if (isSceneObject(obj)) {
5412
- this.stats.sceneObjectCount++;
5414
+ add(...objects) {
5415
+ for (const object of objects) {
5416
+ this.dirty = true;
5417
+ try {
5418
+ super.add(object);
5419
+ } finally {
5420
+ if ((object == null ? void 0 : object.isObject3D) && object !== this) {
5421
+ this.updateObjectRegistration(object, object.parent === this);
5422
+ }
5413
5423
  }
5414
- obj.addEventListener("change", (event) => {
5415
- this.dirty = true;
5416
- });
5417
5424
  }
5418
- return super.add(...object);
5425
+ return this;
5419
5426
  }
5420
- remove(...object) {
5421
- this.dirty = true;
5422
- return super.remove(...object);
5427
+ remove(...objects) {
5428
+ for (const object of objects) {
5429
+ if (!this.children.includes(object)) continue;
5430
+ this.dirty = true;
5431
+ this.updateObjectRegistration(object, false);
5432
+ try {
5433
+ super.remove(object);
5434
+ } finally {
5435
+ this.updateObjectRegistration(object, object.parent === this);
5436
+ }
5437
+ }
5438
+ return this;
5439
+ }
5440
+ updateObjectRegistration(object, attached) {
5441
+ if (this.observedObjects.has(object) === attached) return;
5442
+ if (attached) {
5443
+ this.observedObjects.add(object);
5444
+ object.addEventListener("change", this.onObjectChange);
5445
+ } else {
5446
+ this.observedObjects.delete(object);
5447
+ object.removeEventListener("change", this.onObjectChange);
5448
+ }
5449
+ const change = attached ? 1 : -1;
5450
+ this.stats.objectCount += change;
5451
+ if (isSceneObject(object)) {
5452
+ this.stats.sceneObjectCount += change;
5453
+ }
5423
5454
  }
5424
5455
  async initAndAdd(...object) {
5425
5456
  this.dirty = true;
@@ -5482,1041 +5513,1140 @@ function isMineRenderScene(obj) {
5482
5513
  }
5483
5514
 
5484
5515
  // src/renderer/Renderer.ts
5485
- var import_three18 = require("three");
5516
+ var import_three19 = require("three");
5486
5517
  var import_ts_deepmerge10 = __toESM(require_dist());
5487
5518
  var import_stats = __toESM(require("stats.js"));
5488
5519
  var import_postprocessing = require("postprocessing");
5489
- var _Renderer = class _Renderer {
5490
- constructor(options) {
5491
- this._dirty = true;
5492
- this._animationTimer = void 0;
5493
- this._animationFrame = void 0;
5494
- this._resizeListener = void 0;
5495
- this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
5496
- this._animationLoop = this.animate.bind(this);
5497
- this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
5498
- this._scene = this.createScene();
5499
- this._camera = this.createCamera();
5500
- this._renderer = this.createRenderer();
5501
- this._composer = this.createComposer();
5502
- if (this.options.render.stats) {
5503
- this._stats = new import_stats.default();
5504
- document.body.appendChild(this._stats.dom);
5505
- }
5506
- this.init();
5507
- }
5508
- //<editor-fold desc="INIT">
5509
- createScene() {
5510
- return new MineRenderScene();
5511
- }
5512
- createCamera() {
5513
- switch (this.options.camera.type) {
5514
- case "perspective":
5515
- default:
5516
- return new import_three18.PerspectiveCamera(
5517
- this.options.camera.perspective.fov,
5518
- this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
5519
- this.options.camera.near,
5520
- this.options.camera.far
5521
- );
5522
- case "orthographic":
5523
- return new import_three18.OrthographicCamera(
5524
- this.options.camera.orthographic.left ?? this.viewWidth / -2,
5525
- this.options.camera.orthographic.right ?? this.viewWidth / 2,
5526
- this.options.camera.orthographic.top ?? this.viewHeight / 2,
5527
- this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
5528
- this.options.camera.near,
5529
- this.options.camera.far
5530
- );
5520
+
5521
+ // src/three/OrbitControls.js
5522
+ var import_three18 = require("three");
5523
+ var _changeEvent = { type: "change" };
5524
+ var _startEvent = { type: "start" };
5525
+ var _endEvent = { type: "end" };
5526
+ var OrbitControls = class extends import_three18.EventDispatcher {
5527
+ constructor(object, domElement) {
5528
+ super();
5529
+ if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
5530
+ if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
5531
+ this.object = object;
5532
+ this.domElement = domElement;
5533
+ this.domElement.style.touchAction = "none";
5534
+ this.enabled = true;
5535
+ this.target = new import_three18.Vector3();
5536
+ this.minDistance = 0;
5537
+ this.maxDistance = Infinity;
5538
+ this.minZoom = 0;
5539
+ this.maxZoom = Infinity;
5540
+ this.minPolarAngle = 0;
5541
+ this.maxPolarAngle = Math.PI;
5542
+ this.minAzimuthAngle = -Infinity;
5543
+ this.maxAzimuthAngle = Infinity;
5544
+ this.enableDamping = false;
5545
+ this.dampingFactor = 0.05;
5546
+ this.enableZoom = true;
5547
+ this.zoomSpeed = 1;
5548
+ this.enableRotate = true;
5549
+ this.rotateSpeed = 1;
5550
+ this.enablePan = true;
5551
+ this.panSpeed = 1;
5552
+ this.screenSpacePanning = true;
5553
+ this.keyPanSpeed = 7;
5554
+ this.autoRotate = false;
5555
+ this.autoRotateSpeed = 2;
5556
+ this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
5557
+ this.mouseButtons = { LEFT: import_three18.MOUSE.ROTATE, MIDDLE: import_three18.MOUSE.DOLLY, RIGHT: import_three18.MOUSE.PAN };
5558
+ this.touches = { ONE: import_three18.TOUCH.ROTATE, TWO: import_three18.TOUCH.DOLLY_PAN };
5559
+ this.target0 = this.target.clone();
5560
+ this.position0 = this.object.position.clone();
5561
+ this.zoom0 = this.object.zoom;
5562
+ this._domElementKeyEvents = null;
5563
+ this.getPolarAngle = function() {
5564
+ return spherical.phi;
5565
+ };
5566
+ this.getAzimuthalAngle = function() {
5567
+ return spherical.theta;
5568
+ };
5569
+ this.getDistance = function() {
5570
+ return this.object.position.distanceTo(this.target);
5571
+ };
5572
+ this.saveState = function() {
5573
+ scope.target0.copy(scope.target);
5574
+ scope.position0.copy(scope.object.position);
5575
+ scope.zoom0 = scope.object.zoom;
5576
+ };
5577
+ this.reset = function() {
5578
+ scope.target.copy(scope.target0);
5579
+ scope.object.position.copy(scope.position0);
5580
+ scope.object.zoom = scope.zoom0;
5581
+ scope.object.updateProjectionMatrix();
5582
+ scope.dispatchEvent(_changeEvent);
5583
+ scope.update();
5584
+ state = STATE.NONE;
5585
+ };
5586
+ this.update = function() {
5587
+ const offset = new import_three18.Vector3();
5588
+ const quat = new import_three18.Quaternion().setFromUnitVectors(object.up, new import_three18.Vector3(0, 1, 0));
5589
+ const quatInverse = quat.clone().invert();
5590
+ const lastPosition = new import_three18.Vector3();
5591
+ const lastQuaternion = new import_three18.Quaternion();
5592
+ const twoPI = 2 * Math.PI;
5593
+ return function update() {
5594
+ const position = scope.object.position;
5595
+ offset.copy(position).sub(scope.target);
5596
+ offset.applyQuaternion(quat);
5597
+ spherical.setFromVector3(offset);
5598
+ if (scope.autoRotate && state === STATE.NONE) {
5599
+ rotateLeft(getAutoRotationAngle());
5600
+ }
5601
+ if (scope.enableDamping) {
5602
+ spherical.theta += sphericalDelta.theta * scope.dampingFactor;
5603
+ spherical.phi += sphericalDelta.phi * scope.dampingFactor;
5604
+ } else {
5605
+ spherical.theta += sphericalDelta.theta;
5606
+ spherical.phi += sphericalDelta.phi;
5607
+ }
5608
+ let min = scope.minAzimuthAngle;
5609
+ let max = scope.maxAzimuthAngle;
5610
+ if (isFinite(min) && isFinite(max)) {
5611
+ if (min < -Math.PI) min += twoPI;
5612
+ else if (min > Math.PI) min -= twoPI;
5613
+ if (max < -Math.PI) max += twoPI;
5614
+ else if (max > Math.PI) max -= twoPI;
5615
+ if (min <= max) {
5616
+ spherical.theta = Math.max(min, Math.min(max, spherical.theta));
5617
+ } else {
5618
+ spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
5619
+ }
5620
+ }
5621
+ spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
5622
+ spherical.makeSafe();
5623
+ spherical.radius *= scale;
5624
+ spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
5625
+ if (scope.enableDamping === true) {
5626
+ scope.target.addScaledVector(panOffset, scope.dampingFactor);
5627
+ } else {
5628
+ scope.target.add(panOffset);
5629
+ }
5630
+ offset.setFromSpherical(spherical);
5631
+ offset.applyQuaternion(quatInverse);
5632
+ position.copy(scope.target).add(offset);
5633
+ scope.object.lookAt(scope.target);
5634
+ if (scope.enableDamping === true) {
5635
+ sphericalDelta.theta *= 1 - scope.dampingFactor;
5636
+ sphericalDelta.phi *= 1 - scope.dampingFactor;
5637
+ panOffset.multiplyScalar(1 - scope.dampingFactor);
5638
+ } else {
5639
+ sphericalDelta.set(0, 0, 0);
5640
+ panOffset.set(0, 0, 0);
5641
+ }
5642
+ scale = 1;
5643
+ if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
5644
+ scope.dispatchEvent(_changeEvent);
5645
+ lastPosition.copy(scope.object.position);
5646
+ lastQuaternion.copy(scope.object.quaternion);
5647
+ zoomChanged = false;
5648
+ return true;
5649
+ }
5650
+ return false;
5651
+ };
5652
+ }();
5653
+ this.dispose = function() {
5654
+ scope.domElement.removeEventListener("contextmenu", onContextMenu);
5655
+ scope.domElement.removeEventListener("pointerdown", onPointerDown);
5656
+ scope.domElement.removeEventListener("pointercancel", onPointerCancel);
5657
+ scope.domElement.removeEventListener("wheel", onMouseWheel);
5658
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
5659
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
5660
+ if (scope._domElementKeyEvents !== null) {
5661
+ scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
5662
+ }
5663
+ };
5664
+ const scope = this;
5665
+ const STATE = {
5666
+ NONE: -1,
5667
+ ROTATE: 0,
5668
+ DOLLY: 1,
5669
+ PAN: 2,
5670
+ TOUCH_ROTATE: 3,
5671
+ TOUCH_PAN: 4,
5672
+ TOUCH_DOLLY_PAN: 5,
5673
+ TOUCH_DOLLY_ROTATE: 6
5674
+ };
5675
+ let state = STATE.NONE;
5676
+ const EPS = 1e-6;
5677
+ const spherical = new import_three18.Spherical();
5678
+ const sphericalDelta = new import_three18.Spherical();
5679
+ let scale = 1;
5680
+ const panOffset = new import_three18.Vector3();
5681
+ let zoomChanged = false;
5682
+ const rotateStart = new import_three18.Vector2();
5683
+ const rotateEnd = new import_three18.Vector2();
5684
+ const rotateDelta = new import_three18.Vector2();
5685
+ const panStart = new import_three18.Vector2();
5686
+ const panEnd = new import_three18.Vector2();
5687
+ const panDelta = new import_three18.Vector2();
5688
+ const dollyStart = new import_three18.Vector2();
5689
+ const dollyEnd = new import_three18.Vector2();
5690
+ const dollyDelta = new import_three18.Vector2();
5691
+ const pointers = [];
5692
+ const pointerPositions = {};
5693
+ function getAutoRotationAngle() {
5694
+ return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
5531
5695
  }
5532
- }
5533
- createRenderer() {
5534
- const renderer = new import_three18.WebGLRenderer({
5535
- antialias: this.options.render.antialias,
5536
- alpha: true,
5537
- powerPreference: "high-performance",
5538
- depth: true
5539
- });
5540
- renderer.setClearColor(0, 0);
5541
- renderer.shadowMap.enabled = true;
5542
- renderer.shadowMap.type = import_three18.PCFSoftShadowMap;
5543
- renderer.outputEncoding = import_three18.LinearEncoding;
5544
- renderer.setSize(this.viewWidth, this.viewHeight);
5545
- return renderer;
5546
- }
5547
- createComposer() {
5548
- const composer = new import_postprocessing.EffectComposer(this.renderer);
5549
- if (!this.options.composer.enabled) return composer;
5550
- composer.setSize(this.viewWidth, this.viewHeight);
5551
- composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
5552
- return composer;
5553
- }
5554
- //</editor-fold>
5555
- init() {
5556
- if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
5557
- window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
5696
+ function getZoomScale() {
5697
+ return Math.pow(0.95, scope.zoomSpeed);
5558
5698
  }
5559
- if (this.options.debug.grid) {
5560
- const gridHelper = new import_three18.GridHelper(128, 16);
5561
- this.scene.add(gridHelper);
5562
- const gridHelper2 = new import_three18.GridHelper(128, 16);
5563
- gridHelper2.rotation.x = 90 * (Math.PI / 180);
5564
- this.scene.add(gridHelper2);
5565
- const gridHelper3 = new import_three18.GridHelper(128, 16);
5566
- gridHelper3.rotation.z = 90 * (Math.PI / 180);
5567
- this.scene.add(gridHelper3);
5699
+ function rotateLeft(angle) {
5700
+ sphericalDelta.theta -= angle;
5568
5701
  }
5569
- if (this.options.debug.axes) {
5570
- const axesHelper = new import_three18.AxesHelper(64);
5571
- this.scene.add(axesHelper);
5702
+ function rotateUp(angle) {
5703
+ sphericalDelta.phi -= angle;
5572
5704
  }
5573
- if (this.options.camera.position) {
5574
- if (isVector3(this.options.camera.position)) {
5575
- this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
5576
- } else if (isTripleArray(this.options.camera.position)) {
5577
- this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
5705
+ const panLeft = function() {
5706
+ const v = new import_three18.Vector3();
5707
+ return function panLeft2(distance, objectMatrix) {
5708
+ v.setFromMatrixColumn(objectMatrix, 0);
5709
+ v.multiplyScalar(-distance);
5710
+ panOffset.add(v);
5711
+ };
5712
+ }();
5713
+ const panUp = function() {
5714
+ const v = new import_three18.Vector3();
5715
+ return function panUp2(distance, objectMatrix) {
5716
+ if (scope.screenSpacePanning === true) {
5717
+ v.setFromMatrixColumn(objectMatrix, 1);
5718
+ } else {
5719
+ v.setFromMatrixColumn(objectMatrix, 0);
5720
+ v.crossVectors(scope.object.up, v);
5721
+ }
5722
+ v.multiplyScalar(distance);
5723
+ panOffset.add(v);
5724
+ };
5725
+ }();
5726
+ const pan = function() {
5727
+ const offset = new import_three18.Vector3();
5728
+ return function pan2(deltaX, deltaY) {
5729
+ const element = scope.domElement;
5730
+ if (scope.object.isPerspectiveCamera) {
5731
+ const position = scope.object.position;
5732
+ offset.copy(position).sub(scope.target);
5733
+ let targetDistance = offset.length();
5734
+ targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
5735
+ panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
5736
+ panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
5737
+ } else if (scope.object.isOrthographicCamera) {
5738
+ panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
5739
+ panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
5740
+ } else {
5741
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
5742
+ scope.enablePan = false;
5743
+ }
5744
+ };
5745
+ }();
5746
+ function dollyOut(dollyScale) {
5747
+ if (scope.object.isPerspectiveCamera) {
5748
+ scale /= dollyScale;
5749
+ } else if (scope.object.isOrthographicCamera) {
5750
+ scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
5751
+ scope.object.updateProjectionMatrix();
5752
+ zoomChanged = true;
5753
+ } else {
5754
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
5755
+ scope.enableZoom = false;
5578
5756
  }
5579
5757
  }
5580
- if (this.options.camera.lookingAt) {
5581
- if (isVector3(this.options.camera.lookingAt)) {
5582
- this.camera.lookAt(this.options.camera.lookingAt);
5583
- } else if (isTripleArray(this.options.camera.lookingAt)) {
5584
- this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
5758
+ function dollyIn(dollyScale) {
5759
+ if (scope.object.isPerspectiveCamera) {
5760
+ scale *= dollyScale;
5761
+ } else if (scope.object.isOrthographicCamera) {
5762
+ scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
5763
+ scope.object.updateProjectionMatrix();
5764
+ zoomChanged = true;
5765
+ } else {
5766
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
5767
+ scope.enableZoom = false;
5585
5768
  }
5586
5769
  }
5587
- if (this.options.render.autoResize) {
5588
- this._resizeListener = () => {
5589
- this.resize(this.viewWidth, this.viewHeight);
5590
- };
5591
- window.addEventListener("resize", this._resizeListener);
5592
- }
5593
- }
5594
- get element() {
5595
- return this._element;
5596
- }
5597
- appendTo(element) {
5598
- this._element = element;
5599
- this._element.appendChild(this.renderer.domElement);
5600
- if (this.viewWidth == 0) {
5601
- console.warn("0 element width");
5770
+ function handleMouseDownRotate(event) {
5771
+ rotateStart.set(event.clientX, event.clientY);
5602
5772
  }
5603
- if (this.viewHeight == 0) {
5604
- console.warn("0 element height");
5773
+ function handleMouseDownDolly(event) {
5774
+ dollyStart.set(event.clientX, event.clientY);
5605
5775
  }
5606
- this.resize(this.viewWidth, this.viewHeight);
5607
- }
5608
- /**
5609
- * Register an EventDispatcher which may update the scene or renderer in order to redraw the scene
5610
- */
5611
- registerEventDispatcher(dispatcher, changeEvent2 = "change") {
5612
- dispatcher.addEventListener(changeEvent2, (event) => {
5613
- this._dirty = true;
5614
- });
5615
- }
5616
- resize(width, height) {
5617
- if (isPerspectiveCamera(this.camera)) {
5618
- this.camera.aspect = width / height;
5619
- this.camera.updateProjectionMatrix();
5620
- } else if (isOrthographicCamera(this.camera)) {
5621
- this.camera.left = width / -2;
5622
- this.camera.right = width / 2;
5623
- this.camera.top = height / 2;
5624
- this.camera.bottom = height / -2;
5625
- this.camera.updateProjectionMatrix();
5776
+ function handleMouseDownPan(event) {
5777
+ panStart.set(event.clientX, event.clientY);
5626
5778
  }
5627
- this.renderer.setSize(width, height);
5628
- this.composer.setSize(width, height);
5629
- }
5630
- //<editor-fold desc="RENDER">
5631
- get dirty() {
5632
- return this._dirty || this.scene.dirty;
5633
- }
5634
- set dirty(dirty) {
5635
- this._dirty = dirty;
5636
- this.scene.dirty = dirty;
5637
- }
5638
- start() {
5639
- stop();
5640
- this.renderer.setAnimationLoop(this._animationLoop);
5641
- }
5642
- stop() {
5643
- this.renderer.setAnimationLoop(null);
5644
- if (this._animationTimer)
5645
- clearTimeout(this._animationTimer);
5646
- this._animationTimer = void 0;
5647
- if (this._animationFrame)
5648
- cancelAnimationFrame(this._animationFrame);
5649
- this._animationFrame = void 0;
5650
- }
5651
- animate(t) {
5652
- if (this._stats) {
5653
- this._stats.begin();
5779
+ function handleMouseMoveRotate(event) {
5780
+ rotateEnd.set(event.clientX, event.clientY);
5781
+ rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
5782
+ const element = scope.domElement;
5783
+ rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
5784
+ rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
5785
+ rotateStart.copy(rotateEnd);
5786
+ scope.update();
5654
5787
  }
5655
- if (this.dirty || this.options.render.renderAlways) {
5656
- if (this.options.composer.enabled) {
5657
- this.composer.render();
5658
- } else {
5659
- this.renderer.render(this.scene, this.camera);
5788
+ function handleMouseMoveDolly(event) {
5789
+ dollyEnd.set(event.clientX, event.clientY);
5790
+ dollyDelta.subVectors(dollyEnd, dollyStart);
5791
+ if (dollyDelta.y > 0) {
5792
+ dollyOut(getZoomScale());
5793
+ } else if (dollyDelta.y < 0) {
5794
+ dollyIn(getZoomScale());
5660
5795
  }
5796
+ dollyStart.copy(dollyEnd);
5797
+ scope.update();
5661
5798
  }
5662
- this.dirty = false;
5663
- if (this._stats) {
5664
- this._stats.end();
5799
+ function handleMouseMovePan(event) {
5800
+ panEnd.set(event.clientX, event.clientY);
5801
+ panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
5802
+ pan(panDelta.x, panDelta.y);
5803
+ panStart.copy(panEnd);
5804
+ scope.update();
5665
5805
  }
5666
- }
5667
- //</editor-fold>
5668
- toImage() {
5669
- return this.renderer.domElement.toDataURL();
5670
- }
5671
- ///
5672
- get attachedToBody() {
5673
- return this.element === document.body;
5674
- }
5675
- get viewWidth() {
5676
- var _a;
5677
- return this.attachedToBody ? window.innerWidth : ((_a = this.element) == null ? void 0 : _a.offsetWidth) || 0;
5678
- }
5679
- get viewHeight() {
5680
- var _a;
5681
- return this.attachedToBody ? window.innerHeight : ((_a = this.element) == null ? void 0 : _a.offsetHeight) || 0;
5682
- }
5683
- get scene() {
5684
- return this._scene;
5685
- }
5686
- get camera() {
5687
- return this._camera;
5688
- }
5689
- get renderer() {
5690
- return this._renderer;
5691
- }
5692
- get composer() {
5693
- return this._composer;
5694
- }
5695
- ///
5696
- };
5697
- _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
5698
- camera: {
5699
- type: "perspective",
5700
- near: 1,
5701
- far: 5e3,
5702
- perspective: {
5703
- aspect: void 0,
5704
- fov: 50
5705
- },
5706
- orthographic: {
5707
- left: void 0,
5708
- right: void 0,
5709
- top: void 0,
5710
- bottom: void 0
5711
- },
5712
- position: new import_three18.Vector3(50, 50, 50),
5713
- lookingAt: new import_three18.Vector3(0, 0, 0)
5714
- },
5715
- render: {
5716
- fpsLimit: 60,
5717
- stats: false,
5718
- antialias: true,
5719
- shade: true,
5720
- autoResize: true,
5721
- renderAlways: false
5722
- },
5723
- composer: {
5724
- enabled: true
5725
- },
5726
- debug: {
5727
- grid: false,
5728
- axes: false
5729
- }
5730
- });
5731
- var Renderer = _Renderer;
5732
-
5733
- // src/skin/Skins.ts
5734
- var Skins = class {
5735
- //<editor-fold desc="Skins">
5736
- static async fromUuidOrUsername(uuidOrUsername) {
5737
- if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
5738
- return this.fromUuid(uuidOrUsername);
5806
+ function handleMouseUp() {
5739
5807
  }
5740
- return this.fromUsername(uuidOrUsername);
5741
- }
5742
- static async fromUuid(uuid) {
5743
- return this.getSkinProxySkinUrl(uuid);
5744
- }
5745
- static async fromUsername(username) {
5746
- return this.usernameToUuid(username).then((uuid) => {
5747
- if (uuid) {
5748
- return this.fromUuid(uuid);
5749
- }
5750
- return void 0;
5751
- });
5752
- }
5753
- static async fromMineSkin(mineskinId) {
5754
- return this.getMineSkin(mineskinId).then((mineskin) => {
5755
- if (mineskin) {
5756
- return mineskin["data"]["texture"]["value"]["urls"]["skins"];
5808
+ function handleMouseWheel(event) {
5809
+ if (event.deltaY < 0) {
5810
+ dollyIn(getZoomScale());
5811
+ } else if (event.deltaY > 0) {
5812
+ dollyOut(getZoomScale());
5757
5813
  }
5758
- return void 0;
5759
- });
5760
- }
5761
- //</editor-fold>
5762
- //<editor-fold desc="Capes">
5763
- static async capeFromUuidOrUsername(uuidOrUsername) {
5764
- if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
5765
- return this.capeFromUuid(uuidOrUsername);
5766
- }
5767
- return this.capeFromUsername(uuidOrUsername);
5768
- }
5769
- static async capeFromUuid(uuid) {
5770
- return this.getSkinProxyCapeUrl(uuid);
5771
- }
5772
- static async capeFromUsername(username) {
5773
- return this.usernameToUuid(username).then((uuid) => {
5774
- if (uuid) {
5775
- return this.capeFromUuid(uuid);
5776
- }
5777
- return void 0;
5778
- });
5779
- }
5780
- static async capeFromCapesDev(uuid, capeType = "minecraft") {
5781
- return this.getCapesDev(uuid, capeType).then((cape) => {
5782
- if (cape) {
5783
- return cape == null ? void 0 : cape.stillImageUrl;
5784
- }
5785
- return void 0;
5786
- });
5787
- }
5788
- //</editor-fold>
5789
- //<editor-fold desc="Helpers">
5790
- static async usernameToUuid(username) {
5791
- return this.usernameToUuidSkinProxy(username);
5792
- }
5793
- static async usernameToUuidSkinProxy(username) {
5794
- return Requests.genericRequest({
5795
- baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
5796
- url: "/uuid/" + username
5797
- }).then((res) => {
5798
- if (res.status === 200) {
5799
- return res.data["id"];
5800
- }
5801
- return void 0;
5802
- }).catch((err) => {
5803
- console.warn(err);
5804
- return void 0;
5805
- });
5806
- }
5807
- static async usernameToUuidMineTools(username) {
5808
- return Requests.genericRequest({
5809
- baseURL: "https://api.minetools.eu",
5810
- url: "/uuid/" + username
5811
- }).then((res) => {
5812
- if (res.status === 200) {
5813
- return res.data["id"];
5814
- }
5815
- return void 0;
5816
- }).catch((err) => {
5817
- console.warn(err);
5818
- return void 0;
5819
- });
5820
- }
5821
- static async getProfileFromMinetools(uuid) {
5822
- return Requests.genericRequest({
5823
- baseURL: "https://api.minetools.eu",
5824
- url: "/profile/" + uuid
5825
- }).then((res) => {
5826
- if (res.status === 200) {
5827
- return res.data;
5828
- }
5829
- });
5830
- }
5831
- static async getMineSkin(mineskinId) {
5832
- return Requests.genericRequest({
5833
- baseURL: "https://api.mineskin.org",
5834
- url: "/get/uuid/" + mineskinId
5835
- }).then((res) => {
5836
- if (res.status === 200) {
5837
- return res.data;
5838
- }
5839
- return void 0;
5840
- }).catch((err) => {
5841
- console.warn(err);
5842
- return void 0;
5843
- });
5844
- }
5845
- static async getCapesDev(uuid, type = "all") {
5846
- return Requests.genericRequest({
5847
- baseURL: "https://api.capes.dev",
5848
- url: "/load/" + uuid + "/" + type
5849
- }).then((res) => {
5850
- if (res.status === 200) {
5851
- return res.data;
5852
- }
5853
- return void 0;
5854
- }).catch((err) => {
5855
- console.warn(err);
5856
- return void 0;
5857
- });
5858
- }
5859
- static getCrafatarSkinUrl(uuid) {
5860
- return "https://crafatar.com/skins/" + uuid;
5861
- }
5862
- static getCrafatarCapeUrl(uuid) {
5863
- return "https://crafatar.com/capes/" + uuid;
5864
- }
5865
- static getMcHeadsSkinUrl(uuid) {
5866
- return "https://mc-heads.net/skin/" + uuid;
5867
- }
5868
- static getMineSkinPlayerSkinUrl(uuid) {
5869
- return "https://mineskin.org/skin/player/" + uuid;
5870
- }
5871
- static getSkinProxySkinUrl(uuid) {
5872
- return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
5873
- }
5874
- static getSkinProxyCapeUrl(uuid) {
5875
- return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
5876
- }
5877
- //</editor-fold>
5878
- };
5879
-
5880
- // src/three/OrbitControls.js
5881
- var import_three20 = require("three");
5882
- var _changeEvent = { type: "change" };
5883
- var _startEvent = { type: "start" };
5884
- var _endEvent = { type: "end" };
5885
- var OrbitControls = class extends import_three20.EventDispatcher {
5886
- constructor(object, domElement) {
5887
- super();
5888
- if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
5889
- if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
5890
- this.object = object;
5891
- this.domElement = domElement;
5892
- this.domElement.style.touchAction = "none";
5893
- this.enabled = true;
5894
- this.target = new import_three20.Vector3();
5895
- this.minDistance = 0;
5896
- this.maxDistance = Infinity;
5897
- this.minZoom = 0;
5898
- this.maxZoom = Infinity;
5899
- this.minPolarAngle = 0;
5900
- this.maxPolarAngle = Math.PI;
5901
- this.minAzimuthAngle = -Infinity;
5902
- this.maxAzimuthAngle = Infinity;
5903
- this.enableDamping = false;
5904
- this.dampingFactor = 0.05;
5905
- this.enableZoom = true;
5906
- this.zoomSpeed = 1;
5907
- this.enableRotate = true;
5908
- this.rotateSpeed = 1;
5909
- this.enablePan = true;
5910
- this.panSpeed = 1;
5911
- this.screenSpacePanning = true;
5912
- this.keyPanSpeed = 7;
5913
- this.autoRotate = false;
5914
- this.autoRotateSpeed = 2;
5915
- this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
5916
- this.mouseButtons = { LEFT: import_three20.MOUSE.ROTATE, MIDDLE: import_three20.MOUSE.DOLLY, RIGHT: import_three20.MOUSE.PAN };
5917
- this.touches = { ONE: import_three20.TOUCH.ROTATE, TWO: import_three20.TOUCH.DOLLY_PAN };
5918
- this.target0 = this.target.clone();
5919
- this.position0 = this.object.position.clone();
5920
- this.zoom0 = this.object.zoom;
5921
- this._domElementKeyEvents = null;
5922
- this.getPolarAngle = function() {
5923
- return spherical.phi;
5924
- };
5925
- this.getAzimuthalAngle = function() {
5926
- return spherical.theta;
5927
- };
5928
- this.getDistance = function() {
5929
- return this.object.position.distanceTo(this.target);
5930
- };
5931
- this.saveState = function() {
5932
- scope.target0.copy(scope.target);
5933
- scope.position0.copy(scope.object.position);
5934
- scope.zoom0 = scope.object.zoom;
5935
- };
5936
- this.reset = function() {
5937
- scope.target.copy(scope.target0);
5938
- scope.object.position.copy(scope.position0);
5939
- scope.object.zoom = scope.zoom0;
5940
- scope.object.updateProjectionMatrix();
5941
- scope.dispatchEvent(_changeEvent);
5942
5814
  scope.update();
5943
- state = STATE.NONE;
5944
- };
5945
- this.update = function() {
5946
- const offset = new import_three20.Vector3();
5947
- const quat = new import_three20.Quaternion().setFromUnitVectors(object.up, new import_three20.Vector3(0, 1, 0));
5948
- const quatInverse = quat.clone().invert();
5949
- const lastPosition = new import_three20.Vector3();
5950
- const lastQuaternion = new import_three20.Quaternion();
5951
- const twoPI = 2 * Math.PI;
5952
- return function update() {
5953
- const position = scope.object.position;
5954
- offset.copy(position).sub(scope.target);
5955
- offset.applyQuaternion(quat);
5956
- spherical.setFromVector3(offset);
5957
- if (scope.autoRotate && state === STATE.NONE) {
5958
- rotateLeft(getAutoRotationAngle());
5959
- }
5960
- if (scope.enableDamping) {
5961
- spherical.theta += sphericalDelta.theta * scope.dampingFactor;
5962
- spherical.phi += sphericalDelta.phi * scope.dampingFactor;
5963
- } else {
5964
- spherical.theta += sphericalDelta.theta;
5965
- spherical.phi += sphericalDelta.phi;
5966
- }
5967
- let min = scope.minAzimuthAngle;
5968
- let max = scope.maxAzimuthAngle;
5969
- if (isFinite(min) && isFinite(max)) {
5970
- if (min < -Math.PI) min += twoPI;
5971
- else if (min > Math.PI) min -= twoPI;
5972
- if (max < -Math.PI) max += twoPI;
5973
- else if (max > Math.PI) max -= twoPI;
5974
- if (min <= max) {
5975
- spherical.theta = Math.max(min, Math.min(max, spherical.theta));
5976
- } else {
5977
- spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
5978
- }
5979
- }
5980
- spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
5981
- spherical.makeSafe();
5982
- spherical.radius *= scale;
5983
- spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
5984
- if (scope.enableDamping === true) {
5985
- scope.target.addScaledVector(panOffset, scope.dampingFactor);
5986
- } else {
5987
- scope.target.add(panOffset);
5988
- }
5989
- offset.setFromSpherical(spherical);
5990
- offset.applyQuaternion(quatInverse);
5991
- position.copy(scope.target).add(offset);
5992
- scope.object.lookAt(scope.target);
5993
- if (scope.enableDamping === true) {
5994
- sphericalDelta.theta *= 1 - scope.dampingFactor;
5995
- sphericalDelta.phi *= 1 - scope.dampingFactor;
5996
- panOffset.multiplyScalar(1 - scope.dampingFactor);
5997
- } else {
5998
- sphericalDelta.set(0, 0, 0);
5999
- panOffset.set(0, 0, 0);
6000
- }
6001
- scale = 1;
6002
- if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
6003
- scope.dispatchEvent(_changeEvent);
6004
- lastPosition.copy(scope.object.position);
6005
- lastQuaternion.copy(scope.object.quaternion);
6006
- zoomChanged = false;
6007
- return true;
6008
- }
6009
- return false;
6010
- };
6011
- }();
6012
- this.dispose = function() {
6013
- scope.domElement.removeEventListener("contextmenu", onContextMenu);
6014
- scope.domElement.removeEventListener("pointerdown", onPointerDown);
6015
- scope.domElement.removeEventListener("pointercancel", onPointerCancel);
6016
- scope.domElement.removeEventListener("wheel", onMouseWheel);
6017
- scope.domElement.removeEventListener("pointermove", onPointerMove);
6018
- scope.domElement.removeEventListener("pointerup", onPointerUp);
6019
- if (scope._domElementKeyEvents !== null) {
6020
- scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
6021
- }
6022
- };
6023
- const scope = this;
6024
- const STATE = {
6025
- NONE: -1,
6026
- ROTATE: 0,
6027
- DOLLY: 1,
6028
- PAN: 2,
6029
- TOUCH_ROTATE: 3,
6030
- TOUCH_PAN: 4,
6031
- TOUCH_DOLLY_PAN: 5,
6032
- TOUCH_DOLLY_ROTATE: 6
6033
- };
6034
- let state = STATE.NONE;
6035
- const EPS = 1e-6;
6036
- const spherical = new import_three20.Spherical();
6037
- const sphericalDelta = new import_three20.Spherical();
6038
- let scale = 1;
6039
- const panOffset = new import_three20.Vector3();
6040
- let zoomChanged = false;
6041
- const rotateStart = new import_three20.Vector2();
6042
- const rotateEnd = new import_three20.Vector2();
6043
- const rotateDelta = new import_three20.Vector2();
6044
- const panStart = new import_three20.Vector2();
6045
- const panEnd = new import_three20.Vector2();
6046
- const panDelta = new import_three20.Vector2();
6047
- const dollyStart = new import_three20.Vector2();
6048
- const dollyEnd = new import_three20.Vector2();
6049
- const dollyDelta = new import_three20.Vector2();
6050
- const pointers = [];
6051
- const pointerPositions = {};
6052
- function getAutoRotationAngle() {
6053
- return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
6054
5815
  }
6055
- function getZoomScale() {
6056
- return Math.pow(0.95, scope.zoomSpeed);
6057
- }
6058
- function rotateLeft(angle) {
6059
- sphericalDelta.theta -= angle;
6060
- }
6061
- function rotateUp(angle) {
6062
- sphericalDelta.phi -= angle;
5816
+ function handleKeyDown(event) {
5817
+ let needsUpdate = false;
5818
+ switch (event.code) {
5819
+ case scope.keys.UP:
5820
+ pan(0, scope.keyPanSpeed);
5821
+ needsUpdate = true;
5822
+ break;
5823
+ case scope.keys.BOTTOM:
5824
+ pan(0, -scope.keyPanSpeed);
5825
+ needsUpdate = true;
5826
+ break;
5827
+ case scope.keys.LEFT:
5828
+ pan(scope.keyPanSpeed, 0);
5829
+ needsUpdate = true;
5830
+ break;
5831
+ case scope.keys.RIGHT:
5832
+ pan(-scope.keyPanSpeed, 0);
5833
+ needsUpdate = true;
5834
+ break;
5835
+ }
5836
+ if (needsUpdate) {
5837
+ event.preventDefault();
5838
+ scope.update();
5839
+ }
6063
5840
  }
6064
- const panLeft = function() {
6065
- const v = new import_three20.Vector3();
6066
- return function panLeft2(distance, objectMatrix) {
6067
- v.setFromMatrixColumn(objectMatrix, 0);
6068
- v.multiplyScalar(-distance);
6069
- panOffset.add(v);
6070
- };
6071
- }();
6072
- const panUp = function() {
6073
- const v = new import_three20.Vector3();
6074
- return function panUp2(distance, objectMatrix) {
6075
- if (scope.screenSpacePanning === true) {
6076
- v.setFromMatrixColumn(objectMatrix, 1);
6077
- } else {
6078
- v.setFromMatrixColumn(objectMatrix, 0);
6079
- v.crossVectors(scope.object.up, v);
6080
- }
6081
- v.multiplyScalar(distance);
6082
- panOffset.add(v);
6083
- };
6084
- }();
6085
- const pan = function() {
6086
- const offset = new import_three20.Vector3();
6087
- return function pan2(deltaX, deltaY) {
6088
- const element = scope.domElement;
6089
- if (scope.object.isPerspectiveCamera) {
6090
- const position = scope.object.position;
6091
- offset.copy(position).sub(scope.target);
6092
- let targetDistance = offset.length();
6093
- targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
6094
- panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
6095
- panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
6096
- } else if (scope.object.isOrthographicCamera) {
6097
- panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
6098
- panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
6099
- } else {
6100
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
6101
- scope.enablePan = false;
6102
- }
6103
- };
6104
- }();
6105
- function dollyOut(dollyScale) {
6106
- if (scope.object.isPerspectiveCamera) {
6107
- scale /= dollyScale;
6108
- } else if (scope.object.isOrthographicCamera) {
6109
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
6110
- scope.object.updateProjectionMatrix();
6111
- zoomChanged = true;
5841
+ function handleTouchStartRotate() {
5842
+ if (pointers.length === 1) {
5843
+ rotateStart.set(pointers[0].pageX, pointers[0].pageY);
6112
5844
  } else {
6113
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
6114
- scope.enableZoom = false;
5845
+ const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
5846
+ const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
5847
+ rotateStart.set(x, y);
6115
5848
  }
6116
5849
  }
6117
- function dollyIn(dollyScale) {
6118
- if (scope.object.isPerspectiveCamera) {
6119
- scale *= dollyScale;
6120
- } else if (scope.object.isOrthographicCamera) {
6121
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
6122
- scope.object.updateProjectionMatrix();
6123
- zoomChanged = true;
5850
+ function handleTouchStartPan() {
5851
+ if (pointers.length === 1) {
5852
+ panStart.set(pointers[0].pageX, pointers[0].pageY);
6124
5853
  } else {
6125
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
6126
- scope.enableZoom = false;
5854
+ const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
5855
+ const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
5856
+ panStart.set(x, y);
6127
5857
  }
6128
5858
  }
6129
- function handleMouseDownRotate(event) {
6130
- rotateStart.set(event.clientX, event.clientY);
5859
+ function handleTouchStartDolly() {
5860
+ const dx = pointers[0].pageX - pointers[1].pageX;
5861
+ const dy = pointers[0].pageY - pointers[1].pageY;
5862
+ const distance = Math.sqrt(dx * dx + dy * dy);
5863
+ dollyStart.set(0, distance);
6131
5864
  }
6132
- function handleMouseDownDolly(event) {
6133
- dollyStart.set(event.clientX, event.clientY);
5865
+ function handleTouchStartDollyPan() {
5866
+ if (scope.enableZoom) handleTouchStartDolly();
5867
+ if (scope.enablePan) handleTouchStartPan();
6134
5868
  }
6135
- function handleMouseDownPan(event) {
6136
- panStart.set(event.clientX, event.clientY);
5869
+ function handleTouchStartDollyRotate() {
5870
+ if (scope.enableZoom) handleTouchStartDolly();
5871
+ if (scope.enableRotate) handleTouchStartRotate();
6137
5872
  }
6138
- function handleMouseMoveRotate(event) {
6139
- rotateEnd.set(event.clientX, event.clientY);
5873
+ function handleTouchMoveRotate(event) {
5874
+ if (pointers.length == 1) {
5875
+ rotateEnd.set(event.pageX, event.pageY);
5876
+ } else {
5877
+ const position = getSecondPointerPosition(event);
5878
+ const x = 0.5 * (event.pageX + position.x);
5879
+ const y = 0.5 * (event.pageY + position.y);
5880
+ rotateEnd.set(x, y);
5881
+ }
6140
5882
  rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
6141
5883
  const element = scope.domElement;
6142
5884
  rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
6143
5885
  rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
6144
5886
  rotateStart.copy(rotateEnd);
6145
- scope.update();
6146
5887
  }
6147
- function handleMouseMoveDolly(event) {
6148
- dollyEnd.set(event.clientX, event.clientY);
6149
- dollyDelta.subVectors(dollyEnd, dollyStart);
6150
- if (dollyDelta.y > 0) {
6151
- dollyOut(getZoomScale());
6152
- } else if (dollyDelta.y < 0) {
6153
- dollyIn(getZoomScale());
5888
+ function handleTouchMovePan(event) {
5889
+ if (pointers.length === 1) {
5890
+ panEnd.set(event.pageX, event.pageY);
5891
+ } else {
5892
+ const position = getSecondPointerPosition(event);
5893
+ const x = 0.5 * (event.pageX + position.x);
5894
+ const y = 0.5 * (event.pageY + position.y);
5895
+ panEnd.set(x, y);
6154
5896
  }
6155
- dollyStart.copy(dollyEnd);
6156
- scope.update();
6157
- }
6158
- function handleMouseMovePan(event) {
6159
- panEnd.set(event.clientX, event.clientY);
6160
5897
  panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
6161
5898
  pan(panDelta.x, panDelta.y);
6162
5899
  panStart.copy(panEnd);
6163
- scope.update();
6164
5900
  }
6165
- function handleMouseUp() {
5901
+ function handleTouchMoveDolly(event) {
5902
+ const position = getSecondPointerPosition(event);
5903
+ const dx = event.pageX - position.x;
5904
+ const dy = event.pageY - position.y;
5905
+ const distance = Math.sqrt(dx * dx + dy * dy);
5906
+ dollyEnd.set(0, distance);
5907
+ dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
5908
+ dollyOut(dollyDelta.y);
5909
+ dollyStart.copy(dollyEnd);
5910
+ }
5911
+ function handleTouchMoveDollyPan(event) {
5912
+ if (scope.enableZoom) handleTouchMoveDolly(event);
5913
+ if (scope.enablePan) handleTouchMovePan(event);
5914
+ }
5915
+ function handleTouchMoveDollyRotate(event) {
5916
+ if (scope.enableZoom) handleTouchMoveDolly(event);
5917
+ if (scope.enableRotate) handleTouchMoveRotate(event);
5918
+ }
5919
+ function handleTouchEnd() {
5920
+ }
5921
+ function onPointerDown(event) {
5922
+ if (scope.enabled === false) return;
5923
+ if (pointers.length === 0) {
5924
+ scope.domElement.setPointerCapture(event.pointerId);
5925
+ scope.domElement.addEventListener("pointermove", onPointerMove);
5926
+ scope.domElement.addEventListener("pointerup", onPointerUp);
5927
+ }
5928
+ addPointer(event);
5929
+ if (event.pointerType === "touch") {
5930
+ onTouchStart(event);
5931
+ } else {
5932
+ onMouseDown(event);
5933
+ }
5934
+ }
5935
+ function onPointerMove(event) {
5936
+ if (scope.enabled === false) return;
5937
+ if (event.pointerType === "touch") {
5938
+ onTouchMove(event);
5939
+ } else {
5940
+ onMouseMove(event);
5941
+ }
5942
+ }
5943
+ function onPointerUp(event) {
5944
+ if (scope.enabled === false) return;
5945
+ if (event.pointerType === "touch") {
5946
+ onTouchEnd();
5947
+ } else {
5948
+ onMouseUp(event);
5949
+ }
5950
+ removePointer(event);
5951
+ if (pointers.length === 0) {
5952
+ scope.domElement.releasePointerCapture(event.pointerId);
5953
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
5954
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
5955
+ }
5956
+ }
5957
+ function onPointerCancel(event) {
5958
+ removePointer(event);
5959
+ }
5960
+ function onMouseDown(event) {
5961
+ let mouseAction;
5962
+ switch (event.button) {
5963
+ case 0:
5964
+ mouseAction = scope.mouseButtons.LEFT;
5965
+ break;
5966
+ case 1:
5967
+ mouseAction = scope.mouseButtons.MIDDLE;
5968
+ break;
5969
+ case 2:
5970
+ mouseAction = scope.mouseButtons.RIGHT;
5971
+ break;
5972
+ default:
5973
+ mouseAction = -1;
5974
+ }
5975
+ switch (mouseAction) {
5976
+ case import_three18.MOUSE.DOLLY:
5977
+ if (scope.enableZoom === false) return;
5978
+ handleMouseDownDolly(event);
5979
+ state = STATE.DOLLY;
5980
+ break;
5981
+ case import_three18.MOUSE.ROTATE:
5982
+ if (event.ctrlKey || event.metaKey || event.shiftKey) {
5983
+ if (scope.enablePan === false) return;
5984
+ handleMouseDownPan(event);
5985
+ state = STATE.PAN;
5986
+ } else {
5987
+ if (scope.enableRotate === false) return;
5988
+ handleMouseDownRotate(event);
5989
+ state = STATE.ROTATE;
5990
+ }
5991
+ break;
5992
+ case import_three18.MOUSE.PAN:
5993
+ if (event.ctrlKey || event.metaKey || event.shiftKey) {
5994
+ if (scope.enableRotate === false) return;
5995
+ handleMouseDownRotate(event);
5996
+ state = STATE.ROTATE;
5997
+ } else {
5998
+ if (scope.enablePan === false) return;
5999
+ handleMouseDownPan(event);
6000
+ state = STATE.PAN;
6001
+ }
6002
+ break;
6003
+ default:
6004
+ state = STATE.NONE;
6005
+ }
6006
+ if (state !== STATE.NONE) {
6007
+ scope.dispatchEvent(_startEvent);
6008
+ }
6009
+ }
6010
+ function onMouseMove(event) {
6011
+ if (scope.enabled === false) return;
6012
+ switch (state) {
6013
+ case STATE.ROTATE:
6014
+ if (scope.enableRotate === false) return;
6015
+ handleMouseMoveRotate(event);
6016
+ break;
6017
+ case STATE.DOLLY:
6018
+ if (scope.enableZoom === false) return;
6019
+ handleMouseMoveDolly(event);
6020
+ break;
6021
+ case STATE.PAN:
6022
+ if (scope.enablePan === false) return;
6023
+ handleMouseMovePan(event);
6024
+ break;
6025
+ }
6026
+ }
6027
+ function onMouseUp(event) {
6028
+ handleMouseUp(event);
6029
+ scope.dispatchEvent(_endEvent);
6030
+ state = STATE.NONE;
6031
+ }
6032
+ function onMouseWheel(event) {
6033
+ if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
6034
+ event.preventDefault();
6035
+ scope.dispatchEvent(_startEvent);
6036
+ handleMouseWheel(event);
6037
+ scope.dispatchEvent(_endEvent);
6038
+ }
6039
+ function onKeyDown(event) {
6040
+ if (scope.enabled === false || scope.enablePan === false) return;
6041
+ handleKeyDown(event);
6166
6042
  }
6167
- function handleMouseWheel(event) {
6168
- if (event.deltaY < 0) {
6169
- dollyIn(getZoomScale());
6170
- } else if (event.deltaY > 0) {
6171
- dollyOut(getZoomScale());
6043
+ function onTouchStart(event) {
6044
+ trackPointer(event);
6045
+ switch (pointers.length) {
6046
+ case 1:
6047
+ switch (scope.touches.ONE) {
6048
+ case import_three18.TOUCH.ROTATE:
6049
+ if (scope.enableRotate === false) return;
6050
+ handleTouchStartRotate();
6051
+ state = STATE.TOUCH_ROTATE;
6052
+ break;
6053
+ case import_three18.TOUCH.PAN:
6054
+ if (scope.enablePan === false) return;
6055
+ handleTouchStartPan();
6056
+ state = STATE.TOUCH_PAN;
6057
+ break;
6058
+ default:
6059
+ state = STATE.NONE;
6060
+ }
6061
+ break;
6062
+ case 2:
6063
+ switch (scope.touches.TWO) {
6064
+ case import_three18.TOUCH.DOLLY_PAN:
6065
+ if (scope.enableZoom === false && scope.enablePan === false) return;
6066
+ handleTouchStartDollyPan();
6067
+ state = STATE.TOUCH_DOLLY_PAN;
6068
+ break;
6069
+ case import_three18.TOUCH.DOLLY_ROTATE:
6070
+ if (scope.enableZoom === false && scope.enableRotate === false) return;
6071
+ handleTouchStartDollyRotate();
6072
+ state = STATE.TOUCH_DOLLY_ROTATE;
6073
+ break;
6074
+ default:
6075
+ state = STATE.NONE;
6076
+ }
6077
+ break;
6078
+ default:
6079
+ state = STATE.NONE;
6080
+ }
6081
+ if (state !== STATE.NONE) {
6082
+ scope.dispatchEvent(_startEvent);
6172
6083
  }
6173
- scope.update();
6174
6084
  }
6175
- function handleKeyDown(event) {
6176
- let needsUpdate = false;
6177
- switch (event.code) {
6178
- case scope.keys.UP:
6179
- pan(0, scope.keyPanSpeed);
6180
- needsUpdate = true;
6085
+ function onTouchMove(event) {
6086
+ trackPointer(event);
6087
+ switch (state) {
6088
+ case STATE.TOUCH_ROTATE:
6089
+ if (scope.enableRotate === false) return;
6090
+ handleTouchMoveRotate(event);
6091
+ scope.update();
6181
6092
  break;
6182
- case scope.keys.BOTTOM:
6183
- pan(0, -scope.keyPanSpeed);
6184
- needsUpdate = true;
6093
+ case STATE.TOUCH_PAN:
6094
+ if (scope.enablePan === false) return;
6095
+ handleTouchMovePan(event);
6096
+ scope.update();
6185
6097
  break;
6186
- case scope.keys.LEFT:
6187
- pan(scope.keyPanSpeed, 0);
6188
- needsUpdate = true;
6098
+ case STATE.TOUCH_DOLLY_PAN:
6099
+ if (scope.enableZoom === false && scope.enablePan === false) return;
6100
+ handleTouchMoveDollyPan(event);
6101
+ scope.update();
6189
6102
  break;
6190
- case scope.keys.RIGHT:
6191
- pan(-scope.keyPanSpeed, 0);
6192
- needsUpdate = true;
6103
+ case STATE.TOUCH_DOLLY_ROTATE:
6104
+ if (scope.enableZoom === false && scope.enableRotate === false) return;
6105
+ handleTouchMoveDollyRotate(event);
6106
+ scope.update();
6193
6107
  break;
6194
- }
6195
- if (needsUpdate) {
6196
- event.preventDefault();
6197
- scope.update();
6108
+ default:
6109
+ state = STATE.NONE;
6198
6110
  }
6199
6111
  }
6200
- function handleTouchStartRotate() {
6201
- if (pointers.length === 1) {
6202
- rotateStart.set(pointers[0].pageX, pointers[0].pageY);
6203
- } else {
6204
- const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
6205
- const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
6206
- rotateStart.set(x, y);
6112
+ function onTouchEnd(event) {
6113
+ handleTouchEnd(event);
6114
+ scope.dispatchEvent(_endEvent);
6115
+ state = STATE.NONE;
6116
+ }
6117
+ function onContextMenu(event) {
6118
+ if (scope.enabled === false) return;
6119
+ event.preventDefault();
6120
+ }
6121
+ function addPointer(event) {
6122
+ pointers.push(event);
6123
+ }
6124
+ function removePointer(event) {
6125
+ delete pointerPositions[event.pointerId];
6126
+ for (let i = 0; i < pointers.length; i++) {
6127
+ if (pointers[i].pointerId == event.pointerId) {
6128
+ pointers.splice(i, 1);
6129
+ return;
6130
+ }
6207
6131
  }
6208
6132
  }
6209
- function handleTouchStartPan() {
6210
- if (pointers.length === 1) {
6211
- panStart.set(pointers[0].pageX, pointers[0].pageY);
6212
- } else {
6213
- const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
6214
- const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
6215
- panStart.set(x, y);
6133
+ function trackPointer(event) {
6134
+ let position = pointerPositions[event.pointerId];
6135
+ if (position === void 0) {
6136
+ position = new import_three18.Vector2();
6137
+ pointerPositions[event.pointerId] = position;
6216
6138
  }
6139
+ position.set(event.pageX, event.pageY);
6217
6140
  }
6218
- function handleTouchStartDolly() {
6219
- const dx = pointers[0].pageX - pointers[1].pageX;
6220
- const dy = pointers[0].pageY - pointers[1].pageY;
6221
- const distance = Math.sqrt(dx * dx + dy * dy);
6222
- dollyStart.set(0, distance);
6141
+ function getSecondPointerPosition(event) {
6142
+ const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
6143
+ return pointerPositions[pointer.pointerId];
6223
6144
  }
6224
- function handleTouchStartDollyPan() {
6225
- if (scope.enableZoom) handleTouchStartDolly();
6226
- if (scope.enablePan) handleTouchStartPan();
6145
+ scope.domElement.addEventListener("contextmenu", onContextMenu);
6146
+ scope.domElement.addEventListener("pointerdown", onPointerDown);
6147
+ scope.domElement.addEventListener("pointercancel", onPointerCancel);
6148
+ scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
6149
+ this.update();
6150
+ }
6151
+ };
6152
+ var MapControls = class extends OrbitControls {
6153
+ constructor(object, domElement) {
6154
+ super(object, domElement);
6155
+ this.screenSpacePanning = false;
6156
+ this.mouseButtons.LEFT = import_three18.MOUSE.PAN;
6157
+ this.mouseButtons.RIGHT = import_three18.MOUSE.ROTATE;
6158
+ this.touches.ONE = import_three18.TOUCH.PAN;
6159
+ this.touches.TWO = import_three18.TOUCH.DOLLY_ROTATE;
6160
+ }
6161
+ };
6162
+
6163
+ // src/renderer/Renderer.ts
6164
+ var _Renderer = class _Renderer {
6165
+ constructor(options) {
6166
+ this._dirty = true;
6167
+ this._animationTimer = void 0;
6168
+ this._animationFrame = void 0;
6169
+ this._resizeListener = void 0;
6170
+ this._disposed = false;
6171
+ this._debugHelpers = [];
6172
+ this._eventDispatchers = /* @__PURE__ */ new Map();
6173
+ this._changeListener = () => {
6174
+ this._dirty = true;
6175
+ };
6176
+ this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6177
+ this._animationLoop = this.animate.bind(this);
6178
+ this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6179
+ this._scene = this.createScene();
6180
+ this._camera = this.createCamera();
6181
+ this._renderer = this.createRenderer();
6182
+ this._composer = this.createComposer();
6183
+ if (this.options.render.stats) {
6184
+ this._stats = new import_stats.default();
6185
+ document.body.appendChild(this._stats.dom);
6227
6186
  }
6228
- function handleTouchStartDollyRotate() {
6229
- if (scope.enableZoom) handleTouchStartDolly();
6230
- if (scope.enableRotate) handleTouchStartRotate();
6187
+ this.init();
6188
+ this._controls = this.createControls();
6189
+ }
6190
+ //<editor-fold desc="INIT">
6191
+ createScene() {
6192
+ return new MineRenderScene();
6193
+ }
6194
+ createCamera() {
6195
+ switch (this.options.camera.type) {
6196
+ case "perspective":
6197
+ default:
6198
+ return new import_three19.PerspectiveCamera(
6199
+ this.options.camera.perspective.fov,
6200
+ this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
6201
+ this.options.camera.near,
6202
+ this.options.camera.far
6203
+ );
6204
+ case "orthographic":
6205
+ return new import_three19.OrthographicCamera(
6206
+ this.options.camera.orthographic.left ?? this.viewWidth / -2,
6207
+ this.options.camera.orthographic.right ?? this.viewWidth / 2,
6208
+ this.options.camera.orthographic.top ?? this.viewHeight / 2,
6209
+ this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
6210
+ this.options.camera.near,
6211
+ this.options.camera.far
6212
+ );
6231
6213
  }
6232
- function handleTouchMoveRotate(event) {
6233
- if (pointers.length == 1) {
6234
- rotateEnd.set(event.pageX, event.pageY);
6235
- } else {
6236
- const position = getSecondPointerPosition(event);
6237
- const x = 0.5 * (event.pageX + position.x);
6238
- const y = 0.5 * (event.pageY + position.y);
6239
- rotateEnd.set(x, y);
6240
- }
6241
- rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
6242
- const element = scope.domElement;
6243
- rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
6244
- rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
6245
- rotateStart.copy(rotateEnd);
6214
+ }
6215
+ createRenderer() {
6216
+ const renderer = new import_three19.WebGLRenderer({
6217
+ antialias: this.options.render.antialias,
6218
+ alpha: true,
6219
+ powerPreference: "high-performance",
6220
+ depth: true
6221
+ });
6222
+ renderer.setClearColor(0, 0);
6223
+ renderer.shadowMap.enabled = true;
6224
+ renderer.shadowMap.type = import_three19.PCFSoftShadowMap;
6225
+ renderer.outputEncoding = import_three19.LinearEncoding;
6226
+ renderer.setSize(this.viewWidth, this.viewHeight);
6227
+ return renderer;
6228
+ }
6229
+ createComposer() {
6230
+ const composer = new import_postprocessing.EffectComposer(this.renderer);
6231
+ if (!this.options.composer.enabled) return composer;
6232
+ composer.setSize(this.viewWidth, this.viewHeight);
6233
+ composer.addPass(new import_postprocessing.RenderPass(this.scene, this.camera));
6234
+ return composer;
6235
+ }
6236
+ createControls() {
6237
+ var _a;
6238
+ if (!((_a = this.options.controls) == null ? void 0 : _a.enabled)) return void 0;
6239
+ const position = this.camera.position.clone();
6240
+ const controls = new OrbitControls(this.camera, this.renderer.domElement);
6241
+ this.camera.position.copy(position);
6242
+ const target = this.options.camera.lookingAt;
6243
+ if (isVector3(target)) {
6244
+ controls.target.copy(target);
6245
+ } else if (isTripleArray(target)) {
6246
+ controls.target.set(target[0], target[1], target[2]);
6247
+ }
6248
+ controls.update();
6249
+ controls.saveState();
6250
+ this.registerEventDispatcher(controls);
6251
+ return controls;
6252
+ }
6253
+ //</editor-fold>
6254
+ init() {
6255
+ if (this._disposed) return;
6256
+ if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
6257
+ window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
6246
6258
  }
6247
- function handleTouchMovePan(event) {
6248
- if (pointers.length === 1) {
6249
- panEnd.set(event.pageX, event.pageY);
6250
- } else {
6251
- const position = getSecondPointerPosition(event);
6252
- const x = 0.5 * (event.pageX + position.x);
6253
- const y = 0.5 * (event.pageY + position.y);
6254
- panEnd.set(x, y);
6259
+ if (this.options.debug.grid) {
6260
+ const gridHelper = new import_three19.GridHelper(128, 16);
6261
+ this._debugHelpers.push(gridHelper);
6262
+ this.scene.add(gridHelper);
6263
+ const gridHelper2 = new import_three19.GridHelper(128, 16);
6264
+ this._debugHelpers.push(gridHelper2);
6265
+ gridHelper2.rotation.x = 90 * (Math.PI / 180);
6266
+ this.scene.add(gridHelper2);
6267
+ const gridHelper3 = new import_three19.GridHelper(128, 16);
6268
+ this._debugHelpers.push(gridHelper3);
6269
+ gridHelper3.rotation.z = 90 * (Math.PI / 180);
6270
+ this.scene.add(gridHelper3);
6271
+ }
6272
+ if (this.options.debug.axes) {
6273
+ const axesHelper = new import_three19.AxesHelper(64);
6274
+ this._debugHelpers.push(axesHelper);
6275
+ this.scene.add(axesHelper);
6276
+ }
6277
+ if (this.options.camera.position) {
6278
+ if (isVector3(this.options.camera.position)) {
6279
+ this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
6280
+ } else if (isTripleArray(this.options.camera.position)) {
6281
+ this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
6255
6282
  }
6256
- panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
6257
- pan(panDelta.x, panDelta.y);
6258
- panStart.copy(panEnd);
6259
6283
  }
6260
- function handleTouchMoveDolly(event) {
6261
- const position = getSecondPointerPosition(event);
6262
- const dx = event.pageX - position.x;
6263
- const dy = event.pageY - position.y;
6264
- const distance = Math.sqrt(dx * dx + dy * dy);
6265
- dollyEnd.set(0, distance);
6266
- dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
6267
- dollyOut(dollyDelta.y);
6268
- dollyStart.copy(dollyEnd);
6284
+ if (this.options.camera.lookingAt) {
6285
+ if (isVector3(this.options.camera.lookingAt)) {
6286
+ this.camera.lookAt(this.options.camera.lookingAt);
6287
+ } else if (isTripleArray(this.options.camera.lookingAt)) {
6288
+ this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
6289
+ }
6269
6290
  }
6270
- function handleTouchMoveDollyPan(event) {
6271
- if (scope.enableZoom) handleTouchMoveDolly(event);
6272
- if (scope.enablePan) handleTouchMovePan(event);
6291
+ if (this.options.render.autoResize && !this._resizeListener) {
6292
+ this._resizeListener = () => {
6293
+ this.resize(this.viewWidth, this.viewHeight);
6294
+ };
6295
+ window.addEventListener("resize", this._resizeListener);
6273
6296
  }
6274
- function handleTouchMoveDollyRotate(event) {
6275
- if (scope.enableZoom) handleTouchMoveDolly(event);
6276
- if (scope.enableRotate) handleTouchMoveRotate(event);
6297
+ }
6298
+ get element() {
6299
+ return this._element;
6300
+ }
6301
+ appendTo(element) {
6302
+ if (this._disposed) return;
6303
+ this._element = element;
6304
+ this._element.appendChild(this.renderer.domElement);
6305
+ if (this.viewWidth == 0) {
6306
+ console.warn("0 element width");
6277
6307
  }
6278
- function handleTouchEnd() {
6308
+ if (this.viewHeight == 0) {
6309
+ console.warn("0 element height");
6279
6310
  }
6280
- function onPointerDown(event) {
6281
- if (scope.enabled === false) return;
6282
- if (pointers.length === 0) {
6283
- scope.domElement.setPointerCapture(event.pointerId);
6284
- scope.domElement.addEventListener("pointermove", onPointerMove);
6285
- scope.domElement.addEventListener("pointerup", onPointerUp);
6286
- }
6287
- addPointer(event);
6288
- if (event.pointerType === "touch") {
6289
- onTouchStart(event);
6290
- } else {
6291
- onMouseDown(event);
6292
- }
6311
+ this.resize(this.viewWidth, this.viewHeight);
6312
+ }
6313
+ /**
6314
+ * Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
6315
+ * The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
6316
+ */
6317
+ registerEventDispatcher(dispatcher, changeEvent2 = "change") {
6318
+ if (this._disposed) return;
6319
+ let events = this._eventDispatchers.get(dispatcher);
6320
+ if (!events) {
6321
+ events = /* @__PURE__ */ new Set();
6322
+ this._eventDispatchers.set(dispatcher, events);
6293
6323
  }
6294
- function onPointerMove(event) {
6295
- if (scope.enabled === false) return;
6296
- if (event.pointerType === "touch") {
6297
- onTouchMove(event);
6298
- } else {
6299
- onMouseMove(event);
6300
- }
6324
+ if (events.has(changeEvent2)) return;
6325
+ events.add(changeEvent2);
6326
+ dispatcher.addEventListener(changeEvent2, this._changeListener);
6327
+ }
6328
+ resize(width, height) {
6329
+ if (this._disposed) return;
6330
+ if (isPerspectiveCamera(this.camera)) {
6331
+ this.camera.aspect = width / height;
6332
+ this.camera.updateProjectionMatrix();
6333
+ } else if (isOrthographicCamera(this.camera)) {
6334
+ this.camera.left = width / -2;
6335
+ this.camera.right = width / 2;
6336
+ this.camera.top = height / 2;
6337
+ this.camera.bottom = height / -2;
6338
+ this.camera.updateProjectionMatrix();
6301
6339
  }
6302
- function onPointerUp(event) {
6303
- if (scope.enabled === false) return;
6304
- if (event.pointerType === "touch") {
6305
- onTouchEnd();
6340
+ this.renderer.setSize(width, height);
6341
+ this.composer.setSize(width, height);
6342
+ this._dirty = true;
6343
+ }
6344
+ //<editor-fold desc="RENDER">
6345
+ get dirty() {
6346
+ return this._dirty || this.scene.dirty;
6347
+ }
6348
+ set dirty(dirty) {
6349
+ this._dirty = dirty;
6350
+ this.scene.dirty = dirty;
6351
+ }
6352
+ start() {
6353
+ if (this._disposed) return;
6354
+ this.stop();
6355
+ this.renderer.setAnimationLoop(this._animationLoop);
6356
+ }
6357
+ stop() {
6358
+ if (this._disposed) return;
6359
+ this.renderer.setAnimationLoop(null);
6360
+ if (this._animationTimer)
6361
+ clearTimeout(this._animationTimer);
6362
+ this._animationTimer = void 0;
6363
+ if (this._animationFrame)
6364
+ cancelAnimationFrame(this._animationFrame);
6365
+ this._animationFrame = void 0;
6366
+ }
6367
+ /**
6368
+ * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
6369
+ * renderer cannot be restarted. Scene objects are detached; shared assets and caller-owned
6370
+ * controls must be managed by their owners.
6371
+ */
6372
+ dispose() {
6373
+ var _a;
6374
+ if (this._disposed) return;
6375
+ this.stop();
6376
+ this._disposed = true;
6377
+ if (this._resizeListener) {
6378
+ window.removeEventListener("resize", this._resizeListener);
6379
+ this._resizeListener = void 0;
6380
+ }
6381
+ for (const [dispatcher, events] of this._eventDispatchers) {
6382
+ for (const event of events) {
6383
+ dispatcher.removeEventListener(event, this._changeListener);
6384
+ }
6385
+ }
6386
+ this._eventDispatchers.clear();
6387
+ (_a = this._stats) == null ? void 0 : _a.dom.remove();
6388
+ this._stats = void 0;
6389
+ this.renderer.domElement.remove();
6390
+ this._element = void 0;
6391
+ if (this._controls) {
6392
+ const controls = this._controls;
6393
+ this._controls = void 0;
6394
+ controls.enabled = false;
6395
+ controls.dispose();
6396
+ }
6397
+ this.scene.clear();
6398
+ for (const helper of this._debugHelpers) {
6399
+ helper.geometry.dispose();
6400
+ const materials = Array.isArray(helper.material) ? helper.material : [helper.material];
6401
+ for (const material of materials) {
6402
+ material.dispose();
6403
+ }
6404
+ }
6405
+ this._debugHelpers.length = 0;
6406
+ this.composer.dispose();
6407
+ this.renderer.dispose();
6408
+ this.renderer.forceContextLoss();
6409
+ }
6410
+ animate(t) {
6411
+ var _a;
6412
+ if (this._disposed) return;
6413
+ if (this._stats) {
6414
+ this._stats.begin();
6415
+ }
6416
+ if ((_a = this._controls) == null ? void 0 : _a.enabled) {
6417
+ this._controls.update();
6418
+ }
6419
+ if (this._disposed) return;
6420
+ if (this.dirty || this.options.render.renderAlways) {
6421
+ if (this.options.composer.enabled) {
6422
+ this.composer.render();
6306
6423
  } else {
6307
- onMouseUp(event);
6308
- }
6309
- removePointer(event);
6310
- if (pointers.length === 0) {
6311
- scope.domElement.releasePointerCapture(event.pointerId);
6312
- scope.domElement.removeEventListener("pointermove", onPointerMove);
6313
- scope.domElement.removeEventListener("pointerup", onPointerUp);
6424
+ this.renderer.render(this.scene, this.camera);
6314
6425
  }
6315
6426
  }
6316
- function onPointerCancel(event) {
6317
- removePointer(event);
6427
+ this.dirty = false;
6428
+ if (this._stats) {
6429
+ this._stats.end();
6318
6430
  }
6319
- function onMouseDown(event) {
6320
- let mouseAction;
6321
- switch (event.button) {
6322
- case 0:
6323
- mouseAction = scope.mouseButtons.LEFT;
6324
- break;
6325
- case 1:
6326
- mouseAction = scope.mouseButtons.MIDDLE;
6327
- break;
6328
- case 2:
6329
- mouseAction = scope.mouseButtons.RIGHT;
6330
- break;
6331
- default:
6332
- mouseAction = -1;
6333
- }
6334
- switch (mouseAction) {
6335
- case import_three20.MOUSE.DOLLY:
6336
- if (scope.enableZoom === false) return;
6337
- handleMouseDownDolly(event);
6338
- state = STATE.DOLLY;
6339
- break;
6340
- case import_three20.MOUSE.ROTATE:
6341
- if (event.ctrlKey || event.metaKey || event.shiftKey) {
6342
- if (scope.enablePan === false) return;
6343
- handleMouseDownPan(event);
6344
- state = STATE.PAN;
6345
- } else {
6346
- if (scope.enableRotate === false) return;
6347
- handleMouseDownRotate(event);
6348
- state = STATE.ROTATE;
6349
- }
6350
- break;
6351
- case import_three20.MOUSE.PAN:
6352
- if (event.ctrlKey || event.metaKey || event.shiftKey) {
6353
- if (scope.enableRotate === false) return;
6354
- handleMouseDownRotate(event);
6355
- state = STATE.ROTATE;
6356
- } else {
6357
- if (scope.enablePan === false) return;
6358
- handleMouseDownPan(event);
6359
- state = STATE.PAN;
6360
- }
6361
- break;
6362
- default:
6363
- state = STATE.NONE;
6431
+ }
6432
+ //</editor-fold>
6433
+ toImage() {
6434
+ return this.renderer.domElement.toDataURL();
6435
+ }
6436
+ ///
6437
+ get attachedToBody() {
6438
+ return this.element === document.body;
6439
+ }
6440
+ get viewWidth() {
6441
+ var _a;
6442
+ return this.attachedToBody ? window.innerWidth : ((_a = this.element) == null ? void 0 : _a.offsetWidth) || 0;
6443
+ }
6444
+ get viewHeight() {
6445
+ var _a;
6446
+ return this.attachedToBody ? window.innerHeight : ((_a = this.element) == null ? void 0 : _a.offsetHeight) || 0;
6447
+ }
6448
+ get scene() {
6449
+ return this._scene;
6450
+ }
6451
+ get camera() {
6452
+ return this._camera;
6453
+ }
6454
+ get renderer() {
6455
+ return this._renderer;
6456
+ }
6457
+ get composer() {
6458
+ return this._composer;
6459
+ }
6460
+ /** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
6461
+ get controls() {
6462
+ return this._controls;
6463
+ }
6464
+ ///
6465
+ };
6466
+ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
6467
+ camera: {
6468
+ type: "perspective",
6469
+ near: 1,
6470
+ far: 5e3,
6471
+ perspective: {
6472
+ aspect: void 0,
6473
+ fov: 50
6474
+ },
6475
+ orthographic: {
6476
+ left: void 0,
6477
+ right: void 0,
6478
+ top: void 0,
6479
+ bottom: void 0
6480
+ },
6481
+ position: new import_three19.Vector3(50, 50, 50),
6482
+ lookingAt: new import_three19.Vector3(0, 0, 0)
6483
+ },
6484
+ render: {
6485
+ fpsLimit: 60,
6486
+ stats: false,
6487
+ antialias: true,
6488
+ shade: true,
6489
+ autoResize: true,
6490
+ renderAlways: false
6491
+ },
6492
+ composer: {
6493
+ enabled: true
6494
+ },
6495
+ controls: {
6496
+ enabled: false
6497
+ },
6498
+ debug: {
6499
+ grid: false,
6500
+ axes: false
6501
+ }
6502
+ });
6503
+ var Renderer = _Renderer;
6504
+
6505
+ // src/skin/Skins.ts
6506
+ var Skins = class {
6507
+ //<editor-fold desc="Skins">
6508
+ static async fromUuidOrUsername(uuidOrUsername) {
6509
+ if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
6510
+ return this.fromUuid(uuidOrUsername);
6511
+ }
6512
+ return this.fromUsername(uuidOrUsername);
6513
+ }
6514
+ static async fromUuid(uuid) {
6515
+ return this.getSkinProxySkinUrl(uuid);
6516
+ }
6517
+ static async fromUsername(username) {
6518
+ return this.usernameToUuid(username).then((uuid) => {
6519
+ if (uuid) {
6520
+ return this.fromUuid(uuid);
6364
6521
  }
6365
- if (state !== STATE.NONE) {
6366
- scope.dispatchEvent(_startEvent);
6522
+ return void 0;
6523
+ });
6524
+ }
6525
+ static async fromMineSkin(mineskinId) {
6526
+ return this.getMineSkin(mineskinId).then((mineskin) => {
6527
+ if (mineskin) {
6528
+ return mineskin["data"]["texture"]["value"]["urls"]["skins"];
6367
6529
  }
6530
+ return void 0;
6531
+ });
6532
+ }
6533
+ //</editor-fold>
6534
+ //<editor-fold desc="Capes">
6535
+ static async capeFromUuidOrUsername(uuidOrUsername) {
6536
+ if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
6537
+ return this.capeFromUuid(uuidOrUsername);
6368
6538
  }
6369
- function onMouseMove(event) {
6370
- if (scope.enabled === false) return;
6371
- switch (state) {
6372
- case STATE.ROTATE:
6373
- if (scope.enableRotate === false) return;
6374
- handleMouseMoveRotate(event);
6375
- break;
6376
- case STATE.DOLLY:
6377
- if (scope.enableZoom === false) return;
6378
- handleMouseMoveDolly(event);
6379
- break;
6380
- case STATE.PAN:
6381
- if (scope.enablePan === false) return;
6382
- handleMouseMovePan(event);
6383
- break;
6539
+ return this.capeFromUsername(uuidOrUsername);
6540
+ }
6541
+ static async capeFromUuid(uuid) {
6542
+ return this.getSkinProxyCapeUrl(uuid);
6543
+ }
6544
+ static async capeFromUsername(username) {
6545
+ return this.usernameToUuid(username).then((uuid) => {
6546
+ if (uuid) {
6547
+ return this.capeFromUuid(uuid);
6384
6548
  }
6385
- }
6386
- function onMouseUp(event) {
6387
- handleMouseUp(event);
6388
- scope.dispatchEvent(_endEvent);
6389
- state = STATE.NONE;
6390
- }
6391
- function onMouseWheel(event) {
6392
- if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
6393
- event.preventDefault();
6394
- scope.dispatchEvent(_startEvent);
6395
- handleMouseWheel(event);
6396
- scope.dispatchEvent(_endEvent);
6397
- }
6398
- function onKeyDown(event) {
6399
- if (scope.enabled === false || scope.enablePan === false) return;
6400
- handleKeyDown(event);
6401
- }
6402
- function onTouchStart(event) {
6403
- trackPointer(event);
6404
- switch (pointers.length) {
6405
- case 1:
6406
- switch (scope.touches.ONE) {
6407
- case import_three20.TOUCH.ROTATE:
6408
- if (scope.enableRotate === false) return;
6409
- handleTouchStartRotate();
6410
- state = STATE.TOUCH_ROTATE;
6411
- break;
6412
- case import_three20.TOUCH.PAN:
6413
- if (scope.enablePan === false) return;
6414
- handleTouchStartPan();
6415
- state = STATE.TOUCH_PAN;
6416
- break;
6417
- default:
6418
- state = STATE.NONE;
6419
- }
6420
- break;
6421
- case 2:
6422
- switch (scope.touches.TWO) {
6423
- case import_three20.TOUCH.DOLLY_PAN:
6424
- if (scope.enableZoom === false && scope.enablePan === false) return;
6425
- handleTouchStartDollyPan();
6426
- state = STATE.TOUCH_DOLLY_PAN;
6427
- break;
6428
- case import_three20.TOUCH.DOLLY_ROTATE:
6429
- if (scope.enableZoom === false && scope.enableRotate === false) return;
6430
- handleTouchStartDollyRotate();
6431
- state = STATE.TOUCH_DOLLY_ROTATE;
6432
- break;
6433
- default:
6434
- state = STATE.NONE;
6435
- }
6436
- break;
6437
- default:
6438
- state = STATE.NONE;
6549
+ return void 0;
6550
+ });
6551
+ }
6552
+ static async capeFromCapesDev(uuid, capeType = "minecraft") {
6553
+ return this.getCapesDev(uuid, capeType).then((cape) => {
6554
+ if (cape) {
6555
+ return cape == null ? void 0 : cape.stillImageUrl;
6439
6556
  }
6440
- if (state !== STATE.NONE) {
6441
- scope.dispatchEvent(_startEvent);
6557
+ return void 0;
6558
+ });
6559
+ }
6560
+ //</editor-fold>
6561
+ //<editor-fold desc="Helpers">
6562
+ static async usernameToUuid(username) {
6563
+ return this.usernameToUuidSkinProxy(username);
6564
+ }
6565
+ static async usernameToUuidSkinProxy(username) {
6566
+ return Requests.genericRequest({
6567
+ baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
6568
+ url: "/uuid/" + username
6569
+ }).then((res) => {
6570
+ if (res.status === 200) {
6571
+ return res.data["id"];
6442
6572
  }
6443
- }
6444
- function onTouchMove(event) {
6445
- trackPointer(event);
6446
- switch (state) {
6447
- case STATE.TOUCH_ROTATE:
6448
- if (scope.enableRotate === false) return;
6449
- handleTouchMoveRotate(event);
6450
- scope.update();
6451
- break;
6452
- case STATE.TOUCH_PAN:
6453
- if (scope.enablePan === false) return;
6454
- handleTouchMovePan(event);
6455
- scope.update();
6456
- break;
6457
- case STATE.TOUCH_DOLLY_PAN:
6458
- if (scope.enableZoom === false && scope.enablePan === false) return;
6459
- handleTouchMoveDollyPan(event);
6460
- scope.update();
6461
- break;
6462
- case STATE.TOUCH_DOLLY_ROTATE:
6463
- if (scope.enableZoom === false && scope.enableRotate === false) return;
6464
- handleTouchMoveDollyRotate(event);
6465
- scope.update();
6466
- break;
6467
- default:
6468
- state = STATE.NONE;
6573
+ return void 0;
6574
+ }).catch((err) => {
6575
+ console.warn(err);
6576
+ return void 0;
6577
+ });
6578
+ }
6579
+ static async usernameToUuidMineTools(username) {
6580
+ return Requests.genericRequest({
6581
+ baseURL: "https://api.minetools.eu",
6582
+ url: "/uuid/" + username
6583
+ }).then((res) => {
6584
+ if (res.status === 200) {
6585
+ return res.data["id"];
6469
6586
  }
6470
- }
6471
- function onTouchEnd(event) {
6472
- handleTouchEnd(event);
6473
- scope.dispatchEvent(_endEvent);
6474
- state = STATE.NONE;
6475
- }
6476
- function onContextMenu(event) {
6477
- if (scope.enabled === false) return;
6478
- event.preventDefault();
6479
- }
6480
- function addPointer(event) {
6481
- pointers.push(event);
6482
- }
6483
- function removePointer(event) {
6484
- delete pointerPositions[event.pointerId];
6485
- for (let i = 0; i < pointers.length; i++) {
6486
- if (pointers[i].pointerId == event.pointerId) {
6487
- pointers.splice(i, 1);
6488
- return;
6489
- }
6587
+ return void 0;
6588
+ }).catch((err) => {
6589
+ console.warn(err);
6590
+ return void 0;
6591
+ });
6592
+ }
6593
+ static async getProfileFromMinetools(uuid) {
6594
+ return Requests.genericRequest({
6595
+ baseURL: "https://api.minetools.eu",
6596
+ url: "/profile/" + uuid
6597
+ }).then((res) => {
6598
+ if (res.status === 200) {
6599
+ return res.data;
6490
6600
  }
6491
- }
6492
- function trackPointer(event) {
6493
- let position = pointerPositions[event.pointerId];
6494
- if (position === void 0) {
6495
- position = new import_three20.Vector2();
6496
- pointerPositions[event.pointerId] = position;
6601
+ });
6602
+ }
6603
+ static async getMineSkin(mineskinId) {
6604
+ return Requests.genericRequest({
6605
+ baseURL: "https://api.mineskin.org",
6606
+ url: "/get/uuid/" + mineskinId
6607
+ }).then((res) => {
6608
+ if (res.status === 200) {
6609
+ return res.data;
6497
6610
  }
6498
- position.set(event.pageX, event.pageY);
6499
- }
6500
- function getSecondPointerPosition(event) {
6501
- const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
6502
- return pointerPositions[pointer.pointerId];
6503
- }
6504
- scope.domElement.addEventListener("contextmenu", onContextMenu);
6505
- scope.domElement.addEventListener("pointerdown", onPointerDown);
6506
- scope.domElement.addEventListener("pointercancel", onPointerCancel);
6507
- scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
6508
- this.update();
6611
+ return void 0;
6612
+ }).catch((err) => {
6613
+ console.warn(err);
6614
+ return void 0;
6615
+ });
6509
6616
  }
6510
- };
6511
- var MapControls = class extends OrbitControls {
6512
- constructor(object, domElement) {
6513
- super(object, domElement);
6514
- this.screenSpacePanning = false;
6515
- this.mouseButtons.LEFT = import_three20.MOUSE.PAN;
6516
- this.mouseButtons.RIGHT = import_three20.MOUSE.ROTATE;
6517
- this.touches.ONE = import_three20.TOUCH.PAN;
6518
- this.touches.TWO = import_three20.TOUCH.DOLLY_ROTATE;
6617
+ static async getCapesDev(uuid, type = "all") {
6618
+ return Requests.genericRequest({
6619
+ baseURL: "https://api.capes.dev",
6620
+ url: "/load/" + uuid + "/" + type
6621
+ }).then((res) => {
6622
+ if (res.status === 200) {
6623
+ return res.data;
6624
+ }
6625
+ return void 0;
6626
+ }).catch((err) => {
6627
+ console.warn(err);
6628
+ return void 0;
6629
+ });
6630
+ }
6631
+ static getCrafatarSkinUrl(uuid) {
6632
+ return "https://crafatar.com/skins/" + uuid;
6519
6633
  }
6634
+ static getCrafatarCapeUrl(uuid) {
6635
+ return "https://crafatar.com/capes/" + uuid;
6636
+ }
6637
+ static getMcHeadsSkinUrl(uuid) {
6638
+ return "https://mc-heads.net/skin/" + uuid;
6639
+ }
6640
+ static getMineSkinPlayerSkinUrl(uuid) {
6641
+ return "https://mineskin.org/skin/player/" + uuid;
6642
+ }
6643
+ static getSkinProxySkinUrl(uuid) {
6644
+ return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
6645
+ }
6646
+ static getSkinProxyCapeUrl(uuid) {
6647
+ return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
6648
+ }
6649
+ //</editor-fold>
6520
6650
  };
6521
6651
 
6522
6652
  // src/world/Chunk.ts