iflow-engine-base 2.0.6 → 2.1.0

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.
@@ -675,7 +675,7 @@ function ic(o) {
675
675
  }
676
676
  class Pr {
677
677
  constructor(e, t, n, i) {
678
- this._Engine = e, this.camera = t, this.domElement = n, this._isEnabled = !1, this._rayOriginOffset = new M.Vector3(0, -1, 0), this._camerLocalDirection = new M.Vector3(), this._tmpVector = new M.Vector3(), this._rayCaster = new M.Raycaster(), this._fallingTime = 0, this._euler = new M.Euler(0, 0, 0, "YZX"), this._prevMouseX = 0, this._prevMouseY = 0, this.applyGravity = !1, this.gravityMinHeight = !0, this.applyCollision = !0, this.positionEasing = !0, this.lookflag = 1, this.lookSpeed = 8e-3, this.moveSpeed = 0.02, this.playerHeight = 1.4, this.maxRotateX = 0.8, this.g = 9.8, this.bindmousedown = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchStart.bind(this) : this.onMouseDown.bind(this), this.bindmouseup = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchEnd.bind(this) : this.onMouseUp.bind(this), this.bindmousemove = this._Engine && this._Engine.DeviceType !== "PC" ? this.onTouchMove.bind(this) : this.onMouseMove.bind(this), this.bindonKeyDown = this.onKeyDown.bind(this), this.bindonKeyUp = this.onKeyUp.bind(this), this.bindMousewheel = this.onMousewheel.bind(this), this.needMousewheel = !1, this.moveWheelRun = !0, this.moveWheelStop = !1, this.wheelClock, this.keydown = !1, this.GetEngine = () => e;
678
+ this._Engine = e, this.camera = t, this.domElement = n, this._isEnabled = !1, this._rayOriginOffset = new M.Vector3(0, -1, 0), this._camerLocalDirection = new M.Vector3(), this._tmpVector = new M.Vector3(), this._rayCaster = new M.Raycaster(), this._fallingTime = 0, this._euler = new M.Euler(0, 0, 0, "YZX"), this._prevMouseX = 0, this._prevMouseY = 0, this.applyGravity = !1, this.gravityMinHeight = !0, this.applyCollision = !0, this.positionEasing = !0, this.lookflag = 1, this.lookSpeed = 8e-3, this.moveSpeed = 0.02, this.playerHeight = 1.4, this.maxRotateX = 0.8, this.g = 9.8, this.bindmousedown = this._Engine && this._Engine.deviceType !== "PC" ? this.onTouchStart.bind(this) : this.onMouseDown.bind(this), this.bindmouseup = this._Engine && this._Engine.deviceType !== "PC" ? this.onTouchEnd.bind(this) : this.onMouseUp.bind(this), this.bindmousemove = this._Engine && this._Engine.deviceType !== "PC" ? this.onTouchMove.bind(this) : this.onMouseMove.bind(this), this.bindonKeyDown = this.onKeyDown.bind(this), this.bindonKeyUp = this.onKeyUp.bind(this), this.bindMousewheel = this.onMousewheel.bind(this), this.needMousewheel = !1, this.moveWheelRun = !0, this.moveWheelStop = !1, this.wheelClock, this.keydown = !1, this.GetEngine = () => e;
679
679
  }
680
680
  /**
681
681
  * @param {Object} colliders set objects for collision detection
@@ -700,7 +700,7 @@ class Pr {
700
700
  console.log("[FirstPersonCameraControl] addEvents - DeviceType:", e, "isPC:", t), t ? (console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"), this.domElement.addEventListener("mousedown", this.bindmousedown, !1), this.domElement.addEventListener("mouseup", this.bindmouseup, !1)) : (console.log("[FirstPersonCameraControl] 添加触摸事件监听器"), this.domElement.addEventListener("touchstart", this.bindmousedown, !1), this.domElement.addEventListener("touchend", this.bindmouseup, !1)), window.addEventListener("keydown", this.bindonKeyDown, !1), window.addEventListener("keyup", this.bindonKeyUp, !1), this.needMousewheel && (document.addEventListener && document.addEventListener("DOMMouseScroll", this.bindMousewheel, !1), window.addEventListener("mousewheel", this.bindMousewheel, !1));
701
701
  }
702
702
  removeEvents() {
703
- this._Engine && this._Engine.DeviceType !== "PC" ? (this.domElement.removeEventListener("touchstart", this.bindmousedown), this.domElement.removeEventListener("touchend", this.bindmouseup), this.domElement.removeEventListener("touchmove", this.bindmousemove)) : (this.domElement.removeEventListener("mousedown", this.bindmousedown), this.domElement.removeEventListener("mouseup", this.bindmouseup), this.domElement.removeEventListener("mousemove", this.bindmousemove)), window.removeEventListener("keydown", this.bindonKeyDown), window.removeEventListener("keyup", this.bindonKeyUp), this.needMousewheel && (document.addEventListener && document.removeEventListener("DOMMouseScroll", this.bindMousewheel), window.removeEventListener("mousewheel", this.bindMousewheel));
703
+ this._Engine && this._Engine.deviceType !== "PC" ? (this.domElement.removeEventListener("touchstart", this.bindmousedown), this.domElement.removeEventListener("touchend", this.bindmouseup), this.domElement.removeEventListener("touchmove", this.bindmousemove)) : (this.domElement.removeEventListener("mousedown", this.bindmousedown), this.domElement.removeEventListener("mouseup", this.bindmouseup), this.domElement.removeEventListener("mousemove", this.bindmousemove)), window.removeEventListener("keydown", this.bindonKeyDown), window.removeEventListener("keyup", this.bindonKeyUp), this.needMousewheel && (document.addEventListener && document.removeEventListener("DOMMouseScroll", this.bindMousewheel), window.removeEventListener("mousewheel", this.bindMousewheel));
704
704
  }
705
705
  onMousewheel(e) {
706
706
  debugger;
@@ -1243,11 +1243,11 @@ class sc {
1243
1243
  }
1244
1244
  // 设置漫游速度
1245
1245
  setMoveSpeed(e) {
1246
- this.firstPersonControls.moveSpeed = e;
1246
+ this.firstPersonControls.moveSpeed = e * 0.1;
1247
1247
  }
1248
1248
  // 获取当前移动速度
1249
1249
  getMoveSpeed() {
1250
- return this.firstPersonControls.moveSpeed;
1250
+ return this.firstPersonControls.moveSpeed * 10;
1251
1251
  }
1252
1252
  // 设置是否碰撞
1253
1253
  setApplyCollision(e) {
@@ -1280,7 +1280,7 @@ class sc {
1280
1280
  }
1281
1281
  // 切换默认模式
1282
1282
  switchDefaultMode() {
1283
- this.firstPersonControls && (this.firstPersonControls.enabled = !1, this.engine.cameraModule.switchToOrthographicCamera()), this.orbitControls.enabled = !0;
1283
+ this.firstPersonControls && (this.firstPersonControls.enabled = !1), this.orbitControls.enabled = !0;
1284
1284
  }
1285
1285
  // 控制鼠标交互
1286
1286
  handleMouseUp(e) {
@@ -10267,7 +10267,7 @@ class Gu {
10267
10267
  if (n.object.isInstance) {
10268
10268
  let a = n.matrix, l = [];
10269
10269
  r.indexes.forEach((c) => {
10270
- let d = r.indexes[c][0], m = this.engine.scene.children[d].boundingSphere;
10270
+ let d = c[0], m = this.engine.scene.children[d].geometry.boundingSphere;
10271
10271
  const p = new M.Box3(), f = m.center.clone().applyMatrix4(a), u = m.radius, g = new M.Vector3();
10272
10272
  g.setFromMatrixScale(a);
10273
10273
  const y = Math.max(g.x, g.y, g.z), w = u * y;
@@ -11512,16 +11512,18 @@ function rd(o, e, t) {
11512
11512
  }, n.CameraGoHome = function() {
11513
11513
  var f = o.octreeBox.getBoundingBox(), u = f.min.clone().add(f.max.clone()).multiplyScalar(0.5);
11514
11514
  let g = new M.Vector3(1, 1, 1);
11515
- var y = f.max.distanceTo(f.min), w = u.clone().add(g.multiplyScalar(y));
11515
+ var y = f.max.distanceTo(f.min), w = u.clone().add(g.multiplyScalar(y * 0.5));
11516
11516
  if (e.camera.isOrthographicCamera) {
11517
11517
  var x = o.container.clientWidth / o.container.clientHeight, _ = y * 0.6;
11518
11518
  e.camera.left = -_ * x, e.camera.right = _ * x, e.camera.top = _, e.camera.bottom = -_, e.camera.zoom = 1, e.camera.updateProjectionMatrix();
11519
11519
  }
11520
11520
  l(e.camera.position, w, o.controls.target.clone(), u);
11521
11521
  }, n.zoomToBox = function(f) {
11522
- var u = f.min.clone().add(f.max.clone()).multiplyScalar(0.5), g = e.camera.position.clone().sub(o.controls.target.clone()).normalize(), y = e.camera.position.distanceTo(o.controls.target), w = u.clone().add(g.multiplyScalar(y)), x = e.camera.zoom;
11523
11522
  if (e.camera.isOrthographicCamera) {
11524
- var _ = new M.Vector3(1, 0, 0).applyQuaternion(e.camera.quaternion), v = new M.Vector3(0, 1, 0).applyQuaternion(e.camera.quaternion), C = [
11523
+ let O = function() {
11524
+ i = requestAnimationFrame(O), N.update();
11525
+ };
11526
+ var u = f.min.clone().add(f.max.clone()).multiplyScalar(0.5), g = e.camera.position.clone().sub(o.controls.target.clone()).normalize(), y = e.camera.position.distanceTo(o.controls.target), w = u.clone().add(g.multiplyScalar(y)), x = e.camera.zoom, _ = new M.Vector3(1, 0, 0).applyQuaternion(e.camera.quaternion), v = new M.Vector3(0, 1, 0).applyQuaternion(e.camera.quaternion), C = [
11525
11527
  new M.Vector3(f.min.x, f.min.y, f.min.z),
11526
11528
  new M.Vector3(f.max.x, f.min.y, f.min.z),
11527
11529
  new M.Vector3(f.min.x, f.max.y, f.min.z),
@@ -11537,33 +11539,34 @@ function rd(o, e, t) {
11537
11539
  }
11538
11540
  var b = (P - E) / 2, I = (R - A) / 2, U = (e.camera.right - e.camera.left) / 2, F = (e.camera.top - e.camera.bottom) / 2;
11539
11541
  x = Math.min(U / b, F / I) * 0.75;
11542
+ var K = e.camera.position.clone(), H = o.controls.target.clone(), Y = e.camera.zoom, N = new An.Tween({
11543
+ x1: K.x,
11544
+ y1: K.y,
11545
+ z1: K.z,
11546
+ x2: H.x,
11547
+ y2: H.y,
11548
+ z2: H.z,
11549
+ zoom: Y
11550
+ }).to({
11551
+ x1: w.x,
11552
+ y1: w.y,
11553
+ z1: w.z,
11554
+ x2: u.x,
11555
+ y2: u.y,
11556
+ z2: u.z,
11557
+ zoom: x
11558
+ }, 1e3);
11559
+ N.onUpdate(function(te) {
11560
+ o.controls && (e.camera.position.set(te.x1, te.y1, te.z1), o.controls.target.set(te.x2, te.y2, te.z2), e.camera.isOrthographicCamera && (e.camera.zoom = te.zoom, e.camera.updateProjectionMatrix()), o.controls.auto = !0, o.controls.update(), n.RenderScene());
11561
+ }), N.onComplete(function() {
11562
+ o.controls && (o.controls.auto = !1, n.RenderScene(), cancelAnimationFrame(i), i = null);
11563
+ }), N.easing(An.Easing.Cubic.InOut), N.start(), O();
11564
+ } else {
11565
+ var u = f.min.clone().add(f.max.clone()).multiplyScalar(0.5);
11566
+ let ee = e.camera.position.clone().sub(o.controls.target.clone()).normalize();
11567
+ var w = u.clone().add(ee.multiplyScalar(2 * f.max.distanceTo(f.min)));
11568
+ l(e.camera.position, w, o.controls.target.clone(), u);
11540
11569
  }
11541
- var K = e.camera.position.clone(), H = o.controls.target.clone(), Y = e.camera.zoom, N = new An.Tween({
11542
- x1: K.x,
11543
- y1: K.y,
11544
- z1: K.z,
11545
- x2: H.x,
11546
- y2: H.y,
11547
- z2: H.z,
11548
- zoom: Y
11549
- }).to({
11550
- x1: w.x,
11551
- y1: w.y,
11552
- z1: w.z,
11553
- x2: u.x,
11554
- y2: u.y,
11555
- z2: u.z,
11556
- zoom: x
11557
- }, 1e3);
11558
- N.onUpdate(function(te) {
11559
- o.controls && (e.camera.position.set(te.x1, te.y1, te.z1), o.controls.target.set(te.x2, te.y2, te.z2), e.camera.isOrthographicCamera && (e.camera.zoom = te.zoom, e.camera.updateProjectionMatrix()), o.controls.auto = !0, o.controls.update(), n.RenderScene());
11560
- }), N.onComplete(function() {
11561
- o.controls && (o.controls.auto = !1, n.RenderScene(), cancelAnimationFrame(i), i = null);
11562
- }), N.easing(An.Easing.Cubic.InOut), N.start();
11563
- function O() {
11564
- i = requestAnimationFrame(O), N.update();
11565
- }
11566
- O();
11567
11570
  };
11568
11571
  function l(f, u, g, y, w, x, _ = 1e3, v) {
11569
11572
  var C;
@@ -12913,7 +12916,7 @@ class pd {
12913
12916
  this.points = [];
12914
12917
  }
12915
12918
  handleMouseUp(e) {
12916
- this.engine.DeviceType != "PC" && this.createMeasure();
12919
+ this.engine.deviceType != "PC" && this.createMeasure();
12917
12920
  }
12918
12921
  handleMouseMove(e) {
12919
12922
  if (e.catch == null)
@@ -18791,7 +18794,7 @@ class kp {
18791
18794
  // 业务数据
18792
18795
  models = [];
18793
18796
  reactBoundingClientRect = { left: 0, top: 0 };
18794
- version = "2.0.6";
18797
+ version = "2.1.0";
18795
18798
  versionEl = null;
18796
18799
  // 引擎容器
18797
18800
  container;