@realsee/dnalogel 2.0.0-alpha.2 → 2.0.0-alpha.5

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.
@@ -737,7 +737,7 @@ function flush() {
737
737
  const component = dirty_components[flushidx];
738
738
  flushidx++;
739
739
  set_current_component(component);
740
- update(component.$$);
740
+ update$1(component.$$);
741
741
  }
742
742
  set_current_component(null);
743
743
  dirty_components.length = 0;
@@ -760,7 +760,7 @@ function flush() {
760
760
  seen_callbacks.clear();
761
761
  set_current_component(saved_component);
762
762
  }
763
- function update($$) {
763
+ function update$1($$) {
764
764
  if ($$.fragment !== null) {
765
765
  $$.update();
766
766
  run_all($$.before_update);
@@ -14099,7 +14099,7 @@ function WebGLAttributes(gl, capabilities) {
14099
14099
  attribute = attribute.data;
14100
14100
  return buffers.get(attribute);
14101
14101
  }
14102
- function remove(attribute) {
14102
+ function remove2(attribute) {
14103
14103
  if (attribute.isInterleavedBufferAttribute)
14104
14104
  attribute = attribute.data;
14105
14105
  var data = buffers.get(attribute);
@@ -14121,7 +14121,7 @@ function WebGLAttributes(gl, capabilities) {
14121
14121
  }
14122
14122
  return {
14123
14123
  get,
14124
- remove,
14124
+ remove: remove2,
14125
14125
  update: update2
14126
14126
  };
14127
14127
  }
@@ -16606,7 +16606,7 @@ function WebGLProperties() {
16606
16606
  }
16607
16607
  return map;
16608
16608
  }
16609
- function remove(object) {
16609
+ function remove2(object) {
16610
16610
  properties.delete(object);
16611
16611
  }
16612
16612
  function update2(object, key, value) {
@@ -16617,7 +16617,7 @@ function WebGLProperties() {
16617
16617
  }
16618
16618
  return {
16619
16619
  get,
16620
- remove,
16620
+ remove: remove2,
16621
16621
  update: update2,
16622
16622
  dispose
16623
16623
  };
@@ -25957,7 +25957,7 @@ CompressedTextureLoader.prototype = Object.assign(Object.create(Loader.prototype
25957
25957
  var loader = new FileLoader(this.manager);
25958
25958
  loader.setPath(this.path);
25959
25959
  loader.setResponseType("arraybuffer");
25960
- function loadTexture(i2) {
25960
+ function loadTexture2(i2) {
25961
25961
  loader.load(url[i2], function(buffer) {
25962
25962
  var texDatas = scope.parse(buffer, true);
25963
25963
  images[i2] = {
@@ -25980,7 +25980,7 @@ CompressedTextureLoader.prototype = Object.assign(Object.create(Loader.prototype
25980
25980
  if (Array.isArray(url)) {
25981
25981
  var loaded = 0;
25982
25982
  for (var i = 0, il = url.length; i < il; ++i) {
25983
- loadTexture(i);
25983
+ loadTexture2(i);
25984
25984
  }
25985
25985
  } else {
25986
25986
  loader.load(url, function(buffer) {
@@ -26119,7 +26119,7 @@ CubeTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
26119
26119
  loader.setCrossOrigin(this.crossOrigin);
26120
26120
  loader.setPath(this.path);
26121
26121
  var loaded = 0;
26122
- function loadTexture(i2) {
26122
+ function loadTexture2(i2) {
26123
26123
  loader.load(urls[i2], function(image) {
26124
26124
  texture.images[i2] = image;
26125
26125
  loaded++;
@@ -26131,7 +26131,7 @@ CubeTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {
26131
26131
  }, void 0, onError);
26132
26132
  }
26133
26133
  for (var i = 0; i < urls.length; ++i) {
26134
- loadTexture(i);
26134
+ loadTexture2(i);
26135
26135
  }
26136
26136
  return texture;
26137
26137
  }
@@ -33730,12 +33730,12 @@ var FBXLoader = function() {
33730
33730
  }
33731
33731
  fbxTree = new TextParser().parse(FBXText);
33732
33732
  }
33733
- var textureLoader = new TextureLoader(this.manager).setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
33734
- return new FBXTreeParser(textureLoader, this.manager).parse(fbxTree);
33733
+ var textureLoader2 = new TextureLoader(this.manager).setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
33734
+ return new FBXTreeParser(textureLoader2, this.manager).parse(fbxTree);
33735
33735
  }
33736
33736
  });
33737
- function FBXTreeParser(textureLoader, manager) {
33738
- this.textureLoader = textureLoader;
33737
+ function FBXTreeParser(textureLoader2, manager) {
33738
+ this.textureLoader = textureLoader2;
33739
33739
  this.manager = manager;
33740
33740
  }
33741
33741
  FBXTreeParser.prototype = {
@@ -36934,19 +36934,36 @@ var Tween = function() {
36934
36934
  };
36935
36935
  return Tween2;
36936
36936
  }();
36937
+ var VERSION = "18.6.4";
36938
+ var nextId = Sequence.nextId;
36937
36939
  var TWEEN = mainGroup;
36938
- TWEEN.getAll.bind(TWEEN);
36939
- TWEEN.removeAll.bind(TWEEN);
36940
- TWEEN.add.bind(TWEEN);
36941
- TWEEN.remove.bind(TWEEN);
36942
- TWEEN.update.bind(TWEEN);
36940
+ var getAll = TWEEN.getAll.bind(TWEEN);
36941
+ var removeAll = TWEEN.removeAll.bind(TWEEN);
36942
+ var add = TWEEN.add.bind(TWEEN);
36943
+ var remove = TWEEN.remove.bind(TWEEN);
36944
+ var update = TWEEN.update.bind(TWEEN);
36945
+ var exports = {
36946
+ Easing: Easing$1,
36947
+ Group,
36948
+ Interpolation,
36949
+ now: now$1,
36950
+ Sequence,
36951
+ nextId,
36952
+ Tween,
36953
+ VERSION,
36954
+ getAll,
36955
+ removeAll,
36956
+ add,
36957
+ remove,
36958
+ update
36959
+ };
36943
36960
  const _requestAnimationFrame = window.requestAnimationFrame || ((fn) => setTimeout(fn, 16));
36944
36961
  const _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
36945
- function nextFrame(fn, delay = 0) {
36962
+ function nextFrame$1(fn, delay = 0) {
36946
36963
  if (delay <= 0)
36947
36964
  _requestAnimationFrame(fn);
36948
36965
  else
36949
- _requestAnimationFrame(() => nextFrame(fn, delay - 1));
36966
+ _requestAnimationFrame(() => nextFrame$1(fn, delay - 1));
36950
36967
  }
36951
36968
  function requestAnimationFrameInterval(callback, frame = 60) {
36952
36969
  let index = -1;
@@ -36970,7 +36987,7 @@ function requestAnimationFrameInterval(callback, frame = 60) {
36970
36987
  const Easing = Easing$1;
36971
36988
  function tween(from, to2, duration, easing = Easing.Linear.None) {
36972
36989
  const tween2 = new Tween(from).to(to2, duration).easing(easing);
36973
- nextFrame(() => tween2.start(0));
36990
+ nextFrame$1(() => tween2.start(0));
36974
36991
  const cancelAnimationFrame2 = requestAnimationFrameInterval((time) => {
36975
36992
  if (tween2.update(time) === false)
36976
36993
  cancelAnimationFrame2();
@@ -36995,7 +37012,7 @@ function tween(from, to2, duration, easing = Easing.Linear.None) {
36995
37012
  };
36996
37013
  return tween2;
36997
37014
  }
36998
- function tweenProgress(duration, easing) {
37015
+ function tweenProgress$1(duration, easing) {
36999
37016
  return tween({ progress: 0 }, { progress: 1 }, duration, easing);
37000
37017
  }
37001
37018
  var Rotation = /* @__PURE__ */ ((Rotation2) => {
@@ -37118,7 +37135,7 @@ const CameraMovementPlugin = (five) => {
37118
37135
  resolve(false);
37119
37136
  };
37120
37137
  const animeDuration = args.rotateSpeed ? Math.ceil(Math.abs(to2.longitude - from.longitude) / args.rotateSpeed * 1e3) : duration;
37121
- const tween2 = tweenProgress(animeDuration, Easing$1.Linear.None).onUpdate(onUpdate).onComplete(onComplete).onDestroy(onDestroy2);
37138
+ const tween2 = tweenProgress$1(animeDuration, Easing$1.Linear.None).onUpdate(onUpdate).onComplete(onComplete).onDestroy(onDestroy2);
37122
37139
  if (args.rotation === Rotation.Loop) {
37123
37140
  tween2.repeat(Infinity).yoyo(true);
37124
37141
  }
@@ -37142,4 +37159,638 @@ const CameraMovementPlugin = (five) => {
37142
37159
  rotate
37143
37160
  };
37144
37161
  };
37145
- export { CSS3DRenderPlugin, CameraMovementPlugin, ModelChassisCompassPlugin, ModelEntryDoorGuidePlugin, ModelFloorplanPlugin, ModelRoomLabelPlugin, ModelViewPlugin, PanoCursorRaycasterPlugin, PanoFloorplanRadarPlugin, TopviewFloorplanPlugin };
37162
+ function samePointAt(point1, point2) {
37163
+ return point1.x === point2.x && point1.y === point2.y;
37164
+ }
37165
+ function sameK(k1, k2) {
37166
+ if (Math.abs(k1) === Infinity && Math.abs(k2) === Infinity)
37167
+ return true;
37168
+ return Math.abs(k1 - k2) < 1e-3;
37169
+ }
37170
+ function getK(point1, point2) {
37171
+ return (point2.y - point1.y) / (point2.x - point1.x);
37172
+ }
37173
+ function intersectionOfLine(linePoints1, linePoints2, needIntersectionInLine) {
37174
+ const k1 = getK(linePoints1[1], linePoints1[0]);
37175
+ const k2 = getK(linePoints2[1], linePoints2[0]);
37176
+ if (isNaN(k1) || isNaN(k2))
37177
+ return false;
37178
+ if (sameK(k1, k2))
37179
+ return false;
37180
+ if (pointOnLine(linePoints1[0], linePoints2))
37181
+ return linePoints1[0];
37182
+ if (pointOnLine(linePoints1[1], linePoints2))
37183
+ return linePoints1[1];
37184
+ if (pointOnLine(linePoints2[0], linePoints1))
37185
+ return linePoints2[0];
37186
+ if (pointOnLine(linePoints2[1], linePoints1))
37187
+ return linePoints2[1];
37188
+ if (needIntersectionInLine && !isIntersect(linePoints1, linePoints2))
37189
+ return false;
37190
+ const p1 = linePoints1[0];
37191
+ const p2 = linePoints2[0];
37192
+ if (Math.abs(k1) === Infinity) {
37193
+ return { x: p1.x, y: linePoints2[1].y - (linePoints2[1].x - p1.x) * k2 };
37194
+ }
37195
+ if (Math.abs(k2) === Infinity) {
37196
+ return { x: p2.x, y: linePoints1[1].y - (linePoints1[1].x - p2.x) * k1 };
37197
+ }
37198
+ const x = (p2.y - p1.y + k1 * p1.x - k2 * p2.x) / (k1 - k2);
37199
+ const y2 = k1 * x - k1 * p1.x + p1.y;
37200
+ return { x, y: y2 };
37201
+ }
37202
+ function pointOnLine(point, linePoints) {
37203
+ if (samePointAt(point, linePoints[0]))
37204
+ return true;
37205
+ if (samePointAt(point, linePoints[1]))
37206
+ return true;
37207
+ return (linePoints[0].x - point.x) * (point.x - linePoints[1].x) >= 0 && (linePoints[0].y - point.y) * (point.y - linePoints[1].y) >= 0 && sameK(getK(linePoints[0], point), getK(point, linePoints[1]));
37208
+ }
37209
+ function multi(p1, p2, p0) {
37210
+ return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y);
37211
+ }
37212
+ function isIntersect(linePoints1, linePoints2) {
37213
+ if (Math.max(linePoints1[0].x, linePoints1[1].x) >= Math.min(linePoints2[0].x, linePoints2[1].x) && Math.max(linePoints2[0].x, linePoints2[1].x) >= Math.min(linePoints1[0].x, linePoints1[1].x) && Math.max(linePoints1[0].y, linePoints1[1].y) >= Math.min(linePoints2[0].y, linePoints2[1].y) && multi(linePoints2[0], linePoints1[1], linePoints1[0]) * multi(linePoints1[1], linePoints2[1], linePoints1[0]) > 0 && multi(linePoints1[0], linePoints2[1], linePoints2[0]) * multi(linePoints2[1], linePoints1[1], linePoints2[0]) > 0)
37214
+ return 1;
37215
+ return 0;
37216
+ }
37217
+ function nextFrame(fn, delay = 0) {
37218
+ if (delay <= 0)
37219
+ requestAnimationFrame(fn);
37220
+ else
37221
+ requestAnimationFrame(() => nextFrame(fn, delay - 1));
37222
+ }
37223
+ const PanoRulerStyle = `<style type="text/css">
37224
+ .PanoRulerPlugin-rule-line {
37225
+ position: absolute;
37226
+ transform-origin: left center;
37227
+ width: 0;
37228
+ height: 0.0625rem;
37229
+ }
37230
+
37231
+ .PanoRulerPlugin-rule-line::after {
37232
+ content: '';
37233
+ position: absolute;
37234
+ left: -0.125rem;
37235
+ top: -0.1rem;
37236
+ width: 0.25rem;
37237
+ height: 0.25rem;
37238
+ border-radius: 50%;
37239
+ background: #FFFFFF;
37240
+ z-index: 1;
37241
+ animation: viewport-rule-point 0.1s 1s;
37242
+ animation-fill-mode: both;
37243
+ }
37244
+
37245
+ .PanoRulerPlugin-rule-line::before {
37246
+ content: '';
37247
+ position: absolute;
37248
+ right: -0.125rem;
37249
+ top: -0.1rem;
37250
+ width: 0.25rem;
37251
+ height: 0.25rem;
37252
+ border-radius: 50%;
37253
+ background: #FFFFFF;
37254
+ animation: viewport-rule-point 0.1s 1.5s;
37255
+ animation-fill-mode: both;
37256
+ }
37257
+
37258
+ .PanoRulerPlugin-rule-line em {
37259
+ background: #fff;
37260
+ display: block;
37261
+ height: 100%;
37262
+ animation: viewport-rule-line 0.5s ease 1s;
37263
+ animation-fill-mode: both;
37264
+ box-shadow: 0 0 0.25rem rgb(0 0 0 / 40%);
37265
+ }
37266
+
37267
+ .PanoRulerPlugin-rule-label {
37268
+ position: absolute;
37269
+ width: 0;
37270
+ height: 0;
37271
+ top: 0.0625rem;
37272
+ }
37273
+
37274
+ .PanoRulerPlugin-rule-label-name {
37275
+ position: absolute;
37276
+ padding: 0.1875rem 0.375rem;
37277
+ background: rgba(195,195,195,0.30);
37278
+ backdrop-filter: blur(0.25rem);
37279
+ border-radius: 6.25rem;
37280
+ border: 0.0625rem solid rgba(255,255,255,0.6);
37281
+ white-space: nowrap;
37282
+ overflow: hidden;
37283
+ color: #FFFFFF;
37284
+ font-weight: 500;
37285
+ font-size: 0.75rem;
37286
+ line-height: 1;
37287
+ -webkit-animation: viewport-rule-label 0.25s ease 1s;
37288
+ animation: viewport-rule-label 0.25s ease 1s;
37289
+ animation-fill-mode: both;
37290
+ box-shadow: inset 0 0 0.625rem 0 rgba(255,255,255,0.30);
37291
+ }
37292
+
37293
+ @keyframes viewport-rule-line {
37294
+ 0% { width: 0% }
37295
+ 100% { width: 100% }
37296
+ }
37297
+
37298
+ @keyframes viewport-rule-label {
37299
+ 0% { opacity: 0; transform: scaleX(0); }
37300
+ 100% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
37301
+ }
37302
+
37303
+ @keyframes viewport-rule-point {
37304
+ 0% { transform: scaleX(0); }
37305
+ 100% { transform: scaleX(1); }
37306
+ }
37307
+ </style>
37308
+ `;
37309
+ const getDistance = (p1, p2) => {
37310
+ return Math.sqrt(Math.pow(p1.z - p2.z, 2) + Math.pow(p1.x - p2.x, 2));
37311
+ };
37312
+ const getRoomHeightInfo = (roomInfo, five) => {
37313
+ const roomHeightInfo = {};
37314
+ const raycaster = new Raycaster$1();
37315
+ const work = five.work;
37316
+ if (!work)
37317
+ return roomHeightInfo;
37318
+ const observers = roomInfo.observers;
37319
+ work.observers.forEach((observer, index) => {
37320
+ const { standingPosition: position } = observer;
37321
+ const point = new Vector3$1(position.x, position.y, position.z);
37322
+ raycaster.set(point, new Vector3$1(0, 1, 0));
37323
+ const [intersection] = five.model.intersectRaycaster(raycaster);
37324
+ const verticalY = intersection ? intersection.point.y : 2.7;
37325
+ const id = observers[index];
37326
+ if (!id)
37327
+ return roomHeightInfo;
37328
+ const observerRoomName = roomInfo.rooms[id].name;
37329
+ if (roomHeightInfo[observerRoomName] === void 0) {
37330
+ roomHeightInfo[observerRoomName] = {
37331
+ __roof: [verticalY],
37332
+ __floor: [point.y]
37333
+ };
37334
+ } else {
37335
+ roomHeightInfo[observerRoomName].__roof.push(verticalY);
37336
+ roomHeightInfo[observerRoomName].__floor.push(point.y);
37337
+ }
37338
+ });
37339
+ for (const roomName in roomHeightInfo) {
37340
+ const room = roomHeightInfo[roomName];
37341
+ room.__roof.sort();
37342
+ room.__floor.sort();
37343
+ room.floor = room.__floor[~~(room.__floor.length / 2)];
37344
+ room.roof = room.__roof[room.__roof.length - 1];
37345
+ }
37346
+ return roomHeightInfo;
37347
+ };
37348
+ const PanoRulerPlugin = (five, params) => {
37349
+ const state = {
37350
+ enable: false,
37351
+ loaded: false,
37352
+ options: params.options || {
37353
+ distanceText: (distance) => `${distance.toFixed(1)}m`
37354
+ }
37355
+ };
37356
+ const tpl = (name, distance) => {
37357
+ const domStr = `
37358
+ <div class="PanoRulerPlugin-rule-line">
37359
+ <em></em>
37360
+ <div class="PanoRulerPlugin-rule-label">
37361
+ <div class="PanoRulerPlugin-rule-label-name">${state.options.distanceText(distance)}</div>
37362
+ </div>
37363
+ </div>
37364
+ `;
37365
+ const res = document.createElement("div");
37366
+ res.setAttribute("class", "PanoRulerPlugin-rule");
37367
+ res.setAttribute("data-name", name);
37368
+ res.setAttribute("style", "display: none");
37369
+ res.innerHTML = domStr;
37370
+ return res;
37371
+ };
37372
+ const $rule = document.createElement("div");
37373
+ $rule.setAttribute("style", `position: absolute;pointer-events: none;width: 100%;height: 100%;left: 0;top: 0;overflow: hidden;`);
37374
+ const style = document.createElement("div");
37375
+ style.innerHTML = PanoRulerStyle;
37376
+ $rule.appendChild(style);
37377
+ const __rule = {};
37378
+ const _load = (roomInfo, roomRules) => {
37379
+ if (state.loaded) {
37380
+ throw new Error("\u6807\u5C3A\u88AB\u91CD\u590D\u521D\u59CB\u5316\uFF01");
37381
+ }
37382
+ const roomHeightInfo = getRoomHeightInfo(roomInfo, five);
37383
+ const work = five.work;
37384
+ if (!work)
37385
+ return false;
37386
+ for (const obKey in roomRules) {
37387
+ const points = roomRules[obKey];
37388
+ const { standingPosition: defaultPosition } = work.observers[0];
37389
+ const roomPoints = points.map(({ x, z, observers }) => {
37390
+ const pointRoomName = observers.length > 0 ? roomInfo.rooms[roomInfo.observers[observers[0]]].name : "";
37391
+ const medianFloorHeight = roomHeightInfo[pointRoomName] ? roomHeightInfo[pointRoomName].floor : null;
37392
+ let minDistance = Infinity;
37393
+ let nearestPoint = {
37394
+ index: 0,
37395
+ x: defaultPosition.x,
37396
+ y: defaultPosition.y,
37397
+ z: defaultPosition.z
37398
+ };
37399
+ observers.forEach((index) => {
37400
+ if (!work.observers[index])
37401
+ return;
37402
+ const { standingPosition: position } = work.observers[index];
37403
+ const observerPoint = {
37404
+ index,
37405
+ x: position.x,
37406
+ y: position.y,
37407
+ z: position.z
37408
+ };
37409
+ const distance = getDistance({ x, z }, observerPoint);
37410
+ if (medianFloorHeight) {
37411
+ if (distance < minDistance && Math.abs(observerPoint.y - medianFloorHeight) < 0.3) {
37412
+ minDistance = distance;
37413
+ nearestPoint = observerPoint;
37414
+ }
37415
+ } else {
37416
+ if (distance < minDistance) {
37417
+ minDistance = distance;
37418
+ nearestPoint = observerPoint;
37419
+ }
37420
+ }
37421
+ });
37422
+ const _origin = new Vector3$1(x, nearestPoint.y, z);
37423
+ Object.assign(_origin, { observers });
37424
+ const verticalY = roomHeightInfo[pointRoomName] ? roomHeightInfo[pointRoomName].roof : null;
37425
+ const _vertical = !verticalY ? null : new Vector3$1(x, verticalY, z);
37426
+ if (_vertical)
37427
+ Object.assign(_vertical, { observers });
37428
+ const origin = _origin;
37429
+ const vertical = _vertical;
37430
+ return { origin, vertical };
37431
+ });
37432
+ __rule[obKey] = {
37433
+ origins: roomPoints.map((roomPoint) => roomPoint.origin),
37434
+ rules: []
37435
+ };
37436
+ for (const { origin, vertical } of roomPoints) {
37437
+ if (!vertical)
37438
+ continue;
37439
+ const $element = tpl(obKey, origin.distanceTo(vertical));
37440
+ $rule.append($element);
37441
+ __rule[obKey].rules.push({ vertical: true, rule: [origin, vertical], $element });
37442
+ }
37443
+ for (let index = 0; index < roomPoints.length; index++) {
37444
+ let nextIndex = index + 1;
37445
+ if (nextIndex >= roomPoints.length)
37446
+ nextIndex = 0;
37447
+ const { origin } = roomPoints[index];
37448
+ const { origin: next } = roomPoints[nextIndex];
37449
+ const $element = tpl(obKey, origin.distanceTo(next));
37450
+ $rule.append($element);
37451
+ __rule[obKey].rules.push({ vertical: false, rule: [origin, next], $element });
37452
+ }
37453
+ }
37454
+ state.loaded = true;
37455
+ return true;
37456
+ };
37457
+ const load = async (_roomInfo, _roomRules, options) => {
37458
+ const roomInfo = _roomInfo || params.roomInfo;
37459
+ const roomRules = _roomRules || params.roomRules;
37460
+ if (!roomInfo || !roomRules) {
37461
+ throw new Error("\u6807\u5C3A\u6570\u636E\u4F9D\u8D56\u4E0D\u9F50\u5168\uFF01");
37462
+ }
37463
+ state.options = Object.assign({}, state.options, options || {});
37464
+ if (five.model.loaded) {
37465
+ return _load(roomInfo, roomRules);
37466
+ } else {
37467
+ return await new Promise((resolve) => five.once("modelLoaded", () => resolve(_load(roomInfo, roomRules))));
37468
+ }
37469
+ };
37470
+ if (params.roomInfo && params.roomRules) {
37471
+ load(params.roomInfo, params.roomRules);
37472
+ }
37473
+ const getRuleScreenIntr = (startPoint, endPoint, canvasWidth, canvasHeight) => {
37474
+ const screenLines = [
37475
+ [
37476
+ { x: 0, y: 0 },
37477
+ { x: canvasWidth, y: 0 }
37478
+ ],
37479
+ [
37480
+ { x: 0, y: 0 },
37481
+ { x: 0, y: canvasHeight }
37482
+ ],
37483
+ [
37484
+ { x: canvasWidth, y: 0 },
37485
+ { x: canvasWidth, y: canvasHeight }
37486
+ ],
37487
+ [
37488
+ { x: 0, y: canvasHeight },
37489
+ { x: canvasWidth, y: canvasHeight }
37490
+ ]
37491
+ ];
37492
+ const intr = [];
37493
+ for (let i = 0; i < screenLines.length; i++) {
37494
+ const result = intersectionOfLine([startPoint, endPoint], [screenLines[i][0], screenLines[i][1]], true);
37495
+ if (result)
37496
+ intr.push(result);
37497
+ }
37498
+ if (intr.length === 0)
37499
+ return false;
37500
+ else {
37501
+ return intr;
37502
+ }
37503
+ };
37504
+ const freshRule = () => {
37505
+ var _a;
37506
+ const element2 = (_a = five.getElement()) == null ? void 0 : _a.parentElement;
37507
+ if (!element2)
37508
+ return;
37509
+ if (!state.loaded)
37510
+ return;
37511
+ if (Object.keys(__rule).length <= 0)
37512
+ return;
37513
+ const { panoIndex, camera, currentMode } = five;
37514
+ if (panoIndex === void 0)
37515
+ return;
37516
+ let name;
37517
+ for (const _name in __rule) {
37518
+ if (_name.split(",").indexOf(panoIndex.toString()) >= 0)
37519
+ name = _name;
37520
+ }
37521
+ if (!name)
37522
+ return;
37523
+ const cameraPosition = camera.position;
37524
+ const cameraDirection = camera.getWorldDirection(new Vector3$1());
37525
+ const width = element2.clientWidth;
37526
+ const height = element2.clientHeight;
37527
+ if (currentMode !== Five.Mode.Panorama) {
37528
+ for (const _name in __rule) {
37529
+ for (const { $element } of __rule[_name].rules) {
37530
+ $element.style.display = "none";
37531
+ }
37532
+ }
37533
+ return;
37534
+ }
37535
+ for (const _name in __rule) {
37536
+ for (const { $element } of __rule[_name].rules) {
37537
+ $element.style.display = _name === name ? "block" : "none";
37538
+ }
37539
+ }
37540
+ const [visibleOrigin] = __rule[name].origins.slice().filter((point) => point.observers.indexOf(panoIndex) >= 0).sort((pointA, pointB) => {
37541
+ const angleA = pointA.clone().setY(0).sub(cameraPosition).normalize().angleTo(cameraDirection.clone().setY(0));
37542
+ const angleB = pointB.clone().setY(0).sub(cameraPosition).normalize().angleTo(cameraDirection.clone().setY(0));
37543
+ return angleA - angleB;
37544
+ });
37545
+ for (const { rule, vertical, $element } of __rule[name].rules) {
37546
+ const [start, end] = rule;
37547
+ const $line = $element.querySelector(".PanoRulerPlugin-rule-line");
37548
+ if (!$line)
37549
+ return;
37550
+ if (!visibleOrigin) {
37551
+ $element.style.display = "none";
37552
+ continue;
37553
+ }
37554
+ if (start !== visibleOrigin && end !== visibleOrigin) {
37555
+ $element.style.display = "none";
37556
+ continue;
37557
+ }
37558
+ if (start.distanceTo(end) < 0.5) {
37559
+ $element.style.display = "none";
37560
+ continue;
37561
+ }
37562
+ if (start.observers.indexOf(panoIndex) === -1 || end.observers.indexOf(panoIndex) === -1) {
37563
+ $element.style.display = "none";
37564
+ continue;
37565
+ }
37566
+ const startAngle = start.clone().sub(cameraPosition).normalize().angleTo(cameraDirection);
37567
+ if (startAngle > Math.PI / 2) {
37568
+ $element.style.display = "none";
37569
+ continue;
37570
+ }
37571
+ const endAngle = end.clone().sub(cameraPosition).normalize().angleTo(cameraDirection);
37572
+ if (endAngle > Math.PI / 2) {
37573
+ $element.style.display = "none";
37574
+ continue;
37575
+ }
37576
+ const ruleLength = start.distanceTo(end);
37577
+ const midPoint = end.clone().sub(end.clone().sub(start).divide(new Vector3$1(2, 2, 2)));
37578
+ const disFromCameraToMid = midPoint.distanceTo(cameraPosition);
37579
+ if (disFromCameraToMid / ruleLength > 8) {
37580
+ $element.style.display = "none";
37581
+ continue;
37582
+ }
37583
+ const mouseStart = start.clone().project(camera);
37584
+ const startLeft = (mouseStart.x + 1) / 2 * width;
37585
+ const startTop = (-mouseStart.y + 1) / 2 * height;
37586
+ const mouseEnd = end.clone().project(camera);
37587
+ const endLeft = (mouseEnd.x + 1) / 2 * width;
37588
+ const endTop = (-mouseEnd.y + 1) / 2 * height;
37589
+ const distance = Math.sqrt(Math.pow(endLeft - startLeft, 2) + Math.pow(endTop - startTop, 2));
37590
+ let visibleLength = distance;
37591
+ let labelOffset = 50;
37592
+ const intr = getRuleScreenIntr({ x: ~~startLeft, y: ~~startTop }, {
37593
+ x: ~~endLeft,
37594
+ y: ~~endTop
37595
+ }, width, height);
37596
+ if (intr && intr.length === 1) {
37597
+ if (visibleOrigin === start) {
37598
+ visibleLength = Math.sqrt(Math.pow(intr[0].x - startLeft, 2) + Math.pow(intr[0].y - startTop, 2));
37599
+ labelOffset = visibleLength / distance * 50;
37600
+ } else if (visibleOrigin === end) {
37601
+ visibleLength = Math.sqrt(Math.pow(intr[0].x - endLeft, 2) + Math.pow(intr[0].y - endTop, 2));
37602
+ labelOffset = 100 - visibleLength / distance * 50;
37603
+ }
37604
+ }
37605
+ if (intr && intr.length === 2) {
37606
+ const middlePoint = {
37607
+ x: (intr[0].x + intr[1].x) / 2,
37608
+ y: (intr[0].y + intr[1].y) / 2
37609
+ };
37610
+ const distanceFromStart = Math.sqrt(Math.pow(middlePoint.x - startLeft, 2) + Math.pow(middlePoint.y - startTop, 2));
37611
+ labelOffset = distanceFromStart / distance * 100;
37612
+ }
37613
+ const rad = Math.PI / 2 - Math.atan2(endLeft - startLeft, startTop - endTop);
37614
+ const deg = rad / Math.PI * 180;
37615
+ const $label = $line.querySelector(".PanoRulerPlugin-rule-label");
37616
+ const labelWidth = $label.children[0].clientWidth;
37617
+ if (labelWidth >= distance || labelWidth / 2 >= labelOffset / 100 * distance || labelWidth / 2 >= (1 - labelOffset / 100) * distance) {
37618
+ $line.style.display = "none";
37619
+ } else {
37620
+ $line.style.width = distance + "px";
37621
+ $line.style.left = startLeft + "px";
37622
+ $line.style.top = startTop + "px";
37623
+ $line.style.transform = `rotate(${-deg}deg)`;
37624
+ $label.style.left = `${labelOffset}%`;
37625
+ }
37626
+ }
37627
+ };
37628
+ const nextFrameFreshRule = () => nextFrame(freshRule);
37629
+ const throttleFreshRule = throttle(freshRule, 80);
37630
+ const enable = () => {
37631
+ var _a, _b;
37632
+ if (!state.loaded)
37633
+ return false;
37634
+ if (state.enable)
37635
+ return true;
37636
+ $rule.setAttribute("class", "PanoRulerPlugin" + (state.options.className ? " " + state.options.className : ""));
37637
+ (_b = (_a = five.getElement()) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.append($rule);
37638
+ freshRule();
37639
+ five.on("panoArrived", freshRule);
37640
+ five.on("modeChange", freshRule);
37641
+ five.on("cameraDirectionUpdate", nextFrameFreshRule);
37642
+ five.on("movingToPano", nextFrameFreshRule);
37643
+ five.on("mouseWheel", throttleFreshRule);
37644
+ five.on("pinchGesture", throttleFreshRule);
37645
+ state.enable = true;
37646
+ return true;
37647
+ };
37648
+ const disable = () => {
37649
+ if (!state.enable)
37650
+ return true;
37651
+ five.off("panoArrived", freshRule);
37652
+ five.off("modeChange", freshRule);
37653
+ five.off("cameraDirectionUpdate", nextFrameFreshRule);
37654
+ five.off("movingToPano", nextFrameFreshRule);
37655
+ five.off("mouseWheel", throttleFreshRule);
37656
+ five.off("pinchGesture", throttleFreshRule);
37657
+ if ($rule) {
37658
+ $rule.remove();
37659
+ }
37660
+ state.enable = false;
37661
+ return true;
37662
+ };
37663
+ return {
37664
+ enable,
37665
+ disable,
37666
+ load,
37667
+ state
37668
+ };
37669
+ };
37670
+ const textureLoader = new THREE.TextureLoader();
37671
+ async function loadTexture(url) {
37672
+ return new Promise((resolve, reject) => {
37673
+ textureLoader.load(url, resolve, void 0, reject);
37674
+ }).then((texture) => {
37675
+ texture.encoding = THREE.sRGBEncoding;
37676
+ return texture;
37677
+ });
37678
+ }
37679
+ class BetterTween extends exports.Tween {
37680
+ constructor() {
37681
+ super(...arguments);
37682
+ __publicField(this, "disposeMethods", []);
37683
+ __publicField(this, "animationFrameDisposer");
37684
+ __publicField(this, "onDispose", (callback) => {
37685
+ this.disposeMethods.push(callback);
37686
+ return this;
37687
+ });
37688
+ __publicField(this, "play", () => {
37689
+ this.start(0);
37690
+ this.animationFrameDisposer = requestAnimationFrameInterval((time) => this.update(time));
37691
+ return this;
37692
+ });
37693
+ __publicField(this, "dispose", () => {
37694
+ var _a;
37695
+ this.stop();
37696
+ (_a = this.animationFrameDisposer) == null ? void 0 : _a.call(this);
37697
+ this.disposeMethods.forEach((fn) => fn());
37698
+ this.disposeMethods = [];
37699
+ exports.remove(this);
37700
+ });
37701
+ }
37702
+ }
37703
+ function tweenProgress(duration, easing = exports.Easing.Linear.None) {
37704
+ const tween2 = new BetterTween({ progress: 0 }).to({ progress: 1 });
37705
+ if (duration !== void 0)
37706
+ tween2.duration(duration);
37707
+ if (easing !== void 0)
37708
+ tween2.easing(easing);
37709
+ return tween2;
37710
+ }
37711
+ const PanoCompassPlugin = function(five, config) {
37712
+ return new PanoCompassController(five, config);
37713
+ };
37714
+ class PanoCompassController {
37715
+ constructor(five, config) {
37716
+ __publicField(this, "five");
37717
+ __publicField(this, "data");
37718
+ __publicField(this, "config");
37719
+ __publicField(this, "compassMeshTween");
37720
+ __publicField(this, "compassMesh");
37721
+ __publicField(this, "dispose", () => {
37722
+ this.five.off("panoArrived", this.onFivePanoArrived);
37723
+ this.five.off("panoWillArrive", this.onFivePanoWillArrive);
37724
+ this.five.off();
37725
+ });
37726
+ __publicField(this, "loadCompassMesh", async () => {
37727
+ var _a;
37728
+ const compassImageUrl = ((_a = this.config) == null ? void 0 : _a.compassImageUrl) || "//vrlab-image4.ljcdn.com/release/web/v3/north-point-circle.96498e69.png";
37729
+ const texture = await loadTexture(compassImageUrl);
37730
+ const compassGeometry = new THREE.CircleGeometry(0.7, 32);
37731
+ const compassMaterial = new THREE.MeshBasicMaterial({
37732
+ map: texture,
37733
+ transparent: true,
37734
+ opacity: 1,
37735
+ depthTest: false
37736
+ });
37737
+ const compassMesh = new THREE.Mesh(compassGeometry, compassMaterial);
37738
+ compassMesh.rotateX(-Math.PI / 2);
37739
+ compassMesh.name = "pano-compass-mesh";
37740
+ this.compassMesh = compassMesh;
37741
+ this.fixPosition(this.five.panoIndex || 0);
37742
+ if (!this.data)
37743
+ return;
37744
+ this.fixRotation(this.data.north_rad);
37745
+ this.five.scene.add(compassMesh);
37746
+ });
37747
+ __publicField(this, "onFivePanoWillArrive", (panoIndex) => {
37748
+ var _a, _b;
37749
+ if (panoIndex === this.five.panoIndex)
37750
+ return;
37751
+ (_a = this.compassMeshTween) == null ? void 0 : _a.dispose();
37752
+ (_b = this.compassMesh) == null ? void 0 : _b.material.setValues({ opacity: 0 });
37753
+ });
37754
+ __publicField(this, "onFivePanoArrived", (panoIndex) => {
37755
+ var _a, _b;
37756
+ if (((_a = this.compassMesh) == null ? void 0 : _a.material.opacity) !== 0)
37757
+ return;
37758
+ this.fixPosition(panoIndex);
37759
+ (_b = this.compassMeshTween) == null ? void 0 : _b.dispose();
37760
+ this.compassMeshTween = tweenProgress(1e3).onUpdate(({ progress }) => {
37761
+ var _a2;
37762
+ (_a2 = this.compassMesh) == null ? void 0 : _a2.material.setValues({ opacity: progress });
37763
+ this.five.needsRender = true;
37764
+ }).play();
37765
+ });
37766
+ this.five = five;
37767
+ this.config = config;
37768
+ five.once("panoLoaded", this.loadCompassMesh);
37769
+ five.once("dispose", this.dispose);
37770
+ this.five.on("panoArrived", this.onFivePanoArrived);
37771
+ this.five.on("panoWillArrive", this.onFivePanoWillArrive);
37772
+ }
37773
+ load(data) {
37774
+ this.data = data;
37775
+ if (this.compassMesh && !this.five.scene.children.includes(this.compassMesh)) {
37776
+ this.fixRotation(data.north_rad);
37777
+ this.fixPosition(this.five.panoIndex || 0);
37778
+ this.five.scene.add(this.compassMesh);
37779
+ }
37780
+ }
37781
+ fixPosition(panoIndex) {
37782
+ if (!this.compassMesh)
37783
+ return;
37784
+ const standingPosition = this.five.work.observers[panoIndex].standingPosition;
37785
+ const compassPosition = standingPosition.clone().add(new THREE.Vector3(0, 0.01, 0));
37786
+ this.compassMesh.position.copy(compassPosition);
37787
+ this.five.needsRender = true;
37788
+ }
37789
+ fixRotation(northRad) {
37790
+ if (!this.compassMesh)
37791
+ return;
37792
+ this.compassMesh.rotateZ(northRad - Math.PI / 2);
37793
+ this.five.needsRender = true;
37794
+ }
37795
+ }
37796
+ export { CSS3DRenderPlugin, CameraMovementPlugin, ModelChassisCompassPlugin, ModelEntryDoorGuidePlugin, ModelFloorplanPlugin, ModelRoomLabelPlugin, ModelViewPlugin, PanoCompassPlugin, PanoCursorRaycasterPlugin, PanoFloorplanRadarPlugin, PanoRulerPlugin, TopviewFloorplanPlugin };