minerender 2.1.0-alpha.114 → 2.1.0-alpha.115
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 +138 -6
- package/dist/browser/index.d.ts +138 -6
- package/dist/browser/index.js +507 -117
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +452 -62
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +459 -19
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +138 -6
- package/dist/node/index.d.ts +138 -6
- package/dist/node/index.js +509 -117
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +452 -62
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -7645,6 +7645,7 @@ __export(index_node_exports, {
|
|
|
7645
7645
|
EntityObject: () => EntityObject,
|
|
7646
7646
|
Env: () => Env,
|
|
7647
7647
|
FluidModelObject: () => FluidModelObject,
|
|
7648
|
+
FlyControls: () => FlyControls,
|
|
7648
7649
|
Fonts: () => Fonts,
|
|
7649
7650
|
GUI_CONTAINER_LAYOUTS: () => GUI_CONTAINER_LAYOUTS,
|
|
7650
7651
|
Geometries: () => Geometries,
|
|
@@ -7750,6 +7751,7 @@ __export(index_node_exports, {
|
|
|
7750
7751
|
isDisposable: () => isDisposable,
|
|
7751
7752
|
isDoubleArray: () => isDoubleArray,
|
|
7752
7753
|
isEntityObject: () => isEntityObject,
|
|
7754
|
+
isFlyControls: () => isFlyControls,
|
|
7753
7755
|
isGuiObject: () => isGuiObject,
|
|
7754
7756
|
isInstanceManager: () => isInstanceManager,
|
|
7755
7757
|
isInstanceReference: () => isInstanceReference,
|
|
@@ -13319,8 +13321,323 @@ init_ModelObject();
|
|
|
13319
13321
|
// src/index.ts
|
|
13320
13322
|
init_nbt();
|
|
13321
13323
|
|
|
13322
|
-
// src/renderer/
|
|
13324
|
+
// src/renderer/FlyControls.ts
|
|
13323
13325
|
var import_three35 = require("three");
|
|
13326
|
+
var VANILLA_FLY_SPEED = 10.89;
|
|
13327
|
+
var PITCH_LIMIT = Math.PI / 2;
|
|
13328
|
+
var MOVE_EPSILON = 1e-6;
|
|
13329
|
+
var _euler = new import_three35.Euler(0, 0, 0, "YXZ");
|
|
13330
|
+
var _forward = new import_three35.Vector3();
|
|
13331
|
+
var _right = new import_three35.Vector3();
|
|
13332
|
+
var _targetVelocity = new import_three35.Vector3();
|
|
13333
|
+
var FlyControls = class extends import_three35.Controls {
|
|
13334
|
+
constructor(camera, domElement) {
|
|
13335
|
+
super(camera, domElement ?? null);
|
|
13336
|
+
this.isFlyControls = true;
|
|
13337
|
+
/** Horizontal and vertical speed in scene units per second; vanilla creative flight by default. */
|
|
13338
|
+
this.movementSpeed = 16 * VANILLA_FLY_SPEED;
|
|
13339
|
+
/** Speed multiplier while the sprint key is held. */
|
|
13340
|
+
this.sprintMultiplier = 2;
|
|
13341
|
+
/** Radians per pixel of pointer movement. */
|
|
13342
|
+
this.lookSpeed = 2e-3;
|
|
13343
|
+
/** Smooth acceleration and deceleration, approximating vanilla flight momentum. */
|
|
13344
|
+
this.enableDamping = true;
|
|
13345
|
+
/** Portion of the remaining velocity change applied per 60 Hz frame (0–1) when damping is enabled. */
|
|
13346
|
+
this.dampingFactor = 0.25;
|
|
13347
|
+
/** Capture the pointer on click so the mouse turns the camera without dragging; dragging works regardless. */
|
|
13348
|
+
this.pointerLock = true;
|
|
13349
|
+
/** Scroll the wheel to change `movementSpeed` within `speedRange`. */
|
|
13350
|
+
this.enableWheelSpeed = true;
|
|
13351
|
+
/** Minimum and maximum `movementSpeed` reachable with the wheel. */
|
|
13352
|
+
this.speedRange = [16, 16 * 500];
|
|
13353
|
+
/** Touch joystick travel in CSS pixels for full speed. */
|
|
13354
|
+
this.joystickRadius = 64;
|
|
13355
|
+
/** Key bindings by `KeyboardEvent.code`. */
|
|
13356
|
+
this.keys = {
|
|
13357
|
+
forward: ["KeyW", "ArrowUp"],
|
|
13358
|
+
back: ["KeyS", "ArrowDown"],
|
|
13359
|
+
left: ["KeyA", "ArrowLeft"],
|
|
13360
|
+
right: ["KeyD", "ArrowRight"],
|
|
13361
|
+
up: ["Space"],
|
|
13362
|
+
down: ["ShiftLeft", "ShiftRight"],
|
|
13363
|
+
sprint: ["ControlLeft", "ControlRight"]
|
|
13364
|
+
};
|
|
13365
|
+
this._pressed = /* @__PURE__ */ new Set();
|
|
13366
|
+
this._velocity = new import_three35.Vector3();
|
|
13367
|
+
this._lastPosition = new import_three35.Vector3();
|
|
13368
|
+
this._lastQuaternion = new import_three35.Quaternion();
|
|
13369
|
+
this._position0 = new import_three35.Vector3();
|
|
13370
|
+
this._quaternion0 = new import_three35.Quaternion();
|
|
13371
|
+
this._dragMoved = false;
|
|
13372
|
+
this._locked = false;
|
|
13373
|
+
this._onKeyDown = (event) => this.handleKey(event, true);
|
|
13374
|
+
this._onKeyUp = (event) => this.handleKey(event, false);
|
|
13375
|
+
this._onPointerDown = (event) => this.handlePointerDown(event);
|
|
13376
|
+
this._onPointerMove = (event) => this.handlePointerMove(event);
|
|
13377
|
+
this._onPointerUp = (event) => this.handlePointerUp(event);
|
|
13378
|
+
this._onPointerLockChange = () => this.handlePointerLockChange();
|
|
13379
|
+
this._onContextMenu = (event) => event.preventDefault();
|
|
13380
|
+
this._onWheel = (event) => this.handleWheel(event);
|
|
13381
|
+
this._onBlur = () => this.releaseKeys();
|
|
13382
|
+
this._lastPosition.copy(camera.position);
|
|
13383
|
+
this._lastQuaternion.copy(camera.quaternion);
|
|
13384
|
+
this.saveState();
|
|
13385
|
+
if (domElement) this.connect(domElement);
|
|
13386
|
+
}
|
|
13387
|
+
connect(element) {
|
|
13388
|
+
super.connect(element);
|
|
13389
|
+
const document2 = element.ownerDocument;
|
|
13390
|
+
document2.addEventListener("keydown", this._onKeyDown);
|
|
13391
|
+
document2.addEventListener("keyup", this._onKeyUp);
|
|
13392
|
+
document2.addEventListener("pointerlockchange", this._onPointerLockChange);
|
|
13393
|
+
document2.defaultView?.addEventListener("blur", this._onBlur);
|
|
13394
|
+
element.addEventListener("pointerdown", this._onPointerDown);
|
|
13395
|
+
element.addEventListener("pointermove", this._onPointerMove);
|
|
13396
|
+
element.addEventListener("pointerup", this._onPointerUp);
|
|
13397
|
+
element.addEventListener("pointercancel", this._onPointerUp);
|
|
13398
|
+
element.addEventListener("contextmenu", this._onContextMenu);
|
|
13399
|
+
element.addEventListener("wheel", this._onWheel, { passive: false });
|
|
13400
|
+
element.addEventListener("blur", this._onBlur);
|
|
13401
|
+
element.style.touchAction = "none";
|
|
13402
|
+
if (element.tabIndex < 0) element.tabIndex = 0;
|
|
13403
|
+
}
|
|
13404
|
+
disconnect() {
|
|
13405
|
+
const element = this.domElement;
|
|
13406
|
+
if (!element) return;
|
|
13407
|
+
const document2 = element.ownerDocument;
|
|
13408
|
+
document2.removeEventListener("keydown", this._onKeyDown);
|
|
13409
|
+
document2.removeEventListener("keyup", this._onKeyUp);
|
|
13410
|
+
document2.removeEventListener("pointerlockchange", this._onPointerLockChange);
|
|
13411
|
+
document2.defaultView?.removeEventListener("blur", this._onBlur);
|
|
13412
|
+
element.removeEventListener("pointerdown", this._onPointerDown);
|
|
13413
|
+
element.removeEventListener("pointermove", this._onPointerMove);
|
|
13414
|
+
element.removeEventListener("pointerup", this._onPointerUp);
|
|
13415
|
+
element.removeEventListener("pointercancel", this._onPointerUp);
|
|
13416
|
+
element.removeEventListener("contextmenu", this._onContextMenu);
|
|
13417
|
+
element.removeEventListener("wheel", this._onWheel);
|
|
13418
|
+
element.removeEventListener("blur", this._onBlur);
|
|
13419
|
+
element.style.touchAction = "auto";
|
|
13420
|
+
this.unlock();
|
|
13421
|
+
this._locked = false;
|
|
13422
|
+
this.releaseKeys();
|
|
13423
|
+
this._dragPointer = void 0;
|
|
13424
|
+
this._joystick = void 0;
|
|
13425
|
+
}
|
|
13426
|
+
dispose() {
|
|
13427
|
+
this.disconnect();
|
|
13428
|
+
}
|
|
13429
|
+
/** Whether mouse look currently owns the pointer. */
|
|
13430
|
+
get locked() {
|
|
13431
|
+
return this._locked;
|
|
13432
|
+
}
|
|
13433
|
+
/** Requests pointer capture; browsers only allow this from a user gesture. */
|
|
13434
|
+
lock() {
|
|
13435
|
+
const element = this.domElement;
|
|
13436
|
+
if (!element || this._locked || typeof element.requestPointerLock !== "function") return;
|
|
13437
|
+
try {
|
|
13438
|
+
const result = element.requestPointerLock();
|
|
13439
|
+
if (result instanceof Promise) result.catch(() => void 0);
|
|
13440
|
+
} catch {
|
|
13441
|
+
}
|
|
13442
|
+
}
|
|
13443
|
+
/** Releases a captured pointer. */
|
|
13444
|
+
unlock() {
|
|
13445
|
+
const document2 = this.domElement?.ownerDocument;
|
|
13446
|
+
if (document2?.pointerLockElement && document2.pointerLockElement === this.domElement) {
|
|
13447
|
+
document2.exitPointerLock();
|
|
13448
|
+
}
|
|
13449
|
+
}
|
|
13450
|
+
/** Stores the camera pose that {@link reset} restores. */
|
|
13451
|
+
saveState() {
|
|
13452
|
+
this._position0.copy(this.object.position);
|
|
13453
|
+
this._quaternion0.copy(this.object.quaternion);
|
|
13454
|
+
}
|
|
13455
|
+
/** Restores the saved camera pose and stops movement. */
|
|
13456
|
+
reset() {
|
|
13457
|
+
this.object.position.copy(this._position0);
|
|
13458
|
+
this.object.quaternion.copy(this._quaternion0);
|
|
13459
|
+
this._velocity.set(0, 0, 0);
|
|
13460
|
+
this.notifyChange();
|
|
13461
|
+
}
|
|
13462
|
+
/** Horizontal yaw in radians, where zero looks toward -Z. */
|
|
13463
|
+
get yaw() {
|
|
13464
|
+
return _euler.setFromQuaternion(this.object.quaternion).y;
|
|
13465
|
+
}
|
|
13466
|
+
/** Vertical pitch in radians, positive looking up. */
|
|
13467
|
+
get pitch() {
|
|
13468
|
+
return _euler.setFromQuaternion(this.object.quaternion).x;
|
|
13469
|
+
}
|
|
13470
|
+
/** Turns the camera; pitch is clamped to straight up and down. */
|
|
13471
|
+
setRotation(yaw, pitch) {
|
|
13472
|
+
_euler.set(import_three35.MathUtils.clamp(pitch, -PITCH_LIMIT, PITCH_LIMIT), yaw, 0);
|
|
13473
|
+
this.object.quaternion.setFromEuler(_euler);
|
|
13474
|
+
this.notifyChange();
|
|
13475
|
+
}
|
|
13476
|
+
/** Points the camera at a position without rolling it. */
|
|
13477
|
+
lookAt(target) {
|
|
13478
|
+
_forward.copy(target).sub(this.object.position);
|
|
13479
|
+
if (_forward.lengthSq() < MOVE_EPSILON) return;
|
|
13480
|
+
_forward.normalize();
|
|
13481
|
+
this.setRotation(Math.atan2(-_forward.x, -_forward.z), Math.asin(import_three35.MathUtils.clamp(_forward.y, -1, 1)));
|
|
13482
|
+
}
|
|
13483
|
+
/** Whether an action's key is held. */
|
|
13484
|
+
isPressed(action) {
|
|
13485
|
+
return this._pressed.has(action);
|
|
13486
|
+
}
|
|
13487
|
+
/**
|
|
13488
|
+
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
13489
|
+
* and dispatches `change` when the camera moved.
|
|
13490
|
+
*/
|
|
13491
|
+
update(delta) {
|
|
13492
|
+
if (delta === void 0) {
|
|
13493
|
+
const now = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
13494
|
+
delta = this._lastTime === void 0 ? 0 : (now - this._lastTime) / 1e3;
|
|
13495
|
+
this._lastTime = now;
|
|
13496
|
+
}
|
|
13497
|
+
if (!this.enabled) {
|
|
13498
|
+
this._velocity.set(0, 0, 0);
|
|
13499
|
+
return;
|
|
13500
|
+
}
|
|
13501
|
+
if (delta > 0) this.move(delta);
|
|
13502
|
+
this.notifyChange();
|
|
13503
|
+
}
|
|
13504
|
+
move(delta) {
|
|
13505
|
+
const camera = this.object;
|
|
13506
|
+
let forward = (this._pressed.has("forward") ? 1 : 0) - (this._pressed.has("back") ? 1 : 0);
|
|
13507
|
+
let strafe = (this._pressed.has("right") ? 1 : 0) - (this._pressed.has("left") ? 1 : 0);
|
|
13508
|
+
const climb = (this._pressed.has("up") ? 1 : 0) - (this._pressed.has("down") ? 1 : 0);
|
|
13509
|
+
const joystick = this._joystick;
|
|
13510
|
+
if (joystick) {
|
|
13511
|
+
const radius = Math.max(this.joystickRadius, 1);
|
|
13512
|
+
forward = import_three35.MathUtils.clamp(forward + (joystick.originY - joystick.y) / radius, -1, 1);
|
|
13513
|
+
strafe = import_three35.MathUtils.clamp(strafe + (joystick.x - joystick.originX) / radius, -1, 1);
|
|
13514
|
+
}
|
|
13515
|
+
_euler.setFromQuaternion(camera.quaternion);
|
|
13516
|
+
const yaw = _euler.y;
|
|
13517
|
+
_forward.set(-Math.sin(yaw), 0, -Math.cos(yaw));
|
|
13518
|
+
_right.set(Math.cos(yaw), 0, -Math.sin(yaw));
|
|
13519
|
+
_targetVelocity.set(0, 0, 0);
|
|
13520
|
+
if (forward || strafe || climb) {
|
|
13521
|
+
_targetVelocity.addScaledVector(_forward, forward).addScaledVector(_right, strafe);
|
|
13522
|
+
if (_targetVelocity.lengthSq() > 1) _targetVelocity.normalize();
|
|
13523
|
+
_targetVelocity.y = climb;
|
|
13524
|
+
const speed = this.movementSpeed * (this._pressed.has("sprint") ? this.sprintMultiplier : 1);
|
|
13525
|
+
_targetVelocity.multiplyScalar(speed);
|
|
13526
|
+
}
|
|
13527
|
+
if (this.enableDamping) {
|
|
13528
|
+
const blend = 1 - Math.pow(1 - import_three35.MathUtils.clamp(this.dampingFactor, 0, 1), delta * 60);
|
|
13529
|
+
this._velocity.lerp(_targetVelocity, blend);
|
|
13530
|
+
if (_targetVelocity.lengthSq() === 0 && this._velocity.lengthSq() < MOVE_EPSILON) this._velocity.set(0, 0, 0);
|
|
13531
|
+
} else {
|
|
13532
|
+
this._velocity.copy(_targetVelocity);
|
|
13533
|
+
}
|
|
13534
|
+
camera.position.addScaledVector(this._velocity, delta);
|
|
13535
|
+
}
|
|
13536
|
+
notifyChange() {
|
|
13537
|
+
const camera = this.object;
|
|
13538
|
+
if (this._lastPosition.distanceToSquared(camera.position) > MOVE_EPSILON || 8 * (1 - this._lastQuaternion.dot(camera.quaternion)) > MOVE_EPSILON) {
|
|
13539
|
+
this._lastPosition.copy(camera.position);
|
|
13540
|
+
this._lastQuaternion.copy(camera.quaternion);
|
|
13541
|
+
this.dispatchEvent({ type: "change" });
|
|
13542
|
+
}
|
|
13543
|
+
}
|
|
13544
|
+
releaseKeys() {
|
|
13545
|
+
this._pressed.clear();
|
|
13546
|
+
}
|
|
13547
|
+
handleKey(event, down) {
|
|
13548
|
+
const action = this.actionFor(event.code);
|
|
13549
|
+
if (!action) return;
|
|
13550
|
+
const ownsInput = this.enabled && (this._locked || event.target === this.domElement);
|
|
13551
|
+
if (down && !ownsInput) return;
|
|
13552
|
+
const pressed = this._pressed.has(action);
|
|
13553
|
+
if (down) this._pressed.add(action);
|
|
13554
|
+
else this._pressed.delete(action);
|
|
13555
|
+
if (ownsInput || this.enabled && pressed) event.preventDefault();
|
|
13556
|
+
}
|
|
13557
|
+
actionFor(code) {
|
|
13558
|
+
for (const action in this.keys) {
|
|
13559
|
+
if (this.keys[action].includes(code)) return action;
|
|
13560
|
+
}
|
|
13561
|
+
return void 0;
|
|
13562
|
+
}
|
|
13563
|
+
handlePointerDown(event) {
|
|
13564
|
+
const element = this.domElement;
|
|
13565
|
+
if (!this.enabled || !element) return;
|
|
13566
|
+
element.focus?.({ preventScroll: true });
|
|
13567
|
+
if (this._locked) return;
|
|
13568
|
+
if (event.pointerType === "touch" && !this._joystick && this.onJoystickSide(event)) {
|
|
13569
|
+
this._joystick = { id: event.pointerId, originX: event.clientX, originY: event.clientY, x: event.clientX, y: event.clientY };
|
|
13570
|
+
element.setPointerCapture?.(event.pointerId);
|
|
13571
|
+
return;
|
|
13572
|
+
}
|
|
13573
|
+
if (this._dragPointer !== void 0) return;
|
|
13574
|
+
if (event.pointerType === "mouse" && event.button !== 0 && event.button !== 2) return;
|
|
13575
|
+
this._dragPointer = event.pointerId;
|
|
13576
|
+
this._dragMoved = false;
|
|
13577
|
+
element.setPointerCapture?.(event.pointerId);
|
|
13578
|
+
}
|
|
13579
|
+
onJoystickSide(event) {
|
|
13580
|
+
const rect = this.domElement?.getBoundingClientRect?.();
|
|
13581
|
+
return !!rect && event.clientX < rect.left + rect.width / 2;
|
|
13582
|
+
}
|
|
13583
|
+
handlePointerMove(event) {
|
|
13584
|
+
if (!this.enabled) return;
|
|
13585
|
+
const joystick = this._joystick;
|
|
13586
|
+
if (joystick && event.pointerId === joystick.id) {
|
|
13587
|
+
joystick.x = event.clientX;
|
|
13588
|
+
joystick.y = event.clientY;
|
|
13589
|
+
return;
|
|
13590
|
+
}
|
|
13591
|
+
if (!this._locked && event.pointerId !== this._dragPointer) return;
|
|
13592
|
+
const dx = event.movementX ?? 0;
|
|
13593
|
+
const dy = event.movementY ?? 0;
|
|
13594
|
+
if (!dx && !dy) return;
|
|
13595
|
+
this._dragMoved = true;
|
|
13596
|
+
this.turn(dx, dy);
|
|
13597
|
+
}
|
|
13598
|
+
handlePointerUp(event) {
|
|
13599
|
+
if (this._joystick?.id === event.pointerId) {
|
|
13600
|
+
this._joystick = void 0;
|
|
13601
|
+
this.domElement?.releasePointerCapture?.(event.pointerId);
|
|
13602
|
+
return;
|
|
13603
|
+
}
|
|
13604
|
+
if (event.pointerId !== this._dragPointer) return;
|
|
13605
|
+
this._dragPointer = void 0;
|
|
13606
|
+
this.domElement?.releasePointerCapture?.(event.pointerId);
|
|
13607
|
+
if (this.enabled && this.pointerLock && !this._dragMoved && event.pointerType === "mouse" && event.button === 0) {
|
|
13608
|
+
this.lock();
|
|
13609
|
+
}
|
|
13610
|
+
}
|
|
13611
|
+
handleWheel(event) {
|
|
13612
|
+
if (!this.enabled || !this.enableWheelSpeed) return;
|
|
13613
|
+
event.preventDefault();
|
|
13614
|
+
const steps = event.deltaMode === 0 ? event.deltaY / 100 : event.deltaY;
|
|
13615
|
+
const [min, max] = this.speedRange;
|
|
13616
|
+
this.movementSpeed = import_three35.MathUtils.clamp(this.movementSpeed * Math.pow(1.15, -steps), Math.min(min, max), Math.max(min, max));
|
|
13617
|
+
}
|
|
13618
|
+
handlePointerLockChange() {
|
|
13619
|
+
const document2 = this.domElement?.ownerDocument;
|
|
13620
|
+
const locked = !!document2 && document2.pointerLockElement === this.domElement;
|
|
13621
|
+
if (locked === this._locked) return;
|
|
13622
|
+
this._locked = locked;
|
|
13623
|
+
if (!locked) this.releaseKeys();
|
|
13624
|
+
this.dispatchEvent({ type: locked ? "lock" : "unlock" });
|
|
13625
|
+
}
|
|
13626
|
+
turn(dx, dy) {
|
|
13627
|
+
_euler.setFromQuaternion(this.object.quaternion);
|
|
13628
|
+
_euler.y -= dx * this.lookSpeed;
|
|
13629
|
+
_euler.x = import_three35.MathUtils.clamp(_euler.x - dy * this.lookSpeed, -PITCH_LIMIT, PITCH_LIMIT);
|
|
13630
|
+
_euler.z = 0;
|
|
13631
|
+
this.object.quaternion.setFromEuler(_euler);
|
|
13632
|
+
this.notifyChange();
|
|
13633
|
+
}
|
|
13634
|
+
};
|
|
13635
|
+
function isFlyControls(obj) {
|
|
13636
|
+
return obj?.isFlyControls === true;
|
|
13637
|
+
}
|
|
13638
|
+
|
|
13639
|
+
// src/renderer/MineRenderScene.ts
|
|
13640
|
+
var import_three36 = require("three");
|
|
13324
13641
|
init_SceneObject();
|
|
13325
13642
|
var import_ts_deepmerge8 = __toESM(require_dist());
|
|
13326
13643
|
init_ModelObject();
|
|
@@ -14230,7 +14547,7 @@ var SkinObject = class extends SceneObject {
|
|
|
14230
14547
|
// src/renderer/MineRenderScene.ts
|
|
14231
14548
|
init_EntityObject();
|
|
14232
14549
|
init_ItemTints();
|
|
14233
|
-
var MineRenderScene = class _MineRenderScene extends
|
|
14550
|
+
var MineRenderScene = class _MineRenderScene extends import_three36.Scene {
|
|
14234
14551
|
constructor(options) {
|
|
14235
14552
|
super();
|
|
14236
14553
|
this.isMineRenderScene = true;
|
|
@@ -14386,7 +14703,7 @@ function isMineRenderScene(obj) {
|
|
|
14386
14703
|
}
|
|
14387
14704
|
|
|
14388
14705
|
// src/renderer/Renderer.ts
|
|
14389
|
-
var
|
|
14706
|
+
var import_three38 = require("three");
|
|
14390
14707
|
var import_ts_deepmerge9 = __toESM(require_dist());
|
|
14391
14708
|
var import_stats = __toESM(require("stats.js"));
|
|
14392
14709
|
var import_postprocessing = require("postprocessing");
|
|
@@ -14395,11 +14712,11 @@ init_Model();
|
|
|
14395
14712
|
init_three();
|
|
14396
14713
|
|
|
14397
14714
|
// src/three/OrbitControls.js
|
|
14398
|
-
var
|
|
14715
|
+
var import_three37 = require("three");
|
|
14399
14716
|
var _changeEvent = { type: "change" };
|
|
14400
14717
|
var _startEvent = { type: "start" };
|
|
14401
14718
|
var _endEvent = { type: "end" };
|
|
14402
|
-
var OrbitControls = class extends
|
|
14719
|
+
var OrbitControls = class extends import_three37.EventDispatcher {
|
|
14403
14720
|
constructor(object4, domElement) {
|
|
14404
14721
|
super();
|
|
14405
14722
|
if (domElement === void 0) console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.');
|
|
@@ -14408,7 +14725,7 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14408
14725
|
this.domElement = domElement;
|
|
14409
14726
|
this.domElement.style.touchAction = "none";
|
|
14410
14727
|
this.enabled = true;
|
|
14411
|
-
this.target = new
|
|
14728
|
+
this.target = new import_three37.Vector3();
|
|
14412
14729
|
this.minDistance = 0;
|
|
14413
14730
|
this.maxDistance = Infinity;
|
|
14414
14731
|
this.minZoom = 0;
|
|
@@ -14430,8 +14747,8 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14430
14747
|
this.autoRotate = false;
|
|
14431
14748
|
this.autoRotateSpeed = 2;
|
|
14432
14749
|
this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" };
|
|
14433
|
-
this.mouseButtons = { LEFT:
|
|
14434
|
-
this.touches = { ONE:
|
|
14750
|
+
this.mouseButtons = { LEFT: import_three37.MOUSE.ROTATE, MIDDLE: import_three37.MOUSE.DOLLY, RIGHT: import_three37.MOUSE.PAN };
|
|
14751
|
+
this.touches = { ONE: import_three37.TOUCH.ROTATE, TWO: import_three37.TOUCH.DOLLY_PAN };
|
|
14435
14752
|
this.target0 = this.target.clone();
|
|
14436
14753
|
this.position0 = this.object.position.clone();
|
|
14437
14754
|
this.zoom0 = this.object.zoom;
|
|
@@ -14460,11 +14777,11 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14460
14777
|
state = STATE.NONE;
|
|
14461
14778
|
};
|
|
14462
14779
|
this.update = function() {
|
|
14463
|
-
const offset = new
|
|
14464
|
-
const quat = new
|
|
14780
|
+
const offset = new import_three37.Vector3();
|
|
14781
|
+
const quat = new import_three37.Quaternion().setFromUnitVectors(object4.up, new import_three37.Vector3(0, 1, 0));
|
|
14465
14782
|
const quatInverse = quat.clone().invert();
|
|
14466
|
-
const lastPosition = new
|
|
14467
|
-
const lastQuaternion = new
|
|
14783
|
+
const lastPosition = new import_three37.Vector3();
|
|
14784
|
+
const lastQuaternion = new import_three37.Quaternion();
|
|
14468
14785
|
const twoPI = 2 * Math.PI;
|
|
14469
14786
|
return function update() {
|
|
14470
14787
|
const position = scope.object.position;
|
|
@@ -14550,20 +14867,20 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14550
14867
|
};
|
|
14551
14868
|
let state = STATE.NONE;
|
|
14552
14869
|
const EPS = 1e-6;
|
|
14553
|
-
const spherical = new
|
|
14554
|
-
const sphericalDelta = new
|
|
14870
|
+
const spherical = new import_three37.Spherical();
|
|
14871
|
+
const sphericalDelta = new import_three37.Spherical();
|
|
14555
14872
|
let scale = 1;
|
|
14556
|
-
const panOffset = new
|
|
14873
|
+
const panOffset = new import_three37.Vector3();
|
|
14557
14874
|
let zoomChanged = false;
|
|
14558
|
-
const rotateStart = new
|
|
14559
|
-
const rotateEnd = new
|
|
14560
|
-
const rotateDelta = new
|
|
14561
|
-
const panStart = new
|
|
14562
|
-
const panEnd = new
|
|
14563
|
-
const panDelta = new
|
|
14564
|
-
const dollyStart = new
|
|
14565
|
-
const dollyEnd = new
|
|
14566
|
-
const dollyDelta = new
|
|
14875
|
+
const rotateStart = new import_three37.Vector2();
|
|
14876
|
+
const rotateEnd = new import_three37.Vector2();
|
|
14877
|
+
const rotateDelta = new import_three37.Vector2();
|
|
14878
|
+
const panStart = new import_three37.Vector2();
|
|
14879
|
+
const panEnd = new import_three37.Vector2();
|
|
14880
|
+
const panDelta = new import_three37.Vector2();
|
|
14881
|
+
const dollyStart = new import_three37.Vector2();
|
|
14882
|
+
const dollyEnd = new import_three37.Vector2();
|
|
14883
|
+
const dollyDelta = new import_three37.Vector2();
|
|
14567
14884
|
const pointers = [];
|
|
14568
14885
|
const pointerPositions = {};
|
|
14569
14886
|
function getAutoRotationAngle() {
|
|
@@ -14579,7 +14896,7 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14579
14896
|
sphericalDelta.phi -= angle;
|
|
14580
14897
|
}
|
|
14581
14898
|
const panLeft = function() {
|
|
14582
|
-
const v = new
|
|
14899
|
+
const v = new import_three37.Vector3();
|
|
14583
14900
|
return function panLeft2(distance, objectMatrix) {
|
|
14584
14901
|
v.setFromMatrixColumn(objectMatrix, 0);
|
|
14585
14902
|
v.multiplyScalar(-distance);
|
|
@@ -14587,7 +14904,7 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14587
14904
|
};
|
|
14588
14905
|
}();
|
|
14589
14906
|
const panUp = function() {
|
|
14590
|
-
const v = new
|
|
14907
|
+
const v = new import_three37.Vector3();
|
|
14591
14908
|
return function panUp2(distance, objectMatrix) {
|
|
14592
14909
|
if (scope.screenSpacePanning === true) {
|
|
14593
14910
|
v.setFromMatrixColumn(objectMatrix, 1);
|
|
@@ -14600,7 +14917,7 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14600
14917
|
};
|
|
14601
14918
|
}();
|
|
14602
14919
|
const pan = function() {
|
|
14603
|
-
const offset = new
|
|
14920
|
+
const offset = new import_three37.Vector3();
|
|
14604
14921
|
return function pan2(deltaX, deltaY) {
|
|
14605
14922
|
const element = scope.domElement;
|
|
14606
14923
|
if (scope.object.isPerspectiveCamera) {
|
|
@@ -14849,12 +15166,12 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14849
15166
|
mouseAction = -1;
|
|
14850
15167
|
}
|
|
14851
15168
|
switch (mouseAction) {
|
|
14852
|
-
case
|
|
15169
|
+
case import_three37.MOUSE.DOLLY:
|
|
14853
15170
|
if (scope.enableZoom === false) return;
|
|
14854
15171
|
handleMouseDownDolly(event);
|
|
14855
15172
|
state = STATE.DOLLY;
|
|
14856
15173
|
break;
|
|
14857
|
-
case
|
|
15174
|
+
case import_three37.MOUSE.ROTATE:
|
|
14858
15175
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
14859
15176
|
if (scope.enablePan === false) return;
|
|
14860
15177
|
handleMouseDownPan(event);
|
|
@@ -14865,7 +15182,7 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14865
15182
|
state = STATE.ROTATE;
|
|
14866
15183
|
}
|
|
14867
15184
|
break;
|
|
14868
|
-
case
|
|
15185
|
+
case import_three37.MOUSE.PAN:
|
|
14869
15186
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
14870
15187
|
if (scope.enableRotate === false) return;
|
|
14871
15188
|
handleMouseDownRotate(event);
|
|
@@ -14921,12 +15238,12 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14921
15238
|
switch (pointers.length) {
|
|
14922
15239
|
case 1:
|
|
14923
15240
|
switch (scope.touches.ONE) {
|
|
14924
|
-
case
|
|
15241
|
+
case import_three37.TOUCH.ROTATE:
|
|
14925
15242
|
if (scope.enableRotate === false) return;
|
|
14926
15243
|
handleTouchStartRotate();
|
|
14927
15244
|
state = STATE.TOUCH_ROTATE;
|
|
14928
15245
|
break;
|
|
14929
|
-
case
|
|
15246
|
+
case import_three37.TOUCH.PAN:
|
|
14930
15247
|
if (scope.enablePan === false) return;
|
|
14931
15248
|
handleTouchStartPan();
|
|
14932
15249
|
state = STATE.TOUCH_PAN;
|
|
@@ -14937,12 +15254,12 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
14937
15254
|
break;
|
|
14938
15255
|
case 2:
|
|
14939
15256
|
switch (scope.touches.TWO) {
|
|
14940
|
-
case
|
|
15257
|
+
case import_three37.TOUCH.DOLLY_PAN:
|
|
14941
15258
|
if (scope.enableZoom === false && scope.enablePan === false) return;
|
|
14942
15259
|
handleTouchStartDollyPan();
|
|
14943
15260
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
14944
15261
|
break;
|
|
14945
|
-
case
|
|
15262
|
+
case import_three37.TOUCH.DOLLY_ROTATE:
|
|
14946
15263
|
if (scope.enableZoom === false && scope.enableRotate === false) return;
|
|
14947
15264
|
handleTouchStartDollyRotate();
|
|
14948
15265
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
@@ -15009,7 +15326,7 @@ var OrbitControls = class extends import_three36.EventDispatcher {
|
|
|
15009
15326
|
function trackPointer(event) {
|
|
15010
15327
|
let position = pointerPositions[event.pointerId];
|
|
15011
15328
|
if (position === void 0) {
|
|
15012
|
-
position = new
|
|
15329
|
+
position = new import_three37.Vector2();
|
|
15013
15330
|
pointerPositions[event.pointerId] = position;
|
|
15014
15331
|
}
|
|
15015
15332
|
position.set(event.pageX, event.pageY);
|
|
@@ -15029,10 +15346,10 @@ var MapControls = class extends OrbitControls {
|
|
|
15029
15346
|
constructor(object4, domElement) {
|
|
15030
15347
|
super(object4, domElement);
|
|
15031
15348
|
this.screenSpacePanning = false;
|
|
15032
|
-
this.mouseButtons.LEFT =
|
|
15033
|
-
this.mouseButtons.RIGHT =
|
|
15034
|
-
this.touches.ONE =
|
|
15035
|
-
this.touches.TWO =
|
|
15349
|
+
this.mouseButtons.LEFT = import_three37.MOUSE.PAN;
|
|
15350
|
+
this.mouseButtons.RIGHT = import_three37.MOUSE.ROTATE;
|
|
15351
|
+
this.touches.ONE = import_three37.TOUCH.PAN;
|
|
15352
|
+
this.touches.TWO = import_three37.TOUCH.DOLLY_ROTATE;
|
|
15036
15353
|
}
|
|
15037
15354
|
};
|
|
15038
15355
|
|
|
@@ -15111,8 +15428,8 @@ var Renderer = class _Renderer {
|
|
|
15111
15428
|
top: void 0,
|
|
15112
15429
|
bottom: void 0
|
|
15113
15430
|
},
|
|
15114
|
-
position: new
|
|
15115
|
-
lookingAt: new
|
|
15431
|
+
position: new import_three38.Vector3(50, 50, 50),
|
|
15432
|
+
lookingAt: new import_three38.Vector3(0, 0, 0)
|
|
15116
15433
|
},
|
|
15117
15434
|
render: {
|
|
15118
15435
|
fpsLimit: 60,
|
|
@@ -15127,7 +15444,8 @@ var Renderer = class _Renderer {
|
|
|
15127
15444
|
enabled: true
|
|
15128
15445
|
},
|
|
15129
15446
|
controls: {
|
|
15130
|
-
enabled: false
|
|
15447
|
+
enabled: false,
|
|
15448
|
+
mode: "orbit"
|
|
15131
15449
|
},
|
|
15132
15450
|
debug: {
|
|
15133
15451
|
grid: false,
|
|
@@ -15143,14 +15461,14 @@ var Renderer = class _Renderer {
|
|
|
15143
15461
|
switch (this.options.camera.type) {
|
|
15144
15462
|
case "perspective":
|
|
15145
15463
|
default:
|
|
15146
|
-
return new
|
|
15464
|
+
return new import_three38.PerspectiveCamera(
|
|
15147
15465
|
this.options.camera.perspective.fov,
|
|
15148
15466
|
this.options.camera.perspective.aspect ?? this.viewWidth / this.viewHeight,
|
|
15149
15467
|
this.options.camera.near,
|
|
15150
15468
|
this.options.camera.far
|
|
15151
15469
|
);
|
|
15152
15470
|
case "orthographic":
|
|
15153
|
-
return new
|
|
15471
|
+
return new import_three38.OrthographicCamera(
|
|
15154
15472
|
this.options.camera.orthographic.left ?? this.viewWidth / -2,
|
|
15155
15473
|
this.options.camera.orthographic.right ?? this.viewWidth / 2,
|
|
15156
15474
|
this.options.camera.orthographic.top ?? this.viewHeight / 2,
|
|
@@ -15166,7 +15484,7 @@ var Renderer = class _Renderer {
|
|
|
15166
15484
|
}
|
|
15167
15485
|
const pixelRatio = this.options.render.pixelRatio ?? 1;
|
|
15168
15486
|
this._surface?.resize?.(Math.floor(this.viewWidth * pixelRatio), Math.floor(this.viewHeight * pixelRatio));
|
|
15169
|
-
const renderer = new
|
|
15487
|
+
const renderer = new import_three38.WebGLRenderer({
|
|
15170
15488
|
canvas: this._surface?.canvas,
|
|
15171
15489
|
context: this._surface?.context,
|
|
15172
15490
|
antialias: this.options.render.antialias,
|
|
@@ -15176,8 +15494,8 @@ var Renderer = class _Renderer {
|
|
|
15176
15494
|
});
|
|
15177
15495
|
renderer.setClearColor(0, 0);
|
|
15178
15496
|
renderer.shadowMap.enabled = true;
|
|
15179
|
-
renderer.shadowMap.type =
|
|
15180
|
-
renderer.outputColorSpace =
|
|
15497
|
+
renderer.shadowMap.type = import_three38.PCFShadowMap;
|
|
15498
|
+
renderer.outputColorSpace = import_three38.SRGBColorSpace;
|
|
15181
15499
|
if (this._surface) {
|
|
15182
15500
|
renderer.setDrawingBufferSize(this.viewWidth, this.viewHeight, pixelRatio);
|
|
15183
15501
|
} else {
|
|
@@ -15195,20 +15513,77 @@ var Renderer = class _Renderer {
|
|
|
15195
15513
|
}
|
|
15196
15514
|
createControls() {
|
|
15197
15515
|
if (!this.options.controls?.enabled) return void 0;
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15516
|
+
return this.createControlsFor(this.options.controls.mode ?? "orbit", this.initialTarget());
|
|
15517
|
+
}
|
|
15518
|
+
initialTarget() {
|
|
15201
15519
|
const target = this.options.camera.lookingAt;
|
|
15202
|
-
if (isVector3(target))
|
|
15520
|
+
if (isVector3(target)) return target.clone();
|
|
15521
|
+
if (isTripleArray(target)) return new import_three38.Vector3(target[0], target[1], target[2]);
|
|
15522
|
+
return new import_three38.Vector3();
|
|
15523
|
+
}
|
|
15524
|
+
createControlsFor(mode, target) {
|
|
15525
|
+
let controls;
|
|
15526
|
+
if (mode === "fly") {
|
|
15527
|
+
controls = new FlyControls(this.camera, this.renderer.domElement);
|
|
15528
|
+
controls.lookAt(target);
|
|
15529
|
+
controls.saveState();
|
|
15530
|
+
} else {
|
|
15531
|
+
const position = this.camera.position.clone();
|
|
15532
|
+
controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
15533
|
+
this.camera.position.copy(position);
|
|
15203
15534
|
controls.target.copy(target);
|
|
15204
|
-
|
|
15205
|
-
controls.
|
|
15535
|
+
controls.update();
|
|
15536
|
+
controls.saveState();
|
|
15206
15537
|
}
|
|
15207
|
-
|
|
15208
|
-
controls.saveState();
|
|
15538
|
+
this._controlsTime = void 0;
|
|
15209
15539
|
this.registerEventDispatcher(controls);
|
|
15210
15540
|
return controls;
|
|
15211
15541
|
}
|
|
15542
|
+
/**
|
|
15543
|
+
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
15544
|
+
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
15545
|
+
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
15546
|
+
*/
|
|
15547
|
+
setControlsMode(mode) {
|
|
15548
|
+
const current = this._controls;
|
|
15549
|
+
if (this._disposed || !current) return void 0;
|
|
15550
|
+
if (this.controlsMode === mode) return current;
|
|
15551
|
+
let target;
|
|
15552
|
+
if (isFlyControls(current)) {
|
|
15553
|
+
const distance = this._orbitDistance ?? (this.camera.position.distanceTo(this.initialTarget()) || 1);
|
|
15554
|
+
target = new import_three38.Vector3(0, 0, -distance).applyQuaternion(this.camera.quaternion).add(this.camera.position);
|
|
15555
|
+
} else {
|
|
15556
|
+
target = current.target.clone();
|
|
15557
|
+
this._orbitDistance = this.camera.position.distanceTo(target);
|
|
15558
|
+
}
|
|
15559
|
+
const enabled = current.enabled;
|
|
15560
|
+
this.disposeControls(current);
|
|
15561
|
+
this._controls = this.createControlsFor(mode, target);
|
|
15562
|
+
this._controls.enabled = enabled;
|
|
15563
|
+
this.dirty = true;
|
|
15564
|
+
return this._controls;
|
|
15565
|
+
}
|
|
15566
|
+
disposeControls(controls) {
|
|
15567
|
+
this._controls = void 0;
|
|
15568
|
+
this.unregisterEventDispatcher(controls);
|
|
15569
|
+
controls.enabled = false;
|
|
15570
|
+
controls.dispose();
|
|
15571
|
+
}
|
|
15572
|
+
/** Advances owned controls; without a frame time, flight movement does not progress. */
|
|
15573
|
+
updateControls(time) {
|
|
15574
|
+
const controls = this._controls;
|
|
15575
|
+
if (!controls?.enabled) {
|
|
15576
|
+
this._controlsTime = void 0;
|
|
15577
|
+
return;
|
|
15578
|
+
}
|
|
15579
|
+
if (!isFlyControls(controls)) {
|
|
15580
|
+
controls.update();
|
|
15581
|
+
return;
|
|
15582
|
+
}
|
|
15583
|
+
const previous = this._controlsTime;
|
|
15584
|
+
if (time !== void 0) this._controlsTime = time;
|
|
15585
|
+
controls.update(time === void 0 || previous === void 0 ? 0 : (time - previous) / 1e3);
|
|
15586
|
+
}
|
|
15212
15587
|
//</editor-fold>
|
|
15213
15588
|
init() {
|
|
15214
15589
|
if (this._disposed) return;
|
|
@@ -15216,20 +15591,20 @@ var Renderer = class _Renderer {
|
|
|
15216
15591
|
window["__THREE_DEVTOOLS__"].dispatchEvent(new CustomEvent("observe", { detail: this.scene }));
|
|
15217
15592
|
}
|
|
15218
15593
|
if (this.options.debug.grid) {
|
|
15219
|
-
const gridHelper = new
|
|
15594
|
+
const gridHelper = new import_three38.GridHelper(128, 16);
|
|
15220
15595
|
this._debugHelpers.push(gridHelper);
|
|
15221
15596
|
this.scene.add(gridHelper);
|
|
15222
|
-
const gridHelper2 = new
|
|
15597
|
+
const gridHelper2 = new import_three38.GridHelper(128, 16);
|
|
15223
15598
|
this._debugHelpers.push(gridHelper2);
|
|
15224
15599
|
gridHelper2.rotation.x = 90 * (Math.PI / 180);
|
|
15225
15600
|
this.scene.add(gridHelper2);
|
|
15226
|
-
const gridHelper3 = new
|
|
15601
|
+
const gridHelper3 = new import_three38.GridHelper(128, 16);
|
|
15227
15602
|
this._debugHelpers.push(gridHelper3);
|
|
15228
15603
|
gridHelper3.rotation.z = 90 * (Math.PI / 180);
|
|
15229
15604
|
this.scene.add(gridHelper3);
|
|
15230
15605
|
}
|
|
15231
15606
|
if (this.options.debug.axes) {
|
|
15232
|
-
const axesHelper = new
|
|
15607
|
+
const axesHelper = new import_three38.AxesHelper(64);
|
|
15233
15608
|
this._debugHelpers.push(axesHelper);
|
|
15234
15609
|
this.scene.add(axesHelper);
|
|
15235
15610
|
}
|
|
@@ -15285,6 +15660,12 @@ var Renderer = class _Renderer {
|
|
|
15285
15660
|
events.add(changeEvent2);
|
|
15286
15661
|
dispatcher.addEventListener(changeEvent2, this._changeListener);
|
|
15287
15662
|
}
|
|
15663
|
+
unregisterEventDispatcher(dispatcher) {
|
|
15664
|
+
const events = this._eventDispatchers.get(dispatcher);
|
|
15665
|
+
if (!events) return;
|
|
15666
|
+
for (const event of events) dispatcher.removeEventListener(event, this._changeListener);
|
|
15667
|
+
this._eventDispatchers.delete(dispatcher);
|
|
15668
|
+
}
|
|
15288
15669
|
/** Updates the camera and canvas size. Width and height are in CSS pixels. */
|
|
15289
15670
|
resize(width, height) {
|
|
15290
15671
|
if (this._disposed) return;
|
|
@@ -15361,6 +15742,7 @@ var Renderer = class _Renderer {
|
|
|
15361
15742
|
this.renderer.setAnimationLoop(null);
|
|
15362
15743
|
}
|
|
15363
15744
|
this._nextFrameTime = void 0;
|
|
15745
|
+
this._controlsTime = void 0;
|
|
15364
15746
|
for (const subscription of this._frameCallbacks.values()) subscription.previous = void 0;
|
|
15365
15747
|
}
|
|
15366
15748
|
/**
|
|
@@ -15390,10 +15772,7 @@ var Renderer = class _Renderer {
|
|
|
15390
15772
|
}
|
|
15391
15773
|
this._element = void 0;
|
|
15392
15774
|
if (this._controls) {
|
|
15393
|
-
|
|
15394
|
-
this._controls = void 0;
|
|
15395
|
-
controls.enabled = false;
|
|
15396
|
-
controls.dispose();
|
|
15775
|
+
this.disposeControls(this._controls);
|
|
15397
15776
|
}
|
|
15398
15777
|
this.scene.clear();
|
|
15399
15778
|
for (const helper of this._debugHelpers) {
|
|
@@ -15410,9 +15789,7 @@ var Renderer = class _Renderer {
|
|
|
15410
15789
|
}
|
|
15411
15790
|
animate(t = performance.now()) {
|
|
15412
15791
|
if (!this._running) return;
|
|
15413
|
-
|
|
15414
|
-
this._controls.update();
|
|
15415
|
-
}
|
|
15792
|
+
this.updateControls(t);
|
|
15416
15793
|
if (!this._running) return;
|
|
15417
15794
|
if (!this.dirty && !this.options.render.renderAlways && !this._frameCallbacks.size && !this._videoExporter) return;
|
|
15418
15795
|
const interval = this._frameInterval;
|
|
@@ -15449,7 +15826,7 @@ var Renderer = class _Renderer {
|
|
|
15449
15826
|
/** Draws a fresh frame without starting the animation loop or invoking frame callbacks. */
|
|
15450
15827
|
renderOnce() {
|
|
15451
15828
|
if (this._disposed) throw new Error("Cannot render a disposed renderer");
|
|
15452
|
-
|
|
15829
|
+
this.updateControls();
|
|
15453
15830
|
this.drawFrame();
|
|
15454
15831
|
}
|
|
15455
15832
|
/**
|
|
@@ -15479,7 +15856,7 @@ var Renderer = class _Renderer {
|
|
|
15479
15856
|
try {
|
|
15480
15857
|
if (!wasRunning) this.start();
|
|
15481
15858
|
this._videoExporter = exporter;
|
|
15482
|
-
|
|
15859
|
+
this.updateControls();
|
|
15483
15860
|
this.drawFrame();
|
|
15484
15861
|
} catch (error) {
|
|
15485
15862
|
exporter.cancel(error);
|
|
@@ -15530,6 +15907,19 @@ var Renderer = class _Renderer {
|
|
|
15530
15907
|
get controls() {
|
|
15531
15908
|
return this._controls;
|
|
15532
15909
|
}
|
|
15910
|
+
/** Renderer-owned OrbitControls, or undefined in fly mode or without controls. */
|
|
15911
|
+
get orbitControls() {
|
|
15912
|
+
return this._controls && !isFlyControls(this._controls) ? this._controls : void 0;
|
|
15913
|
+
}
|
|
15914
|
+
/** Renderer-owned {@link FlyControls}, or undefined in orbit mode or without controls. */
|
|
15915
|
+
get flyControls() {
|
|
15916
|
+
return isFlyControls(this._controls) ? this._controls : void 0;
|
|
15917
|
+
}
|
|
15918
|
+
/** The active renderer-owned controls mode, or undefined without controls. */
|
|
15919
|
+
get controlsMode() {
|
|
15920
|
+
if (!this._controls) return void 0;
|
|
15921
|
+
return isFlyControls(this._controls) ? "fly" : "orbit";
|
|
15922
|
+
}
|
|
15533
15923
|
///
|
|
15534
15924
|
};
|
|
15535
15925
|
|
|
@@ -15778,7 +16168,7 @@ function parseSceneDocument(value) {
|
|
|
15778
16168
|
}
|
|
15779
16169
|
|
|
15780
16170
|
// src/scene/SceneDocumentLoader.ts
|
|
15781
|
-
var
|
|
16171
|
+
var import_three40 = require("three");
|
|
15782
16172
|
init_AssetKey();
|
|
15783
16173
|
init_AssetLoader();
|
|
15784
16174
|
init_BlockStates();
|
|
@@ -15839,7 +16229,7 @@ var SceneDocumentLoader = class {
|
|
|
15839
16229
|
if (definition.minecraftVersion !== void 0 && definition.minecraftVersion !== AssetLoader.version) {
|
|
15840
16230
|
throw new Error(`Scene requires Minecraft ${definition.minecraftVersion}; call AssetLoader.setVersion("${definition.minecraftVersion}") before loading it`);
|
|
15841
16231
|
}
|
|
15842
|
-
const root = new
|
|
16232
|
+
const root = new import_three40.Group();
|
|
15843
16233
|
root.name = "MineRender scene document";
|
|
15844
16234
|
const objects = [];
|
|
15845
16235
|
let disposed = false;
|
|
@@ -15879,7 +16269,7 @@ var SceneDocumentLoader = class {
|
|
|
15879
16269
|
return this.loadValidatedObject(scene, definition, parent);
|
|
15880
16270
|
}
|
|
15881
16271
|
static async loadValidatedObject(scene, definition, parent) {
|
|
15882
|
-
const root = new
|
|
16272
|
+
const root = new import_three40.Group();
|
|
15883
16273
|
root.name = definition.name ?? definition.id;
|
|
15884
16274
|
root.userData.sceneObjectId = definition.id;
|
|
15885
16275
|
root.position.fromArray(definition.position ?? [0, 0, 0]);
|
|
@@ -16757,12 +17147,12 @@ var AnvilWorldSource = class {
|
|
|
16757
17147
|
};
|
|
16758
17148
|
|
|
16759
17149
|
// src/world/Chunk.ts
|
|
16760
|
-
var
|
|
17150
|
+
var import_three44 = require("three");
|
|
16761
17151
|
init_BlockStates();
|
|
16762
17152
|
init_AssetKey();
|
|
16763
17153
|
|
|
16764
17154
|
// src/world/MineRenderWorld.ts
|
|
16765
|
-
var
|
|
17155
|
+
var import_three42 = require("three");
|
|
16766
17156
|
init_Model();
|
|
16767
17157
|
init_util();
|
|
16768
17158
|
init_AssetKey();
|
|
@@ -16770,7 +17160,7 @@ init_BlockStates();
|
|
|
16770
17160
|
init_CubeFace();
|
|
16771
17161
|
|
|
16772
17162
|
// src/world/SectionModels.ts
|
|
16773
|
-
var
|
|
17163
|
+
var import_three41 = require("three");
|
|
16774
17164
|
init_AssetKey();
|
|
16775
17165
|
init_Models();
|
|
16776
17166
|
init_CubeFace();
|
|
@@ -16794,7 +17184,7 @@ function cached(map, key, load) {
|
|
|
16794
17184
|
}
|
|
16795
17185
|
function compactQuads(geometry, keep) {
|
|
16796
17186
|
const quads = keep.flatMap((kept, index) => kept ? [index] : []);
|
|
16797
|
-
const compact = new
|
|
17187
|
+
const compact = new import_three41.BufferGeometry();
|
|
16798
17188
|
for (const [name, size] of Object.entries({ position: 3, normal: 3, uv: 2, uvBounds: 4, color: 3 })) {
|
|
16799
17189
|
const source2 = geometry.getAttribute(name);
|
|
16800
17190
|
const defaults = name === "uvBounds" ? [0, 0, 1, 1] : name === "color" ? [1, 1, 1] : void 0;
|
|
@@ -16806,7 +17196,7 @@ function compactQuads(geometry, keep) {
|
|
|
16806
17196
|
}
|
|
16807
17197
|
}
|
|
16808
17198
|
}
|
|
16809
|
-
compact.setAttribute(name, new
|
|
17199
|
+
compact.setAttribute(name, new import_three41.BufferAttribute(values, size));
|
|
16810
17200
|
}
|
|
16811
17201
|
const source = geometry.getIndex();
|
|
16812
17202
|
const indices = [];
|
|
@@ -16880,7 +17270,7 @@ var SectionModels = class {
|
|
|
16880
17270
|
});
|
|
16881
17271
|
await object4.init();
|
|
16882
17272
|
let geometry = object4.children[0].geometry;
|
|
16883
|
-
geometry.applyMatrix4(new
|
|
17273
|
+
geometry.applyMatrix4(new import_three41.Matrix4().makeRotationFromEuler(rotation));
|
|
16884
17274
|
object4.clear();
|
|
16885
17275
|
const keep = [];
|
|
16886
17276
|
const cullFaces = [];
|
|
@@ -16894,7 +17284,7 @@ var SectionModels = class {
|
|
|
16894
17284
|
cullFaces.push(0);
|
|
16895
17285
|
continue;
|
|
16896
17286
|
}
|
|
16897
|
-
const normal = new
|
|
17287
|
+
const normal = new import_three41.Vector3(...CUBE_FACE_OFFSETS[local]).applyEuler(rotation);
|
|
16898
17288
|
const world = CUBE_FACE_OFFSETS.findIndex(([x, y, z]) => Math.abs(normal.x - x) < 1e-6 && Math.abs(normal.y - y) < 1e-6 && Math.abs(normal.z - z) < 1e-6);
|
|
16899
17289
|
cullFaces.push(world < 0 ? 0 : 1 << world);
|
|
16900
17290
|
}
|
|
@@ -17090,17 +17480,17 @@ var MineRenderWorld = class {
|
|
|
17090
17480
|
}
|
|
17091
17481
|
getBlockAt(posOrX, y, z) {
|
|
17092
17482
|
if (typeof posOrX == "number") {
|
|
17093
|
-
return this.getBlockAt(new
|
|
17483
|
+
return this.getBlockAt(new import_three42.Vector3(posOrX, y, z));
|
|
17094
17484
|
}
|
|
17095
17485
|
if (isTripleArray(posOrX)) {
|
|
17096
|
-
return this.getBlockAt(new
|
|
17486
|
+
return this.getBlockAt(new import_three42.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
17097
17487
|
}
|
|
17098
17488
|
this.validatePosBounds(posOrX);
|
|
17099
17489
|
return this.getChunkAt(posOrX)?.getBlockAt(posOrX);
|
|
17100
17490
|
}
|
|
17101
17491
|
getBiomeAt(posOrX, y, z) {
|
|
17102
|
-
if (typeof posOrX === "number") return this.getBiomeAt(new
|
|
17103
|
-
if (isTripleArray(posOrX)) return this.getBiomeAt(new
|
|
17492
|
+
if (typeof posOrX === "number") return this.getBiomeAt(new import_three42.Vector3(posOrX, y, z));
|
|
17493
|
+
if (isTripleArray(posOrX)) return this.getBiomeAt(new import_three42.Vector3(...posOrX));
|
|
17104
17494
|
this.validatePosBounds(posOrX);
|
|
17105
17495
|
const cx = Math.floor(posOrX.x / 16), cy = Math.floor(posOrX.y / 16), cz = Math.floor(posOrX.z / 16);
|
|
17106
17496
|
const lx = posOrX.x - cx * 16, ly = posOrX.y - cy * 16, lz = posOrX.z - cz * 16;
|
|
@@ -17108,10 +17498,10 @@ var MineRenderWorld = class {
|
|
|
17108
17498
|
}
|
|
17109
17499
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
17110
17500
|
if (typeof posOrX == "number") {
|
|
17111
|
-
return this.setBlockAt(new
|
|
17501
|
+
return this.setBlockAt(new import_three42.Vector3(posOrX, yOrBlock, z), block);
|
|
17112
17502
|
}
|
|
17113
17503
|
if (isTripleArray(posOrX)) {
|
|
17114
|
-
return this.setBlockAt(new
|
|
17504
|
+
return this.setBlockAt(new import_three42.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
17115
17505
|
}
|
|
17116
17506
|
return this.placeBlock(posOrX, yOrBlock);
|
|
17117
17507
|
}
|
|
@@ -17122,10 +17512,10 @@ var MineRenderWorld = class {
|
|
|
17122
17512
|
}
|
|
17123
17513
|
async setBlockVisibleAt(posOrX, yOrVisible, z, visible) {
|
|
17124
17514
|
if (typeof posOrX === "number") {
|
|
17125
|
-
return this.setBlockVisibleAt(new
|
|
17515
|
+
return this.setBlockVisibleAt(new import_three42.Vector3(posOrX, yOrVisible, z), visible);
|
|
17126
17516
|
}
|
|
17127
17517
|
if (isTripleArray(posOrX)) {
|
|
17128
|
-
return this.setBlockVisibleAt(new
|
|
17518
|
+
return this.setBlockVisibleAt(new import_three42.Vector3(...posOrX), yOrVisible);
|
|
17129
17519
|
}
|
|
17130
17520
|
this.validatePosBounds(posOrX);
|
|
17131
17521
|
await this.getChunkAt(posOrX)?.setBlockVisibleAt(posOrX, yOrVisible);
|
|
@@ -17151,7 +17541,7 @@ var MineRenderWorld = class {
|
|
|
17151
17541
|
const collect = async (positions2) => {
|
|
17152
17542
|
for (const pos of positions2) changes.set(pos.toArray().join(","), pos);
|
|
17153
17543
|
};
|
|
17154
|
-
const place = (block) => this.placeBlock(new
|
|
17544
|
+
const place = (block) => this.placeBlock(new import_three42.Vector3(...block.position), block, collect);
|
|
17155
17545
|
const keys = /* @__PURE__ */ new Map();
|
|
17156
17546
|
const types = /* @__PURE__ */ new Set();
|
|
17157
17547
|
for (const block of multiblock.blocks) {
|
|
@@ -17167,7 +17557,7 @@ var MineRenderWorld = class {
|
|
|
17167
17557
|
}
|
|
17168
17558
|
if (!executor) {
|
|
17169
17559
|
const groups2 = /* @__PURE__ */ new Map();
|
|
17170
|
-
const position = new
|
|
17560
|
+
const position = new import_three42.Vector3();
|
|
17171
17561
|
for (const block of multiblock.blocks) {
|
|
17172
17562
|
const [x, y, z] = block.position;
|
|
17173
17563
|
this.validatePosBounds(position.set(x, y, z));
|
|
@@ -17207,7 +17597,7 @@ var MineRenderWorld = class {
|
|
|
17207
17597
|
try {
|
|
17208
17598
|
positions = await chunk.placeBlocks(blocks);
|
|
17209
17599
|
} finally {
|
|
17210
|
-
positions ??= blocks.map(({ index }) => new
|
|
17600
|
+
positions ??= blocks.map(({ index }) => new import_three42.Vector3(
|
|
17211
17601
|
chunk.x * 16 + index % 16,
|
|
17212
17602
|
chunk.y * 16 + Math.floor(index / 256),
|
|
17213
17603
|
chunk.z * 16 + Math.floor(index / 16) % 16
|
|
@@ -17246,7 +17636,7 @@ var MineRenderWorld = class {
|
|
|
17246
17636
|
let sliceStart = performance.now();
|
|
17247
17637
|
for (const section of chunk.sections) {
|
|
17248
17638
|
if (section.biomes) {
|
|
17249
|
-
const position = new
|
|
17639
|
+
const position = new import_three42.Vector3(chunk.x * 16, section.y * 16, chunk.z * 16);
|
|
17250
17640
|
this.validatePosBounds(position);
|
|
17251
17641
|
const copy = [...section.biomes];
|
|
17252
17642
|
if (copy.length !== 64 || !copy.every((id) => typeof id === "string" && id.length > 0)) {
|
|
@@ -17259,7 +17649,7 @@ var MineRenderWorld = class {
|
|
|
17259
17649
|
}
|
|
17260
17650
|
if (!executor) {
|
|
17261
17651
|
if (!occupiedSections.has(section.y)) continue;
|
|
17262
|
-
const position = new
|
|
17652
|
+
const position = new import_three42.Vector3(chunk.x * 16, section.y * 16, chunk.z * 16);
|
|
17263
17653
|
this.validatePosBounds(position);
|
|
17264
17654
|
const target = this.getOrCreateChunkAt(position);
|
|
17265
17655
|
try {
|
|
@@ -17353,7 +17743,7 @@ var MineRenderWorld = class {
|
|
|
17353
17743
|
this.sectionModels?.clear();
|
|
17354
17744
|
}
|
|
17355
17745
|
updateCulling(positions) {
|
|
17356
|
-
const neighbor = new
|
|
17746
|
+
const neighbor = new import_three42.Vector3();
|
|
17357
17747
|
for (const pos of positions) {
|
|
17358
17748
|
const cx = Math.floor(pos.x / 16), cy = Math.floor(pos.y / 16), cz = Math.floor(pos.z / 16);
|
|
17359
17749
|
const chunk = this._chunks.get(`${cx}_${cy}_${cz}`);
|
|
@@ -17445,7 +17835,7 @@ var MineRenderWorld = class {
|
|
|
17445
17835
|
}
|
|
17446
17836
|
/** Converts block coordinates to scene units by multiplying each component by 16. */
|
|
17447
17837
|
static worldToScenePosition(pos) {
|
|
17448
|
-
return new
|
|
17838
|
+
return new import_three42.Vector3(
|
|
17449
17839
|
pos.x * 16,
|
|
17450
17840
|
pos.y * 16,
|
|
17451
17841
|
pos.z * 16
|
|
@@ -17453,7 +17843,7 @@ var MineRenderWorld = class {
|
|
|
17453
17843
|
}
|
|
17454
17844
|
/** Converts scene units to block coordinates without rounding to an integer block. */
|
|
17455
17845
|
static sceneToWorldPosition(pos) {
|
|
17456
|
-
return new
|
|
17846
|
+
return new import_three42.Vector3(
|
|
17457
17847
|
pos.x / 16,
|
|
17458
17848
|
pos.y / 16,
|
|
17459
17849
|
pos.z / 16
|
|
@@ -17476,7 +17866,7 @@ var MineRenderWorld = class {
|
|
|
17476
17866
|
init_Model();
|
|
17477
17867
|
|
|
17478
17868
|
// src/world/SectionMesh.ts
|
|
17479
|
-
var
|
|
17869
|
+
var import_three43 = require("three");
|
|
17480
17870
|
init_CanvasCompat();
|
|
17481
17871
|
init_Materials();
|
|
17482
17872
|
|
|
@@ -17705,7 +18095,7 @@ var SectionWorker = class _SectionWorker {
|
|
|
17705
18095
|
|
|
17706
18096
|
// src/world/SectionMesh.ts
|
|
17707
18097
|
var templateCache = /* @__PURE__ */ new WeakMap();
|
|
17708
|
-
var WATER_TINT = new
|
|
18098
|
+
var WATER_TINT = new import_three43.Color(4159204).toArray();
|
|
17709
18099
|
function toInput(entries, maxAtlasSize, fluids) {
|
|
17710
18100
|
if (!Number.isInteger(maxAtlasSize) || maxAtlasSize < 1) throw new RangeError("Section atlas size must be a positive integer");
|
|
17711
18101
|
const atlases = [];
|
|
@@ -17800,7 +18190,7 @@ function toInput(entries, maxAtlasSize, fluids) {
|
|
|
17800
18190
|
}
|
|
17801
18191
|
return { input, atlases };
|
|
17802
18192
|
}
|
|
17803
|
-
var SectionMesh = class _SectionMesh extends
|
|
18193
|
+
var SectionMesh = class _SectionMesh extends import_three43.Group {
|
|
17804
18194
|
constructor() {
|
|
17805
18195
|
super(...arguments);
|
|
17806
18196
|
this.ownedMeshes = [];
|
|
@@ -17825,26 +18215,26 @@ var SectionMesh = class _SectionMesh extends import_three42.Group {
|
|
|
17825
18215
|
for (const { atlas, x, y } of page.placements) {
|
|
17826
18216
|
context.drawImage(atlases[atlas].image.canvas, x, y);
|
|
17827
18217
|
}
|
|
17828
|
-
const geometry = new
|
|
17829
|
-
geometry.setAttribute("position", new
|
|
17830
|
-
geometry.setAttribute("normal", new
|
|
17831
|
-
geometry.setAttribute("uv", new
|
|
17832
|
-
geometry.setAttribute("uvBounds", new
|
|
17833
|
-
geometry.setAttribute("color", new
|
|
17834
|
-
geometry.setIndex(new
|
|
18218
|
+
const geometry = new import_three43.BufferGeometry();
|
|
18219
|
+
geometry.setAttribute("position", new import_three43.Float32BufferAttribute(page.positions.buffer, 3));
|
|
18220
|
+
geometry.setAttribute("normal", new import_three43.Float32BufferAttribute(page.normals.buffer, 3));
|
|
18221
|
+
geometry.setAttribute("uv", new import_three43.Float32BufferAttribute(page.uvs.buffer, 2));
|
|
18222
|
+
geometry.setAttribute("uvBounds", new import_three43.Float32BufferAttribute(page.uvBounds.buffer, 4));
|
|
18223
|
+
geometry.setAttribute("color", new import_three43.Float32BufferAttribute(page.colors.buffer, 3));
|
|
18224
|
+
geometry.setIndex(new import_three43.Uint32BufferAttribute(page.indices.buffer, 1));
|
|
17835
18225
|
geometry.computeBoundingBox();
|
|
17836
18226
|
geometry.computeBoundingSphere();
|
|
17837
18227
|
const transparent = page.layer === 2 ? atlases[page.placements[0].atlas].hasTranslucency : page.layer === 1;
|
|
17838
18228
|
const material = Materials.createShadedCanvasMaterial(canvas, transparent, false, true);
|
|
17839
|
-
material.side =
|
|
18229
|
+
material.side = import_three43.FrontSide;
|
|
17840
18230
|
if (page.layer === 2) {
|
|
17841
|
-
material.side =
|
|
18231
|
+
material.side = import_three43.DoubleSide;
|
|
17842
18232
|
material.forceSinglePass = true;
|
|
17843
18233
|
material.depthWrite = !material.transparent;
|
|
17844
18234
|
}
|
|
17845
18235
|
material.vertexColors = true;
|
|
17846
18236
|
const texture = material.uniforms?.map?.value ?? material.map;
|
|
17847
|
-
const mesh = new
|
|
18237
|
+
const mesh = new import_three43.Mesh(geometry, material);
|
|
17848
18238
|
section.add(mesh);
|
|
17849
18239
|
const unsubscribe = [];
|
|
17850
18240
|
for (const { atlas: id, x, y } of page.placements) {
|
|
@@ -17890,7 +18280,7 @@ var Chunk = class _Chunk {
|
|
|
17890
18280
|
this.sectionBlocks = /* @__PURE__ */ new Map();
|
|
17891
18281
|
this.hiddenBlocks = /* @__PURE__ */ new Set();
|
|
17892
18282
|
this.fluidCells = new Uint8Array(4096);
|
|
17893
|
-
this.blockPosition = new
|
|
18283
|
+
this.blockPosition = new import_three44.Vector3();
|
|
17894
18284
|
this.meshDirty = false;
|
|
17895
18285
|
this.meshGeneration = 0;
|
|
17896
18286
|
this.scene = scene;
|
|
@@ -17900,10 +18290,10 @@ var Chunk = class _Chunk {
|
|
|
17900
18290
|
}
|
|
17901
18291
|
getBlockAt(posOrX, y, z) {
|
|
17902
18292
|
if (typeof posOrX == "number") {
|
|
17903
|
-
return this.getBlockAt(new
|
|
18293
|
+
return this.getBlockAt(new import_three44.Vector3(posOrX, y, z));
|
|
17904
18294
|
}
|
|
17905
18295
|
if (isTripleArray(posOrX)) {
|
|
17906
|
-
return this.getBlockAt(new
|
|
18296
|
+
return this.getBlockAt(new import_three44.Vector3(posOrX[0], posOrX[1], posOrX[2]));
|
|
17907
18297
|
}
|
|
17908
18298
|
const pos = this.blockPosition.set(posOrX.x - this.x * 16, posOrX.y - this.y * 16, posOrX.z - this.z * 16);
|
|
17909
18299
|
const index = _Chunk.chunkPosToBlockIndex(pos);
|
|
@@ -17911,10 +18301,10 @@ var Chunk = class _Chunk {
|
|
|
17911
18301
|
}
|
|
17912
18302
|
async setBlockAt(posOrX, yOrBlock, z, block) {
|
|
17913
18303
|
if (typeof posOrX == "number") {
|
|
17914
|
-
return this.setBlockAt(new
|
|
18304
|
+
return this.setBlockAt(new import_three44.Vector3(posOrX, yOrBlock, z), block);
|
|
17915
18305
|
}
|
|
17916
18306
|
if (isTripleArray(posOrX)) {
|
|
17917
|
-
return this.setBlockAt(new
|
|
18307
|
+
return this.setBlockAt(new import_three44.Vector3(posOrX[0], posOrX[1], posOrX[2]), yOrBlock);
|
|
17918
18308
|
}
|
|
17919
18309
|
const worldPos = posOrX;
|
|
17920
18310
|
const pos = this.worldPosToChunkPos(worldPos);
|
|
@@ -17967,7 +18357,7 @@ var Chunk = class _Chunk {
|
|
|
17967
18357
|
if (this.fluidCells[index]) this.meshDirty = true;
|
|
17968
18358
|
this.fluidCells[index] = 0;
|
|
17969
18359
|
this.renderedBlocks.delete(index);
|
|
17970
|
-
const worldPos = new
|
|
18360
|
+
const worldPos = new import_three44.Vector3(
|
|
17971
18361
|
this.x * 16 + index % 16,
|
|
17972
18362
|
this.y * 16 + Math.floor(index / 256),
|
|
17973
18363
|
this.z * 16 + Math.floor(index / 16) % 16
|
|
@@ -18092,7 +18482,7 @@ var Chunk = class _Chunk {
|
|
|
18092
18482
|
this.z * 16 + Math.floor(index / 16) % 16
|
|
18093
18483
|
]
|
|
18094
18484
|
});
|
|
18095
|
-
object4.setPosition(new
|
|
18485
|
+
object4.setPosition(new import_three44.Vector3(
|
|
18096
18486
|
this.x * 256 + index % 16 * 16,
|
|
18097
18487
|
this.y * 256 + Math.floor(index / 256) * 16,
|
|
18098
18488
|
this.z * 256 + Math.floor(index / 16) % 16 * 16
|
|
@@ -18243,7 +18633,7 @@ var Chunk = class _Chunk {
|
|
|
18243
18633
|
/** Removes stored blocks and render objects. Set `notify` to false to skip the owning world's update. */
|
|
18244
18634
|
async clear(notify = true) {
|
|
18245
18635
|
const positions = notify && this.onBlocksChanged ? [...this.renderedBlocks.keys()].map((index) => this.chunkPosToWorldPos(
|
|
18246
|
-
new
|
|
18636
|
+
new import_three44.Vector3(index % 16, Math.floor(index / 256), Math.floor(index / 16) % 16)
|
|
18247
18637
|
)) : [];
|
|
18248
18638
|
for (const info of this.renderedBlocks.values()) info.object?.removeFromScene();
|
|
18249
18639
|
this.sectionBlocks.clear();
|
|
@@ -18271,14 +18661,14 @@ var Chunk = class _Chunk {
|
|
|
18271
18661
|
return pos.y * 16 * 16 + pos.z * 16 + pos.x;
|
|
18272
18662
|
}
|
|
18273
18663
|
worldPosToChunkPos(pos) {
|
|
18274
|
-
return new
|
|
18664
|
+
return new import_three44.Vector3(
|
|
18275
18665
|
pos.x - this.x * 16,
|
|
18276
18666
|
pos.y - this.y * 16,
|
|
18277
18667
|
pos.z - this.z * 16
|
|
18278
18668
|
);
|
|
18279
18669
|
}
|
|
18280
18670
|
chunkPosToWorldPos(pos) {
|
|
18281
|
-
return new
|
|
18671
|
+
return new import_three44.Vector3(
|
|
18282
18672
|
this.x * 16 + pos.x,
|
|
18283
18673
|
this.y * 16 + pos.y,
|
|
18284
18674
|
this.z * 16 + pos.z
|
|
@@ -18672,6 +19062,7 @@ var NodeRenderer = class _NodeRenderer extends Renderer {
|
|
|
18672
19062
|
EntityObject,
|
|
18673
19063
|
Env,
|
|
18674
19064
|
FluidModelObject,
|
|
19065
|
+
FlyControls,
|
|
18675
19066
|
Fonts,
|
|
18676
19067
|
GUI_CONTAINER_LAYOUTS,
|
|
18677
19068
|
Geometries,
|
|
@@ -18777,6 +19168,7 @@ var NodeRenderer = class _NodeRenderer extends Renderer {
|
|
|
18777
19168
|
isDisposable,
|
|
18778
19169
|
isDoubleArray,
|
|
18779
19170
|
isEntityObject,
|
|
19171
|
+
isFlyControls,
|
|
18780
19172
|
isGuiObject,
|
|
18781
19173
|
isInstanceManager,
|
|
18782
19174
|
isInstanceReference,
|