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
@@ -32,9 +32,9 @@ var __decorateClass = (decorators, target, key, kind) => {
32
32
  return result;
33
33
  };
34
34
 
35
- // node_modules/ts-deepmerge/dist/index.js
35
+ // ../../node_modules/ts-deepmerge/dist/index.js
36
36
  var require_dist = __commonJS({
37
- "node_modules/ts-deepmerge/dist/index.js"(exports) {
37
+ "../../node_modules/ts-deepmerge/dist/index.js"(exports) {
38
38
  "use strict";
39
39
  var __assign = exports && exports.__assign || function() {
40
40
  __assign = Object.assign || function(t) {
@@ -1315,7 +1315,7 @@ var DefaultBlockStates = class {
1315
1315
  };
1316
1316
 
1317
1317
  // src/assets/Assets.ts
1318
- var DEFAULT_ROOT = "https://cdn.mcasset.cloud/file/minecraft-assets/1.17.1";
1318
+ var DEFAULT_ROOT = "https://assets.mcasset.cloud/1.17.1";
1319
1319
  var DEFAULT_NAMESPACE = "minecraft";
1320
1320
  var Assets = class {
1321
1321
  /**
@@ -1668,8 +1668,8 @@ var _AssetLoader = class _AssetLoader {
1668
1668
  };
1669
1669
  _AssetLoader.ROOT = DEFAULT_ROOT;
1670
1670
  _AssetLoader._SOURCES = [];
1671
- _AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master"));
1672
- _AssetLoader.addSource("mcassets", new HostedAssetSource(DEFAULT_ROOT));
1671
+ _AssetLoader.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
1672
+ _AssetLoader.addSource("mcassets", new HostedAssetSource(DEFAULT_ROOT, { retryDefaults: false }));
1673
1673
  var AssetLoader = _AssetLoader;
1674
1674
 
1675
1675
  // src/assets/ModelTextures.ts
@@ -5259,24 +5259,55 @@ var _MineRenderScene = class _MineRenderScene extends Scene2 {
5259
5259
  this.stats = new SceneStats();
5260
5260
  this.instanceManager = new InstanceManager();
5261
5261
  this.dirty = true;
5262
+ this.observedObjects = /* @__PURE__ */ new Set();
5263
+ this.onObjectChange = (event) => {
5264
+ var _a;
5265
+ if (((_a = event.target) == null ? void 0 : _a.parent) === this) {
5266
+ this.dirty = true;
5267
+ }
5268
+ };
5262
5269
  this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
5263
5270
  }
5264
- add(...object) {
5265
- this.dirty = true;
5266
- this.stats.objectCount += object.length;
5267
- for (let obj of object) {
5268
- if (isSceneObject(obj)) {
5269
- this.stats.sceneObjectCount++;
5271
+ add(...objects) {
5272
+ for (const object of objects) {
5273
+ this.dirty = true;
5274
+ try {
5275
+ super.add(object);
5276
+ } finally {
5277
+ if ((object == null ? void 0 : object.isObject3D) && object !== this) {
5278
+ this.updateObjectRegistration(object, object.parent === this);
5279
+ }
5270
5280
  }
5271
- obj.addEventListener("change", (event) => {
5272
- this.dirty = true;
5273
- });
5274
5281
  }
5275
- return super.add(...object);
5282
+ return this;
5276
5283
  }
5277
- remove(...object) {
5278
- this.dirty = true;
5279
- return super.remove(...object);
5284
+ remove(...objects) {
5285
+ for (const object of objects) {
5286
+ if (!this.children.includes(object)) continue;
5287
+ this.dirty = true;
5288
+ this.updateObjectRegistration(object, false);
5289
+ try {
5290
+ super.remove(object);
5291
+ } finally {
5292
+ this.updateObjectRegistration(object, object.parent === this);
5293
+ }
5294
+ }
5295
+ return this;
5296
+ }
5297
+ updateObjectRegistration(object, attached) {
5298
+ if (this.observedObjects.has(object) === attached) return;
5299
+ if (attached) {
5300
+ this.observedObjects.add(object);
5301
+ object.addEventListener("change", this.onObjectChange);
5302
+ } else {
5303
+ this.observedObjects.delete(object);
5304
+ object.removeEventListener("change", this.onObjectChange);
5305
+ }
5306
+ const change = attached ? 1 : -1;
5307
+ this.stats.objectCount += change;
5308
+ if (isSceneObject(object)) {
5309
+ this.stats.sceneObjectCount += change;
5310
+ }
5280
5311
  }
5281
5312
  async initAndAdd(...object) {
5282
5313
  this.dirty = true;
@@ -5339,1049 +5370,1148 @@ function isMineRenderScene(obj) {
5339
5370
  }
5340
5371
 
5341
5372
  // src/renderer/Renderer.ts
5342
- import { AxesHelper as AxesHelper3, GridHelper, LinearEncoding, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, Vector3 as Vector37, WebGLRenderer } from "three";
5373
+ import { AxesHelper as AxesHelper3, GridHelper, LinearEncoding, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, Vector3 as Vector38, WebGLRenderer } from "three";
5343
5374
  var import_ts_deepmerge10 = __toESM(require_dist());
5344
5375
  import Stats from "stats.js";
5345
5376
  import { EffectComposer, RenderPass } from "postprocessing";
5346
- var _Renderer = class _Renderer {
5347
- constructor(options) {
5348
- this._dirty = true;
5349
- this._animationTimer = void 0;
5350
- this._animationFrame = void 0;
5351
- this._resizeListener = void 0;
5352
- this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
5353
- this._animationLoop = this.animate.bind(this);
5354
- this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
5355
- this._scene = this.createScene();
5356
- this._camera = this.createCamera();
5357
- this._renderer = this.createRenderer();
5358
- this._composer = this.createComposer();
5359
- if (this.options.render.stats) {
5360
- this._stats = new Stats();
5361
- document.body.appendChild(this._stats.dom);
5377
+
5378
+ // src/three/OrbitControls.js
5379
+ import {
5380
+ EventDispatcher,
5381
+ MOUSE,
5382
+ Quaternion as Quaternion3,
5383
+ Spherical,
5384
+ TOUCH,
5385
+ Vector2 as Vector23,
5386
+ Vector3 as Vector37
5387
+ } from "three";
5388
+ var _changeEvent = { type: "change" };
5389
+ var _startEvent = { type: "start" };
5390
+ var _endEvent = { type: "end" };
5391
+ var OrbitControls = class extends EventDispatcher {
5392
+ constructor(object, domElement) {
5393
+ super();
5394
+ if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
5395
+ if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
5396
+ this.object = object;
5397
+ this.domElement = domElement;
5398
+ this.domElement.style.touchAction = "none";
5399
+ this.enabled = true;
5400
+ this.target = new Vector37();
5401
+ this.minDistance = 0;
5402
+ this.maxDistance = Infinity;
5403
+ this.minZoom = 0;
5404
+ this.maxZoom = Infinity;
5405
+ this.minPolarAngle = 0;
5406
+ this.maxPolarAngle = Math.PI;
5407
+ this.minAzimuthAngle = -Infinity;
5408
+ this.maxAzimuthAngle = Infinity;
5409
+ this.enableDamping = false;
5410
+ this.dampingFactor = 0.05;
5411
+ this.enableZoom = true;
5412
+ this.zoomSpeed = 1;
5413
+ this.enableRotate = true;
5414
+ this.rotateSpeed = 1;
5415
+ this.enablePan = true;
5416
+ this.panSpeed = 1;
5417
+ this.screenSpacePanning = true;
5418
+ this.keyPanSpeed = 7;
5419
+ this.autoRotate = false;
5420
+ this.autoRotateSpeed = 2;
5421
+ this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
5422
+ this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
5423
+ this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN };
5424
+ this.target0 = this.target.clone();
5425
+ this.position0 = this.object.position.clone();
5426
+ this.zoom0 = this.object.zoom;
5427
+ this._domElementKeyEvents = null;
5428
+ this.getPolarAngle = function() {
5429
+ return spherical.phi;
5430
+ };
5431
+ this.getAzimuthalAngle = function() {
5432
+ return spherical.theta;
5433
+ };
5434
+ this.getDistance = function() {
5435
+ return this.object.position.distanceTo(this.target);
5436
+ };
5437
+ this.saveState = function() {
5438
+ scope.target0.copy(scope.target);
5439
+ scope.position0.copy(scope.object.position);
5440
+ scope.zoom0 = scope.object.zoom;
5441
+ };
5442
+ this.reset = function() {
5443
+ scope.target.copy(scope.target0);
5444
+ scope.object.position.copy(scope.position0);
5445
+ scope.object.zoom = scope.zoom0;
5446
+ scope.object.updateProjectionMatrix();
5447
+ scope.dispatchEvent(_changeEvent);
5448
+ scope.update();
5449
+ state = STATE.NONE;
5450
+ };
5451
+ this.update = function() {
5452
+ const offset = new Vector37();
5453
+ const quat = new Quaternion3().setFromUnitVectors(object.up, new Vector37(0, 1, 0));
5454
+ const quatInverse = quat.clone().invert();
5455
+ const lastPosition = new Vector37();
5456
+ const lastQuaternion = new Quaternion3();
5457
+ const twoPI = 2 * Math.PI;
5458
+ return function update() {
5459
+ const position = scope.object.position;
5460
+ offset.copy(position).sub(scope.target);
5461
+ offset.applyQuaternion(quat);
5462
+ spherical.setFromVector3(offset);
5463
+ if (scope.autoRotate && state === STATE.NONE) {
5464
+ rotateLeft(getAutoRotationAngle());
5465
+ }
5466
+ if (scope.enableDamping) {
5467
+ spherical.theta += sphericalDelta.theta * scope.dampingFactor;
5468
+ spherical.phi += sphericalDelta.phi * scope.dampingFactor;
5469
+ } else {
5470
+ spherical.theta += sphericalDelta.theta;
5471
+ spherical.phi += sphericalDelta.phi;
5472
+ }
5473
+ let min = scope.minAzimuthAngle;
5474
+ let max = scope.maxAzimuthAngle;
5475
+ if (isFinite(min) && isFinite(max)) {
5476
+ if (min < -Math.PI) min += twoPI;
5477
+ else if (min > Math.PI) min -= twoPI;
5478
+ if (max < -Math.PI) max += twoPI;
5479
+ else if (max > Math.PI) max -= twoPI;
5480
+ if (min <= max) {
5481
+ spherical.theta = Math.max(min, Math.min(max, spherical.theta));
5482
+ } else {
5483
+ spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
5484
+ }
5485
+ }
5486
+ spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
5487
+ spherical.makeSafe();
5488
+ spherical.radius *= scale;
5489
+ spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
5490
+ if (scope.enableDamping === true) {
5491
+ scope.target.addScaledVector(panOffset, scope.dampingFactor);
5492
+ } else {
5493
+ scope.target.add(panOffset);
5494
+ }
5495
+ offset.setFromSpherical(spherical);
5496
+ offset.applyQuaternion(quatInverse);
5497
+ position.copy(scope.target).add(offset);
5498
+ scope.object.lookAt(scope.target);
5499
+ if (scope.enableDamping === true) {
5500
+ sphericalDelta.theta *= 1 - scope.dampingFactor;
5501
+ sphericalDelta.phi *= 1 - scope.dampingFactor;
5502
+ panOffset.multiplyScalar(1 - scope.dampingFactor);
5503
+ } else {
5504
+ sphericalDelta.set(0, 0, 0);
5505
+ panOffset.set(0, 0, 0);
5506
+ }
5507
+ scale = 1;
5508
+ if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
5509
+ scope.dispatchEvent(_changeEvent);
5510
+ lastPosition.copy(scope.object.position);
5511
+ lastQuaternion.copy(scope.object.quaternion);
5512
+ zoomChanged = false;
5513
+ return true;
5514
+ }
5515
+ return false;
5516
+ };
5517
+ }();
5518
+ this.dispose = function() {
5519
+ scope.domElement.removeEventListener("contextmenu", onContextMenu);
5520
+ scope.domElement.removeEventListener("pointerdown", onPointerDown);
5521
+ scope.domElement.removeEventListener("pointercancel", onPointerCancel);
5522
+ scope.domElement.removeEventListener("wheel", onMouseWheel);
5523
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
5524
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
5525
+ if (scope._domElementKeyEvents !== null) {
5526
+ scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
5527
+ }
5528
+ };
5529
+ const scope = this;
5530
+ const STATE = {
5531
+ NONE: -1,
5532
+ ROTATE: 0,
5533
+ DOLLY: 1,
5534
+ PAN: 2,
5535
+ TOUCH_ROTATE: 3,
5536
+ TOUCH_PAN: 4,
5537
+ TOUCH_DOLLY_PAN: 5,
5538
+ TOUCH_DOLLY_ROTATE: 6
5539
+ };
5540
+ let state = STATE.NONE;
5541
+ const EPS = 1e-6;
5542
+ const spherical = new Spherical();
5543
+ const sphericalDelta = new Spherical();
5544
+ let scale = 1;
5545
+ const panOffset = new Vector37();
5546
+ let zoomChanged = false;
5547
+ const rotateStart = new Vector23();
5548
+ const rotateEnd = new Vector23();
5549
+ const rotateDelta = new Vector23();
5550
+ const panStart = new Vector23();
5551
+ const panEnd = new Vector23();
5552
+ const panDelta = new Vector23();
5553
+ const dollyStart = new Vector23();
5554
+ const dollyEnd = new Vector23();
5555
+ const dollyDelta = new Vector23();
5556
+ const pointers = [];
5557
+ const pointerPositions = {};
5558
+ function getAutoRotationAngle() {
5559
+ return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
5362
5560
  }
5363
- this.init();
5364
- }
5365
- //<editor-fold desc="INIT">
5366
- createScene() {
5367
- return new MineRenderScene();
5368
- }
5369
- createCamera() {
5370
- switch (this.options.camera.type) {
5371
- case "perspective":
5372
- default:
5373
- return new PerspectiveCamera(
5374
- this.options.camera.perspective.fov,
5375
- this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
5376
- this.options.camera.near,
5377
- this.options.camera.far
5378
- );
5379
- case "orthographic":
5380
- return new OrthographicCamera(
5381
- this.options.camera.orthographic.left ?? this.viewWidth / -2,
5382
- this.options.camera.orthographic.right ?? this.viewWidth / 2,
5383
- this.options.camera.orthographic.top ?? this.viewHeight / 2,
5384
- this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
5385
- this.options.camera.near,
5386
- this.options.camera.far
5387
- );
5561
+ function getZoomScale() {
5562
+ return Math.pow(0.95, scope.zoomSpeed);
5388
5563
  }
5389
- }
5390
- createRenderer() {
5391
- const renderer = new WebGLRenderer({
5392
- antialias: this.options.render.antialias,
5393
- alpha: true,
5394
- powerPreference: "high-performance",
5395
- depth: true
5396
- });
5397
- renderer.setClearColor(0, 0);
5398
- renderer.shadowMap.enabled = true;
5399
- renderer.shadowMap.type = PCFSoftShadowMap;
5400
- renderer.outputEncoding = LinearEncoding;
5401
- renderer.setSize(this.viewWidth, this.viewHeight);
5402
- return renderer;
5403
- }
5404
- createComposer() {
5405
- const composer = new EffectComposer(this.renderer);
5406
- if (!this.options.composer.enabled) return composer;
5407
- composer.setSize(this.viewWidth, this.viewHeight);
5408
- composer.addPass(new RenderPass(this.scene, this.camera));
5409
- return composer;
5410
- }
5411
- //</editor-fold>
5412
- init() {
5413
- if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
5414
- window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
5564
+ function rotateLeft(angle) {
5565
+ sphericalDelta.theta -= angle;
5415
5566
  }
5416
- if (this.options.debug.grid) {
5417
- const gridHelper = new GridHelper(128, 16);
5418
- this.scene.add(gridHelper);
5419
- const gridHelper2 = new GridHelper(128, 16);
5420
- gridHelper2.rotation.x = 90 * (Math.PI / 180);
5421
- this.scene.add(gridHelper2);
5422
- const gridHelper3 = new GridHelper(128, 16);
5423
- gridHelper3.rotation.z = 90 * (Math.PI / 180);
5424
- this.scene.add(gridHelper3);
5567
+ function rotateUp(angle) {
5568
+ sphericalDelta.phi -= angle;
5425
5569
  }
5426
- if (this.options.debug.axes) {
5427
- const axesHelper = new AxesHelper3(64);
5428
- this.scene.add(axesHelper);
5570
+ const panLeft = function() {
5571
+ const v = new Vector37();
5572
+ return function panLeft2(distance, objectMatrix) {
5573
+ v.setFromMatrixColumn(objectMatrix, 0);
5574
+ v.multiplyScalar(-distance);
5575
+ panOffset.add(v);
5576
+ };
5577
+ }();
5578
+ const panUp = function() {
5579
+ const v = new Vector37();
5580
+ return function panUp2(distance, objectMatrix) {
5581
+ if (scope.screenSpacePanning === true) {
5582
+ v.setFromMatrixColumn(objectMatrix, 1);
5583
+ } else {
5584
+ v.setFromMatrixColumn(objectMatrix, 0);
5585
+ v.crossVectors(scope.object.up, v);
5586
+ }
5587
+ v.multiplyScalar(distance);
5588
+ panOffset.add(v);
5589
+ };
5590
+ }();
5591
+ const pan = function() {
5592
+ const offset = new Vector37();
5593
+ return function pan2(deltaX, deltaY) {
5594
+ const element = scope.domElement;
5595
+ if (scope.object.isPerspectiveCamera) {
5596
+ const position = scope.object.position;
5597
+ offset.copy(position).sub(scope.target);
5598
+ let targetDistance = offset.length();
5599
+ targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
5600
+ panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
5601
+ panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
5602
+ } else if (scope.object.isOrthographicCamera) {
5603
+ panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
5604
+ panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
5605
+ } else {
5606
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
5607
+ scope.enablePan = false;
5608
+ }
5609
+ };
5610
+ }();
5611
+ function dollyOut(dollyScale) {
5612
+ if (scope.object.isPerspectiveCamera) {
5613
+ scale /= dollyScale;
5614
+ } else if (scope.object.isOrthographicCamera) {
5615
+ scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
5616
+ scope.object.updateProjectionMatrix();
5617
+ zoomChanged = true;
5618
+ } else {
5619
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
5620
+ scope.enableZoom = false;
5621
+ }
5429
5622
  }
5430
- if (this.options.camera.position) {
5431
- if (isVector3(this.options.camera.position)) {
5432
- this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
5433
- } else if (isTripleArray(this.options.camera.position)) {
5434
- this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
5623
+ function dollyIn(dollyScale) {
5624
+ if (scope.object.isPerspectiveCamera) {
5625
+ scale *= dollyScale;
5626
+ } else if (scope.object.isOrthographicCamera) {
5627
+ scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
5628
+ scope.object.updateProjectionMatrix();
5629
+ zoomChanged = true;
5630
+ } else {
5631
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
5632
+ scope.enableZoom = false;
5435
5633
  }
5436
5634
  }
5437
- if (this.options.camera.lookingAt) {
5438
- if (isVector3(this.options.camera.lookingAt)) {
5439
- this.camera.lookAt(this.options.camera.lookingAt);
5440
- } else if (isTripleArray(this.options.camera.lookingAt)) {
5441
- this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
5635
+ function handleMouseDownRotate(event) {
5636
+ rotateStart.set(event.clientX, event.clientY);
5637
+ }
5638
+ function handleMouseDownDolly(event) {
5639
+ dollyStart.set(event.clientX, event.clientY);
5640
+ }
5641
+ function handleMouseDownPan(event) {
5642
+ panStart.set(event.clientX, event.clientY);
5643
+ }
5644
+ function handleMouseMoveRotate(event) {
5645
+ rotateEnd.set(event.clientX, event.clientY);
5646
+ rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
5647
+ const element = scope.domElement;
5648
+ rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
5649
+ rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
5650
+ rotateStart.copy(rotateEnd);
5651
+ scope.update();
5652
+ }
5653
+ function handleMouseMoveDolly(event) {
5654
+ dollyEnd.set(event.clientX, event.clientY);
5655
+ dollyDelta.subVectors(dollyEnd, dollyStart);
5656
+ if (dollyDelta.y > 0) {
5657
+ dollyOut(getZoomScale());
5658
+ } else if (dollyDelta.y < 0) {
5659
+ dollyIn(getZoomScale());
5442
5660
  }
5661
+ dollyStart.copy(dollyEnd);
5662
+ scope.update();
5443
5663
  }
5444
- if (this.options.render.autoResize) {
5445
- this._resizeListener = () => {
5446
- this.resize(this.viewWidth, this.viewHeight);
5447
- };
5448
- window.addEventListener("resize", this._resizeListener);
5664
+ function handleMouseMovePan(event) {
5665
+ panEnd.set(event.clientX, event.clientY);
5666
+ panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
5667
+ pan(panDelta.x, panDelta.y);
5668
+ panStart.copy(panEnd);
5669
+ scope.update();
5449
5670
  }
5450
- }
5451
- get element() {
5452
- return this._element;
5453
- }
5454
- appendTo(element) {
5455
- this._element = element;
5456
- this._element.appendChild(this.renderer.domElement);
5457
- if (this.viewWidth == 0) {
5458
- console.warn("0 element width");
5671
+ function handleMouseUp() {
5459
5672
  }
5460
- if (this.viewHeight == 0) {
5461
- console.warn("0 element height");
5673
+ function handleMouseWheel(event) {
5674
+ if (event.deltaY < 0) {
5675
+ dollyIn(getZoomScale());
5676
+ } else if (event.deltaY > 0) {
5677
+ dollyOut(getZoomScale());
5678
+ }
5679
+ scope.update();
5462
5680
  }
5463
- this.resize(this.viewWidth, this.viewHeight);
5464
- }
5465
- /**
5466
- * Register an EventDispatcher which may update the scene or renderer in order to redraw the scene
5467
- */
5468
- registerEventDispatcher(dispatcher, changeEvent2 = "change") {
5469
- dispatcher.addEventListener(changeEvent2, (event) => {
5470
- this._dirty = true;
5471
- });
5472
- }
5473
- resize(width, height) {
5474
- if (isPerspectiveCamera(this.camera)) {
5475
- this.camera.aspect = width / height;
5476
- this.camera.updateProjectionMatrix();
5477
- } else if (isOrthographicCamera(this.camera)) {
5478
- this.camera.left = width / -2;
5479
- this.camera.right = width / 2;
5480
- this.camera.top = height / 2;
5481
- this.camera.bottom = height / -2;
5482
- this.camera.updateProjectionMatrix();
5681
+ function handleKeyDown(event) {
5682
+ let needsUpdate = false;
5683
+ switch (event.code) {
5684
+ case scope.keys.UP:
5685
+ pan(0, scope.keyPanSpeed);
5686
+ needsUpdate = true;
5687
+ break;
5688
+ case scope.keys.BOTTOM:
5689
+ pan(0, -scope.keyPanSpeed);
5690
+ needsUpdate = true;
5691
+ break;
5692
+ case scope.keys.LEFT:
5693
+ pan(scope.keyPanSpeed, 0);
5694
+ needsUpdate = true;
5695
+ break;
5696
+ case scope.keys.RIGHT:
5697
+ pan(-scope.keyPanSpeed, 0);
5698
+ needsUpdate = true;
5699
+ break;
5700
+ }
5701
+ if (needsUpdate) {
5702
+ event.preventDefault();
5703
+ scope.update();
5704
+ }
5483
5705
  }
5484
- this.renderer.setSize(width, height);
5485
- this.composer.setSize(width, height);
5486
- }
5487
- //<editor-fold desc="RENDER">
5488
- get dirty() {
5489
- return this._dirty || this.scene.dirty;
5490
- }
5491
- set dirty(dirty) {
5492
- this._dirty = dirty;
5493
- this.scene.dirty = dirty;
5494
- }
5495
- start() {
5496
- stop();
5497
- this.renderer.setAnimationLoop(this._animationLoop);
5498
- }
5499
- stop() {
5500
- this.renderer.setAnimationLoop(null);
5501
- if (this._animationTimer)
5502
- clearTimeout(this._animationTimer);
5503
- this._animationTimer = void 0;
5504
- if (this._animationFrame)
5505
- cancelAnimationFrame(this._animationFrame);
5506
- this._animationFrame = void 0;
5507
- }
5508
- animate(t) {
5509
- if (this._stats) {
5510
- this._stats.begin();
5706
+ function handleTouchStartRotate() {
5707
+ if (pointers.length === 1) {
5708
+ rotateStart.set(pointers[0].pageX, pointers[0].pageY);
5709
+ } else {
5710
+ const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
5711
+ const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
5712
+ rotateStart.set(x, y);
5713
+ }
5511
5714
  }
5512
- if (this.dirty || this.options.render.renderAlways) {
5513
- if (this.options.composer.enabled) {
5514
- this.composer.render();
5715
+ function handleTouchStartPan() {
5716
+ if (pointers.length === 1) {
5717
+ panStart.set(pointers[0].pageX, pointers[0].pageY);
5515
5718
  } else {
5516
- this.renderer.render(this.scene, this.camera);
5719
+ const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
5720
+ const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
5721
+ panStart.set(x, y);
5517
5722
  }
5518
5723
  }
5519
- this.dirty = false;
5520
- if (this._stats) {
5521
- this._stats.end();
5724
+ function handleTouchStartDolly() {
5725
+ const dx = pointers[0].pageX - pointers[1].pageX;
5726
+ const dy = pointers[0].pageY - pointers[1].pageY;
5727
+ const distance = Math.sqrt(dx * dx + dy * dy);
5728
+ dollyStart.set(0, distance);
5522
5729
  }
5523
- }
5524
- //</editor-fold>
5525
- toImage() {
5526
- return this.renderer.domElement.toDataURL();
5527
- }
5528
- ///
5529
- get attachedToBody() {
5530
- return this.element === document.body;
5531
- }
5532
- get viewWidth() {
5533
- var _a;
5534
- return this.attachedToBody ? window.innerWidth : ((_a = this.element) == null ? void 0 : _a.offsetWidth) || 0;
5535
- }
5536
- get viewHeight() {
5537
- var _a;
5538
- return this.attachedToBody ? window.innerHeight : ((_a = this.element) == null ? void 0 : _a.offsetHeight) || 0;
5539
- }
5540
- get scene() {
5541
- return this._scene;
5542
- }
5543
- get camera() {
5544
- return this._camera;
5545
- }
5546
- get renderer() {
5547
- return this._renderer;
5548
- }
5549
- get composer() {
5550
- return this._composer;
5551
- }
5552
- ///
5553
- };
5554
- _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
5555
- camera: {
5556
- type: "perspective",
5557
- near: 1,
5558
- far: 5e3,
5559
- perspective: {
5560
- aspect: void 0,
5561
- fov: 50
5562
- },
5563
- orthographic: {
5564
- left: void 0,
5565
- right: void 0,
5566
- top: void 0,
5567
- bottom: void 0
5568
- },
5569
- position: new Vector37(50, 50, 50),
5570
- lookingAt: new Vector37(0, 0, 0)
5571
- },
5572
- render: {
5573
- fpsLimit: 60,
5574
- stats: false,
5575
- antialias: true,
5576
- shade: true,
5577
- autoResize: true,
5578
- renderAlways: false
5579
- },
5580
- composer: {
5581
- enabled: true
5582
- },
5583
- debug: {
5584
- grid: false,
5585
- axes: false
5586
- }
5587
- });
5588
- var Renderer = _Renderer;
5589
-
5590
- // src/skin/Skins.ts
5591
- var Skins = class {
5592
- //<editor-fold desc="Skins">
5593
- static async fromUuidOrUsername(uuidOrUsername) {
5594
- if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
5595
- return this.fromUuid(uuidOrUsername);
5730
+ function handleTouchStartDollyPan() {
5731
+ if (scope.enableZoom) handleTouchStartDolly();
5732
+ if (scope.enablePan) handleTouchStartPan();
5596
5733
  }
5597
- return this.fromUsername(uuidOrUsername);
5598
- }
5599
- static async fromUuid(uuid) {
5600
- return this.getSkinProxySkinUrl(uuid);
5601
- }
5602
- static async fromUsername(username) {
5603
- return this.usernameToUuid(username).then((uuid) => {
5604
- if (uuid) {
5605
- return this.fromUuid(uuid);
5606
- }
5607
- return void 0;
5608
- });
5609
- }
5610
- static async fromMineSkin(mineskinId) {
5611
- return this.getMineSkin(mineskinId).then((mineskin) => {
5612
- if (mineskin) {
5613
- return mineskin["data"]["texture"]["value"]["urls"]["skins"];
5614
- }
5615
- return void 0;
5616
- });
5617
- }
5618
- //</editor-fold>
5619
- //<editor-fold desc="Capes">
5620
- static async capeFromUuidOrUsername(uuidOrUsername) {
5621
- if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
5622
- return this.capeFromUuid(uuidOrUsername);
5734
+ function handleTouchStartDollyRotate() {
5735
+ if (scope.enableZoom) handleTouchStartDolly();
5736
+ if (scope.enableRotate) handleTouchStartRotate();
5623
5737
  }
5624
- return this.capeFromUsername(uuidOrUsername);
5625
- }
5626
- static async capeFromUuid(uuid) {
5627
- return this.getSkinProxyCapeUrl(uuid);
5628
- }
5629
- static async capeFromUsername(username) {
5630
- return this.usernameToUuid(username).then((uuid) => {
5631
- if (uuid) {
5632
- return this.capeFromUuid(uuid);
5633
- }
5634
- return void 0;
5635
- });
5636
- }
5637
- static async capeFromCapesDev(uuid, capeType = "minecraft") {
5638
- return this.getCapesDev(uuid, capeType).then((cape) => {
5639
- if (cape) {
5640
- return cape == null ? void 0 : cape.stillImageUrl;
5641
- }
5642
- return void 0;
5643
- });
5644
- }
5645
- //</editor-fold>
5646
- //<editor-fold desc="Helpers">
5647
- static async usernameToUuid(username) {
5648
- return this.usernameToUuidSkinProxy(username);
5649
- }
5650
- static async usernameToUuidSkinProxy(username) {
5651
- return Requests.genericRequest({
5652
- baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
5653
- url: "/uuid/" + username
5654
- }).then((res) => {
5655
- if (res.status === 200) {
5656
- return res.data["id"];
5657
- }
5658
- return void 0;
5659
- }).catch((err) => {
5660
- console.warn(err);
5661
- return void 0;
5662
- });
5663
- }
5664
- static async usernameToUuidMineTools(username) {
5665
- return Requests.genericRequest({
5666
- baseURL: "https://api.minetools.eu",
5667
- url: "/uuid/" + username
5668
- }).then((res) => {
5669
- if (res.status === 200) {
5670
- return res.data["id"];
5671
- }
5672
- return void 0;
5673
- }).catch((err) => {
5674
- console.warn(err);
5675
- return void 0;
5676
- });
5677
- }
5678
- static async getProfileFromMinetools(uuid) {
5679
- return Requests.genericRequest({
5680
- baseURL: "https://api.minetools.eu",
5681
- url: "/profile/" + uuid
5682
- }).then((res) => {
5683
- if (res.status === 200) {
5684
- return res.data;
5685
- }
5686
- });
5687
- }
5688
- static async getMineSkin(mineskinId) {
5689
- return Requests.genericRequest({
5690
- baseURL: "https://api.mineskin.org",
5691
- url: "/get/uuid/" + mineskinId
5692
- }).then((res) => {
5693
- if (res.status === 200) {
5694
- return res.data;
5695
- }
5696
- return void 0;
5697
- }).catch((err) => {
5698
- console.warn(err);
5699
- return void 0;
5700
- });
5701
- }
5702
- static async getCapesDev(uuid, type = "all") {
5703
- return Requests.genericRequest({
5704
- baseURL: "https://api.capes.dev",
5705
- url: "/load/" + uuid + "/" + type
5706
- }).then((res) => {
5707
- if (res.status === 200) {
5708
- return res.data;
5709
- }
5710
- return void 0;
5711
- }).catch((err) => {
5712
- console.warn(err);
5713
- return void 0;
5714
- });
5715
- }
5716
- static getCrafatarSkinUrl(uuid) {
5717
- return "https://crafatar.com/skins/" + uuid;
5718
- }
5719
- static getCrafatarCapeUrl(uuid) {
5720
- return "https://crafatar.com/capes/" + uuid;
5721
- }
5722
- static getMcHeadsSkinUrl(uuid) {
5723
- return "https://mc-heads.net/skin/" + uuid;
5724
- }
5725
- static getMineSkinPlayerSkinUrl(uuid) {
5726
- return "https://mineskin.org/skin/player/" + uuid;
5727
- }
5728
- static getSkinProxySkinUrl(uuid) {
5729
- return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
5730
- }
5731
- static getSkinProxyCapeUrl(uuid) {
5732
- return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
5733
- }
5734
- //</editor-fold>
5735
- };
5736
-
5737
- // src/three/OrbitControls.js
5738
- import {
5739
- EventDispatcher as EventDispatcher2,
5740
- MOUSE,
5741
- Quaternion as Quaternion3,
5742
- Spherical,
5743
- TOUCH,
5744
- Vector2 as Vector23,
5745
- Vector3 as Vector38
5746
- } from "three";
5747
- var _changeEvent = { type: "change" };
5748
- var _startEvent = { type: "start" };
5749
- var _endEvent = { type: "end" };
5750
- var OrbitControls = class extends EventDispatcher2 {
5751
- constructor(object, domElement) {
5752
- super();
5753
- if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
5754
- if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
5755
- this.object = object;
5756
- this.domElement = domElement;
5757
- this.domElement.style.touchAction = "none";
5758
- this.enabled = true;
5759
- this.target = new Vector38();
5760
- this.minDistance = 0;
5761
- this.maxDistance = Infinity;
5762
- this.minZoom = 0;
5763
- this.maxZoom = Infinity;
5764
- this.minPolarAngle = 0;
5765
- this.maxPolarAngle = Math.PI;
5766
- this.minAzimuthAngle = -Infinity;
5767
- this.maxAzimuthAngle = Infinity;
5768
- this.enableDamping = false;
5769
- this.dampingFactor = 0.05;
5770
- this.enableZoom = true;
5771
- this.zoomSpeed = 1;
5772
- this.enableRotate = true;
5773
- this.rotateSpeed = 1;
5774
- this.enablePan = true;
5775
- this.panSpeed = 1;
5776
- this.screenSpacePanning = true;
5777
- this.keyPanSpeed = 7;
5778
- this.autoRotate = false;
5779
- this.autoRotateSpeed = 2;
5780
- this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
5781
- this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
5782
- this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN };
5783
- this.target0 = this.target.clone();
5784
- this.position0 = this.object.position.clone();
5785
- this.zoom0 = this.object.zoom;
5786
- this._domElementKeyEvents = null;
5787
- this.getPolarAngle = function() {
5788
- return spherical.phi;
5789
- };
5790
- this.getAzimuthalAngle = function() {
5791
- return spherical.theta;
5792
- };
5793
- this.getDistance = function() {
5794
- return this.object.position.distanceTo(this.target);
5795
- };
5796
- this.saveState = function() {
5797
- scope.target0.copy(scope.target);
5798
- scope.position0.copy(scope.object.position);
5799
- scope.zoom0 = scope.object.zoom;
5800
- };
5801
- this.reset = function() {
5802
- scope.target.copy(scope.target0);
5803
- scope.object.position.copy(scope.position0);
5804
- scope.object.zoom = scope.zoom0;
5805
- scope.object.updateProjectionMatrix();
5806
- scope.dispatchEvent(_changeEvent);
5807
- scope.update();
5808
- state = STATE.NONE;
5809
- };
5810
- this.update = function() {
5811
- const offset = new Vector38();
5812
- const quat = new Quaternion3().setFromUnitVectors(object.up, new Vector38(0, 1, 0));
5813
- const quatInverse = quat.clone().invert();
5814
- const lastPosition = new Vector38();
5815
- const lastQuaternion = new Quaternion3();
5816
- const twoPI = 2 * Math.PI;
5817
- return function update() {
5818
- const position = scope.object.position;
5819
- offset.copy(position).sub(scope.target);
5820
- offset.applyQuaternion(quat);
5821
- spherical.setFromVector3(offset);
5822
- if (scope.autoRotate && state === STATE.NONE) {
5823
- rotateLeft(getAutoRotationAngle());
5824
- }
5825
- if (scope.enableDamping) {
5826
- spherical.theta += sphericalDelta.theta * scope.dampingFactor;
5827
- spherical.phi += sphericalDelta.phi * scope.dampingFactor;
5828
- } else {
5829
- spherical.theta += sphericalDelta.theta;
5830
- spherical.phi += sphericalDelta.phi;
5831
- }
5832
- let min = scope.minAzimuthAngle;
5833
- let max = scope.maxAzimuthAngle;
5834
- if (isFinite(min) && isFinite(max)) {
5835
- if (min < -Math.PI) min += twoPI;
5836
- else if (min > Math.PI) min -= twoPI;
5837
- if (max < -Math.PI) max += twoPI;
5838
- else if (max > Math.PI) max -= twoPI;
5839
- if (min <= max) {
5840
- spherical.theta = Math.max(min, Math.min(max, spherical.theta));
5841
- } else {
5842
- spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
5843
- }
5844
- }
5845
- spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
5846
- spherical.makeSafe();
5847
- spherical.radius *= scale;
5848
- spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
5849
- if (scope.enableDamping === true) {
5850
- scope.target.addScaledVector(panOffset, scope.dampingFactor);
5851
- } else {
5852
- scope.target.add(panOffset);
5853
- }
5854
- offset.setFromSpherical(spherical);
5855
- offset.applyQuaternion(quatInverse);
5856
- position.copy(scope.target).add(offset);
5857
- scope.object.lookAt(scope.target);
5858
- if (scope.enableDamping === true) {
5859
- sphericalDelta.theta *= 1 - scope.dampingFactor;
5860
- sphericalDelta.phi *= 1 - scope.dampingFactor;
5861
- panOffset.multiplyScalar(1 - scope.dampingFactor);
5862
- } else {
5863
- sphericalDelta.set(0, 0, 0);
5864
- panOffset.set(0, 0, 0);
5865
- }
5866
- scale = 1;
5867
- if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
5868
- scope.dispatchEvent(_changeEvent);
5869
- lastPosition.copy(scope.object.position);
5870
- lastQuaternion.copy(scope.object.quaternion);
5871
- zoomChanged = false;
5872
- return true;
5873
- }
5874
- return false;
5875
- };
5876
- }();
5877
- this.dispose = function() {
5878
- scope.domElement.removeEventListener("contextmenu", onContextMenu);
5879
- scope.domElement.removeEventListener("pointerdown", onPointerDown);
5880
- scope.domElement.removeEventListener("pointercancel", onPointerCancel);
5881
- scope.domElement.removeEventListener("wheel", onMouseWheel);
5882
- scope.domElement.removeEventListener("pointermove", onPointerMove);
5883
- scope.domElement.removeEventListener("pointerup", onPointerUp);
5884
- if (scope._domElementKeyEvents !== null) {
5885
- scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
5738
+ function handleTouchMoveRotate(event) {
5739
+ if (pointers.length == 1) {
5740
+ rotateEnd.set(event.pageX, event.pageY);
5741
+ } else {
5742
+ const position = getSecondPointerPosition(event);
5743
+ const x = 0.5 * (event.pageX + position.x);
5744
+ const y = 0.5 * (event.pageY + position.y);
5745
+ rotateEnd.set(x, y);
5886
5746
  }
5887
- };
5888
- const scope = this;
5889
- const STATE = {
5890
- NONE: -1,
5891
- ROTATE: 0,
5892
- DOLLY: 1,
5893
- PAN: 2,
5894
- TOUCH_ROTATE: 3,
5895
- TOUCH_PAN: 4,
5896
- TOUCH_DOLLY_PAN: 5,
5897
- TOUCH_DOLLY_ROTATE: 6
5898
- };
5899
- let state = STATE.NONE;
5900
- const EPS = 1e-6;
5901
- const spherical = new Spherical();
5902
- const sphericalDelta = new Spherical();
5903
- let scale = 1;
5904
- const panOffset = new Vector38();
5905
- let zoomChanged = false;
5906
- const rotateStart = new Vector23();
5907
- const rotateEnd = new Vector23();
5908
- const rotateDelta = new Vector23();
5909
- const panStart = new Vector23();
5910
- const panEnd = new Vector23();
5911
- const panDelta = new Vector23();
5912
- const dollyStart = new Vector23();
5913
- const dollyEnd = new Vector23();
5914
- const dollyDelta = new Vector23();
5915
- const pointers = [];
5916
- const pointerPositions = {};
5917
- function getAutoRotationAngle() {
5918
- return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
5747
+ rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
5748
+ const element = scope.domElement;
5749
+ rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
5750
+ rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
5751
+ rotateStart.copy(rotateEnd);
5752
+ }
5753
+ function handleTouchMovePan(event) {
5754
+ if (pointers.length === 1) {
5755
+ panEnd.set(event.pageX, event.pageY);
5756
+ } else {
5757
+ const position = getSecondPointerPosition(event);
5758
+ const x = 0.5 * (event.pageX + position.x);
5759
+ const y = 0.5 * (event.pageY + position.y);
5760
+ panEnd.set(x, y);
5761
+ }
5762
+ panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
5763
+ pan(panDelta.x, panDelta.y);
5764
+ panStart.copy(panEnd);
5919
5765
  }
5920
- function getZoomScale() {
5921
- return Math.pow(0.95, scope.zoomSpeed);
5766
+ function handleTouchMoveDolly(event) {
5767
+ const position = getSecondPointerPosition(event);
5768
+ const dx = event.pageX - position.x;
5769
+ const dy = event.pageY - position.y;
5770
+ const distance = Math.sqrt(dx * dx + dy * dy);
5771
+ dollyEnd.set(0, distance);
5772
+ dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
5773
+ dollyOut(dollyDelta.y);
5774
+ dollyStart.copy(dollyEnd);
5922
5775
  }
5923
- function rotateLeft(angle) {
5924
- sphericalDelta.theta -= angle;
5776
+ function handleTouchMoveDollyPan(event) {
5777
+ if (scope.enableZoom) handleTouchMoveDolly(event);
5778
+ if (scope.enablePan) handleTouchMovePan(event);
5925
5779
  }
5926
- function rotateUp(angle) {
5927
- sphericalDelta.phi -= angle;
5780
+ function handleTouchMoveDollyRotate(event) {
5781
+ if (scope.enableZoom) handleTouchMoveDolly(event);
5782
+ if (scope.enableRotate) handleTouchMoveRotate(event);
5928
5783
  }
5929
- const panLeft = function() {
5930
- const v = new Vector38();
5931
- return function panLeft2(distance, objectMatrix) {
5932
- v.setFromMatrixColumn(objectMatrix, 0);
5933
- v.multiplyScalar(-distance);
5934
- panOffset.add(v);
5935
- };
5936
- }();
5937
- const panUp = function() {
5938
- const v = new Vector38();
5939
- return function panUp2(distance, objectMatrix) {
5940
- if (scope.screenSpacePanning === true) {
5941
- v.setFromMatrixColumn(objectMatrix, 1);
5942
- } else {
5943
- v.setFromMatrixColumn(objectMatrix, 0);
5944
- v.crossVectors(scope.object.up, v);
5945
- }
5946
- v.multiplyScalar(distance);
5947
- panOffset.add(v);
5948
- };
5949
- }();
5950
- const pan = function() {
5951
- const offset = new Vector38();
5952
- return function pan2(deltaX, deltaY) {
5953
- const element = scope.domElement;
5954
- if (scope.object.isPerspectiveCamera) {
5955
- const position = scope.object.position;
5956
- offset.copy(position).sub(scope.target);
5957
- let targetDistance = offset.length();
5958
- targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
5959
- panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
5960
- panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
5961
- } else if (scope.object.isOrthographicCamera) {
5962
- panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
5963
- panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
5964
- } else {
5965
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
5966
- scope.enablePan = false;
5967
- }
5968
- };
5969
- }();
5970
- function dollyOut(dollyScale) {
5971
- if (scope.object.isPerspectiveCamera) {
5972
- scale /= dollyScale;
5973
- } else if (scope.object.isOrthographicCamera) {
5974
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
5975
- scope.object.updateProjectionMatrix();
5976
- zoomChanged = true;
5784
+ function handleTouchEnd() {
5785
+ }
5786
+ function onPointerDown(event) {
5787
+ if (scope.enabled === false) return;
5788
+ if (pointers.length === 0) {
5789
+ scope.domElement.setPointerCapture(event.pointerId);
5790
+ scope.domElement.addEventListener("pointermove", onPointerMove);
5791
+ scope.domElement.addEventListener("pointerup", onPointerUp);
5792
+ }
5793
+ addPointer(event);
5794
+ if (event.pointerType === "touch") {
5795
+ onTouchStart(event);
5977
5796
  } else {
5978
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
5979
- scope.enableZoom = false;
5797
+ onMouseDown(event);
5980
5798
  }
5981
5799
  }
5982
- function dollyIn(dollyScale) {
5983
- if (scope.object.isPerspectiveCamera) {
5984
- scale *= dollyScale;
5985
- } else if (scope.object.isOrthographicCamera) {
5986
- scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
5987
- scope.object.updateProjectionMatrix();
5988
- zoomChanged = true;
5800
+ function onPointerMove(event) {
5801
+ if (scope.enabled === false) return;
5802
+ if (event.pointerType === "touch") {
5803
+ onTouchMove(event);
5989
5804
  } else {
5990
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
5991
- scope.enableZoom = false;
5805
+ onMouseMove(event);
5992
5806
  }
5993
5807
  }
5994
- function handleMouseDownRotate(event) {
5995
- rotateStart.set(event.clientX, event.clientY);
5808
+ function onPointerUp(event) {
5809
+ if (scope.enabled === false) return;
5810
+ if (event.pointerType === "touch") {
5811
+ onTouchEnd();
5812
+ } else {
5813
+ onMouseUp(event);
5814
+ }
5815
+ removePointer(event);
5816
+ if (pointers.length === 0) {
5817
+ scope.domElement.releasePointerCapture(event.pointerId);
5818
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
5819
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
5820
+ }
5996
5821
  }
5997
- function handleMouseDownDolly(event) {
5998
- dollyStart.set(event.clientX, event.clientY);
5822
+ function onPointerCancel(event) {
5823
+ removePointer(event);
5999
5824
  }
6000
- function handleMouseDownPan(event) {
6001
- panStart.set(event.clientX, event.clientY);
5825
+ function onMouseDown(event) {
5826
+ let mouseAction;
5827
+ switch (event.button) {
5828
+ case 0:
5829
+ mouseAction = scope.mouseButtons.LEFT;
5830
+ break;
5831
+ case 1:
5832
+ mouseAction = scope.mouseButtons.MIDDLE;
5833
+ break;
5834
+ case 2:
5835
+ mouseAction = scope.mouseButtons.RIGHT;
5836
+ break;
5837
+ default:
5838
+ mouseAction = -1;
5839
+ }
5840
+ switch (mouseAction) {
5841
+ case MOUSE.DOLLY:
5842
+ if (scope.enableZoom === false) return;
5843
+ handleMouseDownDolly(event);
5844
+ state = STATE.DOLLY;
5845
+ break;
5846
+ case MOUSE.ROTATE:
5847
+ if (event.ctrlKey || event.metaKey || event.shiftKey) {
5848
+ if (scope.enablePan === false) return;
5849
+ handleMouseDownPan(event);
5850
+ state = STATE.PAN;
5851
+ } else {
5852
+ if (scope.enableRotate === false) return;
5853
+ handleMouseDownRotate(event);
5854
+ state = STATE.ROTATE;
5855
+ }
5856
+ break;
5857
+ case MOUSE.PAN:
5858
+ if (event.ctrlKey || event.metaKey || event.shiftKey) {
5859
+ if (scope.enableRotate === false) return;
5860
+ handleMouseDownRotate(event);
5861
+ state = STATE.ROTATE;
5862
+ } else {
5863
+ if (scope.enablePan === false) return;
5864
+ handleMouseDownPan(event);
5865
+ state = STATE.PAN;
5866
+ }
5867
+ break;
5868
+ default:
5869
+ state = STATE.NONE;
5870
+ }
5871
+ if (state !== STATE.NONE) {
5872
+ scope.dispatchEvent(_startEvent);
5873
+ }
6002
5874
  }
6003
- function handleMouseMoveRotate(event) {
6004
- rotateEnd.set(event.clientX, event.clientY);
6005
- rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
6006
- const element = scope.domElement;
6007
- rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
6008
- rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
6009
- rotateStart.copy(rotateEnd);
6010
- scope.update();
5875
+ function onMouseMove(event) {
5876
+ if (scope.enabled === false) return;
5877
+ switch (state) {
5878
+ case STATE.ROTATE:
5879
+ if (scope.enableRotate === false) return;
5880
+ handleMouseMoveRotate(event);
5881
+ break;
5882
+ case STATE.DOLLY:
5883
+ if (scope.enableZoom === false) return;
5884
+ handleMouseMoveDolly(event);
5885
+ break;
5886
+ case STATE.PAN:
5887
+ if (scope.enablePan === false) return;
5888
+ handleMouseMovePan(event);
5889
+ break;
5890
+ }
6011
5891
  }
6012
- function handleMouseMoveDolly(event) {
6013
- dollyEnd.set(event.clientX, event.clientY);
6014
- dollyDelta.subVectors(dollyEnd, dollyStart);
6015
- if (dollyDelta.y > 0) {
6016
- dollyOut(getZoomScale());
6017
- } else if (dollyDelta.y < 0) {
6018
- dollyIn(getZoomScale());
5892
+ function onMouseUp(event) {
5893
+ handleMouseUp(event);
5894
+ scope.dispatchEvent(_endEvent);
5895
+ state = STATE.NONE;
5896
+ }
5897
+ function onMouseWheel(event) {
5898
+ if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
5899
+ event.preventDefault();
5900
+ scope.dispatchEvent(_startEvent);
5901
+ handleMouseWheel(event);
5902
+ scope.dispatchEvent(_endEvent);
5903
+ }
5904
+ function onKeyDown(event) {
5905
+ if (scope.enabled === false || scope.enablePan === false) return;
5906
+ handleKeyDown(event);
5907
+ }
5908
+ function onTouchStart(event) {
5909
+ trackPointer(event);
5910
+ switch (pointers.length) {
5911
+ case 1:
5912
+ switch (scope.touches.ONE) {
5913
+ case TOUCH.ROTATE:
5914
+ if (scope.enableRotate === false) return;
5915
+ handleTouchStartRotate();
5916
+ state = STATE.TOUCH_ROTATE;
5917
+ break;
5918
+ case TOUCH.PAN:
5919
+ if (scope.enablePan === false) return;
5920
+ handleTouchStartPan();
5921
+ state = STATE.TOUCH_PAN;
5922
+ break;
5923
+ default:
5924
+ state = STATE.NONE;
5925
+ }
5926
+ break;
5927
+ case 2:
5928
+ switch (scope.touches.TWO) {
5929
+ case TOUCH.DOLLY_PAN:
5930
+ if (scope.enableZoom === false && scope.enablePan === false) return;
5931
+ handleTouchStartDollyPan();
5932
+ state = STATE.TOUCH_DOLLY_PAN;
5933
+ break;
5934
+ case TOUCH.DOLLY_ROTATE:
5935
+ if (scope.enableZoom === false && scope.enableRotate === false) return;
5936
+ handleTouchStartDollyRotate();
5937
+ state = STATE.TOUCH_DOLLY_ROTATE;
5938
+ break;
5939
+ default:
5940
+ state = STATE.NONE;
5941
+ }
5942
+ break;
5943
+ default:
5944
+ state = STATE.NONE;
6019
5945
  }
6020
- dollyStart.copy(dollyEnd);
6021
- scope.update();
6022
- }
6023
- function handleMouseMovePan(event) {
6024
- panEnd.set(event.clientX, event.clientY);
6025
- panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
6026
- pan(panDelta.x, panDelta.y);
6027
- panStart.copy(panEnd);
6028
- scope.update();
6029
- }
6030
- function handleMouseUp() {
6031
- }
6032
- function handleMouseWheel(event) {
6033
- if (event.deltaY < 0) {
6034
- dollyIn(getZoomScale());
6035
- } else if (event.deltaY > 0) {
6036
- dollyOut(getZoomScale());
5946
+ if (state !== STATE.NONE) {
5947
+ scope.dispatchEvent(_startEvent);
6037
5948
  }
6038
- scope.update();
6039
5949
  }
6040
- function handleKeyDown(event) {
6041
- let needsUpdate = false;
6042
- switch (event.code) {
6043
- case scope.keys.UP:
6044
- pan(0, scope.keyPanSpeed);
6045
- needsUpdate = true;
5950
+ function onTouchMove(event) {
5951
+ trackPointer(event);
5952
+ switch (state) {
5953
+ case STATE.TOUCH_ROTATE:
5954
+ if (scope.enableRotate === false) return;
5955
+ handleTouchMoveRotate(event);
5956
+ scope.update();
6046
5957
  break;
6047
- case scope.keys.BOTTOM:
6048
- pan(0, -scope.keyPanSpeed);
6049
- needsUpdate = true;
5958
+ case STATE.TOUCH_PAN:
5959
+ if (scope.enablePan === false) return;
5960
+ handleTouchMovePan(event);
5961
+ scope.update();
6050
5962
  break;
6051
- case scope.keys.LEFT:
6052
- pan(scope.keyPanSpeed, 0);
6053
- needsUpdate = true;
5963
+ case STATE.TOUCH_DOLLY_PAN:
5964
+ if (scope.enableZoom === false && scope.enablePan === false) return;
5965
+ handleTouchMoveDollyPan(event);
5966
+ scope.update();
6054
5967
  break;
6055
- case scope.keys.RIGHT:
6056
- pan(-scope.keyPanSpeed, 0);
6057
- needsUpdate = true;
5968
+ case STATE.TOUCH_DOLLY_ROTATE:
5969
+ if (scope.enableZoom === false && scope.enableRotate === false) return;
5970
+ handleTouchMoveDollyRotate(event);
5971
+ scope.update();
6058
5972
  break;
6059
- }
6060
- if (needsUpdate) {
6061
- event.preventDefault();
6062
- scope.update();
5973
+ default:
5974
+ state = STATE.NONE;
6063
5975
  }
6064
5976
  }
6065
- function handleTouchStartRotate() {
6066
- if (pointers.length === 1) {
6067
- rotateStart.set(pointers[0].pageX, pointers[0].pageY);
6068
- } else {
6069
- const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
6070
- const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
6071
- rotateStart.set(x, y);
5977
+ function onTouchEnd(event) {
5978
+ handleTouchEnd(event);
5979
+ scope.dispatchEvent(_endEvent);
5980
+ state = STATE.NONE;
5981
+ }
5982
+ function onContextMenu(event) {
5983
+ if (scope.enabled === false) return;
5984
+ event.preventDefault();
5985
+ }
5986
+ function addPointer(event) {
5987
+ pointers.push(event);
5988
+ }
5989
+ function removePointer(event) {
5990
+ delete pointerPositions[event.pointerId];
5991
+ for (let i = 0; i < pointers.length; i++) {
5992
+ if (pointers[i].pointerId == event.pointerId) {
5993
+ pointers.splice(i, 1);
5994
+ return;
5995
+ }
6072
5996
  }
6073
5997
  }
6074
- function handleTouchStartPan() {
6075
- if (pointers.length === 1) {
6076
- panStart.set(pointers[0].pageX, pointers[0].pageY);
6077
- } else {
6078
- const x = 0.5 * (pointers[0].pageX + pointers[1].pageX);
6079
- const y = 0.5 * (pointers[0].pageY + pointers[1].pageY);
6080
- panStart.set(x, y);
5998
+ function trackPointer(event) {
5999
+ let position = pointerPositions[event.pointerId];
6000
+ if (position === void 0) {
6001
+ position = new Vector23();
6002
+ pointerPositions[event.pointerId] = position;
6081
6003
  }
6004
+ position.set(event.pageX, event.pageY);
6082
6005
  }
6083
- function handleTouchStartDolly() {
6084
- const dx = pointers[0].pageX - pointers[1].pageX;
6085
- const dy = pointers[0].pageY - pointers[1].pageY;
6086
- const distance = Math.sqrt(dx * dx + dy * dy);
6087
- dollyStart.set(0, distance);
6006
+ function getSecondPointerPosition(event) {
6007
+ const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
6008
+ return pointerPositions[pointer.pointerId];
6088
6009
  }
6089
- function handleTouchStartDollyPan() {
6090
- if (scope.enableZoom) handleTouchStartDolly();
6091
- if (scope.enablePan) handleTouchStartPan();
6010
+ scope.domElement.addEventListener("contextmenu", onContextMenu);
6011
+ scope.domElement.addEventListener("pointerdown", onPointerDown);
6012
+ scope.domElement.addEventListener("pointercancel", onPointerCancel);
6013
+ scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
6014
+ this.update();
6015
+ }
6016
+ };
6017
+ var MapControls = class extends OrbitControls {
6018
+ constructor(object, domElement) {
6019
+ super(object, domElement);
6020
+ this.screenSpacePanning = false;
6021
+ this.mouseButtons.LEFT = MOUSE.PAN;
6022
+ this.mouseButtons.RIGHT = MOUSE.ROTATE;
6023
+ this.touches.ONE = TOUCH.PAN;
6024
+ this.touches.TWO = TOUCH.DOLLY_ROTATE;
6025
+ }
6026
+ };
6027
+
6028
+ // src/renderer/Renderer.ts
6029
+ var _Renderer = class _Renderer {
6030
+ constructor(options) {
6031
+ this._dirty = true;
6032
+ this._animationTimer = void 0;
6033
+ this._animationFrame = void 0;
6034
+ this._resizeListener = void 0;
6035
+ this._disposed = false;
6036
+ this._debugHelpers = [];
6037
+ this._eventDispatchers = /* @__PURE__ */ new Map();
6038
+ this._changeListener = () => {
6039
+ this._dirty = true;
6040
+ };
6041
+ this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6042
+ this._animationLoop = this.animate.bind(this);
6043
+ this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6044
+ this._scene = this.createScene();
6045
+ this._camera = this.createCamera();
6046
+ this._renderer = this.createRenderer();
6047
+ this._composer = this.createComposer();
6048
+ if (this.options.render.stats) {
6049
+ this._stats = new Stats();
6050
+ document.body.appendChild(this._stats.dom);
6092
6051
  }
6093
- function handleTouchStartDollyRotate() {
6094
- if (scope.enableZoom) handleTouchStartDolly();
6095
- if (scope.enableRotate) handleTouchStartRotate();
6052
+ this.init();
6053
+ this._controls = this.createControls();
6054
+ }
6055
+ //<editor-fold desc="INIT">
6056
+ createScene() {
6057
+ return new MineRenderScene();
6058
+ }
6059
+ createCamera() {
6060
+ switch (this.options.camera.type) {
6061
+ case "perspective":
6062
+ default:
6063
+ return new PerspectiveCamera(
6064
+ this.options.camera.perspective.fov,
6065
+ this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
6066
+ this.options.camera.near,
6067
+ this.options.camera.far
6068
+ );
6069
+ case "orthographic":
6070
+ return new OrthographicCamera(
6071
+ this.options.camera.orthographic.left ?? this.viewWidth / -2,
6072
+ this.options.camera.orthographic.right ?? this.viewWidth / 2,
6073
+ this.options.camera.orthographic.top ?? this.viewHeight / 2,
6074
+ this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
6075
+ this.options.camera.near,
6076
+ this.options.camera.far
6077
+ );
6096
6078
  }
6097
- function handleTouchMoveRotate(event) {
6098
- if (pointers.length == 1) {
6099
- rotateEnd.set(event.pageX, event.pageY);
6100
- } else {
6101
- const position = getSecondPointerPosition(event);
6102
- const x = 0.5 * (event.pageX + position.x);
6103
- const y = 0.5 * (event.pageY + position.y);
6104
- rotateEnd.set(x, y);
6079
+ }
6080
+ createRenderer() {
6081
+ const renderer = new WebGLRenderer({
6082
+ antialias: this.options.render.antialias,
6083
+ alpha: true,
6084
+ powerPreference: "high-performance",
6085
+ depth: true
6086
+ });
6087
+ renderer.setClearColor(0, 0);
6088
+ renderer.shadowMap.enabled = true;
6089
+ renderer.shadowMap.type = PCFSoftShadowMap;
6090
+ renderer.outputEncoding = LinearEncoding;
6091
+ renderer.setSize(this.viewWidth, this.viewHeight);
6092
+ return renderer;
6093
+ }
6094
+ createComposer() {
6095
+ const composer = new EffectComposer(this.renderer);
6096
+ if (!this.options.composer.enabled) return composer;
6097
+ composer.setSize(this.viewWidth, this.viewHeight);
6098
+ composer.addPass(new RenderPass(this.scene, this.camera));
6099
+ return composer;
6100
+ }
6101
+ createControls() {
6102
+ var _a;
6103
+ if (!((_a = this.options.controls) == null ? void 0 : _a.enabled)) return void 0;
6104
+ const position = this.camera.position.clone();
6105
+ const controls = new OrbitControls(this.camera, this.renderer.domElement);
6106
+ this.camera.position.copy(position);
6107
+ const target = this.options.camera.lookingAt;
6108
+ if (isVector3(target)) {
6109
+ controls.target.copy(target);
6110
+ } else if (isTripleArray(target)) {
6111
+ controls.target.set(target[0], target[1], target[2]);
6112
+ }
6113
+ controls.update();
6114
+ controls.saveState();
6115
+ this.registerEventDispatcher(controls);
6116
+ return controls;
6117
+ }
6118
+ //</editor-fold>
6119
+ init() {
6120
+ if (this._disposed) return;
6121
+ if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
6122
+ window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
6123
+ }
6124
+ if (this.options.debug.grid) {
6125
+ const gridHelper = new GridHelper(128, 16);
6126
+ this._debugHelpers.push(gridHelper);
6127
+ this.scene.add(gridHelper);
6128
+ const gridHelper2 = new GridHelper(128, 16);
6129
+ this._debugHelpers.push(gridHelper2);
6130
+ gridHelper2.rotation.x = 90 * (Math.PI / 180);
6131
+ this.scene.add(gridHelper2);
6132
+ const gridHelper3 = new GridHelper(128, 16);
6133
+ this._debugHelpers.push(gridHelper3);
6134
+ gridHelper3.rotation.z = 90 * (Math.PI / 180);
6135
+ this.scene.add(gridHelper3);
6136
+ }
6137
+ if (this.options.debug.axes) {
6138
+ const axesHelper = new AxesHelper3(64);
6139
+ this._debugHelpers.push(axesHelper);
6140
+ this.scene.add(axesHelper);
6141
+ }
6142
+ if (this.options.camera.position) {
6143
+ if (isVector3(this.options.camera.position)) {
6144
+ this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
6145
+ } else if (isTripleArray(this.options.camera.position)) {
6146
+ this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
6105
6147
  }
6106
- rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
6107
- const element = scope.domElement;
6108
- rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
6109
- rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
6110
- rotateStart.copy(rotateEnd);
6111
6148
  }
6112
- function handleTouchMovePan(event) {
6113
- if (pointers.length === 1) {
6114
- panEnd.set(event.pageX, event.pageY);
6115
- } else {
6116
- const position = getSecondPointerPosition(event);
6117
- const x = 0.5 * (event.pageX + position.x);
6118
- const y = 0.5 * (event.pageY + position.y);
6119
- panEnd.set(x, y);
6149
+ if (this.options.camera.lookingAt) {
6150
+ if (isVector3(this.options.camera.lookingAt)) {
6151
+ this.camera.lookAt(this.options.camera.lookingAt);
6152
+ } else if (isTripleArray(this.options.camera.lookingAt)) {
6153
+ this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
6120
6154
  }
6121
- panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
6122
- pan(panDelta.x, panDelta.y);
6123
- panStart.copy(panEnd);
6124
6155
  }
6125
- function handleTouchMoveDolly(event) {
6126
- const position = getSecondPointerPosition(event);
6127
- const dx = event.pageX - position.x;
6128
- const dy = event.pageY - position.y;
6129
- const distance = Math.sqrt(dx * dx + dy * dy);
6130
- dollyEnd.set(0, distance);
6131
- dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
6132
- dollyOut(dollyDelta.y);
6133
- dollyStart.copy(dollyEnd);
6156
+ if (this.options.render.autoResize && !this._resizeListener) {
6157
+ this._resizeListener = () => {
6158
+ this.resize(this.viewWidth, this.viewHeight);
6159
+ };
6160
+ window.addEventListener("resize", this._resizeListener);
6161
+ }
6162
+ }
6163
+ get element() {
6164
+ return this._element;
6165
+ }
6166
+ appendTo(element) {
6167
+ if (this._disposed) return;
6168
+ this._element = element;
6169
+ this._element.appendChild(this.renderer.domElement);
6170
+ if (this.viewWidth == 0) {
6171
+ console.warn("0 element width");
6134
6172
  }
6135
- function handleTouchMoveDollyPan(event) {
6136
- if (scope.enableZoom) handleTouchMoveDolly(event);
6137
- if (scope.enablePan) handleTouchMovePan(event);
6173
+ if (this.viewHeight == 0) {
6174
+ console.warn("0 element height");
6138
6175
  }
6139
- function handleTouchMoveDollyRotate(event) {
6140
- if (scope.enableZoom) handleTouchMoveDolly(event);
6141
- if (scope.enableRotate) handleTouchMoveRotate(event);
6176
+ this.resize(this.viewWidth, this.viewHeight);
6177
+ }
6178
+ /**
6179
+ * Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
6180
+ * The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
6181
+ */
6182
+ registerEventDispatcher(dispatcher, changeEvent2 = "change") {
6183
+ if (this._disposed) return;
6184
+ let events = this._eventDispatchers.get(dispatcher);
6185
+ if (!events) {
6186
+ events = /* @__PURE__ */ new Set();
6187
+ this._eventDispatchers.set(dispatcher, events);
6142
6188
  }
6143
- function handleTouchEnd() {
6189
+ if (events.has(changeEvent2)) return;
6190
+ events.add(changeEvent2);
6191
+ dispatcher.addEventListener(changeEvent2, this._changeListener);
6192
+ }
6193
+ resize(width, height) {
6194
+ if (this._disposed) return;
6195
+ if (isPerspectiveCamera(this.camera)) {
6196
+ this.camera.aspect = width / height;
6197
+ this.camera.updateProjectionMatrix();
6198
+ } else if (isOrthographicCamera(this.camera)) {
6199
+ this.camera.left = width / -2;
6200
+ this.camera.right = width / 2;
6201
+ this.camera.top = height / 2;
6202
+ this.camera.bottom = height / -2;
6203
+ this.camera.updateProjectionMatrix();
6144
6204
  }
6145
- function onPointerDown(event) {
6146
- if (scope.enabled === false) return;
6147
- if (pointers.length === 0) {
6148
- scope.domElement.setPointerCapture(event.pointerId);
6149
- scope.domElement.addEventListener("pointermove", onPointerMove);
6150
- scope.domElement.addEventListener("pointerup", onPointerUp);
6151
- }
6152
- addPointer(event);
6153
- if (event.pointerType === "touch") {
6154
- onTouchStart(event);
6155
- } else {
6156
- onMouseDown(event);
6157
- }
6205
+ this.renderer.setSize(width, height);
6206
+ this.composer.setSize(width, height);
6207
+ this._dirty = true;
6208
+ }
6209
+ //<editor-fold desc="RENDER">
6210
+ get dirty() {
6211
+ return this._dirty || this.scene.dirty;
6212
+ }
6213
+ set dirty(dirty) {
6214
+ this._dirty = dirty;
6215
+ this.scene.dirty = dirty;
6216
+ }
6217
+ start() {
6218
+ if (this._disposed) return;
6219
+ this.stop();
6220
+ this.renderer.setAnimationLoop(this._animationLoop);
6221
+ }
6222
+ stop() {
6223
+ if (this._disposed) return;
6224
+ this.renderer.setAnimationLoop(null);
6225
+ if (this._animationTimer)
6226
+ clearTimeout(this._animationTimer);
6227
+ this._animationTimer = void 0;
6228
+ if (this._animationFrame)
6229
+ cancelAnimationFrame(this._animationFrame);
6230
+ this._animationFrame = void 0;
6231
+ }
6232
+ /**
6233
+ * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
6234
+ * renderer cannot be restarted. Scene objects are detached; shared assets and caller-owned
6235
+ * controls must be managed by their owners.
6236
+ */
6237
+ dispose() {
6238
+ var _a;
6239
+ if (this._disposed) return;
6240
+ this.stop();
6241
+ this._disposed = true;
6242
+ if (this._resizeListener) {
6243
+ window.removeEventListener("resize", this._resizeListener);
6244
+ this._resizeListener = void 0;
6245
+ }
6246
+ for (const [dispatcher, events] of this._eventDispatchers) {
6247
+ for (const event of events) {
6248
+ dispatcher.removeEventListener(event, this._changeListener);
6249
+ }
6250
+ }
6251
+ this._eventDispatchers.clear();
6252
+ (_a = this._stats) == null ? void 0 : _a.dom.remove();
6253
+ this._stats = void 0;
6254
+ this.renderer.domElement.remove();
6255
+ this._element = void 0;
6256
+ if (this._controls) {
6257
+ const controls = this._controls;
6258
+ this._controls = void 0;
6259
+ controls.enabled = false;
6260
+ controls.dispose();
6261
+ }
6262
+ this.scene.clear();
6263
+ for (const helper of this._debugHelpers) {
6264
+ helper.geometry.dispose();
6265
+ const materials = Array.isArray(helper.material) ? helper.material : [helper.material];
6266
+ for (const material of materials) {
6267
+ material.dispose();
6268
+ }
6269
+ }
6270
+ this._debugHelpers.length = 0;
6271
+ this.composer.dispose();
6272
+ this.renderer.dispose();
6273
+ this.renderer.forceContextLoss();
6274
+ }
6275
+ animate(t) {
6276
+ var _a;
6277
+ if (this._disposed) return;
6278
+ if (this._stats) {
6279
+ this._stats.begin();
6158
6280
  }
6159
- function onPointerMove(event) {
6160
- if (scope.enabled === false) return;
6161
- if (event.pointerType === "touch") {
6162
- onTouchMove(event);
6163
- } else {
6164
- onMouseMove(event);
6165
- }
6281
+ if ((_a = this._controls) == null ? void 0 : _a.enabled) {
6282
+ this._controls.update();
6166
6283
  }
6167
- function onPointerUp(event) {
6168
- if (scope.enabled === false) return;
6169
- if (event.pointerType === "touch") {
6170
- onTouchEnd();
6284
+ if (this._disposed) return;
6285
+ if (this.dirty || this.options.render.renderAlways) {
6286
+ if (this.options.composer.enabled) {
6287
+ this.composer.render();
6171
6288
  } else {
6172
- onMouseUp(event);
6173
- }
6174
- removePointer(event);
6175
- if (pointers.length === 0) {
6176
- scope.domElement.releasePointerCapture(event.pointerId);
6177
- scope.domElement.removeEventListener("pointermove", onPointerMove);
6178
- scope.domElement.removeEventListener("pointerup", onPointerUp);
6289
+ this.renderer.render(this.scene, this.camera);
6179
6290
  }
6180
6291
  }
6181
- function onPointerCancel(event) {
6182
- removePointer(event);
6292
+ this.dirty = false;
6293
+ if (this._stats) {
6294
+ this._stats.end();
6183
6295
  }
6184
- function onMouseDown(event) {
6185
- let mouseAction;
6186
- switch (event.button) {
6187
- case 0:
6188
- mouseAction = scope.mouseButtons.LEFT;
6189
- break;
6190
- case 1:
6191
- mouseAction = scope.mouseButtons.MIDDLE;
6192
- break;
6193
- case 2:
6194
- mouseAction = scope.mouseButtons.RIGHT;
6195
- break;
6196
- default:
6197
- mouseAction = -1;
6198
- }
6199
- switch (mouseAction) {
6200
- case MOUSE.DOLLY:
6201
- if (scope.enableZoom === false) return;
6202
- handleMouseDownDolly(event);
6203
- state = STATE.DOLLY;
6204
- break;
6205
- case MOUSE.ROTATE:
6206
- if (event.ctrlKey || event.metaKey || event.shiftKey) {
6207
- if (scope.enablePan === false) return;
6208
- handleMouseDownPan(event);
6209
- state = STATE.PAN;
6210
- } else {
6211
- if (scope.enableRotate === false) return;
6212
- handleMouseDownRotate(event);
6213
- state = STATE.ROTATE;
6214
- }
6215
- break;
6216
- case MOUSE.PAN:
6217
- if (event.ctrlKey || event.metaKey || event.shiftKey) {
6218
- if (scope.enableRotate === false) return;
6219
- handleMouseDownRotate(event);
6220
- state = STATE.ROTATE;
6221
- } else {
6222
- if (scope.enablePan === false) return;
6223
- handleMouseDownPan(event);
6224
- state = STATE.PAN;
6225
- }
6226
- break;
6227
- default:
6228
- state = STATE.NONE;
6296
+ }
6297
+ //</editor-fold>
6298
+ toImage() {
6299
+ return this.renderer.domElement.toDataURL();
6300
+ }
6301
+ ///
6302
+ get attachedToBody() {
6303
+ return this.element === document.body;
6304
+ }
6305
+ get viewWidth() {
6306
+ var _a;
6307
+ return this.attachedToBody ? window.innerWidth : ((_a = this.element) == null ? void 0 : _a.offsetWidth) || 0;
6308
+ }
6309
+ get viewHeight() {
6310
+ var _a;
6311
+ return this.attachedToBody ? window.innerHeight : ((_a = this.element) == null ? void 0 : _a.offsetHeight) || 0;
6312
+ }
6313
+ get scene() {
6314
+ return this._scene;
6315
+ }
6316
+ get camera() {
6317
+ return this._camera;
6318
+ }
6319
+ get renderer() {
6320
+ return this._renderer;
6321
+ }
6322
+ get composer() {
6323
+ return this._composer;
6324
+ }
6325
+ /** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
6326
+ get controls() {
6327
+ return this._controls;
6328
+ }
6329
+ ///
6330
+ };
6331
+ _Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
6332
+ camera: {
6333
+ type: "perspective",
6334
+ near: 1,
6335
+ far: 5e3,
6336
+ perspective: {
6337
+ aspect: void 0,
6338
+ fov: 50
6339
+ },
6340
+ orthographic: {
6341
+ left: void 0,
6342
+ right: void 0,
6343
+ top: void 0,
6344
+ bottom: void 0
6345
+ },
6346
+ position: new Vector38(50, 50, 50),
6347
+ lookingAt: new Vector38(0, 0, 0)
6348
+ },
6349
+ render: {
6350
+ fpsLimit: 60,
6351
+ stats: false,
6352
+ antialias: true,
6353
+ shade: true,
6354
+ autoResize: true,
6355
+ renderAlways: false
6356
+ },
6357
+ composer: {
6358
+ enabled: true
6359
+ },
6360
+ controls: {
6361
+ enabled: false
6362
+ },
6363
+ debug: {
6364
+ grid: false,
6365
+ axes: false
6366
+ }
6367
+ });
6368
+ var Renderer = _Renderer;
6369
+
6370
+ // src/skin/Skins.ts
6371
+ var Skins = class {
6372
+ //<editor-fold desc="Skins">
6373
+ static async fromUuidOrUsername(uuidOrUsername) {
6374
+ if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
6375
+ return this.fromUuid(uuidOrUsername);
6376
+ }
6377
+ return this.fromUsername(uuidOrUsername);
6378
+ }
6379
+ static async fromUuid(uuid) {
6380
+ return this.getSkinProxySkinUrl(uuid);
6381
+ }
6382
+ static async fromUsername(username) {
6383
+ return this.usernameToUuid(username).then((uuid) => {
6384
+ if (uuid) {
6385
+ return this.fromUuid(uuid);
6229
6386
  }
6230
- if (state !== STATE.NONE) {
6231
- scope.dispatchEvent(_startEvent);
6387
+ return void 0;
6388
+ });
6389
+ }
6390
+ static async fromMineSkin(mineskinId) {
6391
+ return this.getMineSkin(mineskinId).then((mineskin) => {
6392
+ if (mineskin) {
6393
+ return mineskin["data"]["texture"]["value"]["urls"]["skins"];
6232
6394
  }
6395
+ return void 0;
6396
+ });
6397
+ }
6398
+ //</editor-fold>
6399
+ //<editor-fold desc="Capes">
6400
+ static async capeFromUuidOrUsername(uuidOrUsername) {
6401
+ if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
6402
+ return this.capeFromUuid(uuidOrUsername);
6233
6403
  }
6234
- function onMouseMove(event) {
6235
- if (scope.enabled === false) return;
6236
- switch (state) {
6237
- case STATE.ROTATE:
6238
- if (scope.enableRotate === false) return;
6239
- handleMouseMoveRotate(event);
6240
- break;
6241
- case STATE.DOLLY:
6242
- if (scope.enableZoom === false) return;
6243
- handleMouseMoveDolly(event);
6244
- break;
6245
- case STATE.PAN:
6246
- if (scope.enablePan === false) return;
6247
- handleMouseMovePan(event);
6248
- break;
6404
+ return this.capeFromUsername(uuidOrUsername);
6405
+ }
6406
+ static async capeFromUuid(uuid) {
6407
+ return this.getSkinProxyCapeUrl(uuid);
6408
+ }
6409
+ static async capeFromUsername(username) {
6410
+ return this.usernameToUuid(username).then((uuid) => {
6411
+ if (uuid) {
6412
+ return this.capeFromUuid(uuid);
6249
6413
  }
6250
- }
6251
- function onMouseUp(event) {
6252
- handleMouseUp(event);
6253
- scope.dispatchEvent(_endEvent);
6254
- state = STATE.NONE;
6255
- }
6256
- function onMouseWheel(event) {
6257
- if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
6258
- event.preventDefault();
6259
- scope.dispatchEvent(_startEvent);
6260
- handleMouseWheel(event);
6261
- scope.dispatchEvent(_endEvent);
6262
- }
6263
- function onKeyDown(event) {
6264
- if (scope.enabled === false || scope.enablePan === false) return;
6265
- handleKeyDown(event);
6266
- }
6267
- function onTouchStart(event) {
6268
- trackPointer(event);
6269
- switch (pointers.length) {
6270
- case 1:
6271
- switch (scope.touches.ONE) {
6272
- case TOUCH.ROTATE:
6273
- if (scope.enableRotate === false) return;
6274
- handleTouchStartRotate();
6275
- state = STATE.TOUCH_ROTATE;
6276
- break;
6277
- case TOUCH.PAN:
6278
- if (scope.enablePan === false) return;
6279
- handleTouchStartPan();
6280
- state = STATE.TOUCH_PAN;
6281
- break;
6282
- default:
6283
- state = STATE.NONE;
6284
- }
6285
- break;
6286
- case 2:
6287
- switch (scope.touches.TWO) {
6288
- case TOUCH.DOLLY_PAN:
6289
- if (scope.enableZoom === false && scope.enablePan === false) return;
6290
- handleTouchStartDollyPan();
6291
- state = STATE.TOUCH_DOLLY_PAN;
6292
- break;
6293
- case TOUCH.DOLLY_ROTATE:
6294
- if (scope.enableZoom === false && scope.enableRotate === false) return;
6295
- handleTouchStartDollyRotate();
6296
- state = STATE.TOUCH_DOLLY_ROTATE;
6297
- break;
6298
- default:
6299
- state = STATE.NONE;
6300
- }
6301
- break;
6302
- default:
6303
- state = STATE.NONE;
6414
+ return void 0;
6415
+ });
6416
+ }
6417
+ static async capeFromCapesDev(uuid, capeType = "minecraft") {
6418
+ return this.getCapesDev(uuid, capeType).then((cape) => {
6419
+ if (cape) {
6420
+ return cape == null ? void 0 : cape.stillImageUrl;
6304
6421
  }
6305
- if (state !== STATE.NONE) {
6306
- scope.dispatchEvent(_startEvent);
6422
+ return void 0;
6423
+ });
6424
+ }
6425
+ //</editor-fold>
6426
+ //<editor-fold desc="Helpers">
6427
+ static async usernameToUuid(username) {
6428
+ return this.usernameToUuidSkinProxy(username);
6429
+ }
6430
+ static async usernameToUuidSkinProxy(username) {
6431
+ return Requests.genericRequest({
6432
+ baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
6433
+ url: "/uuid/" + username
6434
+ }).then((res) => {
6435
+ if (res.status === 200) {
6436
+ return res.data["id"];
6307
6437
  }
6308
- }
6309
- function onTouchMove(event) {
6310
- trackPointer(event);
6311
- switch (state) {
6312
- case STATE.TOUCH_ROTATE:
6313
- if (scope.enableRotate === false) return;
6314
- handleTouchMoveRotate(event);
6315
- scope.update();
6316
- break;
6317
- case STATE.TOUCH_PAN:
6318
- if (scope.enablePan === false) return;
6319
- handleTouchMovePan(event);
6320
- scope.update();
6321
- break;
6322
- case STATE.TOUCH_DOLLY_PAN:
6323
- if (scope.enableZoom === false && scope.enablePan === false) return;
6324
- handleTouchMoveDollyPan(event);
6325
- scope.update();
6326
- break;
6327
- case STATE.TOUCH_DOLLY_ROTATE:
6328
- if (scope.enableZoom === false && scope.enableRotate === false) return;
6329
- handleTouchMoveDollyRotate(event);
6330
- scope.update();
6331
- break;
6332
- default:
6333
- state = STATE.NONE;
6438
+ return void 0;
6439
+ }).catch((err) => {
6440
+ console.warn(err);
6441
+ return void 0;
6442
+ });
6443
+ }
6444
+ static async usernameToUuidMineTools(username) {
6445
+ return Requests.genericRequest({
6446
+ baseURL: "https://api.minetools.eu",
6447
+ url: "/uuid/" + username
6448
+ }).then((res) => {
6449
+ if (res.status === 200) {
6450
+ return res.data["id"];
6334
6451
  }
6335
- }
6336
- function onTouchEnd(event) {
6337
- handleTouchEnd(event);
6338
- scope.dispatchEvent(_endEvent);
6339
- state = STATE.NONE;
6340
- }
6341
- function onContextMenu(event) {
6342
- if (scope.enabled === false) return;
6343
- event.preventDefault();
6344
- }
6345
- function addPointer(event) {
6346
- pointers.push(event);
6347
- }
6348
- function removePointer(event) {
6349
- delete pointerPositions[event.pointerId];
6350
- for (let i = 0; i < pointers.length; i++) {
6351
- if (pointers[i].pointerId == event.pointerId) {
6352
- pointers.splice(i, 1);
6353
- return;
6354
- }
6452
+ return void 0;
6453
+ }).catch((err) => {
6454
+ console.warn(err);
6455
+ return void 0;
6456
+ });
6457
+ }
6458
+ static async getProfileFromMinetools(uuid) {
6459
+ return Requests.genericRequest({
6460
+ baseURL: "https://api.minetools.eu",
6461
+ url: "/profile/" + uuid
6462
+ }).then((res) => {
6463
+ if (res.status === 200) {
6464
+ return res.data;
6355
6465
  }
6356
- }
6357
- function trackPointer(event) {
6358
- let position = pointerPositions[event.pointerId];
6359
- if (position === void 0) {
6360
- position = new Vector23();
6361
- pointerPositions[event.pointerId] = position;
6466
+ });
6467
+ }
6468
+ static async getMineSkin(mineskinId) {
6469
+ return Requests.genericRequest({
6470
+ baseURL: "https://api.mineskin.org",
6471
+ url: "/get/uuid/" + mineskinId
6472
+ }).then((res) => {
6473
+ if (res.status === 200) {
6474
+ return res.data;
6362
6475
  }
6363
- position.set(event.pageX, event.pageY);
6364
- }
6365
- function getSecondPointerPosition(event) {
6366
- const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
6367
- return pointerPositions[pointer.pointerId];
6368
- }
6369
- scope.domElement.addEventListener("contextmenu", onContextMenu);
6370
- scope.domElement.addEventListener("pointerdown", onPointerDown);
6371
- scope.domElement.addEventListener("pointercancel", onPointerCancel);
6372
- scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
6373
- this.update();
6476
+ return void 0;
6477
+ }).catch((err) => {
6478
+ console.warn(err);
6479
+ return void 0;
6480
+ });
6374
6481
  }
6375
- };
6376
- var MapControls = class extends OrbitControls {
6377
- constructor(object, domElement) {
6378
- super(object, domElement);
6379
- this.screenSpacePanning = false;
6380
- this.mouseButtons.LEFT = MOUSE.PAN;
6381
- this.mouseButtons.RIGHT = MOUSE.ROTATE;
6382
- this.touches.ONE = TOUCH.PAN;
6383
- this.touches.TWO = TOUCH.DOLLY_ROTATE;
6482
+ static async getCapesDev(uuid, type = "all") {
6483
+ return Requests.genericRequest({
6484
+ baseURL: "https://api.capes.dev",
6485
+ url: "/load/" + uuid + "/" + type
6486
+ }).then((res) => {
6487
+ if (res.status === 200) {
6488
+ return res.data;
6489
+ }
6490
+ return void 0;
6491
+ }).catch((err) => {
6492
+ console.warn(err);
6493
+ return void 0;
6494
+ });
6495
+ }
6496
+ static getCrafatarSkinUrl(uuid) {
6497
+ return "https://crafatar.com/skins/" + uuid;
6384
6498
  }
6499
+ static getCrafatarCapeUrl(uuid) {
6500
+ return "https://crafatar.com/capes/" + uuid;
6501
+ }
6502
+ static getMcHeadsSkinUrl(uuid) {
6503
+ return "https://mc-heads.net/skin/" + uuid;
6504
+ }
6505
+ static getMineSkinPlayerSkinUrl(uuid) {
6506
+ return "https://mineskin.org/skin/player/" + uuid;
6507
+ }
6508
+ static getSkinProxySkinUrl(uuid) {
6509
+ return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
6510
+ }
6511
+ static getSkinProxyCapeUrl(uuid) {
6512
+ return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
6513
+ }
6514
+ //</editor-fold>
6385
6515
  };
6386
6516
 
6387
6517
  // src/world/Chunk.ts