iflow-engine-base 2.0.6 → 2.1.1

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) {
@@ -10031,7 +10031,7 @@ function Bu(o, e, t) {
10031
10031
  indexes: /* @__PURE__ */ new Map()
10032
10032
  }) : (n.find((r) => r.glb == i.glb).meshes.push(i), n.find((r) => r.glb == i.glb).currentIndex += i.geometry.index.count);
10033
10033
  let s = n.find((r) => r.glb == i.glb);
10034
- s.indexes.set(Number(i.name), [s.currentIndex - i.geometry.index.count, s.currentIndex]);
10034
+ s.indexes.has(Number(i.name)) ? s.indexes.get(Number(i.name)).push([s.currentIndex - i.geometry.index.count, s.currentIndex]) : s.indexes.set(Number(i.name), [[s.currentIndex - i.geometry.index.count, s.currentIndex]]);
10035
10035
  }), n.forEach((i) => {
10036
10036
  let s = e.scene.children.find((r) => r instanceof M.Mesh && r.url == o && r.glb == i.glb);
10037
10037
  if (s != null)
@@ -10045,7 +10045,9 @@ function Bu(o, e, t) {
10045
10045
  if (h != null) {
10046
10046
  let c = 0;
10047
10047
  i.indexes.forEach((d) => {
10048
- h.nodesMap.get(Number(i.meshes[c].name)).indexes == null && (h.nodesMap.get(Number(i.meshes[c].name)).indexes = []), h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index, c++, d[0], d[1]]);
10048
+ d.forEach((m) => {
10049
+ h.nodesMap.get(Number(i.meshes[c].name)).indexes == null && (h.nodesMap.get(Number(i.meshes[c].name)).indexes = []), h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index, c++, m[0], m[1]]);
10050
+ });
10049
10051
  });
10050
10052
  }
10051
10053
  }
@@ -10267,7 +10269,7 @@ class Gu {
10267
10269
  if (n.object.isInstance) {
10268
10270
  let a = n.matrix, l = [];
10269
10271
  r.indexes.forEach((c) => {
10270
- let d = r.indexes[c][0], m = this.engine.scene.children[d].boundingSphere;
10272
+ let d = c[0], m = this.engine.scene.children[d].geometry.boundingSphere;
10271
10273
  const p = new M.Box3(), f = m.center.clone().applyMatrix4(a), u = m.radius, g = new M.Vector3();
10272
10274
  g.setFromMatrixScale(a);
10273
10275
  const y = Math.max(g.x, g.y, g.z), w = u * y;
@@ -11512,16 +11514,18 @@ function rd(o, e, t) {
11512
11514
  }, n.CameraGoHome = function() {
11513
11515
  var f = o.octreeBox.getBoundingBox(), u = f.min.clone().add(f.max.clone()).multiplyScalar(0.5);
11514
11516
  let g = new M.Vector3(1, 1, 1);
11515
- var y = f.max.distanceTo(f.min), w = u.clone().add(g.multiplyScalar(y));
11517
+ var y = f.max.distanceTo(f.min), w = u.clone().add(g.multiplyScalar(y * 0.5));
11516
11518
  if (e.camera.isOrthographicCamera) {
11517
11519
  var x = o.container.clientWidth / o.container.clientHeight, _ = y * 0.6;
11518
11520
  e.camera.left = -_ * x, e.camera.right = _ * x, e.camera.top = _, e.camera.bottom = -_, e.camera.zoom = 1, e.camera.updateProjectionMatrix();
11519
11521
  }
11520
11522
  l(e.camera.position, w, o.controls.target.clone(), u);
11521
11523
  }, 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
11524
  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 = [
11525
+ let O = function() {
11526
+ i = requestAnimationFrame(O), N.update();
11527
+ };
11528
+ 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
11529
  new M.Vector3(f.min.x, f.min.y, f.min.z),
11526
11530
  new M.Vector3(f.max.x, f.min.y, f.min.z),
11527
11531
  new M.Vector3(f.min.x, f.max.y, f.min.z),
@@ -11537,33 +11541,34 @@ function rd(o, e, t) {
11537
11541
  }
11538
11542
  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
11543
  x = Math.min(U / b, F / I) * 0.75;
11544
+ var K = e.camera.position.clone(), H = o.controls.target.clone(), Y = e.camera.zoom, N = new An.Tween({
11545
+ x1: K.x,
11546
+ y1: K.y,
11547
+ z1: K.z,
11548
+ x2: H.x,
11549
+ y2: H.y,
11550
+ z2: H.z,
11551
+ zoom: Y
11552
+ }).to({
11553
+ x1: w.x,
11554
+ y1: w.y,
11555
+ z1: w.z,
11556
+ x2: u.x,
11557
+ y2: u.y,
11558
+ z2: u.z,
11559
+ zoom: x
11560
+ }, 1e3);
11561
+ N.onUpdate(function(te) {
11562
+ 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());
11563
+ }), N.onComplete(function() {
11564
+ o.controls && (o.controls.auto = !1, n.RenderScene(), cancelAnimationFrame(i), i = null);
11565
+ }), N.easing(An.Easing.Cubic.InOut), N.start(), O();
11566
+ } else {
11567
+ var u = f.min.clone().add(f.max.clone()).multiplyScalar(0.5);
11568
+ let ee = e.camera.position.clone().sub(o.controls.target.clone()).normalize();
11569
+ var w = u.clone().add(ee.multiplyScalar(2 * f.max.distanceTo(f.min)));
11570
+ l(e.camera.position, w, o.controls.target.clone(), u);
11540
11571
  }
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
11572
  };
11568
11573
  function l(f, u, g, y, w, x, _ = 1e3, v) {
11569
11574
  var C;
@@ -12913,7 +12918,7 @@ class pd {
12913
12918
  this.points = [];
12914
12919
  }
12915
12920
  handleMouseUp(e) {
12916
- this.engine.DeviceType != "PC" && this.createMeasure();
12921
+ this.engine.deviceType != "PC" && this.createMeasure();
12917
12922
  }
12918
12923
  handleMouseMove(e) {
12919
12924
  if (e.catch == null)
@@ -18791,7 +18796,7 @@ class kp {
18791
18796
  // 业务数据
18792
18797
  models = [];
18793
18798
  reactBoundingClientRect = { left: 0, top: 0 };
18794
- version = "2.0.6";
18799
+ version = "2.1.1";
18795
18800
  versionEl = null;
18796
18801
  // 引擎容器
18797
18802
  container;