minerender 2.1.0-alpha.1 → 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.
- package/dist/browser/index.d.mts +105 -83
- package/dist/browser/index.d.ts +105 -83
- package/dist/browser/index.js +1089 -963
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1102 -976
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +1122 -998
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +105 -83
- package/dist/node/index.d.ts +105 -83
- package/dist/node/index.js +1095 -965
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1107 -977
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -82665,24 +82665,54 @@ return ${compiler2.callType("value", tagType)}
|
|
|
82665
82665
|
this.stats = new SceneStats();
|
|
82666
82666
|
this.instanceManager = new InstanceManager();
|
|
82667
82667
|
this.dirty = true;
|
|
82668
|
+
this.observedObjects = /* @__PURE__ */ new Set();
|
|
82669
|
+
this.onObjectChange = (event) => {
|
|
82670
|
+
if (event.target?.parent === this) {
|
|
82671
|
+
this.dirty = true;
|
|
82672
|
+
}
|
|
82673
|
+
};
|
|
82668
82674
|
this.options = (0, import_ts_deepmerge9.default)({}, _MineRenderScene.DEFAULT_OPTIONS, options ?? {});
|
|
82669
82675
|
}
|
|
82670
|
-
add(...
|
|
82671
|
-
|
|
82672
|
-
|
|
82673
|
-
|
|
82674
|
-
|
|
82675
|
-
|
|
82676
|
+
add(...objects) {
|
|
82677
|
+
for (const object of objects) {
|
|
82678
|
+
this.dirty = true;
|
|
82679
|
+
try {
|
|
82680
|
+
super.add(object);
|
|
82681
|
+
} finally {
|
|
82682
|
+
if (object?.isObject3D && object !== this) {
|
|
82683
|
+
this.updateObjectRegistration(object, object.parent === this);
|
|
82684
|
+
}
|
|
82676
82685
|
}
|
|
82677
|
-
obj.addEventListener("change", (event) => {
|
|
82678
|
-
this.dirty = true;
|
|
82679
|
-
});
|
|
82680
82686
|
}
|
|
82681
|
-
return
|
|
82687
|
+
return this;
|
|
82682
82688
|
}
|
|
82683
|
-
remove(...
|
|
82684
|
-
|
|
82685
|
-
|
|
82689
|
+
remove(...objects) {
|
|
82690
|
+
for (const object of objects) {
|
|
82691
|
+
if (!this.children.includes(object)) continue;
|
|
82692
|
+
this.dirty = true;
|
|
82693
|
+
this.updateObjectRegistration(object, false);
|
|
82694
|
+
try {
|
|
82695
|
+
super.remove(object);
|
|
82696
|
+
} finally {
|
|
82697
|
+
this.updateObjectRegistration(object, object.parent === this);
|
|
82698
|
+
}
|
|
82699
|
+
}
|
|
82700
|
+
return this;
|
|
82701
|
+
}
|
|
82702
|
+
updateObjectRegistration(object, attached) {
|
|
82703
|
+
if (this.observedObjects.has(object) === attached) return;
|
|
82704
|
+
if (attached) {
|
|
82705
|
+
this.observedObjects.add(object);
|
|
82706
|
+
object.addEventListener("change", this.onObjectChange);
|
|
82707
|
+
} else {
|
|
82708
|
+
this.observedObjects.delete(object);
|
|
82709
|
+
object.removeEventListener("change", this.onObjectChange);
|
|
82710
|
+
}
|
|
82711
|
+
const change = attached ? 1 : -1;
|
|
82712
|
+
this.stats.objectCount += change;
|
|
82713
|
+
if (isSceneObject(object)) {
|
|
82714
|
+
this.stats.sceneObjectCount += change;
|
|
82715
|
+
}
|
|
82686
82716
|
}
|
|
82687
82717
|
async initAndAdd(...object) {
|
|
82688
82718
|
this.dirty = true;
|
|
@@ -84513,1068 +84543,1162 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
|
|
|
84513
84543
|
return lerp2(a4, b4, 1 - 0.125);
|
|
84514
84544
|
}
|
|
84515
84545
|
|
|
84516
|
-
// src/
|
|
84517
|
-
|
|
84518
|
-
|
|
84519
|
-
|
|
84520
|
-
|
|
84521
|
-
|
|
84522
|
-
|
|
84523
|
-
|
|
84524
|
-
|
|
84525
|
-
|
|
84526
|
-
|
|
84527
|
-
|
|
84528
|
-
this.
|
|
84529
|
-
this.
|
|
84530
|
-
|
|
84531
|
-
|
|
84532
|
-
|
|
84546
|
+
// src/three/OrbitControls.js
|
|
84547
|
+
init_dirname();
|
|
84548
|
+
init_buffer2();
|
|
84549
|
+
init_process2();
|
|
84550
|
+
var _changeEvent = { type: "change" };
|
|
84551
|
+
var _startEvent = { type: "start" };
|
|
84552
|
+
var _endEvent = { type: "end" };
|
|
84553
|
+
var OrbitControls = class extends EventDispatcher {
|
|
84554
|
+
constructor(object, domElement) {
|
|
84555
|
+
super();
|
|
84556
|
+
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
84557
|
+
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
84558
|
+
this.object = object;
|
|
84559
|
+
this.domElement = domElement;
|
|
84560
|
+
this.domElement.style.touchAction = "none";
|
|
84561
|
+
this.enabled = true;
|
|
84562
|
+
this.target = new Vector3();
|
|
84563
|
+
this.minDistance = 0;
|
|
84564
|
+
this.maxDistance = Infinity;
|
|
84565
|
+
this.minZoom = 0;
|
|
84566
|
+
this.maxZoom = Infinity;
|
|
84567
|
+
this.minPolarAngle = 0;
|
|
84568
|
+
this.maxPolarAngle = Math.PI;
|
|
84569
|
+
this.minAzimuthAngle = -Infinity;
|
|
84570
|
+
this.maxAzimuthAngle = Infinity;
|
|
84571
|
+
this.enableDamping = false;
|
|
84572
|
+
this.dampingFactor = 0.05;
|
|
84573
|
+
this.enableZoom = true;
|
|
84574
|
+
this.zoomSpeed = 1;
|
|
84575
|
+
this.enableRotate = true;
|
|
84576
|
+
this.rotateSpeed = 1;
|
|
84577
|
+
this.enablePan = true;
|
|
84578
|
+
this.panSpeed = 1;
|
|
84579
|
+
this.screenSpacePanning = true;
|
|
84580
|
+
this.keyPanSpeed = 7;
|
|
84581
|
+
this.autoRotate = false;
|
|
84582
|
+
this.autoRotateSpeed = 2;
|
|
84583
|
+
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
84584
|
+
this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
|
|
84585
|
+
this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN };
|
|
84586
|
+
this.target0 = this.target.clone();
|
|
84587
|
+
this.position0 = this.object.position.clone();
|
|
84588
|
+
this.zoom0 = this.object.zoom;
|
|
84589
|
+
this._domElementKeyEvents = null;
|
|
84590
|
+
this.getPolarAngle = function() {
|
|
84591
|
+
return spherical.phi;
|
|
84592
|
+
};
|
|
84593
|
+
this.getAzimuthalAngle = function() {
|
|
84594
|
+
return spherical.theta;
|
|
84595
|
+
};
|
|
84596
|
+
this.getDistance = function() {
|
|
84597
|
+
return this.object.position.distanceTo(this.target);
|
|
84598
|
+
};
|
|
84599
|
+
this.saveState = function() {
|
|
84600
|
+
scope.target0.copy(scope.target);
|
|
84601
|
+
scope.position0.copy(scope.object.position);
|
|
84602
|
+
scope.zoom0 = scope.object.zoom;
|
|
84603
|
+
};
|
|
84604
|
+
this.reset = function() {
|
|
84605
|
+
scope.target.copy(scope.target0);
|
|
84606
|
+
scope.object.position.copy(scope.position0);
|
|
84607
|
+
scope.object.zoom = scope.zoom0;
|
|
84608
|
+
scope.object.updateProjectionMatrix();
|
|
84609
|
+
scope.dispatchEvent(_changeEvent);
|
|
84610
|
+
scope.update();
|
|
84611
|
+
state = STATE.NONE;
|
|
84612
|
+
};
|
|
84613
|
+
this.update = function() {
|
|
84614
|
+
const offset = new Vector3();
|
|
84615
|
+
const quat = new Quaternion().setFromUnitVectors(object.up, new Vector3(0, 1, 0));
|
|
84616
|
+
const quatInverse = quat.clone().invert();
|
|
84617
|
+
const lastPosition = new Vector3();
|
|
84618
|
+
const lastQuaternion = new Quaternion();
|
|
84619
|
+
const twoPI = 2 * Math.PI;
|
|
84620
|
+
return function update() {
|
|
84621
|
+
const position = scope.object.position;
|
|
84622
|
+
offset.copy(position).sub(scope.target);
|
|
84623
|
+
offset.applyQuaternion(quat);
|
|
84624
|
+
spherical.setFromVector3(offset);
|
|
84625
|
+
if (scope.autoRotate && state === STATE.NONE) {
|
|
84626
|
+
rotateLeft(getAutoRotationAngle());
|
|
84627
|
+
}
|
|
84628
|
+
if (scope.enableDamping) {
|
|
84629
|
+
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
84630
|
+
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
84631
|
+
} else {
|
|
84632
|
+
spherical.theta += sphericalDelta.theta;
|
|
84633
|
+
spherical.phi += sphericalDelta.phi;
|
|
84634
|
+
}
|
|
84635
|
+
let min = scope.minAzimuthAngle;
|
|
84636
|
+
let max = scope.maxAzimuthAngle;
|
|
84637
|
+
if (isFinite(min) && isFinite(max)) {
|
|
84638
|
+
if (min < -Math.PI) min += twoPI;
|
|
84639
|
+
else if (min > Math.PI) min -= twoPI;
|
|
84640
|
+
if (max < -Math.PI) max += twoPI;
|
|
84641
|
+
else if (max > Math.PI) max -= twoPI;
|
|
84642
|
+
if (min <= max) {
|
|
84643
|
+
spherical.theta = Math.max(min, Math.min(max, spherical.theta));
|
|
84644
|
+
} else {
|
|
84645
|
+
spherical.theta = spherical.theta > (min + max) / 2 ? Math.max(min, spherical.theta) : Math.min(max, spherical.theta);
|
|
84646
|
+
}
|
|
84647
|
+
}
|
|
84648
|
+
spherical.phi = Math.max(scope.minPolarAngle, Math.min(scope.maxPolarAngle, spherical.phi));
|
|
84649
|
+
spherical.makeSafe();
|
|
84650
|
+
spherical.radius *= scale;
|
|
84651
|
+
spherical.radius = Math.max(scope.minDistance, Math.min(scope.maxDistance, spherical.radius));
|
|
84652
|
+
if (scope.enableDamping === true) {
|
|
84653
|
+
scope.target.addScaledVector(panOffset, scope.dampingFactor);
|
|
84654
|
+
} else {
|
|
84655
|
+
scope.target.add(panOffset);
|
|
84656
|
+
}
|
|
84657
|
+
offset.setFromSpherical(spherical);
|
|
84658
|
+
offset.applyQuaternion(quatInverse);
|
|
84659
|
+
position.copy(scope.target).add(offset);
|
|
84660
|
+
scope.object.lookAt(scope.target);
|
|
84661
|
+
if (scope.enableDamping === true) {
|
|
84662
|
+
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
84663
|
+
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
84664
|
+
panOffset.multiplyScalar(1 - scope.dampingFactor);
|
|
84665
|
+
} else {
|
|
84666
|
+
sphericalDelta.set(0, 0, 0);
|
|
84667
|
+
panOffset.set(0, 0, 0);
|
|
84668
|
+
}
|
|
84669
|
+
scale = 1;
|
|
84670
|
+
if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
|
|
84671
|
+
scope.dispatchEvent(_changeEvent);
|
|
84672
|
+
lastPosition.copy(scope.object.position);
|
|
84673
|
+
lastQuaternion.copy(scope.object.quaternion);
|
|
84674
|
+
zoomChanged = false;
|
|
84675
|
+
return true;
|
|
84676
|
+
}
|
|
84677
|
+
return false;
|
|
84678
|
+
};
|
|
84679
|
+
}();
|
|
84680
|
+
this.dispose = function() {
|
|
84681
|
+
scope.domElement.removeEventListener("contextmenu", onContextMenu);
|
|
84682
|
+
scope.domElement.removeEventListener("pointerdown", onPointerDown);
|
|
84683
|
+
scope.domElement.removeEventListener("pointercancel", onPointerCancel);
|
|
84684
|
+
scope.domElement.removeEventListener("wheel", onMouseWheel);
|
|
84685
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
84686
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
84687
|
+
if (scope._domElementKeyEvents !== null) {
|
|
84688
|
+
scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
|
|
84689
|
+
}
|
|
84690
|
+
};
|
|
84691
|
+
const scope = this;
|
|
84692
|
+
const STATE = {
|
|
84693
|
+
NONE: -1,
|
|
84694
|
+
ROTATE: 0,
|
|
84695
|
+
DOLLY: 1,
|
|
84696
|
+
PAN: 2,
|
|
84697
|
+
TOUCH_ROTATE: 3,
|
|
84698
|
+
TOUCH_PAN: 4,
|
|
84699
|
+
TOUCH_DOLLY_PAN: 5,
|
|
84700
|
+
TOUCH_DOLLY_ROTATE: 6
|
|
84701
|
+
};
|
|
84702
|
+
let state = STATE.NONE;
|
|
84703
|
+
const EPS = 1e-6;
|
|
84704
|
+
const spherical = new Spherical();
|
|
84705
|
+
const sphericalDelta = new Spherical();
|
|
84706
|
+
let scale = 1;
|
|
84707
|
+
const panOffset = new Vector3();
|
|
84708
|
+
let zoomChanged = false;
|
|
84709
|
+
const rotateStart = new Vector2();
|
|
84710
|
+
const rotateEnd = new Vector2();
|
|
84711
|
+
const rotateDelta = new Vector2();
|
|
84712
|
+
const panStart = new Vector2();
|
|
84713
|
+
const panEnd = new Vector2();
|
|
84714
|
+
const panDelta = new Vector2();
|
|
84715
|
+
const dollyStart = new Vector2();
|
|
84716
|
+
const dollyEnd = new Vector2();
|
|
84717
|
+
const dollyDelta = new Vector2();
|
|
84718
|
+
const pointers = [];
|
|
84719
|
+
const pointerPositions = {};
|
|
84720
|
+
function getAutoRotationAngle() {
|
|
84721
|
+
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
84533
84722
|
}
|
|
84534
|
-
|
|
84535
|
-
|
|
84536
|
-
//<editor-fold desc="INIT">
|
|
84537
|
-
createScene() {
|
|
84538
|
-
return new MineRenderScene();
|
|
84539
|
-
}
|
|
84540
|
-
createCamera() {
|
|
84541
|
-
switch (this.options.camera.type) {
|
|
84542
|
-
case "perspective":
|
|
84543
|
-
default:
|
|
84544
|
-
return new PerspectiveCamera(
|
|
84545
|
-
this.options.camera.perspective.fov,
|
|
84546
|
-
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
84547
|
-
this.options.camera.near,
|
|
84548
|
-
this.options.camera.far
|
|
84549
|
-
);
|
|
84550
|
-
case "orthographic":
|
|
84551
|
-
return new OrthographicCamera(
|
|
84552
|
-
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
84553
|
-
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
84554
|
-
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
84555
|
-
this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
|
|
84556
|
-
this.options.camera.near,
|
|
84557
|
-
this.options.camera.far
|
|
84558
|
-
);
|
|
84723
|
+
function getZoomScale() {
|
|
84724
|
+
return Math.pow(0.95, scope.zoomSpeed);
|
|
84559
84725
|
}
|
|
84560
|
-
|
|
84561
|
-
|
|
84562
|
-
const renderer = new WebGLRenderer({
|
|
84563
|
-
antialias: this.options.render.antialias,
|
|
84564
|
-
alpha: true,
|
|
84565
|
-
powerPreference: "high-performance",
|
|
84566
|
-
depth: true
|
|
84567
|
-
});
|
|
84568
|
-
renderer.setClearColor(0, 0);
|
|
84569
|
-
renderer.shadowMap.enabled = true;
|
|
84570
|
-
renderer.shadowMap.type = PCFSoftShadowMap;
|
|
84571
|
-
renderer.outputEncoding = LinearEncoding;
|
|
84572
|
-
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
84573
|
-
return renderer;
|
|
84574
|
-
}
|
|
84575
|
-
createComposer() {
|
|
84576
|
-
const composer = new EffectComposer(this.renderer);
|
|
84577
|
-
if (!this.options.composer.enabled) return composer;
|
|
84578
|
-
composer.setSize(this.viewWidth, this.viewHeight);
|
|
84579
|
-
composer.addPass(new RenderPass(this.scene, this.camera));
|
|
84580
|
-
return composer;
|
|
84581
|
-
}
|
|
84582
|
-
//</editor-fold>
|
|
84583
|
-
init() {
|
|
84584
|
-
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
84585
|
-
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
84726
|
+
function rotateLeft(angle) {
|
|
84727
|
+
sphericalDelta.theta -= angle;
|
|
84586
84728
|
}
|
|
84587
|
-
|
|
84588
|
-
|
|
84589
|
-
this.scene.add(gridHelper);
|
|
84590
|
-
const gridHelper2 = new GridHelper(128, 16);
|
|
84591
|
-
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
84592
|
-
this.scene.add(gridHelper2);
|
|
84593
|
-
const gridHelper3 = new GridHelper(128, 16);
|
|
84594
|
-
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
84595
|
-
this.scene.add(gridHelper3);
|
|
84729
|
+
function rotateUp(angle) {
|
|
84730
|
+
sphericalDelta.phi -= angle;
|
|
84596
84731
|
}
|
|
84597
|
-
|
|
84598
|
-
const
|
|
84599
|
-
|
|
84732
|
+
const panLeft = function() {
|
|
84733
|
+
const v5 = new Vector3();
|
|
84734
|
+
return function panLeft2(distance, objectMatrix) {
|
|
84735
|
+
v5.setFromMatrixColumn(objectMatrix, 0);
|
|
84736
|
+
v5.multiplyScalar(-distance);
|
|
84737
|
+
panOffset.add(v5);
|
|
84738
|
+
};
|
|
84739
|
+
}();
|
|
84740
|
+
const panUp = function() {
|
|
84741
|
+
const v5 = new Vector3();
|
|
84742
|
+
return function panUp2(distance, objectMatrix) {
|
|
84743
|
+
if (scope.screenSpacePanning === true) {
|
|
84744
|
+
v5.setFromMatrixColumn(objectMatrix, 1);
|
|
84745
|
+
} else {
|
|
84746
|
+
v5.setFromMatrixColumn(objectMatrix, 0);
|
|
84747
|
+
v5.crossVectors(scope.object.up, v5);
|
|
84748
|
+
}
|
|
84749
|
+
v5.multiplyScalar(distance);
|
|
84750
|
+
panOffset.add(v5);
|
|
84751
|
+
};
|
|
84752
|
+
}();
|
|
84753
|
+
const pan = function() {
|
|
84754
|
+
const offset = new Vector3();
|
|
84755
|
+
return function pan2(deltaX, deltaY) {
|
|
84756
|
+
const element = scope.domElement;
|
|
84757
|
+
if (scope.object.isPerspectiveCamera) {
|
|
84758
|
+
const position = scope.object.position;
|
|
84759
|
+
offset.copy(position).sub(scope.target);
|
|
84760
|
+
let targetDistance = offset.length();
|
|
84761
|
+
targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
|
|
84762
|
+
panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
|
|
84763
|
+
panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
|
|
84764
|
+
} else if (scope.object.isOrthographicCamera) {
|
|
84765
|
+
panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
|
|
84766
|
+
panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
|
|
84767
|
+
} else {
|
|
84768
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
|
|
84769
|
+
scope.enablePan = false;
|
|
84770
|
+
}
|
|
84771
|
+
};
|
|
84772
|
+
}();
|
|
84773
|
+
function dollyOut(dollyScale) {
|
|
84774
|
+
if (scope.object.isPerspectiveCamera) {
|
|
84775
|
+
scale /= dollyScale;
|
|
84776
|
+
} else if (scope.object.isOrthographicCamera) {
|
|
84777
|
+
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
|
|
84778
|
+
scope.object.updateProjectionMatrix();
|
|
84779
|
+
zoomChanged = true;
|
|
84780
|
+
} else {
|
|
84781
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
84782
|
+
scope.enableZoom = false;
|
|
84783
|
+
}
|
|
84600
84784
|
}
|
|
84601
|
-
|
|
84602
|
-
if (
|
|
84603
|
-
|
|
84604
|
-
} else if (
|
|
84605
|
-
|
|
84785
|
+
function dollyIn(dollyScale) {
|
|
84786
|
+
if (scope.object.isPerspectiveCamera) {
|
|
84787
|
+
scale *= dollyScale;
|
|
84788
|
+
} else if (scope.object.isOrthographicCamera) {
|
|
84789
|
+
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom / dollyScale));
|
|
84790
|
+
scope.object.updateProjectionMatrix();
|
|
84791
|
+
zoomChanged = true;
|
|
84792
|
+
} else {
|
|
84793
|
+
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
84794
|
+
scope.enableZoom = false;
|
|
84606
84795
|
}
|
|
84607
84796
|
}
|
|
84608
|
-
|
|
84609
|
-
|
|
84610
|
-
|
|
84611
|
-
|
|
84612
|
-
|
|
84797
|
+
function handleMouseDownRotate(event) {
|
|
84798
|
+
rotateStart.set(event.clientX, event.clientY);
|
|
84799
|
+
}
|
|
84800
|
+
function handleMouseDownDolly(event) {
|
|
84801
|
+
dollyStart.set(event.clientX, event.clientY);
|
|
84802
|
+
}
|
|
84803
|
+
function handleMouseDownPan(event) {
|
|
84804
|
+
panStart.set(event.clientX, event.clientY);
|
|
84805
|
+
}
|
|
84806
|
+
function handleMouseMoveRotate(event) {
|
|
84807
|
+
rotateEnd.set(event.clientX, event.clientY);
|
|
84808
|
+
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
84809
|
+
const element = scope.domElement;
|
|
84810
|
+
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
84811
|
+
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
84812
|
+
rotateStart.copy(rotateEnd);
|
|
84813
|
+
scope.update();
|
|
84814
|
+
}
|
|
84815
|
+
function handleMouseMoveDolly(event) {
|
|
84816
|
+
dollyEnd.set(event.clientX, event.clientY);
|
|
84817
|
+
dollyDelta.subVectors(dollyEnd, dollyStart);
|
|
84818
|
+
if (dollyDelta.y > 0) {
|
|
84819
|
+
dollyOut(getZoomScale());
|
|
84820
|
+
} else if (dollyDelta.y < 0) {
|
|
84821
|
+
dollyIn(getZoomScale());
|
|
84613
84822
|
}
|
|
84823
|
+
dollyStart.copy(dollyEnd);
|
|
84824
|
+
scope.update();
|
|
84614
84825
|
}
|
|
84615
|
-
|
|
84616
|
-
|
|
84617
|
-
|
|
84618
|
-
|
|
84619
|
-
|
|
84826
|
+
function handleMouseMovePan(event) {
|
|
84827
|
+
panEnd.set(event.clientX, event.clientY);
|
|
84828
|
+
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
84829
|
+
pan(panDelta.x, panDelta.y);
|
|
84830
|
+
panStart.copy(panEnd);
|
|
84831
|
+
scope.update();
|
|
84620
84832
|
}
|
|
84621
|
-
|
|
84622
|
-
get element() {
|
|
84623
|
-
return this._element;
|
|
84624
|
-
}
|
|
84625
|
-
appendTo(element) {
|
|
84626
|
-
this._element = element;
|
|
84627
|
-
this._element.appendChild(this.renderer.domElement);
|
|
84628
|
-
if (this.viewWidth == 0) {
|
|
84629
|
-
console.warn("0 element width");
|
|
84833
|
+
function handleMouseUp() {
|
|
84630
84834
|
}
|
|
84631
|
-
|
|
84632
|
-
|
|
84835
|
+
function handleMouseWheel(event) {
|
|
84836
|
+
if (event.deltaY < 0) {
|
|
84837
|
+
dollyIn(getZoomScale());
|
|
84838
|
+
} else if (event.deltaY > 0) {
|
|
84839
|
+
dollyOut(getZoomScale());
|
|
84840
|
+
}
|
|
84841
|
+
scope.update();
|
|
84633
84842
|
}
|
|
84634
|
-
|
|
84635
|
-
|
|
84636
|
-
|
|
84637
|
-
|
|
84638
|
-
|
|
84639
|
-
|
|
84640
|
-
|
|
84641
|
-
|
|
84642
|
-
|
|
84643
|
-
|
|
84644
|
-
|
|
84645
|
-
|
|
84646
|
-
|
|
84647
|
-
|
|
84648
|
-
|
|
84649
|
-
|
|
84650
|
-
|
|
84651
|
-
|
|
84652
|
-
|
|
84653
|
-
|
|
84843
|
+
function handleKeyDown(event) {
|
|
84844
|
+
let needsUpdate = false;
|
|
84845
|
+
switch (event.code) {
|
|
84846
|
+
case scope.keys.UP:
|
|
84847
|
+
pan(0, scope.keyPanSpeed);
|
|
84848
|
+
needsUpdate = true;
|
|
84849
|
+
break;
|
|
84850
|
+
case scope.keys.BOTTOM:
|
|
84851
|
+
pan(0, -scope.keyPanSpeed);
|
|
84852
|
+
needsUpdate = true;
|
|
84853
|
+
break;
|
|
84854
|
+
case scope.keys.LEFT:
|
|
84855
|
+
pan(scope.keyPanSpeed, 0);
|
|
84856
|
+
needsUpdate = true;
|
|
84857
|
+
break;
|
|
84858
|
+
case scope.keys.RIGHT:
|
|
84859
|
+
pan(-scope.keyPanSpeed, 0);
|
|
84860
|
+
needsUpdate = true;
|
|
84861
|
+
break;
|
|
84862
|
+
}
|
|
84863
|
+
if (needsUpdate) {
|
|
84864
|
+
event.preventDefault();
|
|
84865
|
+
scope.update();
|
|
84866
|
+
}
|
|
84654
84867
|
}
|
|
84655
|
-
|
|
84656
|
-
|
|
84657
|
-
|
|
84658
|
-
|
|
84659
|
-
|
|
84660
|
-
|
|
84661
|
-
|
|
84662
|
-
|
|
84663
|
-
this._dirty = dirty;
|
|
84664
|
-
this.scene.dirty = dirty;
|
|
84665
|
-
}
|
|
84666
|
-
start() {
|
|
84667
|
-
stop();
|
|
84668
|
-
this.renderer.setAnimationLoop(this._animationLoop);
|
|
84669
|
-
}
|
|
84670
|
-
stop() {
|
|
84671
|
-
this.renderer.setAnimationLoop(null);
|
|
84672
|
-
if (this._animationTimer)
|
|
84673
|
-
clearTimeout(this._animationTimer);
|
|
84674
|
-
this._animationTimer = void 0;
|
|
84675
|
-
if (this._animationFrame)
|
|
84676
|
-
cancelAnimationFrame(this._animationFrame);
|
|
84677
|
-
this._animationFrame = void 0;
|
|
84678
|
-
}
|
|
84679
|
-
animate(t5) {
|
|
84680
|
-
if (this._stats) {
|
|
84681
|
-
this._stats.begin();
|
|
84868
|
+
function handleTouchStartRotate() {
|
|
84869
|
+
if (pointers.length === 1) {
|
|
84870
|
+
rotateStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
84871
|
+
} else {
|
|
84872
|
+
const x4 = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
84873
|
+
const y5 = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
84874
|
+
rotateStart.set(x4, y5);
|
|
84875
|
+
}
|
|
84682
84876
|
}
|
|
84683
|
-
|
|
84684
|
-
if (
|
|
84685
|
-
|
|
84877
|
+
function handleTouchStartPan() {
|
|
84878
|
+
if (pointers.length === 1) {
|
|
84879
|
+
panStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
84686
84880
|
} else {
|
|
84687
|
-
|
|
84881
|
+
const x4 = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
84882
|
+
const y5 = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
84883
|
+
panStart.set(x4, y5);
|
|
84688
84884
|
}
|
|
84689
84885
|
}
|
|
84690
|
-
|
|
84691
|
-
|
|
84692
|
-
|
|
84886
|
+
function handleTouchStartDolly() {
|
|
84887
|
+
const dx = pointers[0].pageX - pointers[1].pageX;
|
|
84888
|
+
const dy = pointers[0].pageY - pointers[1].pageY;
|
|
84889
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
84890
|
+
dollyStart.set(0, distance);
|
|
84693
84891
|
}
|
|
84694
|
-
|
|
84695
|
-
|
|
84696
|
-
|
|
84697
|
-
return this.renderer.domElement.toDataURL();
|
|
84698
|
-
}
|
|
84699
|
-
///
|
|
84700
|
-
get attachedToBody() {
|
|
84701
|
-
return this.element === document.body;
|
|
84702
|
-
}
|
|
84703
|
-
get viewWidth() {
|
|
84704
|
-
return this.attachedToBody ? window.innerWidth : this.element?.offsetWidth || 0;
|
|
84705
|
-
}
|
|
84706
|
-
get viewHeight() {
|
|
84707
|
-
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
84708
|
-
}
|
|
84709
|
-
get scene() {
|
|
84710
|
-
return this._scene;
|
|
84711
|
-
}
|
|
84712
|
-
get camera() {
|
|
84713
|
-
return this._camera;
|
|
84714
|
-
}
|
|
84715
|
-
get renderer() {
|
|
84716
|
-
return this._renderer;
|
|
84717
|
-
}
|
|
84718
|
-
get composer() {
|
|
84719
|
-
return this._composer;
|
|
84720
|
-
}
|
|
84721
|
-
///
|
|
84722
|
-
};
|
|
84723
|
-
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
|
|
84724
|
-
camera: {
|
|
84725
|
-
type: "perspective",
|
|
84726
|
-
near: 1,
|
|
84727
|
-
far: 5e3,
|
|
84728
|
-
perspective: {
|
|
84729
|
-
aspect: void 0,
|
|
84730
|
-
fov: 50
|
|
84731
|
-
},
|
|
84732
|
-
orthographic: {
|
|
84733
|
-
left: void 0,
|
|
84734
|
-
right: void 0,
|
|
84735
|
-
top: void 0,
|
|
84736
|
-
bottom: void 0
|
|
84737
|
-
},
|
|
84738
|
-
position: new Vector3(50, 50, 50),
|
|
84739
|
-
lookingAt: new Vector3(0, 0, 0)
|
|
84740
|
-
},
|
|
84741
|
-
render: {
|
|
84742
|
-
fpsLimit: 60,
|
|
84743
|
-
stats: false,
|
|
84744
|
-
antialias: true,
|
|
84745
|
-
shade: true,
|
|
84746
|
-
autoResize: true,
|
|
84747
|
-
renderAlways: false
|
|
84748
|
-
},
|
|
84749
|
-
composer: {
|
|
84750
|
-
enabled: true
|
|
84751
|
-
},
|
|
84752
|
-
debug: {
|
|
84753
|
-
grid: false,
|
|
84754
|
-
axes: false
|
|
84755
|
-
}
|
|
84756
|
-
});
|
|
84757
|
-
var Renderer = _Renderer;
|
|
84758
|
-
|
|
84759
|
-
// src/renderer/SceneObjectOptions.ts
|
|
84760
|
-
init_dirname();
|
|
84761
|
-
init_buffer2();
|
|
84762
|
-
init_process2();
|
|
84763
|
-
|
|
84764
|
-
// src/skin/index.ts
|
|
84765
|
-
init_dirname();
|
|
84766
|
-
init_buffer2();
|
|
84767
|
-
init_process2();
|
|
84768
|
-
|
|
84769
|
-
// src/skin/Skins.ts
|
|
84770
|
-
init_dirname();
|
|
84771
|
-
init_buffer2();
|
|
84772
|
-
init_process2();
|
|
84773
|
-
var Skins = class {
|
|
84774
|
-
//<editor-fold desc="Skins">
|
|
84775
|
-
static async fromUuidOrUsername(uuidOrUsername) {
|
|
84776
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
84777
|
-
return this.fromUuid(uuidOrUsername);
|
|
84892
|
+
function handleTouchStartDollyPan() {
|
|
84893
|
+
if (scope.enableZoom) handleTouchStartDolly();
|
|
84894
|
+
if (scope.enablePan) handleTouchStartPan();
|
|
84778
84895
|
}
|
|
84779
|
-
|
|
84780
|
-
|
|
84781
|
-
|
|
84782
|
-
|
|
84783
|
-
|
|
84784
|
-
|
|
84785
|
-
|
|
84786
|
-
|
|
84787
|
-
|
|
84788
|
-
|
|
84789
|
-
|
|
84790
|
-
|
|
84791
|
-
}
|
|
84792
|
-
static async fromMineSkin(mineskinId) {
|
|
84793
|
-
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
84794
|
-
if (mineskin) {
|
|
84795
|
-
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
84896
|
+
function handleTouchStartDollyRotate() {
|
|
84897
|
+
if (scope.enableZoom) handleTouchStartDolly();
|
|
84898
|
+
if (scope.enableRotate) handleTouchStartRotate();
|
|
84899
|
+
}
|
|
84900
|
+
function handleTouchMoveRotate(event) {
|
|
84901
|
+
if (pointers.length == 1) {
|
|
84902
|
+
rotateEnd.set(event.pageX, event.pageY);
|
|
84903
|
+
} else {
|
|
84904
|
+
const position = getSecondPointerPosition(event);
|
|
84905
|
+
const x4 = 0.5 * (event.pageX + position.x);
|
|
84906
|
+
const y5 = 0.5 * (event.pageY + position.y);
|
|
84907
|
+
rotateEnd.set(x4, y5);
|
|
84796
84908
|
}
|
|
84797
|
-
|
|
84798
|
-
|
|
84799
|
-
|
|
84800
|
-
|
|
84801
|
-
|
|
84802
|
-
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
84803
|
-
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
84804
|
-
return this.capeFromUuid(uuidOrUsername);
|
|
84909
|
+
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
84910
|
+
const element = scope.domElement;
|
|
84911
|
+
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
84912
|
+
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
84913
|
+
rotateStart.copy(rotateEnd);
|
|
84805
84914
|
}
|
|
84806
|
-
|
|
84807
|
-
|
|
84808
|
-
|
|
84809
|
-
|
|
84810
|
-
|
|
84811
|
-
|
|
84812
|
-
|
|
84813
|
-
|
|
84814
|
-
return this.capeFromUuid(uuid);
|
|
84915
|
+
function handleTouchMovePan(event) {
|
|
84916
|
+
if (pointers.length === 1) {
|
|
84917
|
+
panEnd.set(event.pageX, event.pageY);
|
|
84918
|
+
} else {
|
|
84919
|
+
const position = getSecondPointerPosition(event);
|
|
84920
|
+
const x4 = 0.5 * (event.pageX + position.x);
|
|
84921
|
+
const y5 = 0.5 * (event.pageY + position.y);
|
|
84922
|
+
panEnd.set(x4, y5);
|
|
84815
84923
|
}
|
|
84816
|
-
|
|
84817
|
-
|
|
84818
|
-
|
|
84819
|
-
|
|
84820
|
-
|
|
84821
|
-
|
|
84822
|
-
|
|
84924
|
+
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
84925
|
+
pan(panDelta.x, panDelta.y);
|
|
84926
|
+
panStart.copy(panEnd);
|
|
84927
|
+
}
|
|
84928
|
+
function handleTouchMoveDolly(event) {
|
|
84929
|
+
const position = getSecondPointerPosition(event);
|
|
84930
|
+
const dx = event.pageX - position.x;
|
|
84931
|
+
const dy = event.pageY - position.y;
|
|
84932
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
84933
|
+
dollyEnd.set(0, distance);
|
|
84934
|
+
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
84935
|
+
dollyOut(dollyDelta.y);
|
|
84936
|
+
dollyStart.copy(dollyEnd);
|
|
84937
|
+
}
|
|
84938
|
+
function handleTouchMoveDollyPan(event) {
|
|
84939
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
84940
|
+
if (scope.enablePan) handleTouchMovePan(event);
|
|
84941
|
+
}
|
|
84942
|
+
function handleTouchMoveDollyRotate(event) {
|
|
84943
|
+
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
84944
|
+
if (scope.enableRotate) handleTouchMoveRotate(event);
|
|
84945
|
+
}
|
|
84946
|
+
function handleTouchEnd() {
|
|
84947
|
+
}
|
|
84948
|
+
function onPointerDown(event) {
|
|
84949
|
+
if (scope.enabled === false) return;
|
|
84950
|
+
if (pointers.length === 0) {
|
|
84951
|
+
scope.domElement.setPointerCapture(event.pointerId);
|
|
84952
|
+
scope.domElement.addEventListener("pointermove", onPointerMove);
|
|
84953
|
+
scope.domElement.addEventListener("pointerup", onPointerUp);
|
|
84823
84954
|
}
|
|
84824
|
-
|
|
84825
|
-
|
|
84826
|
-
|
|
84827
|
-
|
|
84828
|
-
|
|
84829
|
-
static async usernameToUuid(username) {
|
|
84830
|
-
return this.usernameToUuidSkinProxy(username);
|
|
84831
|
-
}
|
|
84832
|
-
static async usernameToUuidSkinProxy(username) {
|
|
84833
|
-
return Requests.genericRequest({
|
|
84834
|
-
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
84835
|
-
url: "/uuid/" + username
|
|
84836
|
-
}).then((res) => {
|
|
84837
|
-
if (res.status === 200) {
|
|
84838
|
-
return res.data["id"];
|
|
84955
|
+
addPointer(event);
|
|
84956
|
+
if (event.pointerType === "touch") {
|
|
84957
|
+
onTouchStart(event);
|
|
84958
|
+
} else {
|
|
84959
|
+
onMouseDown(event);
|
|
84839
84960
|
}
|
|
84840
|
-
|
|
84841
|
-
|
|
84842
|
-
|
|
84843
|
-
|
|
84844
|
-
|
|
84845
|
-
|
|
84846
|
-
|
|
84847
|
-
return Requests.genericRequest({
|
|
84848
|
-
baseURL: "https://api.minetools.eu",
|
|
84849
|
-
url: "/uuid/" + username
|
|
84850
|
-
}).then((res) => {
|
|
84851
|
-
if (res.status === 200) {
|
|
84852
|
-
return res.data["id"];
|
|
84961
|
+
}
|
|
84962
|
+
function onPointerMove(event) {
|
|
84963
|
+
if (scope.enabled === false) return;
|
|
84964
|
+
if (event.pointerType === "touch") {
|
|
84965
|
+
onTouchMove(event);
|
|
84966
|
+
} else {
|
|
84967
|
+
onMouseMove(event);
|
|
84853
84968
|
}
|
|
84854
|
-
|
|
84855
|
-
|
|
84856
|
-
|
|
84857
|
-
|
|
84858
|
-
|
|
84859
|
-
|
|
84860
|
-
|
|
84861
|
-
return Requests.genericRequest({
|
|
84862
|
-
baseURL: "https://api.minetools.eu",
|
|
84863
|
-
url: "/profile/" + uuid
|
|
84864
|
-
}).then((res) => {
|
|
84865
|
-
if (res.status === 200) {
|
|
84866
|
-
return res.data;
|
|
84969
|
+
}
|
|
84970
|
+
function onPointerUp(event) {
|
|
84971
|
+
if (scope.enabled === false) return;
|
|
84972
|
+
if (event.pointerType === "touch") {
|
|
84973
|
+
onTouchEnd();
|
|
84974
|
+
} else {
|
|
84975
|
+
onMouseUp(event);
|
|
84867
84976
|
}
|
|
84868
|
-
|
|
84869
|
-
|
|
84870
|
-
|
|
84871
|
-
|
|
84872
|
-
|
|
84873
|
-
url: "/get/uuid/" + mineskinId
|
|
84874
|
-
}).then((res) => {
|
|
84875
|
-
if (res.status === 200) {
|
|
84876
|
-
return res.data;
|
|
84977
|
+
removePointer(event);
|
|
84978
|
+
if (pointers.length === 0) {
|
|
84979
|
+
scope.domElement.releasePointerCapture(event.pointerId);
|
|
84980
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
84981
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
84877
84982
|
}
|
|
84878
|
-
|
|
84879
|
-
|
|
84880
|
-
|
|
84881
|
-
|
|
84882
|
-
|
|
84883
|
-
|
|
84884
|
-
|
|
84885
|
-
|
|
84886
|
-
|
|
84887
|
-
|
|
84888
|
-
|
|
84889
|
-
|
|
84890
|
-
|
|
84983
|
+
}
|
|
84984
|
+
function onPointerCancel(event) {
|
|
84985
|
+
removePointer(event);
|
|
84986
|
+
}
|
|
84987
|
+
function onMouseDown(event) {
|
|
84988
|
+
let mouseAction;
|
|
84989
|
+
switch (event.button) {
|
|
84990
|
+
case 0:
|
|
84991
|
+
mouseAction = scope.mouseButtons.LEFT;
|
|
84992
|
+
break;
|
|
84993
|
+
case 1:
|
|
84994
|
+
mouseAction = scope.mouseButtons.MIDDLE;
|
|
84995
|
+
break;
|
|
84996
|
+
case 2:
|
|
84997
|
+
mouseAction = scope.mouseButtons.RIGHT;
|
|
84998
|
+
break;
|
|
84999
|
+
default:
|
|
85000
|
+
mouseAction = -1;
|
|
84891
85001
|
}
|
|
84892
|
-
|
|
84893
|
-
|
|
84894
|
-
|
|
84895
|
-
|
|
84896
|
-
|
|
84897
|
-
|
|
84898
|
-
|
|
84899
|
-
|
|
84900
|
-
|
|
84901
|
-
|
|
84902
|
-
|
|
84903
|
-
}
|
|
84904
|
-
static getMcHeadsSkinUrl(uuid) {
|
|
84905
|
-
return "https://mc-heads.net/skin/" + uuid;
|
|
84906
|
-
}
|
|
84907
|
-
static getMineSkinPlayerSkinUrl(uuid) {
|
|
84908
|
-
return "https://mineskin.org/skin/player/" + uuid;
|
|
84909
|
-
}
|
|
84910
|
-
static getSkinProxySkinUrl(uuid) {
|
|
84911
|
-
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
84912
|
-
}
|
|
84913
|
-
static getSkinProxyCapeUrl(uuid) {
|
|
84914
|
-
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
84915
|
-
}
|
|
84916
|
-
//</editor-fold>
|
|
84917
|
-
};
|
|
84918
|
-
|
|
84919
|
-
// src/skin/scene/index.ts
|
|
84920
|
-
init_dirname();
|
|
84921
|
-
init_buffer2();
|
|
84922
|
-
init_process2();
|
|
84923
|
-
|
|
84924
|
-
// src/texture/index.ts
|
|
84925
|
-
init_dirname();
|
|
84926
|
-
init_buffer2();
|
|
84927
|
-
init_process2();
|
|
84928
|
-
|
|
84929
|
-
// src/three/index.ts
|
|
84930
|
-
init_dirname();
|
|
84931
|
-
init_buffer2();
|
|
84932
|
-
init_process2();
|
|
84933
|
-
|
|
84934
|
-
// src/three/OrbitControls.js
|
|
84935
|
-
init_dirname();
|
|
84936
|
-
init_buffer2();
|
|
84937
|
-
init_process2();
|
|
84938
|
-
var _changeEvent = { type: "change" };
|
|
84939
|
-
var _startEvent = { type: "start" };
|
|
84940
|
-
var _endEvent = { type: "end" };
|
|
84941
|
-
var OrbitControls = class extends EventDispatcher {
|
|
84942
|
-
constructor(object, domElement) {
|
|
84943
|
-
super();
|
|
84944
|
-
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
84945
|
-
if (domElement === document) console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.');
|
|
84946
|
-
this.object = object;
|
|
84947
|
-
this.domElement = domElement;
|
|
84948
|
-
this.domElement.style.touchAction = "none";
|
|
84949
|
-
this.enabled = true;
|
|
84950
|
-
this.target = new Vector3();
|
|
84951
|
-
this.minDistance = 0;
|
|
84952
|
-
this.maxDistance = Infinity;
|
|
84953
|
-
this.minZoom = 0;
|
|
84954
|
-
this.maxZoom = Infinity;
|
|
84955
|
-
this.minPolarAngle = 0;
|
|
84956
|
-
this.maxPolarAngle = Math.PI;
|
|
84957
|
-
this.minAzimuthAngle = -Infinity;
|
|
84958
|
-
this.maxAzimuthAngle = Infinity;
|
|
84959
|
-
this.enableDamping = false;
|
|
84960
|
-
this.dampingFactor = 0.05;
|
|
84961
|
-
this.enableZoom = true;
|
|
84962
|
-
this.zoomSpeed = 1;
|
|
84963
|
-
this.enableRotate = true;
|
|
84964
|
-
this.rotateSpeed = 1;
|
|
84965
|
-
this.enablePan = true;
|
|
84966
|
-
this.panSpeed = 1;
|
|
84967
|
-
this.screenSpacePanning = true;
|
|
84968
|
-
this.keyPanSpeed = 7;
|
|
84969
|
-
this.autoRotate = false;
|
|
84970
|
-
this.autoRotateSpeed = 2;
|
|
84971
|
-
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
84972
|
-
this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
|
|
84973
|
-
this.touches = { ONE: TOUCH.ROTATE, TWO: TOUCH.DOLLY_PAN };
|
|
84974
|
-
this.target0 = this.target.clone();
|
|
84975
|
-
this.position0 = this.object.position.clone();
|
|
84976
|
-
this.zoom0 = this.object.zoom;
|
|
84977
|
-
this._domElementKeyEvents = null;
|
|
84978
|
-
this.getPolarAngle = function() {
|
|
84979
|
-
return spherical.phi;
|
|
84980
|
-
};
|
|
84981
|
-
this.getAzimuthalAngle = function() {
|
|
84982
|
-
return spherical.theta;
|
|
84983
|
-
};
|
|
84984
|
-
this.getDistance = function() {
|
|
84985
|
-
return this.object.position.distanceTo(this.target);
|
|
84986
|
-
};
|
|
84987
|
-
this.saveState = function() {
|
|
84988
|
-
scope.target0.copy(scope.target);
|
|
84989
|
-
scope.position0.copy(scope.object.position);
|
|
84990
|
-
scope.zoom0 = scope.object.zoom;
|
|
84991
|
-
};
|
|
84992
|
-
this.reset = function() {
|
|
84993
|
-
scope.target.copy(scope.target0);
|
|
84994
|
-
scope.object.position.copy(scope.position0);
|
|
84995
|
-
scope.object.zoom = scope.zoom0;
|
|
84996
|
-
scope.object.updateProjectionMatrix();
|
|
84997
|
-
scope.dispatchEvent(_changeEvent);
|
|
84998
|
-
scope.update();
|
|
84999
|
-
state = STATE.NONE;
|
|
85000
|
-
};
|
|
85001
|
-
this.update = function() {
|
|
85002
|
-
const offset = new Vector3();
|
|
85003
|
-
const quat = new Quaternion().setFromUnitVectors(object.up, new Vector3(0, 1, 0));
|
|
85004
|
-
const quatInverse = quat.clone().invert();
|
|
85005
|
-
const lastPosition = new Vector3();
|
|
85006
|
-
const lastQuaternion = new Quaternion();
|
|
85007
|
-
const twoPI = 2 * Math.PI;
|
|
85008
|
-
return function update() {
|
|
85009
|
-
const position = scope.object.position;
|
|
85010
|
-
offset.copy(position).sub(scope.target);
|
|
85011
|
-
offset.applyQuaternion(quat);
|
|
85012
|
-
spherical.setFromVector3(offset);
|
|
85013
|
-
if (scope.autoRotate && state === STATE.NONE) {
|
|
85014
|
-
rotateLeft(getAutoRotationAngle());
|
|
85015
|
-
}
|
|
85016
|
-
if (scope.enableDamping) {
|
|
85017
|
-
spherical.theta += sphericalDelta.theta * scope.dampingFactor;
|
|
85018
|
-
spherical.phi += sphericalDelta.phi * scope.dampingFactor;
|
|
85019
|
-
} else {
|
|
85020
|
-
spherical.theta += sphericalDelta.theta;
|
|
85021
|
-
spherical.phi += sphericalDelta.phi;
|
|
85022
|
-
}
|
|
85023
|
-
let min = scope.minAzimuthAngle;
|
|
85024
|
-
let max = scope.maxAzimuthAngle;
|
|
85025
|
-
if (isFinite(min) && isFinite(max)) {
|
|
85026
|
-
if (min < -Math.PI) min += twoPI;
|
|
85027
|
-
else if (min > Math.PI) min -= twoPI;
|
|
85028
|
-
if (max < -Math.PI) max += twoPI;
|
|
85029
|
-
else if (max > Math.PI) max -= twoPI;
|
|
85030
|
-
if (min <= max) {
|
|
85031
|
-
spherical.theta = Math.max(min, Math.min(max, spherical.theta));
|
|
85002
|
+
switch (mouseAction) {
|
|
85003
|
+
case MOUSE.DOLLY:
|
|
85004
|
+
if (scope.enableZoom === false) return;
|
|
85005
|
+
handleMouseDownDolly(event);
|
|
85006
|
+
state = STATE.DOLLY;
|
|
85007
|
+
break;
|
|
85008
|
+
case MOUSE.ROTATE:
|
|
85009
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
85010
|
+
if (scope.enablePan === false) return;
|
|
85011
|
+
handleMouseDownPan(event);
|
|
85012
|
+
state = STATE.PAN;
|
|
85032
85013
|
} else {
|
|
85033
|
-
|
|
85014
|
+
if (scope.enableRotate === false) return;
|
|
85015
|
+
handleMouseDownRotate(event);
|
|
85016
|
+
state = STATE.ROTATE;
|
|
85034
85017
|
}
|
|
85035
|
-
|
|
85036
|
-
|
|
85037
|
-
|
|
85038
|
-
|
|
85039
|
-
|
|
85040
|
-
|
|
85041
|
-
|
|
85042
|
-
|
|
85043
|
-
|
|
85044
|
-
|
|
85045
|
-
|
|
85046
|
-
|
|
85047
|
-
|
|
85048
|
-
|
|
85049
|
-
if (scope.enableDamping === true) {
|
|
85050
|
-
sphericalDelta.theta *= 1 - scope.dampingFactor;
|
|
85051
|
-
sphericalDelta.phi *= 1 - scope.dampingFactor;
|
|
85052
|
-
panOffset.multiplyScalar(1 - scope.dampingFactor);
|
|
85053
|
-
} else {
|
|
85054
|
-
sphericalDelta.set(0, 0, 0);
|
|
85055
|
-
panOffset.set(0, 0, 0);
|
|
85056
|
-
}
|
|
85057
|
-
scale = 1;
|
|
85058
|
-
if (zoomChanged || lastPosition.distanceToSquared(scope.object.position) > EPS || 8 * (1 - lastQuaternion.dot(scope.object.quaternion)) > EPS) {
|
|
85059
|
-
scope.dispatchEvent(_changeEvent);
|
|
85060
|
-
lastPosition.copy(scope.object.position);
|
|
85061
|
-
lastQuaternion.copy(scope.object.quaternion);
|
|
85062
|
-
zoomChanged = false;
|
|
85063
|
-
return true;
|
|
85064
|
-
}
|
|
85065
|
-
return false;
|
|
85066
|
-
};
|
|
85067
|
-
}();
|
|
85068
|
-
this.dispose = function() {
|
|
85069
|
-
scope.domElement.removeEventListener("contextmenu", onContextMenu);
|
|
85070
|
-
scope.domElement.removeEventListener("pointerdown", onPointerDown);
|
|
85071
|
-
scope.domElement.removeEventListener("pointercancel", onPointerCancel);
|
|
85072
|
-
scope.domElement.removeEventListener("wheel", onMouseWheel);
|
|
85073
|
-
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
85074
|
-
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
85075
|
-
if (scope._domElementKeyEvents !== null) {
|
|
85076
|
-
scope._domElementKeyEvents.removeEventListener("keydown", onKeyDown);
|
|
85018
|
+
break;
|
|
85019
|
+
case MOUSE.PAN:
|
|
85020
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
85021
|
+
if (scope.enableRotate === false) return;
|
|
85022
|
+
handleMouseDownRotate(event);
|
|
85023
|
+
state = STATE.ROTATE;
|
|
85024
|
+
} else {
|
|
85025
|
+
if (scope.enablePan === false) return;
|
|
85026
|
+
handleMouseDownPan(event);
|
|
85027
|
+
state = STATE.PAN;
|
|
85028
|
+
}
|
|
85029
|
+
break;
|
|
85030
|
+
default:
|
|
85031
|
+
state = STATE.NONE;
|
|
85077
85032
|
}
|
|
85078
|
-
|
|
85079
|
-
|
|
85080
|
-
const STATE = {
|
|
85081
|
-
NONE: -1,
|
|
85082
|
-
ROTATE: 0,
|
|
85083
|
-
DOLLY: 1,
|
|
85084
|
-
PAN: 2,
|
|
85085
|
-
TOUCH_ROTATE: 3,
|
|
85086
|
-
TOUCH_PAN: 4,
|
|
85087
|
-
TOUCH_DOLLY_PAN: 5,
|
|
85088
|
-
TOUCH_DOLLY_ROTATE: 6
|
|
85089
|
-
};
|
|
85090
|
-
let state = STATE.NONE;
|
|
85091
|
-
const EPS = 1e-6;
|
|
85092
|
-
const spherical = new Spherical();
|
|
85093
|
-
const sphericalDelta = new Spherical();
|
|
85094
|
-
let scale = 1;
|
|
85095
|
-
const panOffset = new Vector3();
|
|
85096
|
-
let zoomChanged = false;
|
|
85097
|
-
const rotateStart = new Vector2();
|
|
85098
|
-
const rotateEnd = new Vector2();
|
|
85099
|
-
const rotateDelta = new Vector2();
|
|
85100
|
-
const panStart = new Vector2();
|
|
85101
|
-
const panEnd = new Vector2();
|
|
85102
|
-
const panDelta = new Vector2();
|
|
85103
|
-
const dollyStart = new Vector2();
|
|
85104
|
-
const dollyEnd = new Vector2();
|
|
85105
|
-
const dollyDelta = new Vector2();
|
|
85106
|
-
const pointers = [];
|
|
85107
|
-
const pointerPositions = {};
|
|
85108
|
-
function getAutoRotationAngle() {
|
|
85109
|
-
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
85110
|
-
}
|
|
85111
|
-
function getZoomScale() {
|
|
85112
|
-
return Math.pow(0.95, scope.zoomSpeed);
|
|
85113
|
-
}
|
|
85114
|
-
function rotateLeft(angle) {
|
|
85115
|
-
sphericalDelta.theta -= angle;
|
|
85116
|
-
}
|
|
85117
|
-
function rotateUp(angle) {
|
|
85118
|
-
sphericalDelta.phi -= angle;
|
|
85119
|
-
}
|
|
85120
|
-
const panLeft = function() {
|
|
85121
|
-
const v5 = new Vector3();
|
|
85122
|
-
return function panLeft2(distance, objectMatrix) {
|
|
85123
|
-
v5.setFromMatrixColumn(objectMatrix, 0);
|
|
85124
|
-
v5.multiplyScalar(-distance);
|
|
85125
|
-
panOffset.add(v5);
|
|
85126
|
-
};
|
|
85127
|
-
}();
|
|
85128
|
-
const panUp = function() {
|
|
85129
|
-
const v5 = new Vector3();
|
|
85130
|
-
return function panUp2(distance, objectMatrix) {
|
|
85131
|
-
if (scope.screenSpacePanning === true) {
|
|
85132
|
-
v5.setFromMatrixColumn(objectMatrix, 1);
|
|
85133
|
-
} else {
|
|
85134
|
-
v5.setFromMatrixColumn(objectMatrix, 0);
|
|
85135
|
-
v5.crossVectors(scope.object.up, v5);
|
|
85136
|
-
}
|
|
85137
|
-
v5.multiplyScalar(distance);
|
|
85138
|
-
panOffset.add(v5);
|
|
85139
|
-
};
|
|
85140
|
-
}();
|
|
85141
|
-
const pan = function() {
|
|
85142
|
-
const offset = new Vector3();
|
|
85143
|
-
return function pan2(deltaX, deltaY) {
|
|
85144
|
-
const element = scope.domElement;
|
|
85145
|
-
if (scope.object.isPerspectiveCamera) {
|
|
85146
|
-
const position = scope.object.position;
|
|
85147
|
-
offset.copy(position).sub(scope.target);
|
|
85148
|
-
let targetDistance = offset.length();
|
|
85149
|
-
targetDistance *= Math.tan(scope.object.fov / 2 * Math.PI / 180);
|
|
85150
|
-
panLeft(2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix);
|
|
85151
|
-
panUp(2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix);
|
|
85152
|
-
} else if (scope.object.isOrthographicCamera) {
|
|
85153
|
-
panLeft(deltaX * (scope.object.right - scope.object.left) / scope.object.zoom / element.clientWidth, scope.object.matrix);
|
|
85154
|
-
panUp(deltaY * (scope.object.top - scope.object.bottom) / scope.object.zoom / element.clientHeight, scope.object.matrix);
|
|
85155
|
-
} else {
|
|
85156
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.");
|
|
85157
|
-
scope.enablePan = false;
|
|
85158
|
-
}
|
|
85159
|
-
};
|
|
85160
|
-
}();
|
|
85161
|
-
function dollyOut(dollyScale) {
|
|
85162
|
-
if (scope.object.isPerspectiveCamera) {
|
|
85163
|
-
scale /= dollyScale;
|
|
85164
|
-
} else if (scope.object.isOrthographicCamera) {
|
|
85165
|
-
scope.object.zoom = Math.max(scope.minZoom, Math.min(scope.maxZoom, scope.object.zoom * dollyScale));
|
|
85166
|
-
scope.object.updateProjectionMatrix();
|
|
85167
|
-
zoomChanged = true;
|
|
85168
|
-
} else {
|
|
85169
|
-
console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.");
|
|
85170
|
-
scope.enableZoom = false;
|
|
85033
|
+
if (state !== STATE.NONE) {
|
|
85034
|
+
scope.dispatchEvent(_startEvent);
|
|
85171
85035
|
}
|
|
85172
85036
|
}
|
|
85173
|
-
function
|
|
85174
|
-
if (scope.
|
|
85175
|
-
|
|
85176
|
-
|
|
85177
|
-
|
|
85178
|
-
|
|
85179
|
-
|
|
85180
|
-
|
|
85181
|
-
|
|
85182
|
-
|
|
85037
|
+
function onMouseMove(event) {
|
|
85038
|
+
if (scope.enabled === false) return;
|
|
85039
|
+
switch (state) {
|
|
85040
|
+
case STATE.ROTATE:
|
|
85041
|
+
if (scope.enableRotate === false) return;
|
|
85042
|
+
handleMouseMoveRotate(event);
|
|
85043
|
+
break;
|
|
85044
|
+
case STATE.DOLLY:
|
|
85045
|
+
if (scope.enableZoom === false) return;
|
|
85046
|
+
handleMouseMoveDolly(event);
|
|
85047
|
+
break;
|
|
85048
|
+
case STATE.PAN:
|
|
85049
|
+
if (scope.enablePan === false) return;
|
|
85050
|
+
handleMouseMovePan(event);
|
|
85051
|
+
break;
|
|
85183
85052
|
}
|
|
85184
85053
|
}
|
|
85185
|
-
function
|
|
85186
|
-
|
|
85187
|
-
|
|
85188
|
-
|
|
85189
|
-
dollyStart.set(event.clientX, event.clientY);
|
|
85054
|
+
function onMouseUp(event) {
|
|
85055
|
+
handleMouseUp(event);
|
|
85056
|
+
scope.dispatchEvent(_endEvent);
|
|
85057
|
+
state = STATE.NONE;
|
|
85190
85058
|
}
|
|
85191
|
-
function
|
|
85192
|
-
|
|
85059
|
+
function onMouseWheel(event) {
|
|
85060
|
+
if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;
|
|
85061
|
+
event.preventDefault();
|
|
85062
|
+
scope.dispatchEvent(_startEvent);
|
|
85063
|
+
handleMouseWheel(event);
|
|
85064
|
+
scope.dispatchEvent(_endEvent);
|
|
85193
85065
|
}
|
|
85194
|
-
function
|
|
85195
|
-
|
|
85196
|
-
|
|
85197
|
-
const element = scope.domElement;
|
|
85198
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
85199
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
85200
|
-
rotateStart.copy(rotateEnd);
|
|
85201
|
-
scope.update();
|
|
85066
|
+
function onKeyDown(event) {
|
|
85067
|
+
if (scope.enabled === false || scope.enablePan === false) return;
|
|
85068
|
+
handleKeyDown(event);
|
|
85202
85069
|
}
|
|
85203
|
-
function
|
|
85204
|
-
|
|
85205
|
-
|
|
85206
|
-
|
|
85207
|
-
|
|
85208
|
-
|
|
85209
|
-
|
|
85070
|
+
function onTouchStart(event) {
|
|
85071
|
+
trackPointer(event);
|
|
85072
|
+
switch (pointers.length) {
|
|
85073
|
+
case 1:
|
|
85074
|
+
switch (scope.touches.ONE) {
|
|
85075
|
+
case TOUCH.ROTATE:
|
|
85076
|
+
if (scope.enableRotate === false) return;
|
|
85077
|
+
handleTouchStartRotate();
|
|
85078
|
+
state = STATE.TOUCH_ROTATE;
|
|
85079
|
+
break;
|
|
85080
|
+
case TOUCH.PAN:
|
|
85081
|
+
if (scope.enablePan === false) return;
|
|
85082
|
+
handleTouchStartPan();
|
|
85083
|
+
state = STATE.TOUCH_PAN;
|
|
85084
|
+
break;
|
|
85085
|
+
default:
|
|
85086
|
+
state = STATE.NONE;
|
|
85087
|
+
}
|
|
85088
|
+
break;
|
|
85089
|
+
case 2:
|
|
85090
|
+
switch (scope.touches.TWO) {
|
|
85091
|
+
case TOUCH.DOLLY_PAN:
|
|
85092
|
+
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
85093
|
+
handleTouchStartDollyPan();
|
|
85094
|
+
state = STATE.TOUCH_DOLLY_PAN;
|
|
85095
|
+
break;
|
|
85096
|
+
case TOUCH.DOLLY_ROTATE:
|
|
85097
|
+
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
85098
|
+
handleTouchStartDollyRotate();
|
|
85099
|
+
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
85100
|
+
break;
|
|
85101
|
+
default:
|
|
85102
|
+
state = STATE.NONE;
|
|
85103
|
+
}
|
|
85104
|
+
break;
|
|
85105
|
+
default:
|
|
85106
|
+
state = STATE.NONE;
|
|
85210
85107
|
}
|
|
85211
|
-
|
|
85212
|
-
|
|
85213
|
-
}
|
|
85214
|
-
function handleMouseMovePan(event) {
|
|
85215
|
-
panEnd.set(event.clientX, event.clientY);
|
|
85216
|
-
panDelta.subVectors(panEnd, panStart).multiplyScalar(scope.panSpeed);
|
|
85217
|
-
pan(panDelta.x, panDelta.y);
|
|
85218
|
-
panStart.copy(panEnd);
|
|
85219
|
-
scope.update();
|
|
85220
|
-
}
|
|
85221
|
-
function handleMouseUp() {
|
|
85222
|
-
}
|
|
85223
|
-
function handleMouseWheel(event) {
|
|
85224
|
-
if (event.deltaY < 0) {
|
|
85225
|
-
dollyIn(getZoomScale());
|
|
85226
|
-
} else if (event.deltaY > 0) {
|
|
85227
|
-
dollyOut(getZoomScale());
|
|
85108
|
+
if (state !== STATE.NONE) {
|
|
85109
|
+
scope.dispatchEvent(_startEvent);
|
|
85228
85110
|
}
|
|
85229
|
-
scope.update();
|
|
85230
85111
|
}
|
|
85231
|
-
function
|
|
85232
|
-
|
|
85233
|
-
switch (
|
|
85234
|
-
case
|
|
85235
|
-
|
|
85236
|
-
|
|
85112
|
+
function onTouchMove(event) {
|
|
85113
|
+
trackPointer(event);
|
|
85114
|
+
switch (state) {
|
|
85115
|
+
case STATE.TOUCH_ROTATE:
|
|
85116
|
+
if (scope.enableRotate === false) return;
|
|
85117
|
+
handleTouchMoveRotate(event);
|
|
85118
|
+
scope.update();
|
|
85237
85119
|
break;
|
|
85238
|
-
case
|
|
85239
|
-
|
|
85240
|
-
|
|
85120
|
+
case STATE.TOUCH_PAN:
|
|
85121
|
+
if (scope.enablePan === false) return;
|
|
85122
|
+
handleTouchMovePan(event);
|
|
85123
|
+
scope.update();
|
|
85241
85124
|
break;
|
|
85242
|
-
case
|
|
85243
|
-
|
|
85244
|
-
|
|
85125
|
+
case STATE.TOUCH_DOLLY_PAN:
|
|
85126
|
+
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
85127
|
+
handleTouchMoveDollyPan(event);
|
|
85128
|
+
scope.update();
|
|
85245
85129
|
break;
|
|
85246
|
-
case
|
|
85247
|
-
|
|
85248
|
-
|
|
85130
|
+
case STATE.TOUCH_DOLLY_ROTATE:
|
|
85131
|
+
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
85132
|
+
handleTouchMoveDollyRotate(event);
|
|
85133
|
+
scope.update();
|
|
85249
85134
|
break;
|
|
85250
|
-
|
|
85251
|
-
|
|
85252
|
-
event.preventDefault();
|
|
85253
|
-
scope.update();
|
|
85254
|
-
}
|
|
85255
|
-
}
|
|
85256
|
-
function handleTouchStartRotate() {
|
|
85257
|
-
if (pointers.length === 1) {
|
|
85258
|
-
rotateStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
85259
|
-
} else {
|
|
85260
|
-
const x4 = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
85261
|
-
const y5 = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
85262
|
-
rotateStart.set(x4, y5);
|
|
85263
|
-
}
|
|
85264
|
-
}
|
|
85265
|
-
function handleTouchStartPan() {
|
|
85266
|
-
if (pointers.length === 1) {
|
|
85267
|
-
panStart.set(pointers[0].pageX, pointers[0].pageY);
|
|
85268
|
-
} else {
|
|
85269
|
-
const x4 = 0.5 * (pointers[0].pageX + pointers[1].pageX);
|
|
85270
|
-
const y5 = 0.5 * (pointers[0].pageY + pointers[1].pageY);
|
|
85271
|
-
panStart.set(x4, y5);
|
|
85135
|
+
default:
|
|
85136
|
+
state = STATE.NONE;
|
|
85272
85137
|
}
|
|
85273
85138
|
}
|
|
85274
|
-
function
|
|
85275
|
-
|
|
85276
|
-
|
|
85277
|
-
|
|
85278
|
-
dollyStart.set(0, distance);
|
|
85139
|
+
function onTouchEnd(event) {
|
|
85140
|
+
handleTouchEnd(event);
|
|
85141
|
+
scope.dispatchEvent(_endEvent);
|
|
85142
|
+
state = STATE.NONE;
|
|
85279
85143
|
}
|
|
85280
|
-
function
|
|
85281
|
-
if (scope.
|
|
85282
|
-
|
|
85144
|
+
function onContextMenu(event) {
|
|
85145
|
+
if (scope.enabled === false) return;
|
|
85146
|
+
event.preventDefault();
|
|
85283
85147
|
}
|
|
85284
|
-
function
|
|
85285
|
-
|
|
85286
|
-
if (scope.enableRotate) handleTouchStartRotate();
|
|
85148
|
+
function addPointer(event) {
|
|
85149
|
+
pointers.push(event);
|
|
85287
85150
|
}
|
|
85288
|
-
function
|
|
85289
|
-
|
|
85290
|
-
|
|
85291
|
-
|
|
85292
|
-
|
|
85293
|
-
|
|
85294
|
-
|
|
85295
|
-
rotateEnd.set(x4, y5);
|
|
85151
|
+
function removePointer(event) {
|
|
85152
|
+
delete pointerPositions[event.pointerId];
|
|
85153
|
+
for (let i4 = 0; i4 < pointers.length; i4++) {
|
|
85154
|
+
if (pointers[i4].pointerId == event.pointerId) {
|
|
85155
|
+
pointers.splice(i4, 1);
|
|
85156
|
+
return;
|
|
85157
|
+
}
|
|
85296
85158
|
}
|
|
85297
|
-
rotateDelta.subVectors(rotateEnd, rotateStart).multiplyScalar(scope.rotateSpeed);
|
|
85298
|
-
const element = scope.domElement;
|
|
85299
|
-
rotateLeft(2 * Math.PI * rotateDelta.x / element.clientHeight);
|
|
85300
|
-
rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight);
|
|
85301
|
-
rotateStart.copy(rotateEnd);
|
|
85302
85159
|
}
|
|
85303
|
-
function
|
|
85304
|
-
|
|
85305
|
-
|
|
85306
|
-
|
|
85307
|
-
|
|
85308
|
-
const x4 = 0.5 * (event.pageX + position.x);
|
|
85309
|
-
const y5 = 0.5 * (event.pageY + position.y);
|
|
85310
|
-
panEnd.set(x4, y5);
|
|
85160
|
+
function trackPointer(event) {
|
|
85161
|
+
let position = pointerPositions[event.pointerId];
|
|
85162
|
+
if (position === void 0) {
|
|
85163
|
+
position = new Vector2();
|
|
85164
|
+
pointerPositions[event.pointerId] = position;
|
|
85311
85165
|
}
|
|
85312
|
-
|
|
85313
|
-
pan(panDelta.x, panDelta.y);
|
|
85314
|
-
panStart.copy(panEnd);
|
|
85315
|
-
}
|
|
85316
|
-
function handleTouchMoveDolly(event) {
|
|
85317
|
-
const position = getSecondPointerPosition(event);
|
|
85318
|
-
const dx = event.pageX - position.x;
|
|
85319
|
-
const dy = event.pageY - position.y;
|
|
85320
|
-
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
85321
|
-
dollyEnd.set(0, distance);
|
|
85322
|
-
dollyDelta.set(0, Math.pow(dollyEnd.y / dollyStart.y, scope.zoomSpeed));
|
|
85323
|
-
dollyOut(dollyDelta.y);
|
|
85324
|
-
dollyStart.copy(dollyEnd);
|
|
85325
|
-
}
|
|
85326
|
-
function handleTouchMoveDollyPan(event) {
|
|
85327
|
-
if (scope.enableZoom) handleTouchMoveDolly(event);
|
|
85328
|
-
if (scope.enablePan) handleTouchMovePan(event);
|
|
85166
|
+
position.set(event.pageX, event.pageY);
|
|
85329
85167
|
}
|
|
85330
|
-
function
|
|
85331
|
-
|
|
85332
|
-
|
|
85168
|
+
function getSecondPointerPosition(event) {
|
|
85169
|
+
const pointer = event.pointerId === pointers[0].pointerId ? pointers[1] : pointers[0];
|
|
85170
|
+
return pointerPositions[pointer.pointerId];
|
|
85333
85171
|
}
|
|
85334
|
-
|
|
85172
|
+
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
85173
|
+
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
85174
|
+
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
85175
|
+
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
85176
|
+
this.update();
|
|
85177
|
+
}
|
|
85178
|
+
};
|
|
85179
|
+
var MapControls = class extends OrbitControls {
|
|
85180
|
+
constructor(object, domElement) {
|
|
85181
|
+
super(object, domElement);
|
|
85182
|
+
this.screenSpacePanning = false;
|
|
85183
|
+
this.mouseButtons.LEFT = MOUSE.PAN;
|
|
85184
|
+
this.mouseButtons.RIGHT = MOUSE.ROTATE;
|
|
85185
|
+
this.touches.ONE = TOUCH.PAN;
|
|
85186
|
+
this.touches.TWO = TOUCH.DOLLY_ROTATE;
|
|
85187
|
+
}
|
|
85188
|
+
};
|
|
85189
|
+
|
|
85190
|
+
// src/renderer/Renderer.ts
|
|
85191
|
+
var _Renderer = class _Renderer {
|
|
85192
|
+
constructor(options) {
|
|
85193
|
+
this._dirty = true;
|
|
85194
|
+
this._animationTimer = void 0;
|
|
85195
|
+
this._animationFrame = void 0;
|
|
85196
|
+
this._resizeListener = void 0;
|
|
85197
|
+
this._disposed = false;
|
|
85198
|
+
this._debugHelpers = [];
|
|
85199
|
+
this._eventDispatchers = /* @__PURE__ */ new Map();
|
|
85200
|
+
this._changeListener = () => {
|
|
85201
|
+
this._dirty = true;
|
|
85202
|
+
};
|
|
85203
|
+
this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
|
|
85204
|
+
this._animationLoop = this.animate.bind(this);
|
|
85205
|
+
this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
|
|
85206
|
+
this._scene = this.createScene();
|
|
85207
|
+
this._camera = this.createCamera();
|
|
85208
|
+
this._renderer = this.createRenderer();
|
|
85209
|
+
this._composer = this.createComposer();
|
|
85210
|
+
if (this.options.render.stats) {
|
|
85211
|
+
this._stats = new import_stats.default();
|
|
85212
|
+
document.body.appendChild(this._stats.dom);
|
|
85335
85213
|
}
|
|
85336
|
-
|
|
85337
|
-
|
|
85338
|
-
|
|
85339
|
-
|
|
85340
|
-
|
|
85341
|
-
|
|
85342
|
-
|
|
85343
|
-
|
|
85344
|
-
|
|
85345
|
-
|
|
85346
|
-
|
|
85347
|
-
|
|
85348
|
-
|
|
85214
|
+
this.init();
|
|
85215
|
+
this._controls = this.createControls();
|
|
85216
|
+
}
|
|
85217
|
+
//<editor-fold desc="INIT">
|
|
85218
|
+
createScene() {
|
|
85219
|
+
return new MineRenderScene();
|
|
85220
|
+
}
|
|
85221
|
+
createCamera() {
|
|
85222
|
+
switch (this.options.camera.type) {
|
|
85223
|
+
case "perspective":
|
|
85224
|
+
default:
|
|
85225
|
+
return new PerspectiveCamera(
|
|
85226
|
+
this.options.camera.perspective.fov,
|
|
85227
|
+
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
85228
|
+
this.options.camera.near,
|
|
85229
|
+
this.options.camera.far
|
|
85230
|
+
);
|
|
85231
|
+
case "orthographic":
|
|
85232
|
+
return new OrthographicCamera(
|
|
85233
|
+
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
85234
|
+
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
85235
|
+
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
85236
|
+
this.options.camera.orthographic.bottom ?? this.viewHeight / -2,
|
|
85237
|
+
this.options.camera.near,
|
|
85238
|
+
this.options.camera.far
|
|
85239
|
+
);
|
|
85349
85240
|
}
|
|
85350
|
-
|
|
85351
|
-
|
|
85352
|
-
|
|
85353
|
-
|
|
85354
|
-
|
|
85355
|
-
|
|
85356
|
-
|
|
85241
|
+
}
|
|
85242
|
+
createRenderer() {
|
|
85243
|
+
const renderer = new WebGLRenderer({
|
|
85244
|
+
antialias: this.options.render.antialias,
|
|
85245
|
+
alpha: true,
|
|
85246
|
+
powerPreference: "high-performance",
|
|
85247
|
+
depth: true
|
|
85248
|
+
});
|
|
85249
|
+
renderer.setClearColor(0, 0);
|
|
85250
|
+
renderer.shadowMap.enabled = true;
|
|
85251
|
+
renderer.shadowMap.type = PCFSoftShadowMap;
|
|
85252
|
+
renderer.outputEncoding = LinearEncoding;
|
|
85253
|
+
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
85254
|
+
return renderer;
|
|
85255
|
+
}
|
|
85256
|
+
createComposer() {
|
|
85257
|
+
const composer = new EffectComposer(this.renderer);
|
|
85258
|
+
if (!this.options.composer.enabled) return composer;
|
|
85259
|
+
composer.setSize(this.viewWidth, this.viewHeight);
|
|
85260
|
+
composer.addPass(new RenderPass(this.scene, this.camera));
|
|
85261
|
+
return composer;
|
|
85262
|
+
}
|
|
85263
|
+
createControls() {
|
|
85264
|
+
if (!this.options.controls?.enabled) return void 0;
|
|
85265
|
+
const position = this.camera.position.clone();
|
|
85266
|
+
const controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
85267
|
+
this.camera.position.copy(position);
|
|
85268
|
+
const target = this.options.camera.lookingAt;
|
|
85269
|
+
if (isVector3(target)) {
|
|
85270
|
+
controls.target.copy(target);
|
|
85271
|
+
} else if (isTripleArray(target)) {
|
|
85272
|
+
controls.target.set(target[0], target[1], target[2]);
|
|
85273
|
+
}
|
|
85274
|
+
controls.update();
|
|
85275
|
+
controls.saveState();
|
|
85276
|
+
this.registerEventDispatcher(controls);
|
|
85277
|
+
return controls;
|
|
85278
|
+
}
|
|
85279
|
+
//</editor-fold>
|
|
85280
|
+
init() {
|
|
85281
|
+
if (this._disposed) return;
|
|
85282
|
+
if (typeof window["__THREE_DEVTOOLS__"] !== "undefined") {
|
|
85283
|
+
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
85357
85284
|
}
|
|
85358
|
-
|
|
85359
|
-
|
|
85360
|
-
|
|
85361
|
-
|
|
85362
|
-
|
|
85363
|
-
|
|
85364
|
-
|
|
85365
|
-
|
|
85366
|
-
|
|
85367
|
-
|
|
85368
|
-
|
|
85369
|
-
|
|
85370
|
-
}
|
|
85285
|
+
if (this.options.debug.grid) {
|
|
85286
|
+
const gridHelper = new GridHelper(128, 16);
|
|
85287
|
+
this._debugHelpers.push(gridHelper);
|
|
85288
|
+
this.scene.add(gridHelper);
|
|
85289
|
+
const gridHelper2 = new GridHelper(128, 16);
|
|
85290
|
+
this._debugHelpers.push(gridHelper2);
|
|
85291
|
+
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
85292
|
+
this.scene.add(gridHelper2);
|
|
85293
|
+
const gridHelper3 = new GridHelper(128, 16);
|
|
85294
|
+
this._debugHelpers.push(gridHelper3);
|
|
85295
|
+
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
85296
|
+
this.scene.add(gridHelper3);
|
|
85371
85297
|
}
|
|
85372
|
-
|
|
85373
|
-
|
|
85298
|
+
if (this.options.debug.axes) {
|
|
85299
|
+
const axesHelper = new AxesHelper(64);
|
|
85300
|
+
this._debugHelpers.push(axesHelper);
|
|
85301
|
+
this.scene.add(axesHelper);
|
|
85374
85302
|
}
|
|
85375
|
-
|
|
85376
|
-
|
|
85377
|
-
|
|
85378
|
-
|
|
85379
|
-
|
|
85380
|
-
break;
|
|
85381
|
-
case 1:
|
|
85382
|
-
mouseAction = scope.mouseButtons.MIDDLE;
|
|
85383
|
-
break;
|
|
85384
|
-
case 2:
|
|
85385
|
-
mouseAction = scope.mouseButtons.RIGHT;
|
|
85386
|
-
break;
|
|
85387
|
-
default:
|
|
85388
|
-
mouseAction = -1;
|
|
85389
|
-
}
|
|
85390
|
-
switch (mouseAction) {
|
|
85391
|
-
case MOUSE.DOLLY:
|
|
85392
|
-
if (scope.enableZoom === false) return;
|
|
85393
|
-
handleMouseDownDolly(event);
|
|
85394
|
-
state = STATE.DOLLY;
|
|
85395
|
-
break;
|
|
85396
|
-
case MOUSE.ROTATE:
|
|
85397
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
85398
|
-
if (scope.enablePan === false) return;
|
|
85399
|
-
handleMouseDownPan(event);
|
|
85400
|
-
state = STATE.PAN;
|
|
85401
|
-
} else {
|
|
85402
|
-
if (scope.enableRotate === false) return;
|
|
85403
|
-
handleMouseDownRotate(event);
|
|
85404
|
-
state = STATE.ROTATE;
|
|
85405
|
-
}
|
|
85406
|
-
break;
|
|
85407
|
-
case MOUSE.PAN:
|
|
85408
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
85409
|
-
if (scope.enableRotate === false) return;
|
|
85410
|
-
handleMouseDownRotate(event);
|
|
85411
|
-
state = STATE.ROTATE;
|
|
85412
|
-
} else {
|
|
85413
|
-
if (scope.enablePan === false) return;
|
|
85414
|
-
handleMouseDownPan(event);
|
|
85415
|
-
state = STATE.PAN;
|
|
85416
|
-
}
|
|
85417
|
-
break;
|
|
85418
|
-
default:
|
|
85419
|
-
state = STATE.NONE;
|
|
85420
|
-
}
|
|
85421
|
-
if (state !== STATE.NONE) {
|
|
85422
|
-
scope.dispatchEvent(_startEvent);
|
|
85303
|
+
if (this.options.camera.position) {
|
|
85304
|
+
if (isVector3(this.options.camera.position)) {
|
|
85305
|
+
this.camera.position.set(this.options.camera.position.x, this.options.camera.position.y, this.options.camera.position.z);
|
|
85306
|
+
} else if (isTripleArray(this.options.camera.position)) {
|
|
85307
|
+
this.camera.position.set(this.options.camera.position[0], this.options.camera.position[1], this.options.camera.position[2]);
|
|
85423
85308
|
}
|
|
85424
85309
|
}
|
|
85425
|
-
|
|
85426
|
-
if (
|
|
85427
|
-
|
|
85428
|
-
|
|
85429
|
-
|
|
85430
|
-
handleMouseMoveRotate(event);
|
|
85431
|
-
break;
|
|
85432
|
-
case STATE.DOLLY:
|
|
85433
|
-
if (scope.enableZoom === false) return;
|
|
85434
|
-
handleMouseMoveDolly(event);
|
|
85435
|
-
break;
|
|
85436
|
-
case STATE.PAN:
|
|
85437
|
-
if (scope.enablePan === false) return;
|
|
85438
|
-
handleMouseMovePan(event);
|
|
85439
|
-
break;
|
|
85310
|
+
if (this.options.camera.lookingAt) {
|
|
85311
|
+
if (isVector3(this.options.camera.lookingAt)) {
|
|
85312
|
+
this.camera.lookAt(this.options.camera.lookingAt);
|
|
85313
|
+
} else if (isTripleArray(this.options.camera.lookingAt)) {
|
|
85314
|
+
this.camera.lookAt(this.options.camera.lookingAt[0], this.options.camera.lookingAt[1], this.options.camera.lookingAt[2]);
|
|
85440
85315
|
}
|
|
85441
85316
|
}
|
|
85442
|
-
|
|
85443
|
-
|
|
85444
|
-
|
|
85445
|
-
|
|
85317
|
+
if (this.options.render.autoResize && !this._resizeListener) {
|
|
85318
|
+
this._resizeListener = () => {
|
|
85319
|
+
this.resize(this.viewWidth, this.viewHeight);
|
|
85320
|
+
};
|
|
85321
|
+
window.addEventListener("resize", this._resizeListener);
|
|
85446
85322
|
}
|
|
85447
|
-
|
|
85448
|
-
|
|
85449
|
-
|
|
85450
|
-
|
|
85451
|
-
|
|
85452
|
-
|
|
85323
|
+
}
|
|
85324
|
+
get element() {
|
|
85325
|
+
return this._element;
|
|
85326
|
+
}
|
|
85327
|
+
appendTo(element) {
|
|
85328
|
+
if (this._disposed) return;
|
|
85329
|
+
this._element = element;
|
|
85330
|
+
this._element.appendChild(this.renderer.domElement);
|
|
85331
|
+
if (this.viewWidth == 0) {
|
|
85332
|
+
console.warn("0 element width");
|
|
85453
85333
|
}
|
|
85454
|
-
|
|
85455
|
-
|
|
85456
|
-
|
|
85334
|
+
if (this.viewHeight == 0) {
|
|
85335
|
+
console.warn("0 element height");
|
|
85336
|
+
}
|
|
85337
|
+
this.resize(this.viewWidth, this.viewHeight);
|
|
85338
|
+
}
|
|
85339
|
+
/**
|
|
85340
|
+
* Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
|
|
85341
|
+
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
85342
|
+
*/
|
|
85343
|
+
registerEventDispatcher(dispatcher, changeEvent2 = "change") {
|
|
85344
|
+
if (this._disposed) return;
|
|
85345
|
+
let events = this._eventDispatchers.get(dispatcher);
|
|
85346
|
+
if (!events) {
|
|
85347
|
+
events = /* @__PURE__ */ new Set();
|
|
85348
|
+
this._eventDispatchers.set(dispatcher, events);
|
|
85349
|
+
}
|
|
85350
|
+
if (events.has(changeEvent2)) return;
|
|
85351
|
+
events.add(changeEvent2);
|
|
85352
|
+
dispatcher.addEventListener(changeEvent2, this._changeListener);
|
|
85353
|
+
}
|
|
85354
|
+
resize(width, height) {
|
|
85355
|
+
if (this._disposed) return;
|
|
85356
|
+
if (isPerspectiveCamera(this.camera)) {
|
|
85357
|
+
this.camera.aspect = width / height;
|
|
85358
|
+
this.camera.updateProjectionMatrix();
|
|
85359
|
+
} else if (isOrthographicCamera(this.camera)) {
|
|
85360
|
+
this.camera.left = width / -2;
|
|
85361
|
+
this.camera.right = width / 2;
|
|
85362
|
+
this.camera.top = height / 2;
|
|
85363
|
+
this.camera.bottom = height / -2;
|
|
85364
|
+
this.camera.updateProjectionMatrix();
|
|
85365
|
+
}
|
|
85366
|
+
this.renderer.setSize(width, height);
|
|
85367
|
+
this.composer.setSize(width, height);
|
|
85368
|
+
this._dirty = true;
|
|
85369
|
+
}
|
|
85370
|
+
//<editor-fold desc="RENDER">
|
|
85371
|
+
get dirty() {
|
|
85372
|
+
return this._dirty || this.scene.dirty;
|
|
85373
|
+
}
|
|
85374
|
+
set dirty(dirty) {
|
|
85375
|
+
this._dirty = dirty;
|
|
85376
|
+
this.scene.dirty = dirty;
|
|
85377
|
+
}
|
|
85378
|
+
start() {
|
|
85379
|
+
if (this._disposed) return;
|
|
85380
|
+
this.stop();
|
|
85381
|
+
this.renderer.setAnimationLoop(this._animationLoop);
|
|
85382
|
+
}
|
|
85383
|
+
stop() {
|
|
85384
|
+
if (this._disposed) return;
|
|
85385
|
+
this.renderer.setAnimationLoop(null);
|
|
85386
|
+
if (this._animationTimer)
|
|
85387
|
+
clearTimeout(this._animationTimer);
|
|
85388
|
+
this._animationTimer = void 0;
|
|
85389
|
+
if (this._animationFrame)
|
|
85390
|
+
cancelAnimationFrame(this._animationFrame);
|
|
85391
|
+
this._animationFrame = void 0;
|
|
85392
|
+
}
|
|
85393
|
+
/**
|
|
85394
|
+
* Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
|
|
85395
|
+
* renderer cannot be restarted. Scene objects are detached; shared assets and caller-owned
|
|
85396
|
+
* controls must be managed by their owners.
|
|
85397
|
+
*/
|
|
85398
|
+
dispose() {
|
|
85399
|
+
if (this._disposed) return;
|
|
85400
|
+
this.stop();
|
|
85401
|
+
this._disposed = true;
|
|
85402
|
+
if (this._resizeListener) {
|
|
85403
|
+
window.removeEventListener("resize", this._resizeListener);
|
|
85404
|
+
this._resizeListener = void 0;
|
|
85405
|
+
}
|
|
85406
|
+
for (const [dispatcher, events] of this._eventDispatchers) {
|
|
85407
|
+
for (const event of events) {
|
|
85408
|
+
dispatcher.removeEventListener(event, this._changeListener);
|
|
85409
|
+
}
|
|
85410
|
+
}
|
|
85411
|
+
this._eventDispatchers.clear();
|
|
85412
|
+
this._stats?.dom.remove();
|
|
85413
|
+
this._stats = void 0;
|
|
85414
|
+
this.renderer.domElement.remove();
|
|
85415
|
+
this._element = void 0;
|
|
85416
|
+
if (this._controls) {
|
|
85417
|
+
const controls = this._controls;
|
|
85418
|
+
this._controls = void 0;
|
|
85419
|
+
controls.enabled = false;
|
|
85420
|
+
controls.dispose();
|
|
85421
|
+
}
|
|
85422
|
+
this.scene.clear();
|
|
85423
|
+
for (const helper of this._debugHelpers) {
|
|
85424
|
+
helper.geometry.dispose();
|
|
85425
|
+
const materials = Array.isArray(helper.material) ? helper.material : [helper.material];
|
|
85426
|
+
for (const material of materials) {
|
|
85427
|
+
material.dispose();
|
|
85428
|
+
}
|
|
85429
|
+
}
|
|
85430
|
+
this._debugHelpers.length = 0;
|
|
85431
|
+
this.composer.dispose();
|
|
85432
|
+
this.renderer.dispose();
|
|
85433
|
+
this.renderer.forceContextLoss();
|
|
85434
|
+
}
|
|
85435
|
+
animate(t5) {
|
|
85436
|
+
if (this._disposed) return;
|
|
85437
|
+
if (this._stats) {
|
|
85438
|
+
this._stats.begin();
|
|
85439
|
+
}
|
|
85440
|
+
if (this._controls?.enabled) {
|
|
85441
|
+
this._controls.update();
|
|
85442
|
+
}
|
|
85443
|
+
if (this._disposed) return;
|
|
85444
|
+
if (this.dirty || this.options.render.renderAlways) {
|
|
85445
|
+
if (this.options.composer.enabled) {
|
|
85446
|
+
this.composer.render();
|
|
85447
|
+
} else {
|
|
85448
|
+
this.renderer.render(this.scene, this.camera);
|
|
85449
|
+
}
|
|
85450
|
+
}
|
|
85451
|
+
this.dirty = false;
|
|
85452
|
+
if (this._stats) {
|
|
85453
|
+
this._stats.end();
|
|
85454
|
+
}
|
|
85455
|
+
}
|
|
85456
|
+
//</editor-fold>
|
|
85457
|
+
toImage() {
|
|
85458
|
+
return this.renderer.domElement.toDataURL();
|
|
85459
|
+
}
|
|
85460
|
+
///
|
|
85461
|
+
get attachedToBody() {
|
|
85462
|
+
return this.element === document.body;
|
|
85463
|
+
}
|
|
85464
|
+
get viewWidth() {
|
|
85465
|
+
return this.attachedToBody ? window.innerWidth : this.element?.offsetWidth || 0;
|
|
85466
|
+
}
|
|
85467
|
+
get viewHeight() {
|
|
85468
|
+
return this.attachedToBody ? window.innerHeight : this.element?.offsetHeight || 0;
|
|
85469
|
+
}
|
|
85470
|
+
get scene() {
|
|
85471
|
+
return this._scene;
|
|
85472
|
+
}
|
|
85473
|
+
get camera() {
|
|
85474
|
+
return this._camera;
|
|
85475
|
+
}
|
|
85476
|
+
get renderer() {
|
|
85477
|
+
return this._renderer;
|
|
85478
|
+
}
|
|
85479
|
+
get composer() {
|
|
85480
|
+
return this._composer;
|
|
85481
|
+
}
|
|
85482
|
+
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
85483
|
+
get controls() {
|
|
85484
|
+
return this._controls;
|
|
85485
|
+
}
|
|
85486
|
+
///
|
|
85487
|
+
};
|
|
85488
|
+
_Renderer.DEFAULT_OPTIONS = (0, import_ts_deepmerge10.default)({}, {
|
|
85489
|
+
camera: {
|
|
85490
|
+
type: "perspective",
|
|
85491
|
+
near: 1,
|
|
85492
|
+
far: 5e3,
|
|
85493
|
+
perspective: {
|
|
85494
|
+
aspect: void 0,
|
|
85495
|
+
fov: 50
|
|
85496
|
+
},
|
|
85497
|
+
orthographic: {
|
|
85498
|
+
left: void 0,
|
|
85499
|
+
right: void 0,
|
|
85500
|
+
top: void 0,
|
|
85501
|
+
bottom: void 0
|
|
85502
|
+
},
|
|
85503
|
+
position: new Vector3(50, 50, 50),
|
|
85504
|
+
lookingAt: new Vector3(0, 0, 0)
|
|
85505
|
+
},
|
|
85506
|
+
render: {
|
|
85507
|
+
fpsLimit: 60,
|
|
85508
|
+
stats: false,
|
|
85509
|
+
antialias: true,
|
|
85510
|
+
shade: true,
|
|
85511
|
+
autoResize: true,
|
|
85512
|
+
renderAlways: false
|
|
85513
|
+
},
|
|
85514
|
+
composer: {
|
|
85515
|
+
enabled: true
|
|
85516
|
+
},
|
|
85517
|
+
controls: {
|
|
85518
|
+
enabled: false
|
|
85519
|
+
},
|
|
85520
|
+
debug: {
|
|
85521
|
+
grid: false,
|
|
85522
|
+
axes: false
|
|
85523
|
+
}
|
|
85524
|
+
});
|
|
85525
|
+
var Renderer = _Renderer;
|
|
85526
|
+
|
|
85527
|
+
// src/renderer/SceneObjectOptions.ts
|
|
85528
|
+
init_dirname();
|
|
85529
|
+
init_buffer2();
|
|
85530
|
+
init_process2();
|
|
85531
|
+
|
|
85532
|
+
// src/skin/index.ts
|
|
85533
|
+
init_dirname();
|
|
85534
|
+
init_buffer2();
|
|
85535
|
+
init_process2();
|
|
85536
|
+
|
|
85537
|
+
// src/skin/Skins.ts
|
|
85538
|
+
init_dirname();
|
|
85539
|
+
init_buffer2();
|
|
85540
|
+
init_process2();
|
|
85541
|
+
var Skins = class {
|
|
85542
|
+
//<editor-fold desc="Skins">
|
|
85543
|
+
static async fromUuidOrUsername(uuidOrUsername) {
|
|
85544
|
+
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
85545
|
+
return this.fromUuid(uuidOrUsername);
|
|
85457
85546
|
}
|
|
85458
|
-
|
|
85459
|
-
|
|
85460
|
-
|
|
85461
|
-
|
|
85462
|
-
|
|
85463
|
-
|
|
85464
|
-
|
|
85465
|
-
|
|
85466
|
-
|
|
85467
|
-
break;
|
|
85468
|
-
case TOUCH.PAN:
|
|
85469
|
-
if (scope.enablePan === false) return;
|
|
85470
|
-
handleTouchStartPan();
|
|
85471
|
-
state = STATE.TOUCH_PAN;
|
|
85472
|
-
break;
|
|
85473
|
-
default:
|
|
85474
|
-
state = STATE.NONE;
|
|
85475
|
-
}
|
|
85476
|
-
break;
|
|
85477
|
-
case 2:
|
|
85478
|
-
switch (scope.touches.TWO) {
|
|
85479
|
-
case TOUCH.DOLLY_PAN:
|
|
85480
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
85481
|
-
handleTouchStartDollyPan();
|
|
85482
|
-
state = STATE.TOUCH_DOLLY_PAN;
|
|
85483
|
-
break;
|
|
85484
|
-
case TOUCH.DOLLY_ROTATE:
|
|
85485
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
85486
|
-
handleTouchStartDollyRotate();
|
|
85487
|
-
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
85488
|
-
break;
|
|
85489
|
-
default:
|
|
85490
|
-
state = STATE.NONE;
|
|
85491
|
-
}
|
|
85492
|
-
break;
|
|
85493
|
-
default:
|
|
85494
|
-
state = STATE.NONE;
|
|
85547
|
+
return this.fromUsername(uuidOrUsername);
|
|
85548
|
+
}
|
|
85549
|
+
static async fromUuid(uuid) {
|
|
85550
|
+
return this.getSkinProxySkinUrl(uuid);
|
|
85551
|
+
}
|
|
85552
|
+
static async fromUsername(username) {
|
|
85553
|
+
return this.usernameToUuid(username).then((uuid) => {
|
|
85554
|
+
if (uuid) {
|
|
85555
|
+
return this.fromUuid(uuid);
|
|
85495
85556
|
}
|
|
85496
|
-
|
|
85497
|
-
|
|
85557
|
+
return void 0;
|
|
85558
|
+
});
|
|
85559
|
+
}
|
|
85560
|
+
static async fromMineSkin(mineskinId) {
|
|
85561
|
+
return this.getMineSkin(mineskinId).then((mineskin) => {
|
|
85562
|
+
if (mineskin) {
|
|
85563
|
+
return mineskin["data"]["texture"]["value"]["urls"]["skins"];
|
|
85498
85564
|
}
|
|
85565
|
+
return void 0;
|
|
85566
|
+
});
|
|
85567
|
+
}
|
|
85568
|
+
//</editor-fold>
|
|
85569
|
+
//<editor-fold desc="Capes">
|
|
85570
|
+
static async capeFromUuidOrUsername(uuidOrUsername) {
|
|
85571
|
+
if (uuidOrUsername.length === 32 || uuidOrUsername.length === 36) {
|
|
85572
|
+
return this.capeFromUuid(uuidOrUsername);
|
|
85499
85573
|
}
|
|
85500
|
-
|
|
85501
|
-
|
|
85502
|
-
|
|
85503
|
-
|
|
85504
|
-
|
|
85505
|
-
|
|
85506
|
-
|
|
85507
|
-
|
|
85508
|
-
|
|
85509
|
-
if (scope.enablePan === false) return;
|
|
85510
|
-
handleTouchMovePan(event);
|
|
85511
|
-
scope.update();
|
|
85512
|
-
break;
|
|
85513
|
-
case STATE.TOUCH_DOLLY_PAN:
|
|
85514
|
-
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
85515
|
-
handleTouchMoveDollyPan(event);
|
|
85516
|
-
scope.update();
|
|
85517
|
-
break;
|
|
85518
|
-
case STATE.TOUCH_DOLLY_ROTATE:
|
|
85519
|
-
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
85520
|
-
handleTouchMoveDollyRotate(event);
|
|
85521
|
-
scope.update();
|
|
85522
|
-
break;
|
|
85523
|
-
default:
|
|
85524
|
-
state = STATE.NONE;
|
|
85574
|
+
return this.capeFromUsername(uuidOrUsername);
|
|
85575
|
+
}
|
|
85576
|
+
static async capeFromUuid(uuid) {
|
|
85577
|
+
return this.getSkinProxyCapeUrl(uuid);
|
|
85578
|
+
}
|
|
85579
|
+
static async capeFromUsername(username) {
|
|
85580
|
+
return this.usernameToUuid(username).then((uuid) => {
|
|
85581
|
+
if (uuid) {
|
|
85582
|
+
return this.capeFromUuid(uuid);
|
|
85525
85583
|
}
|
|
85526
|
-
|
|
85527
|
-
|
|
85528
|
-
|
|
85529
|
-
|
|
85530
|
-
|
|
85531
|
-
|
|
85532
|
-
|
|
85533
|
-
if (scope.enabled === false) return;
|
|
85534
|
-
event.preventDefault();
|
|
85535
|
-
}
|
|
85536
|
-
function addPointer(event) {
|
|
85537
|
-
pointers.push(event);
|
|
85538
|
-
}
|
|
85539
|
-
function removePointer(event) {
|
|
85540
|
-
delete pointerPositions[event.pointerId];
|
|
85541
|
-
for (let i4 = 0; i4 < pointers.length; i4++) {
|
|
85542
|
-
if (pointers[i4].pointerId == event.pointerId) {
|
|
85543
|
-
pointers.splice(i4, 1);
|
|
85544
|
-
return;
|
|
85545
|
-
}
|
|
85584
|
+
return void 0;
|
|
85585
|
+
});
|
|
85586
|
+
}
|
|
85587
|
+
static async capeFromCapesDev(uuid, capeType = "minecraft") {
|
|
85588
|
+
return this.getCapesDev(uuid, capeType).then((cape) => {
|
|
85589
|
+
if (cape) {
|
|
85590
|
+
return cape?.stillImageUrl;
|
|
85546
85591
|
}
|
|
85547
|
-
|
|
85548
|
-
|
|
85549
|
-
|
|
85550
|
-
|
|
85551
|
-
|
|
85552
|
-
|
|
85592
|
+
return void 0;
|
|
85593
|
+
});
|
|
85594
|
+
}
|
|
85595
|
+
//</editor-fold>
|
|
85596
|
+
//<editor-fold desc="Helpers">
|
|
85597
|
+
static async usernameToUuid(username) {
|
|
85598
|
+
return this.usernameToUuidSkinProxy(username);
|
|
85599
|
+
}
|
|
85600
|
+
static async usernameToUuidSkinProxy(username) {
|
|
85601
|
+
return Requests.genericRequest({
|
|
85602
|
+
baseURL: "https://minecraft-skin-proxy.inventive.workers.dev",
|
|
85603
|
+
url: "/uuid/" + username
|
|
85604
|
+
}).then((res) => {
|
|
85605
|
+
if (res.status === 200) {
|
|
85606
|
+
return res.data["id"];
|
|
85553
85607
|
}
|
|
85554
|
-
|
|
85555
|
-
}
|
|
85556
|
-
|
|
85557
|
-
|
|
85558
|
-
|
|
85559
|
-
}
|
|
85560
|
-
scope.domElement.addEventListener("contextmenu", onContextMenu);
|
|
85561
|
-
scope.domElement.addEventListener("pointerdown", onPointerDown);
|
|
85562
|
-
scope.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
85563
|
-
scope.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
85564
|
-
this.update();
|
|
85608
|
+
return void 0;
|
|
85609
|
+
}).catch((err) => {
|
|
85610
|
+
console.warn(err);
|
|
85611
|
+
return void 0;
|
|
85612
|
+
});
|
|
85565
85613
|
}
|
|
85566
|
-
|
|
85567
|
-
|
|
85568
|
-
|
|
85569
|
-
|
|
85570
|
-
|
|
85571
|
-
|
|
85572
|
-
|
|
85573
|
-
|
|
85574
|
-
|
|
85614
|
+
static async usernameToUuidMineTools(username) {
|
|
85615
|
+
return Requests.genericRequest({
|
|
85616
|
+
baseURL: "https://api.minetools.eu",
|
|
85617
|
+
url: "/uuid/" + username
|
|
85618
|
+
}).then((res) => {
|
|
85619
|
+
if (res.status === 200) {
|
|
85620
|
+
return res.data["id"];
|
|
85621
|
+
}
|
|
85622
|
+
return void 0;
|
|
85623
|
+
}).catch((err) => {
|
|
85624
|
+
console.warn(err);
|
|
85625
|
+
return void 0;
|
|
85626
|
+
});
|
|
85627
|
+
}
|
|
85628
|
+
static async getProfileFromMinetools(uuid) {
|
|
85629
|
+
return Requests.genericRequest({
|
|
85630
|
+
baseURL: "https://api.minetools.eu",
|
|
85631
|
+
url: "/profile/" + uuid
|
|
85632
|
+
}).then((res) => {
|
|
85633
|
+
if (res.status === 200) {
|
|
85634
|
+
return res.data;
|
|
85635
|
+
}
|
|
85636
|
+
});
|
|
85637
|
+
}
|
|
85638
|
+
static async getMineSkin(mineskinId) {
|
|
85639
|
+
return Requests.genericRequest({
|
|
85640
|
+
baseURL: "https://api.mineskin.org",
|
|
85641
|
+
url: "/get/uuid/" + mineskinId
|
|
85642
|
+
}).then((res) => {
|
|
85643
|
+
if (res.status === 200) {
|
|
85644
|
+
return res.data;
|
|
85645
|
+
}
|
|
85646
|
+
return void 0;
|
|
85647
|
+
}).catch((err) => {
|
|
85648
|
+
console.warn(err);
|
|
85649
|
+
return void 0;
|
|
85650
|
+
});
|
|
85651
|
+
}
|
|
85652
|
+
static async getCapesDev(uuid, type = "all") {
|
|
85653
|
+
return Requests.genericRequest({
|
|
85654
|
+
baseURL: "https://api.capes.dev",
|
|
85655
|
+
url: "/load/" + uuid + "/" + type
|
|
85656
|
+
}).then((res) => {
|
|
85657
|
+
if (res.status === 200) {
|
|
85658
|
+
return res.data;
|
|
85659
|
+
}
|
|
85660
|
+
return void 0;
|
|
85661
|
+
}).catch((err) => {
|
|
85662
|
+
console.warn(err);
|
|
85663
|
+
return void 0;
|
|
85664
|
+
});
|
|
85665
|
+
}
|
|
85666
|
+
static getCrafatarSkinUrl(uuid) {
|
|
85667
|
+
return "https://crafatar.com/skins/" + uuid;
|
|
85668
|
+
}
|
|
85669
|
+
static getCrafatarCapeUrl(uuid) {
|
|
85670
|
+
return "https://crafatar.com/capes/" + uuid;
|
|
85671
|
+
}
|
|
85672
|
+
static getMcHeadsSkinUrl(uuid) {
|
|
85673
|
+
return "https://mc-heads.net/skin/" + uuid;
|
|
85674
|
+
}
|
|
85675
|
+
static getMineSkinPlayerSkinUrl(uuid) {
|
|
85676
|
+
return "https://mineskin.org/skin/player/" + uuid;
|
|
85677
|
+
}
|
|
85678
|
+
static getSkinProxySkinUrl(uuid) {
|
|
85679
|
+
return "https://minecraft-skin-proxy.inventive.workers.dev/skin/" + uuid;
|
|
85680
|
+
}
|
|
85681
|
+
static getSkinProxyCapeUrl(uuid) {
|
|
85682
|
+
return "https://minecraft-skin-proxy.inventive.workers.dev/cape/" + uuid;
|
|
85575
85683
|
}
|
|
85684
|
+
//</editor-fold>
|
|
85576
85685
|
};
|
|
85577
85686
|
|
|
85687
|
+
// src/skin/scene/index.ts
|
|
85688
|
+
init_dirname();
|
|
85689
|
+
init_buffer2();
|
|
85690
|
+
init_process2();
|
|
85691
|
+
|
|
85692
|
+
// src/texture/index.ts
|
|
85693
|
+
init_dirname();
|
|
85694
|
+
init_buffer2();
|
|
85695
|
+
init_process2();
|
|
85696
|
+
|
|
85697
|
+
// src/three/index.ts
|
|
85698
|
+
init_dirname();
|
|
85699
|
+
init_buffer2();
|
|
85700
|
+
init_process2();
|
|
85701
|
+
|
|
85578
85702
|
// src/world/index.ts
|
|
85579
85703
|
init_dirname();
|
|
85580
85704
|
init_buffer2();
|