@vitessce/neuroglancer 3.6.18 → 3.7.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.
@@ -1,5 +1,5 @@
1
1
  import * as React$1 from "react";
2
- import React__default, { useContext, forwardRef, useRef, useMemo, createContext, createElement, PureComponent, Suspense, useCallback } from "react";
2
+ import React__default, { useContext, forwardRef, useRef, useMemo, createContext, createElement, PureComponent, Suspense, useCallback, useState, useEffect } from "react";
3
3
  import { useLoaders, useCoordinationScopes, useCoordination, useObsSetsData, useObsEmbeddingData, TitleInfo } from "@vitessce/vit-s";
4
4
  import * as ReactDOM from "react-dom";
5
5
  const ViewType$1 = {
@@ -617,6 +617,7 @@ const COMPONENT_COORDINATION_TYPES = {
617
617
  CoordinationType$1.SPATIAL_ROTATION_Y,
618
618
  CoordinationType$1.SPATIAL_ROTATION_Z,
619
619
  CoordinationType$1.SPATIAL_AXIS_FIXED,
620
+ CoordinationType$1.SPATIAL_ROTATION_ORBIT,
620
621
  CoordinationType$1.SPATIAL_ORBIT_AXIS,
621
622
  CoordinationType$1.SPATIAL_ZOOM,
622
623
  CoordinationType$1.OBS_FILTER,
@@ -624,14 +625,11 @@ const COMPONENT_COORDINATION_TYPES = {
624
625
  CoordinationType$1.OBS_SET_SELECTION,
625
626
  CoordinationType$1.OBS_SET_FILTER,
626
627
  CoordinationType$1.OBS_SET_HIGHLIGHT,
627
- CoordinationType$1.OBS_SET_COLOR,
628
628
  CoordinationType$1.OBS_TYPE,
629
- CoordinationType$1.ADDITIONAL_OBS_SETS,
630
629
  CoordinationType$1.OBS_SET_COLOR,
631
630
  CoordinationType$1.OBS_COLOR_ENCODING,
632
- CoordinationType$1.OBS_SET_SELECTION,
633
631
  CoordinationType$1.EMBEDDING_TYPE,
634
- CoordinationType$1.OBS_COLOR_ENCODING,
632
+ CoordinationType$1.ADDITIONAL_OBS_SETS,
635
633
  CoordinationType$1.TOOLTIPS_VISIBLE
636
634
  ],
637
635
  [ViewType$1.SCATTERPLOT]: [
@@ -1325,39 +1323,11 @@ function baseGetTag(value) {
1325
1323
  function isObjectLike(value) {
1326
1324
  return value != null && typeof value == "object";
1327
1325
  }
1328
- var symbolTag$3 = "[object Symbol]";
1329
- function isSymbol(value) {
1330
- return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$3;
1331
- }
1332
- function arrayMap(array, iteratee) {
1333
- var index = -1, length2 = array == null ? 0 : array.length, result = Array(length2);
1334
- while (++index < length2) {
1335
- result[index] = iteratee(array[index], index, array);
1336
- }
1337
- return result;
1338
- }
1339
1326
  var isArray = Array.isArray;
1340
- var symbolProto$2 = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto$2 ? symbolProto$2.toString : void 0;
1341
- function baseToString(value) {
1342
- if (typeof value == "string") {
1343
- return value;
1344
- }
1345
- if (isArray(value)) {
1346
- return arrayMap(value, baseToString) + "";
1347
- }
1348
- if (isSymbol(value)) {
1349
- return symbolToString ? symbolToString.call(value) : "";
1350
- }
1351
- var result = value + "";
1352
- return result == "0" && 1 / value == -Infinity ? "-0" : result;
1353
- }
1354
1327
  function isObject(value) {
1355
1328
  var type = typeof value;
1356
1329
  return value != null && (type == "object" || type == "function");
1357
1330
  }
1358
- function identity(value) {
1359
- return value;
1360
- }
1361
1331
  var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
1362
1332
  function isFunction$1(value) {
1363
1333
  if (!isObject(value)) {
@@ -1429,41 +1399,6 @@ var baseCreate = /* @__PURE__ */ function() {
1429
1399
  return result;
1430
1400
  };
1431
1401
  }();
1432
- function apply(func, thisArg, args) {
1433
- switch (args.length) {
1434
- case 0:
1435
- return func.call(thisArg);
1436
- case 1:
1437
- return func.call(thisArg, args[0]);
1438
- case 2:
1439
- return func.call(thisArg, args[0], args[1]);
1440
- case 3:
1441
- return func.call(thisArg, args[0], args[1], args[2]);
1442
- }
1443
- return func.apply(thisArg, args);
1444
- }
1445
- var HOT_COUNT = 800, HOT_SPAN = 16;
1446
- var nativeNow = Date.now;
1447
- function shortOut(func) {
1448
- var count = 0, lastCalled = 0;
1449
- return function() {
1450
- var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
1451
- lastCalled = stamp;
1452
- if (remaining > 0) {
1453
- if (++count >= HOT_COUNT) {
1454
- return arguments[0];
1455
- }
1456
- } else {
1457
- count = 0;
1458
- }
1459
- return func.apply(void 0, arguments);
1460
- };
1461
- }
1462
- function constant(value) {
1463
- return function() {
1464
- return value;
1465
- };
1466
- }
1467
1402
  var defineProperty$1 = function() {
1468
1403
  try {
1469
1404
  var func = getNative(Object, "defineProperty");
@@ -1472,15 +1407,6 @@ var defineProperty$1 = function() {
1472
1407
  } catch (e) {
1473
1408
  }
1474
1409
  }();
1475
- var baseSetToString = !defineProperty$1 ? identity : function(func, string) {
1476
- return defineProperty$1(func, "toString", {
1477
- "configurable": true,
1478
- "enumerable": false,
1479
- "value": constant(string),
1480
- "writable": true
1481
- });
1482
- };
1483
- var setToString = shortOut(baseSetToString);
1484
1410
  function arrayEach(array, iteratee) {
1485
1411
  var index = -1, length2 = array == null ? 0 : array.length;
1486
1412
  while (++index < length2) {
@@ -1520,23 +1446,6 @@ function assignValue(object, key, value) {
1520
1446
  baseAssignValue(object, key, value);
1521
1447
  }
1522
1448
  }
1523
- var nativeMax = Math.max;
1524
- function overRest(func, start, transform) {
1525
- start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
1526
- return function() {
1527
- var args = arguments, index = -1, length2 = nativeMax(args.length - start, 0), array = Array(length2);
1528
- while (++index < length2) {
1529
- array[index] = args[start + index];
1530
- }
1531
- index = -1;
1532
- var otherArgs = Array(start + 1);
1533
- while (++index < start) {
1534
- otherArgs[index] = args[index];
1535
- }
1536
- otherArgs[start] = transform(array);
1537
- return apply(func, this, otherArgs);
1538
- };
1539
- }
1540
1449
  var MAX_SAFE_INTEGER = 9007199254740991;
1541
1450
  function isLength(value) {
1542
1451
  return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
@@ -1644,17 +1553,6 @@ function baseKeys(object) {
1644
1553
  function keys(object) {
1645
1554
  return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1646
1555
  }
1647
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
1648
- function isKey(value, object) {
1649
- if (isArray(value)) {
1650
- return false;
1651
- }
1652
- var type = typeof value;
1653
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
1654
- return true;
1655
- }
1656
- return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
1657
- }
1658
1556
  var nativeCreate = getNative(Object, "create");
1659
1557
  function hashClear() {
1660
1558
  this.__data__ = nativeCreate ? nativeCreate(null) : {};
@@ -1808,71 +1706,6 @@ MapCache.prototype["delete"] = mapCacheDelete;
1808
1706
  MapCache.prototype.get = mapCacheGet;
1809
1707
  MapCache.prototype.has = mapCacheHas;
1810
1708
  MapCache.prototype.set = mapCacheSet;
1811
- var FUNC_ERROR_TEXT = "Expected a function";
1812
- function memoize$2(func, resolver) {
1813
- if (typeof func != "function" || resolver != null && typeof resolver != "function") {
1814
- throw new TypeError(FUNC_ERROR_TEXT);
1815
- }
1816
- var memoized = function() {
1817
- var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
1818
- if (cache.has(key)) {
1819
- return cache.get(key);
1820
- }
1821
- var result = func.apply(this, args);
1822
- memoized.cache = cache.set(key, result) || cache;
1823
- return result;
1824
- };
1825
- memoized.cache = new (memoize$2.Cache || MapCache)();
1826
- return memoized;
1827
- }
1828
- memoize$2.Cache = MapCache;
1829
- var MAX_MEMOIZE_SIZE = 500;
1830
- function memoizeCapped(func) {
1831
- var result = memoize$2(func, function(key) {
1832
- if (cache.size === MAX_MEMOIZE_SIZE) {
1833
- cache.clear();
1834
- }
1835
- return key;
1836
- });
1837
- var cache = result.cache;
1838
- return result;
1839
- }
1840
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1841
- var reEscapeChar = /\\(\\)?/g;
1842
- var stringToPath = memoizeCapped(function(string) {
1843
- var result = [];
1844
- if (string.charCodeAt(0) === 46) {
1845
- result.push("");
1846
- }
1847
- string.replace(rePropName, function(match2, number, quote, subString) {
1848
- result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match2);
1849
- });
1850
- return result;
1851
- });
1852
- function toString(value) {
1853
- return value == null ? "" : baseToString(value);
1854
- }
1855
- function castPath(value, object) {
1856
- if (isArray(value)) {
1857
- return value;
1858
- }
1859
- return isKey(value, object) ? [value] : stringToPath(toString(value));
1860
- }
1861
- function toKey(value) {
1862
- if (typeof value == "string" || isSymbol(value)) {
1863
- return value;
1864
- }
1865
- var result = value + "";
1866
- return result == "0" && 1 / value == -Infinity ? "-0" : result;
1867
- }
1868
- function baseGet(object, path) {
1869
- path = castPath(path, object);
1870
- var index = 0, length2 = path.length;
1871
- while (object != null && index < length2) {
1872
- object = object[toKey(path[index++])];
1873
- }
1874
- return index && index == length2 ? object : void 0;
1875
- }
1876
1709
  function arrayPush(array, values2) {
1877
1710
  var index = -1, length2 = values2.length, offset2 = array.length;
1878
1711
  while (++index < length2) {
@@ -1880,33 +1713,6 @@ function arrayPush(array, values2) {
1880
1713
  }
1881
1714
  return array;
1882
1715
  }
1883
- var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : void 0;
1884
- function isFlattenable(value) {
1885
- return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
1886
- }
1887
- function baseFlatten(array, depth, predicate, isStrict, result) {
1888
- var index = -1, length2 = array.length;
1889
- predicate || (predicate = isFlattenable);
1890
- result || (result = []);
1891
- while (++index < length2) {
1892
- var value = array[index];
1893
- if (predicate(value)) {
1894
- {
1895
- arrayPush(result, value);
1896
- }
1897
- } else {
1898
- result[result.length] = value;
1899
- }
1900
- }
1901
- return result;
1902
- }
1903
- function flatten(array) {
1904
- var length2 = array == null ? 0 : array.length;
1905
- return length2 ? baseFlatten(array) : [];
1906
- }
1907
- function flatRest(func) {
1908
- return setToString(overRest(func, void 0, flatten), func + "");
1909
- }
1910
1716
  var getPrototype = overArg(Object.getPrototypeOf, Object);
1911
1717
  function stackClear() {
1912
1718
  this.__data__ = new ListCache();
@@ -1990,14 +1796,14 @@ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1990
1796
  function getAllKeys(object) {
1991
1797
  return baseGetAllKeys(object, keys, getSymbols);
1992
1798
  }
1993
- var DataView = getNative(root, "DataView");
1799
+ var DataView$1 = getNative(root, "DataView");
1994
1800
  var Promise$1 = getNative(root, "Promise");
1995
1801
  var Set$1 = getNative(root, "Set");
1996
1802
  var mapTag$4 = "[object Map]", objectTag$2 = "[object Object]", promiseTag = "[object Promise]", setTag$4 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
1997
1803
  var dataViewTag$3 = "[object DataView]";
1998
- var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
1804
+ var dataViewCtorString = toSource(DataView$1), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
1999
1805
  var getTag = baseGetTag;
2000
- if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$3 || Map$1 && getTag(new Map$1()) != mapTag$4 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$4 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag$1) {
1806
+ if (DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$3 || Map$1 && getTag(new Map$1()) != mapTag$4 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$4 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag$1) {
2001
1807
  getTag = function(value) {
2002
1808
  var result = baseGetTag(value), Ctor = result == objectTag$2 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
2003
1809
  if (ctorString) {
@@ -2106,7 +1912,7 @@ var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView
2106
1912
  var cloneableTags = {};
2107
1913
  cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag$1] = cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
2108
1914
  cloneableTags[errorTag$1] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
2109
- function baseClone(value, bitmask, customizer2, key, object, stack) {
1915
+ function baseClone(value, bitmask, customizer, key, object, stack) {
2110
1916
  var result;
2111
1917
  if (result !== void 0) {
2112
1918
  return result;
@@ -2139,11 +1945,11 @@ function baseClone(value, bitmask, customizer2, key, object, stack) {
2139
1945
  stack.set(value, result);
2140
1946
  if (isSet(value)) {
2141
1947
  value.forEach(function(subValue) {
2142
- result.add(baseClone(subValue, bitmask, customizer2, subValue, value, stack));
1948
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2143
1949
  });
2144
1950
  } else if (isMap(value)) {
2145
1951
  value.forEach(function(subValue, key2) {
2146
- result.set(key2, baseClone(subValue, bitmask, customizer2, key2, value, stack));
1952
+ result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
2147
1953
  });
2148
1954
  }
2149
1955
  var keysFunc = getAllKeys;
@@ -2153,7 +1959,7 @@ function baseClone(value, bitmask, customizer2, key, object, stack) {
2153
1959
  key2 = subValue;
2154
1960
  subValue = value[key2];
2155
1961
  }
2156
- assignValue(result, key2, baseClone(subValue, bitmask, customizer2, key2, value, stack));
1962
+ assignValue(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
2157
1963
  });
2158
1964
  return result;
2159
1965
  }
@@ -2191,7 +1997,7 @@ function cacheHas(cache, key) {
2191
1997
  return cache.has(key);
2192
1998
  }
2193
1999
  var COMPARE_PARTIAL_FLAG$3 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
2194
- function equalArrays(array, other, bitmask, customizer2, equalFunc, stack) {
2000
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
2195
2001
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, arrLength = array.length, othLength = other.length;
2196
2002
  if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
2197
2003
  return false;
@@ -2206,8 +2012,8 @@ function equalArrays(array, other, bitmask, customizer2, equalFunc, stack) {
2206
2012
  stack.set(other, array);
2207
2013
  while (++index < arrLength) {
2208
2014
  var arrValue = array[index], othValue = other[index];
2209
- if (customizer2) {
2210
- var compared = isPartial ? customizer2(othValue, arrValue, index, other, array, stack) : customizer2(arrValue, othValue, index, array, other, stack);
2015
+ if (customizer) {
2016
+ var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
2211
2017
  }
2212
2018
  if (compared !== void 0) {
2213
2019
  if (compared) {
@@ -2218,14 +2024,14 @@ function equalArrays(array, other, bitmask, customizer2, equalFunc, stack) {
2218
2024
  }
2219
2025
  if (seen) {
2220
2026
  if (!arraySome(other, function(othValue2, othIndex) {
2221
- if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer2, stack))) {
2027
+ if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
2222
2028
  return seen.push(othIndex);
2223
2029
  }
2224
2030
  })) {
2225
2031
  result = false;
2226
2032
  break;
2227
2033
  }
2228
- } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer2, stack))) {
2034
+ } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
2229
2035
  result = false;
2230
2036
  break;
2231
2037
  }
@@ -2252,7 +2058,7 @@ var COMPARE_PARTIAL_FLAG$2 = 1, COMPARE_UNORDERED_FLAG = 2;
2252
2058
  var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
2253
2059
  var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]";
2254
2060
  var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2255
- function equalByTag(object, other, tag, bitmask, customizer2, equalFunc, stack) {
2061
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
2256
2062
  switch (tag) {
2257
2063
  case dataViewTag:
2258
2064
  if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
@@ -2288,7 +2094,7 @@ function equalByTag(object, other, tag, bitmask, customizer2, equalFunc, stack)
2288
2094
  }
2289
2095
  bitmask |= COMPARE_UNORDERED_FLAG;
2290
2096
  stack.set(object, other);
2291
- var result = equalArrays(convert(object), convert(other), bitmask, customizer2, equalFunc, stack);
2097
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
2292
2098
  stack["delete"](object);
2293
2099
  return result;
2294
2100
  case symbolTag:
@@ -2301,7 +2107,7 @@ function equalByTag(object, other, tag, bitmask, customizer2, equalFunc, stack)
2301
2107
  var COMPARE_PARTIAL_FLAG$1 = 1;
2302
2108
  var objectProto$1 = Object.prototype;
2303
2109
  var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2304
- function equalObjects(object, other, bitmask, customizer2, equalFunc, stack) {
2110
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2305
2111
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
2306
2112
  if (objLength != othLength && !isPartial) {
2307
2113
  return false;
@@ -2325,10 +2131,10 @@ function equalObjects(object, other, bitmask, customizer2, equalFunc, stack) {
2325
2131
  while (++index < objLength) {
2326
2132
  key = objProps[index];
2327
2133
  var objValue = object[key], othValue = other[key];
2328
- if (customizer2) {
2329
- var compared = isPartial ? customizer2(othValue, objValue, key, other, object, stack) : customizer2(objValue, othValue, key, object, other, stack);
2134
+ if (customizer) {
2135
+ var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
2330
2136
  }
2331
- if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer2, stack) : compared)) {
2137
+ if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
2332
2138
  result = false;
2333
2139
  break;
2334
2140
  }
@@ -2348,7 +2154,7 @@ var COMPARE_PARTIAL_FLAG = 1;
2348
2154
  var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
2349
2155
  var objectProto = Object.prototype;
2350
2156
  var hasOwnProperty = objectProto.hasOwnProperty;
2351
- function baseIsEqualDeep(object, other, bitmask, customizer2, equalFunc, stack) {
2157
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2352
2158
  var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
2353
2159
  objTag = objTag == argsTag ? objectTag : objTag;
2354
2160
  othTag = othTag == argsTag ? objectTag : othTag;
@@ -2362,105 +2168,37 @@ function baseIsEqualDeep(object, other, bitmask, customizer2, equalFunc, stack)
2362
2168
  }
2363
2169
  if (isSameTag && !objIsObj) {
2364
2170
  stack || (stack = new Stack());
2365
- return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer2, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer2, equalFunc, stack);
2171
+ return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
2366
2172
  }
2367
2173
  if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
2368
2174
  var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
2369
2175
  if (objIsWrapped || othIsWrapped) {
2370
2176
  var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
2371
2177
  stack || (stack = new Stack());
2372
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer2, stack);
2178
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
2373
2179
  }
2374
2180
  }
2375
2181
  if (!isSameTag) {
2376
2182
  return false;
2377
2183
  }
2378
2184
  stack || (stack = new Stack());
2379
- return equalObjects(object, other, bitmask, customizer2, equalFunc, stack);
2185
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
2380
2186
  }
2381
- function baseIsEqual(value, other, bitmask, customizer2, stack) {
2187
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
2382
2188
  if (value === other) {
2383
2189
  return true;
2384
2190
  }
2385
2191
  if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
2386
2192
  return value !== value && other !== other;
2387
2193
  }
2388
- return baseIsEqualDeep(value, other, bitmask, customizer2, baseIsEqual, stack);
2389
- }
2390
- function baseHasIn(object, key) {
2391
- return object != null && key in Object(object);
2392
- }
2393
- function hasPath(object, path, hasFunc) {
2394
- path = castPath(path, object);
2395
- var index = -1, length2 = path.length, result = false;
2396
- while (++index < length2) {
2397
- var key = toKey(path[index]);
2398
- if (!(result = object != null && hasFunc(object, key))) {
2399
- break;
2400
- }
2401
- object = object[key];
2402
- }
2403
- if (result || ++index != length2) {
2404
- return result;
2405
- }
2406
- length2 = object == null ? 0 : object.length;
2407
- return !!length2 && isLength(length2) && isIndex(key, length2) && (isArray(object) || isArguments(object));
2408
- }
2409
- function hasIn(object, path) {
2410
- return object != null && hasPath(object, path, baseHasIn);
2194
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
2411
2195
  }
2412
2196
  function isEqual(value, other) {
2413
2197
  return baseIsEqual(value, other);
2414
2198
  }
2415
- function isEqualWith(value, other, customizer2) {
2416
- customizer2 = typeof customizer2 == "function" ? customizer2 : void 0;
2417
- var result = customizer2 ? customizer2(value, other) : void 0;
2418
- return result === void 0 ? baseIsEqual(value, other, void 0, customizer2) : !!result;
2419
- }
2420
2199
  function isNil(value) {
2421
2200
  return value == null;
2422
2201
  }
2423
- function baseSet(object, path, value, customizer2) {
2424
- if (!isObject(object)) {
2425
- return object;
2426
- }
2427
- path = castPath(path, object);
2428
- var index = -1, length2 = path.length, lastIndex = length2 - 1, nested2 = object;
2429
- while (nested2 != null && ++index < length2) {
2430
- var key = toKey(path[index]), newValue = value;
2431
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
2432
- return object;
2433
- }
2434
- if (index != lastIndex) {
2435
- var objValue = nested2[key];
2436
- newValue = void 0;
2437
- if (newValue === void 0) {
2438
- newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
2439
- }
2440
- }
2441
- assignValue(nested2, key, newValue);
2442
- nested2 = nested2[key];
2443
- }
2444
- return object;
2445
- }
2446
- function basePickBy(object, paths, predicate) {
2447
- var index = -1, length2 = paths.length, result = {};
2448
- while (++index < length2) {
2449
- var path = paths[index], value = baseGet(object, path);
2450
- if (predicate(value, path)) {
2451
- baseSet(result, castPath(path, object), value);
2452
- }
2453
- }
2454
- return result;
2455
- }
2456
- function basePick(object, paths) {
2457
- return basePickBy(object, paths, function(value, path) {
2458
- return hasIn(object, path);
2459
- });
2460
- }
2461
- var pick = flatRest(function(object, paths) {
2462
- return object == null ? {} : basePick(object, paths);
2463
- });
2464
2202
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2465
2203
  function getDefaultExportFromCjs(x) {
2466
2204
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -3844,7 +3582,7 @@ var util;
3844
3582
  function assertIs(_arg) {
3845
3583
  }
3846
3584
  util2.assertIs = assertIs;
3847
- function assertNever(_x) {
3585
+ function assertNever(_x2) {
3848
3586
  throw new Error();
3849
3587
  }
3850
3588
  util2.assertNever = assertNever;
@@ -10958,7 +10696,7 @@ function requireTinycolor() {
10958
10696
  return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
10959
10697
  },
10960
10698
  toHex: function(allow3Char) {
10961
- return rgbToHex(this._r, this._g, this._b, allow3Char);
10699
+ return rgbToHex2(this._r, this._g, this._b, allow3Char);
10962
10700
  },
10963
10701
  toHexString: function(allow3Char) {
10964
10702
  return "#" + this.toHex(allow3Char);
@@ -10988,7 +10726,7 @@ function requireTinycolor() {
10988
10726
  if (this._a < 1) {
10989
10727
  return false;
10990
10728
  }
10991
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
10729
+ return hexNames[rgbToHex2(this._r, this._g, this._b, true)] || false;
10992
10730
  },
10993
10731
  toFilter: function(secondColor) {
10994
10732
  var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
@@ -11244,7 +10982,7 @@ function requireTinycolor() {
11244
10982
  var i = Math2.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod];
11245
10983
  return { r: r * 255, g: g * 255, b: b * 255 };
11246
10984
  }
11247
- function rgbToHex(r, g, b, allow3Char) {
10985
+ function rgbToHex2(r, g, b, allow3Char) {
11248
10986
  var hex = [
11249
10987
  pad2(mathRound(r).toString(16)),
11250
10988
  pad2(mathRound(g).toString(16)),
@@ -12424,9 +12162,9 @@ function requireJson2csv_umd() {
12424
12162
  }
12425
12163
  buffer[offset2 + i - d] |= s * 128;
12426
12164
  }
12427
- var toString2 = {}.toString;
12165
+ var toString = {}.toString;
12428
12166
  var isArray2 = Array.isArray || function(arr) {
12429
- return toString2.call(arr) == "[object Array]";
12167
+ return toString.call(arr) == "[object Array]";
12430
12168
  };
12431
12169
  var INSPECT_MAX_BYTES = 50;
12432
12170
  Buffer2.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== void 0 ? global$1.TYPED_ARRAY_SUPPORT : true;
@@ -12789,7 +12527,7 @@ function requireJson2csv_umd() {
12789
12527
  }
12790
12528
  return this;
12791
12529
  };
12792
- Buffer2.prototype.toString = function toString3() {
12530
+ Buffer2.prototype.toString = function toString2() {
12793
12531
  var length2 = this.length | 0;
12794
12532
  if (length2 === 0) return "";
12795
12533
  if (arguments.length === 0) return utf8Slice(this, 0, length2);
@@ -13874,8 +13612,8 @@ function requireJson2csv_umd() {
13874
13612
  Item.prototype.run = function() {
13875
13613
  this.fun.apply(null, this.array);
13876
13614
  };
13877
- var performance = global$1.performance || {};
13878
- performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
13615
+ var performance2 = global$1.performance || {};
13616
+ performance2.now || performance2.mozNow || performance2.msNow || performance2.oNow || performance2.webkitNow || function() {
13879
13617
  return (/* @__PURE__ */ new Date()).getTime();
13880
13618
  };
13881
13619
  var inherits;
@@ -15684,12 +15422,12 @@ function requireJson2csv_umd() {
15684
15422
  EOL
15685
15423
  };
15686
15424
  var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : {};
15687
- var FUNC_ERROR_TEXT2 = "Expected a function";
15425
+ var FUNC_ERROR_TEXT = "Expected a function";
15688
15426
  var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
15689
15427
  var funcTag2 = "[object Function]", genTag2 = "[object GeneratorFunction]", symbolTag2 = "[object Symbol]";
15690
- var reIsDeepProp2 = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp2 = /^\w*$/, reLeadingDot = /^\./, rePropName2 = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
15428
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
15691
15429
  var reRegExpChar2 = /[\\^$.*+?()[\]{}|]/g;
15692
- var reEscapeChar2 = /\\(\\)?/g;
15430
+ var reEscapeChar = /\\(\\)?/g;
15693
15431
  var reIsHostCtor2 = /^\[object .+?Constructor\]$/;
15694
15432
  var freeGlobal2 = typeof commonjsGlobal$1 == "object" && commonjsGlobal$1 && commonjsGlobal$1.Object === Object && commonjsGlobal$1;
15695
15433
  var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
@@ -15721,7 +15459,7 @@ function requireJson2csv_umd() {
15721
15459
  );
15722
15460
  var Symbol$12 = root2.Symbol, splice2 = arrayProto2.splice;
15723
15461
  var Map2 = getNative2(root2, "Map"), nativeCreate2 = getNative2(Object, "create");
15724
- var symbolProto2 = Symbol$12 ? Symbol$12.prototype : void 0, symbolToString2 = symbolProto2 ? symbolProto2.toString : void 0;
15462
+ var symbolProto2 = Symbol$12 ? Symbol$12.prototype : void 0, symbolToString = symbolProto2 ? symbolProto2.toString : void 0;
15725
15463
  function Hash2(entries) {
15726
15464
  var index = -1, length2 = entries ? entries.length : 0;
15727
15465
  this.clear();
@@ -15845,11 +15583,11 @@ function requireJson2csv_umd() {
15845
15583
  }
15846
15584
  return -1;
15847
15585
  }
15848
- function baseGet2(object, path) {
15849
- path = isKey2(path, object) ? [path] : castPath2(path);
15586
+ function baseGet(object, path) {
15587
+ path = isKey(path, object) ? [path] : castPath(path);
15850
15588
  var index = 0, length2 = path.length;
15851
15589
  while (object != null && index < length2) {
15852
- object = object[toKey2(path[index++])];
15590
+ object = object[toKey(path[index++])];
15853
15591
  }
15854
15592
  return index && index == length2 ? object : void 0;
15855
15593
  }
@@ -15860,18 +15598,18 @@ function requireJson2csv_umd() {
15860
15598
  var pattern = isFunction$12(value) || isHostObject(value) ? reIsNative2 : reIsHostCtor2;
15861
15599
  return pattern.test(toSource2(value));
15862
15600
  }
15863
- function baseToString2(value) {
15601
+ function baseToString(value) {
15864
15602
  if (typeof value == "string") {
15865
15603
  return value;
15866
15604
  }
15867
- if (isSymbol2(value)) {
15868
- return symbolToString2 ? symbolToString2.call(value) : "";
15605
+ if (isSymbol(value)) {
15606
+ return symbolToString ? symbolToString.call(value) : "";
15869
15607
  }
15870
15608
  var result = value + "";
15871
15609
  return result == "0" && 1 / value == -Infinity ? "-0" : result;
15872
15610
  }
15873
- function castPath2(value) {
15874
- return isArray$2(value) ? value : stringToPath2(value);
15611
+ function castPath(value) {
15612
+ return isArray$2(value) ? value : stringToPath(value);
15875
15613
  }
15876
15614
  function getMapData2(map, key) {
15877
15615
  var data = map.__data__;
@@ -15881,15 +15619,15 @@ function requireJson2csv_umd() {
15881
15619
  var value = getValue2(object, key);
15882
15620
  return baseIsNative2(value) ? value : void 0;
15883
15621
  }
15884
- function isKey2(value, object) {
15622
+ function isKey(value, object) {
15885
15623
  if (isArray$2(value)) {
15886
15624
  return false;
15887
15625
  }
15888
15626
  var type = typeof value;
15889
- if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol2(value)) {
15627
+ if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
15890
15628
  return true;
15891
15629
  }
15892
- return reIsPlainProp2.test(value) || !reIsDeepProp2.test(value) || object != null && value in Object(object);
15630
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
15893
15631
  }
15894
15632
  function isKeyable2(value) {
15895
15633
  var type = typeof value;
@@ -15898,19 +15636,19 @@ function requireJson2csv_umd() {
15898
15636
  function isMasked2(func) {
15899
15637
  return !!maskSrcKey2 && maskSrcKey2 in func;
15900
15638
  }
15901
- var stringToPath2 = memoize2(function(string) {
15639
+ var stringToPath = memoize2(function(string) {
15902
15640
  string = toString$1(string);
15903
15641
  var result = [];
15904
15642
  if (reLeadingDot.test(string)) {
15905
15643
  result.push("");
15906
15644
  }
15907
- string.replace(rePropName2, function(match2, number, quote, string2) {
15908
- result.push(quote ? string2.replace(reEscapeChar2, "$1") : number || match2);
15645
+ string.replace(rePropName, function(match2, number, quote, string2) {
15646
+ result.push(quote ? string2.replace(reEscapeChar, "$1") : number || match2);
15909
15647
  });
15910
15648
  return result;
15911
15649
  });
15912
- function toKey2(value) {
15913
- if (typeof value == "string" || isSymbol2(value)) {
15650
+ function toKey(value) {
15651
+ if (typeof value == "string" || isSymbol(value)) {
15914
15652
  return value;
15915
15653
  }
15916
15654
  var result = value + "";
@@ -15931,7 +15669,7 @@ function requireJson2csv_umd() {
15931
15669
  }
15932
15670
  function memoize2(func, resolver) {
15933
15671
  if (typeof func != "function" || resolver && typeof resolver != "function") {
15934
- throw new TypeError(FUNC_ERROR_TEXT2);
15672
+ throw new TypeError(FUNC_ERROR_TEXT);
15935
15673
  }
15936
15674
  var memoized = function() {
15937
15675
  var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
@@ -15961,14 +15699,14 @@ function requireJson2csv_umd() {
15961
15699
  function isObjectLike2(value) {
15962
15700
  return !!value && typeof value == "object";
15963
15701
  }
15964
- function isSymbol2(value) {
15702
+ function isSymbol(value) {
15965
15703
  return typeof value == "symbol" || isObjectLike2(value) && objectToString$1.call(value) == symbolTag2;
15966
15704
  }
15967
15705
  function toString$1(value) {
15968
- return value == null ? "" : baseToString2(value);
15706
+ return value == null ? "" : baseToString(value);
15969
15707
  }
15970
15708
  function get(object, path, defaultValue) {
15971
- var result = object == null ? void 0 : baseGet2(object, path);
15709
+ var result = object == null ? void 0 : baseGet(object, path);
15972
15710
  return result === void 0 ? defaultValue : result;
15973
15711
  }
15974
15712
  var lodash_get = get;
@@ -16992,7 +16730,7 @@ function requireJson2csv_umd() {
16992
16730
  return JSON2CSVAsyncParser2;
16993
16731
  }();
16994
16732
  var JSON2CSVAsyncParser_1 = JSON2CSVAsyncParser;
16995
- function flatten2() {
16733
+ function flatten() {
16996
16734
  var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$objects = _ref.objects, objects = _ref$objects === void 0 ? true : _ref$objects, _ref$arrays = _ref.arrays, arrays = _ref$arrays === void 0 ? false : _ref$arrays, _ref$separator = _ref.separator, separator = _ref$separator === void 0 ? "." : _ref$separator;
16997
16735
  function step(obj, flatDataRow, currentPath) {
16998
16736
  Object.keys(obj).forEach(function(key) {
@@ -17014,7 +16752,7 @@ function requireJson2csv_umd() {
17014
16752
  return step(dataRow, {});
17015
16753
  };
17016
16754
  }
17017
- var flatten_1 = flatten2;
16755
+ var flatten_1 = flatten;
17018
16756
  var setProp$1 = utils.setProp, unsetProp$1 = utils.unsetProp, flattenReducer$3 = utils.flattenReducer;
17019
16757
  function getUnwindablePaths(obj, currentPath) {
17020
16758
  return Object.keys(obj).reduce(function(unwindablePaths, key) {
@@ -19916,7 +19654,7 @@ function requireFactoryWithTypeCheckers() {
19916
19654
  return false;
19917
19655
  }
19918
19656
  }
19919
- function isSymbol2(propType, propValue) {
19657
+ function isSymbol(propType, propValue) {
19920
19658
  if (propType === "symbol") {
19921
19659
  return true;
19922
19660
  }
@@ -19939,7 +19677,7 @@ function requireFactoryWithTypeCheckers() {
19939
19677
  if (propValue instanceof RegExp) {
19940
19678
  return "object";
19941
19679
  }
19942
- if (isSymbol2(propType, propValue)) {
19680
+ if (isSymbol(propType, propValue)) {
19943
19681
  return "symbol";
19944
19682
  }
19945
19683
  return propType;
@@ -22235,7 +21973,7 @@ function generateUtilityClass(componentName, slot, globalStatePrefix = "Mui") {
22235
21973
  return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${ClassNameGenerator.generate(componentName)}-${slot}`;
22236
21974
  }
22237
21975
  const useEnhancedEffect$1 = typeof window !== "undefined" ? React$1.useLayoutEffect : React$1.useEffect;
22238
- function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
21976
+ function clamp$1(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
22239
21977
  return Math.max(min, Math.min(val, max));
22240
21978
  }
22241
21979
  function clampWrapper(value, min = 0, max = 1) {
@@ -22244,7 +21982,7 @@ function clampWrapper(value, min = 0, max = 1) {
22244
21982
  console.error(`MUI: The value provided ${value} is out of range [${min}, ${max}].`);
22245
21983
  }
22246
21984
  }
22247
- return clamp(value, min, max);
21985
+ return clamp$1(value, min, max);
22248
21986
  }
22249
21987
  function hexToRgb(color2) {
22250
21988
  color2 = color2.slice(1);
@@ -23239,8 +22977,8 @@ function getAutoHeightDuration(height2) {
23239
22977
  if (!height2) {
23240
22978
  return 0;
23241
22979
  }
23242
- const constant2 = height2 / 36;
23243
- return Math.min(Math.round((4 + 15 * constant2 ** 0.25 + constant2 / 5) * 10), 3e3);
22980
+ const constant = height2 / 36;
22981
+ return Math.min(Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10), 3e3);
23244
22982
  }
23245
22983
  function createTransitions(inputTransitions) {
23246
22984
  const mergedEasing = {
@@ -25820,6 +25558,7 @@ const globalNeuroglancerCss = `
25820
25558
  .neuroglancer-viewer-top-row,
25821
25559
  .neuroglancer-layer-panel,
25822
25560
  .neuroglancer-side-panel-column,
25561
+ .neuroglancer-display-dimensions-widget,
25823
25562
  .neuroglancer-data-panel-layout-controls button{
25824
25563
  display: none !important;
25825
25564
  }
@@ -27222,7 +26961,8 @@ const globalNeuroglancerStyles = {
27222
26961
  borderColor: "#000",
27223
26962
  borderWidth: "2px"
27224
26963
  },
27225
- ".neuroglancer-panel:focus-within": { borderColor: "#fff" },
26964
+ // Hides the white border around NG view that shows the view is focused
26965
+ // '.neuroglancer-panel:focus-within': { borderColor: '#fff' },
27226
26966
  ".neuroglancer-layer-group-viewer": { outline: "0px" },
27227
26967
  ".neuroglancer-layer-group-viewer-context-menu": {
27228
26968
  flexDirection: "column",
@@ -28428,35 +28168,15 @@ function NeuroglancerGlobalStyles(props) {
28428
28168
  }
28429
28169
  ));
28430
28170
  }
28431
- const LazyReactNeuroglancer = React__default.lazy(() => import("./ReactNeuroglancer-Crquekcy.js"));
28171
+ const LazyReactNeuroglancer = React__default.lazy(() => import("./ReactNeuroglancer-C0i-a6Cw.js"));
28432
28172
  function createWorker() {
28433
28173
  return new WorkerFactory();
28434
28174
  }
28435
- function isValidState(viewerState) {
28436
- const { projectionScale, projectionOrientation, position: position2, dimensions } = viewerState || {};
28437
- return dimensions !== void 0 && typeof projectionScale === "number" && Array.isArray(projectionOrientation) && projectionOrientation.length === 4 && Array.isArray(position2) && position2.length === 3;
28438
- }
28439
- const EPSILON = 1e-7;
28440
- const VIEWSTATE_KEYS = ["projectionScale", "projectionOrientation", "position"];
28441
- function customizer(a, b) {
28442
- if (typeof a === "number" && typeof b === "number") {
28443
- return Math.abs(a - b) > EPSILON;
28444
- }
28445
- return void 0;
28446
- }
28447
- function compareViewerState(prevState, nextState) {
28448
- if (isValidState(nextState)) {
28449
- const prevSubset = pick(prevState, VIEWSTATE_KEYS);
28450
- const nextSubset = pick(nextState, VIEWSTATE_KEYS);
28451
- return isEqualWith(prevSubset, nextSubset, customizer);
28452
- }
28453
- return true;
28454
- }
28455
- class Neuroglancer extends PureComponent {
28175
+ class NeuroglancerComp extends PureComponent {
28456
28176
  constructor(props) {
28457
28177
  super(props);
28458
28178
  this.bundleRoot = createWorker();
28459
- this.viewerState = props.viewerState;
28179
+ this.cellColorMapping = props.cellColorMapping;
28460
28180
  this.justReceivedExternalUpdate = false;
28461
28181
  this.prevElement = null;
28462
28182
  this.prevClickHandler = null;
@@ -28464,107 +28184,1945 @@ class Neuroglancer extends PureComponent {
28464
28184
  this.prevHoverHandler = null;
28465
28185
  this.onViewerStateChanged = this.onViewerStateChanged.bind(this);
28466
28186
  this.onRef = this.onRef.bind(this);
28187
+ this.latestOnSegmentClick = props.onSegmentClick;
28188
+ this.latestOnSelectHoveredCoords = props.onSelectHoveredCoords;
28467
28189
  }
28468
28190
  onRef(viewerRef) {
28469
- const {
28470
- onSegmentClick,
28471
- onSelectHoveredCoords
28472
- } = this.props;
28473
28191
  if (viewerRef) {
28474
28192
  const { viewer } = viewerRef;
28475
28193
  this.prevElement = viewer.element;
28476
28194
  this.prevMouseStateChanged = viewer.mouseState.changed;
28195
+ viewer.inputEventBindings.sliceView.set("at:dblclick0", () => {
28196
+ });
28197
+ viewer.inputEventBindings.perspectiveView.set("at:dblclick0", () => {
28198
+ });
28477
28199
  this.prevClickHandler = (event) => {
28478
28200
  if (event.button === 0) {
28479
- setTimeout(() => {
28480
- const { pickedValue } = viewer.mouseState;
28481
- if (pickedValue && (pickedValue == null ? void 0 : pickedValue.low)) {
28482
- onSegmentClick(pickedValue == null ? void 0 : pickedValue.low);
28201
+ requestAnimationFrame(() => {
28202
+ var _a;
28203
+ const { pickedValue, pickedRenderLayer } = viewer.mouseState;
28204
+ if (pickedValue && pickedValue.low !== void 0 && pickedRenderLayer) {
28205
+ (_a = this.latestOnSegmentClick) == null ? void 0 : _a.call(this, pickedValue.low);
28483
28206
  }
28484
- }, 100);
28207
+ });
28485
28208
  }
28486
28209
  };
28487
- viewer.element.addEventListener("mousedown", this.prevClickHandler);
28488
28210
  this.prevHoverHandler = () => {
28211
+ var _a;
28489
28212
  if (viewer.mouseState.pickedValue !== void 0) {
28490
28213
  const pickedSegment = viewer.mouseState.pickedValue;
28491
- onSelectHoveredCoords(pickedSegment == null ? void 0 : pickedSegment.low);
28214
+ (_a = this.latestOnSelectHoveredCoords) == null ? void 0 : _a.call(this, pickedSegment == null ? void 0 : pickedSegment.low);
28492
28215
  }
28493
28216
  };
28217
+ viewer.element.addEventListener("mouseup", this.prevClickHandler);
28494
28218
  viewer.mouseState.changed.add(this.prevHoverHandler);
28495
28219
  } else {
28496
28220
  if (this.prevElement && this.prevClickHandler) {
28497
- this.prevElement.removeEventListener("mousedown", this.prevClickHandler);
28221
+ this.prevElement.removeEventListener("mouseup", this.prevClickHandler);
28222
+ this.prevClickHandler = null;
28498
28223
  }
28499
28224
  if (this.prevMouseStateChanged && this.prevHoverHandler) {
28500
28225
  this.prevMouseStateChanged.remove(this.prevHoverHandler);
28226
+ this.prevHoverHandler = null;
28501
28227
  }
28228
+ this.prevElement = null;
28229
+ this.prevMouseStateChanged = null;
28502
28230
  }
28503
28231
  }
28504
28232
  onViewerStateChanged(nextState) {
28505
28233
  const { setViewerState } = this.props;
28506
- const { viewerState: prevState } = this;
28507
- if (!this.justReceivedExternalUpdate && !compareViewerState(prevState, nextState)) {
28508
- this.viewerState = nextState;
28509
- this.justReceivedExternalUpdate = false;
28510
- setViewerState(nextState);
28511
- }
28234
+ setViewerState(nextState);
28512
28235
  }
28513
- UNSAFE_componentWillUpdate(prevProps) {
28514
- if (!compareViewerState(this.viewerState, prevProps.viewerState)) {
28515
- this.viewerState = prevProps.viewerState;
28516
- this.justReceivedExternalUpdate = true;
28517
- setTimeout(() => {
28518
- this.justReceivedExternalUpdate = false;
28519
- }, 100);
28236
+ componentDidUpdate(prevProps) {
28237
+ const { onSegmentClick, onSelectHoveredCoords } = this.props;
28238
+ if (prevProps.onSegmentClick !== onSegmentClick) {
28239
+ this.latestOnSegmentClick = onSegmentClick;
28240
+ }
28241
+ if (prevProps.onSelectHoveredCoords !== onSelectHoveredCoords) {
28242
+ this.latestOnSelectHoveredCoords = onSelectHoveredCoords;
28520
28243
  }
28521
28244
  }
28522
28245
  render() {
28523
- const {
28524
- classes
28525
- } = this.props;
28246
+ const { classes, viewerState, cellColorMapping } = this.props;
28526
28247
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(NeuroglancerGlobalStyles, { classes }), /* @__PURE__ */ React__default.createElement("div", { className: classes.neuroglancerWrapper }, /* @__PURE__ */ React__default.createElement(Suspense, { fallback: /* @__PURE__ */ React__default.createElement("div", null, "Loading...") }, /* @__PURE__ */ React__default.createElement(
28527
28248
  LazyReactNeuroglancer,
28528
28249
  {
28529
28250
  brainMapsClientId: "NOT_A_VALID_ID",
28530
- viewerState: this.viewerState,
28251
+ viewerState,
28531
28252
  onViewerStateChanged: this.onViewerStateChanged,
28532
28253
  bundleRoot: this.bundleRoot,
28254
+ cellColorMapping,
28533
28255
  ref: this.onRef
28534
28256
  }
28535
28257
  ))));
28536
28258
  }
28537
28259
  }
28538
- const NEUROGLANCER_ZOOM_BASIS = 16;
28539
- function mapVitessceToNeuroglancer(zoom) {
28540
- return NEUROGLANCER_ZOOM_BASIS * 2 ** -zoom;
28541
- }
28542
- function mapNeuroglancerToVitessce(projectionScale) {
28543
- return -Math.log2(projectionScale / NEUROGLANCER_ZOOM_BASIS);
28260
+ /**
28261
+ * @license
28262
+ * Copyright 2010-2023 Three.js Authors
28263
+ * SPDX-License-Identifier: MIT
28264
+ */
28265
+ const REVISION = "154";
28266
+ const WebGLCoordinateSystem = 2e3;
28267
+ const WebGPUCoordinateSystem = 2001;
28268
+ function clamp(value, min, max) {
28269
+ return Math.max(min, Math.min(max, value));
28270
+ }
28271
+ class Quaternion {
28272
+ constructor(x = 0, y = 0, z2 = 0, w = 1) {
28273
+ this.isQuaternion = true;
28274
+ this._x = x;
28275
+ this._y = y;
28276
+ this._z = z2;
28277
+ this._w = w;
28278
+ }
28279
+ static slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
28280
+ let x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3];
28281
+ const x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
28282
+ if (t === 0) {
28283
+ dst[dstOffset + 0] = x0;
28284
+ dst[dstOffset + 1] = y0;
28285
+ dst[dstOffset + 2] = z0;
28286
+ dst[dstOffset + 3] = w0;
28287
+ return;
28288
+ }
28289
+ if (t === 1) {
28290
+ dst[dstOffset + 0] = x1;
28291
+ dst[dstOffset + 1] = y1;
28292
+ dst[dstOffset + 2] = z1;
28293
+ dst[dstOffset + 3] = w1;
28294
+ return;
28295
+ }
28296
+ if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
28297
+ let s = 1 - t;
28298
+ const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
28299
+ if (sqrSin > Number.EPSILON) {
28300
+ const sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
28301
+ s = Math.sin(s * len) / sin;
28302
+ t = Math.sin(t * len) / sin;
28303
+ }
28304
+ const tDir = t * dir;
28305
+ x0 = x0 * s + x1 * tDir;
28306
+ y0 = y0 * s + y1 * tDir;
28307
+ z0 = z0 * s + z1 * tDir;
28308
+ w0 = w0 * s + w1 * tDir;
28309
+ if (s === 1 - t) {
28310
+ const f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
28311
+ x0 *= f;
28312
+ y0 *= f;
28313
+ z0 *= f;
28314
+ w0 *= f;
28315
+ }
28316
+ }
28317
+ dst[dstOffset] = x0;
28318
+ dst[dstOffset + 1] = y0;
28319
+ dst[dstOffset + 2] = z0;
28320
+ dst[dstOffset + 3] = w0;
28321
+ }
28322
+ static multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {
28323
+ const x0 = src0[srcOffset0];
28324
+ const y0 = src0[srcOffset0 + 1];
28325
+ const z0 = src0[srcOffset0 + 2];
28326
+ const w0 = src0[srcOffset0 + 3];
28327
+ const x1 = src1[srcOffset1];
28328
+ const y1 = src1[srcOffset1 + 1];
28329
+ const z1 = src1[srcOffset1 + 2];
28330
+ const w1 = src1[srcOffset1 + 3];
28331
+ dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;
28332
+ dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;
28333
+ dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;
28334
+ dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;
28335
+ return dst;
28336
+ }
28337
+ get x() {
28338
+ return this._x;
28339
+ }
28340
+ set x(value) {
28341
+ this._x = value;
28342
+ this._onChangeCallback();
28343
+ }
28344
+ get y() {
28345
+ return this._y;
28346
+ }
28347
+ set y(value) {
28348
+ this._y = value;
28349
+ this._onChangeCallback();
28350
+ }
28351
+ get z() {
28352
+ return this._z;
28353
+ }
28354
+ set z(value) {
28355
+ this._z = value;
28356
+ this._onChangeCallback();
28357
+ }
28358
+ get w() {
28359
+ return this._w;
28360
+ }
28361
+ set w(value) {
28362
+ this._w = value;
28363
+ this._onChangeCallback();
28364
+ }
28365
+ set(x, y, z2, w) {
28366
+ this._x = x;
28367
+ this._y = y;
28368
+ this._z = z2;
28369
+ this._w = w;
28370
+ this._onChangeCallback();
28371
+ return this;
28372
+ }
28373
+ clone() {
28374
+ return new this.constructor(this._x, this._y, this._z, this._w);
28375
+ }
28376
+ copy(quaternion) {
28377
+ this._x = quaternion.x;
28378
+ this._y = quaternion.y;
28379
+ this._z = quaternion.z;
28380
+ this._w = quaternion.w;
28381
+ this._onChangeCallback();
28382
+ return this;
28383
+ }
28384
+ setFromEuler(euler, update2) {
28385
+ const x = euler._x, y = euler._y, z2 = euler._z, order = euler._order;
28386
+ const cos = Math.cos;
28387
+ const sin = Math.sin;
28388
+ const c1 = cos(x / 2);
28389
+ const c2 = cos(y / 2);
28390
+ const c3 = cos(z2 / 2);
28391
+ const s1 = sin(x / 2);
28392
+ const s2 = sin(y / 2);
28393
+ const s3 = sin(z2 / 2);
28394
+ switch (order) {
28395
+ case "XYZ":
28396
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
28397
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
28398
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
28399
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
28400
+ break;
28401
+ case "YXZ":
28402
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
28403
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
28404
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
28405
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
28406
+ break;
28407
+ case "ZXY":
28408
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
28409
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
28410
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
28411
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
28412
+ break;
28413
+ case "ZYX":
28414
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
28415
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
28416
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
28417
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
28418
+ break;
28419
+ case "YZX":
28420
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
28421
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
28422
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
28423
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
28424
+ break;
28425
+ case "XZY":
28426
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
28427
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
28428
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
28429
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
28430
+ break;
28431
+ default:
28432
+ console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + order);
28433
+ }
28434
+ if (update2 !== false) this._onChangeCallback();
28435
+ return this;
28436
+ }
28437
+ setFromAxisAngle(axis, angle) {
28438
+ const halfAngle = angle / 2, s = Math.sin(halfAngle);
28439
+ this._x = axis.x * s;
28440
+ this._y = axis.y * s;
28441
+ this._z = axis.z * s;
28442
+ this._w = Math.cos(halfAngle);
28443
+ this._onChangeCallback();
28444
+ return this;
28445
+ }
28446
+ setFromRotationMatrix(m) {
28447
+ const te = m.elements, m11 = te[0], m12 = te[4], m13 = te[8], m21 = te[1], m22 = te[5], m23 = te[9], m31 = te[2], m32 = te[6], m33 = te[10], trace = m11 + m22 + m33;
28448
+ if (trace > 0) {
28449
+ const s = 0.5 / Math.sqrt(trace + 1);
28450
+ this._w = 0.25 / s;
28451
+ this._x = (m32 - m23) * s;
28452
+ this._y = (m13 - m31) * s;
28453
+ this._z = (m21 - m12) * s;
28454
+ } else if (m11 > m22 && m11 > m33) {
28455
+ const s = 2 * Math.sqrt(1 + m11 - m22 - m33);
28456
+ this._w = (m32 - m23) / s;
28457
+ this._x = 0.25 * s;
28458
+ this._y = (m12 + m21) / s;
28459
+ this._z = (m13 + m31) / s;
28460
+ } else if (m22 > m33) {
28461
+ const s = 2 * Math.sqrt(1 + m22 - m11 - m33);
28462
+ this._w = (m13 - m31) / s;
28463
+ this._x = (m12 + m21) / s;
28464
+ this._y = 0.25 * s;
28465
+ this._z = (m23 + m32) / s;
28466
+ } else {
28467
+ const s = 2 * Math.sqrt(1 + m33 - m11 - m22);
28468
+ this._w = (m21 - m12) / s;
28469
+ this._x = (m13 + m31) / s;
28470
+ this._y = (m23 + m32) / s;
28471
+ this._z = 0.25 * s;
28472
+ }
28473
+ this._onChangeCallback();
28474
+ return this;
28475
+ }
28476
+ setFromUnitVectors(vFrom, vTo) {
28477
+ let r = vFrom.dot(vTo) + 1;
28478
+ if (r < Number.EPSILON) {
28479
+ r = 0;
28480
+ if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {
28481
+ this._x = -vFrom.y;
28482
+ this._y = vFrom.x;
28483
+ this._z = 0;
28484
+ this._w = r;
28485
+ } else {
28486
+ this._x = 0;
28487
+ this._y = -vFrom.z;
28488
+ this._z = vFrom.y;
28489
+ this._w = r;
28490
+ }
28491
+ } else {
28492
+ this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
28493
+ this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
28494
+ this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
28495
+ this._w = r;
28496
+ }
28497
+ return this.normalize();
28498
+ }
28499
+ angleTo(q) {
28500
+ return 2 * Math.acos(Math.abs(clamp(this.dot(q), -1, 1)));
28501
+ }
28502
+ rotateTowards(q, step) {
28503
+ const angle = this.angleTo(q);
28504
+ if (angle === 0) return this;
28505
+ const t = Math.min(1, step / angle);
28506
+ this.slerp(q, t);
28507
+ return this;
28508
+ }
28509
+ identity() {
28510
+ return this.set(0, 0, 0, 1);
28511
+ }
28512
+ invert() {
28513
+ return this.conjugate();
28514
+ }
28515
+ conjugate() {
28516
+ this._x *= -1;
28517
+ this._y *= -1;
28518
+ this._z *= -1;
28519
+ this._onChangeCallback();
28520
+ return this;
28521
+ }
28522
+ dot(v) {
28523
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
28524
+ }
28525
+ lengthSq() {
28526
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
28527
+ }
28528
+ length() {
28529
+ return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
28530
+ }
28531
+ normalize() {
28532
+ let l = this.length();
28533
+ if (l === 0) {
28534
+ this._x = 0;
28535
+ this._y = 0;
28536
+ this._z = 0;
28537
+ this._w = 1;
28538
+ } else {
28539
+ l = 1 / l;
28540
+ this._x = this._x * l;
28541
+ this._y = this._y * l;
28542
+ this._z = this._z * l;
28543
+ this._w = this._w * l;
28544
+ }
28545
+ this._onChangeCallback();
28546
+ return this;
28547
+ }
28548
+ multiply(q) {
28549
+ return this.multiplyQuaternions(this, q);
28550
+ }
28551
+ premultiply(q) {
28552
+ return this.multiplyQuaternions(q, this);
28553
+ }
28554
+ multiplyQuaternions(a, b) {
28555
+ const qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
28556
+ const qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
28557
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
28558
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
28559
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
28560
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
28561
+ this._onChangeCallback();
28562
+ return this;
28563
+ }
28564
+ slerp(qb, t) {
28565
+ if (t === 0) return this;
28566
+ if (t === 1) return this.copy(qb);
28567
+ const x = this._x, y = this._y, z2 = this._z, w = this._w;
28568
+ let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z2 * qb._z;
28569
+ if (cosHalfTheta < 0) {
28570
+ this._w = -qb._w;
28571
+ this._x = -qb._x;
28572
+ this._y = -qb._y;
28573
+ this._z = -qb._z;
28574
+ cosHalfTheta = -cosHalfTheta;
28575
+ } else {
28576
+ this.copy(qb);
28577
+ }
28578
+ if (cosHalfTheta >= 1) {
28579
+ this._w = w;
28580
+ this._x = x;
28581
+ this._y = y;
28582
+ this._z = z2;
28583
+ return this;
28584
+ }
28585
+ const sqrSinHalfTheta = 1 - cosHalfTheta * cosHalfTheta;
28586
+ if (sqrSinHalfTheta <= Number.EPSILON) {
28587
+ const s = 1 - t;
28588
+ this._w = s * w + t * this._w;
28589
+ this._x = s * x + t * this._x;
28590
+ this._y = s * y + t * this._y;
28591
+ this._z = s * z2 + t * this._z;
28592
+ this.normalize();
28593
+ this._onChangeCallback();
28594
+ return this;
28595
+ }
28596
+ const sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
28597
+ const halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
28598
+ const ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
28599
+ this._w = w * ratioA + this._w * ratioB;
28600
+ this._x = x * ratioA + this._x * ratioB;
28601
+ this._y = y * ratioA + this._y * ratioB;
28602
+ this._z = z2 * ratioA + this._z * ratioB;
28603
+ this._onChangeCallback();
28604
+ return this;
28605
+ }
28606
+ slerpQuaternions(qa, qb, t) {
28607
+ return this.copy(qa).slerp(qb, t);
28608
+ }
28609
+ random() {
28610
+ const u1 = Math.random();
28611
+ const sqrt1u1 = Math.sqrt(1 - u1);
28612
+ const sqrtu1 = Math.sqrt(u1);
28613
+ const u2 = 2 * Math.PI * Math.random();
28614
+ const u3 = 2 * Math.PI * Math.random();
28615
+ return this.set(
28616
+ sqrt1u1 * Math.cos(u2),
28617
+ sqrtu1 * Math.sin(u3),
28618
+ sqrtu1 * Math.cos(u3),
28619
+ sqrt1u1 * Math.sin(u2)
28620
+ );
28621
+ }
28622
+ equals(quaternion) {
28623
+ return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;
28624
+ }
28625
+ fromArray(array, offset2 = 0) {
28626
+ this._x = array[offset2];
28627
+ this._y = array[offset2 + 1];
28628
+ this._z = array[offset2 + 2];
28629
+ this._w = array[offset2 + 3];
28630
+ this._onChangeCallback();
28631
+ return this;
28632
+ }
28633
+ toArray(array = [], offset2 = 0) {
28634
+ array[offset2] = this._x;
28635
+ array[offset2 + 1] = this._y;
28636
+ array[offset2 + 2] = this._z;
28637
+ array[offset2 + 3] = this._w;
28638
+ return array;
28639
+ }
28640
+ fromBufferAttribute(attribute, index) {
28641
+ this._x = attribute.getX(index);
28642
+ this._y = attribute.getY(index);
28643
+ this._z = attribute.getZ(index);
28644
+ this._w = attribute.getW(index);
28645
+ return this;
28646
+ }
28647
+ toJSON() {
28648
+ return this.toArray();
28649
+ }
28650
+ _onChange(callback) {
28651
+ this._onChangeCallback = callback;
28652
+ return this;
28653
+ }
28654
+ _onChangeCallback() {
28655
+ }
28656
+ *[Symbol.iterator]() {
28657
+ yield this._x;
28658
+ yield this._y;
28659
+ yield this._z;
28660
+ yield this._w;
28661
+ }
28662
+ }
28663
+ class Vector3 {
28664
+ constructor(x = 0, y = 0, z2 = 0) {
28665
+ Vector3.prototype.isVector3 = true;
28666
+ this.x = x;
28667
+ this.y = y;
28668
+ this.z = z2;
28669
+ }
28670
+ set(x, y, z2) {
28671
+ if (z2 === void 0) z2 = this.z;
28672
+ this.x = x;
28673
+ this.y = y;
28674
+ this.z = z2;
28675
+ return this;
28676
+ }
28677
+ setScalar(scalar) {
28678
+ this.x = scalar;
28679
+ this.y = scalar;
28680
+ this.z = scalar;
28681
+ return this;
28682
+ }
28683
+ setX(x) {
28684
+ this.x = x;
28685
+ return this;
28686
+ }
28687
+ setY(y) {
28688
+ this.y = y;
28689
+ return this;
28690
+ }
28691
+ setZ(z2) {
28692
+ this.z = z2;
28693
+ return this;
28694
+ }
28695
+ setComponent(index, value) {
28696
+ switch (index) {
28697
+ case 0:
28698
+ this.x = value;
28699
+ break;
28700
+ case 1:
28701
+ this.y = value;
28702
+ break;
28703
+ case 2:
28704
+ this.z = value;
28705
+ break;
28706
+ default:
28707
+ throw new Error("index is out of range: " + index);
28708
+ }
28709
+ return this;
28710
+ }
28711
+ getComponent(index) {
28712
+ switch (index) {
28713
+ case 0:
28714
+ return this.x;
28715
+ case 1:
28716
+ return this.y;
28717
+ case 2:
28718
+ return this.z;
28719
+ default:
28720
+ throw new Error("index is out of range: " + index);
28721
+ }
28722
+ }
28723
+ clone() {
28724
+ return new this.constructor(this.x, this.y, this.z);
28725
+ }
28726
+ copy(v) {
28727
+ this.x = v.x;
28728
+ this.y = v.y;
28729
+ this.z = v.z;
28730
+ return this;
28731
+ }
28732
+ add(v) {
28733
+ this.x += v.x;
28734
+ this.y += v.y;
28735
+ this.z += v.z;
28736
+ return this;
28737
+ }
28738
+ addScalar(s) {
28739
+ this.x += s;
28740
+ this.y += s;
28741
+ this.z += s;
28742
+ return this;
28743
+ }
28744
+ addVectors(a, b) {
28745
+ this.x = a.x + b.x;
28746
+ this.y = a.y + b.y;
28747
+ this.z = a.z + b.z;
28748
+ return this;
28749
+ }
28750
+ addScaledVector(v, s) {
28751
+ this.x += v.x * s;
28752
+ this.y += v.y * s;
28753
+ this.z += v.z * s;
28754
+ return this;
28755
+ }
28756
+ sub(v) {
28757
+ this.x -= v.x;
28758
+ this.y -= v.y;
28759
+ this.z -= v.z;
28760
+ return this;
28761
+ }
28762
+ subScalar(s) {
28763
+ this.x -= s;
28764
+ this.y -= s;
28765
+ this.z -= s;
28766
+ return this;
28767
+ }
28768
+ subVectors(a, b) {
28769
+ this.x = a.x - b.x;
28770
+ this.y = a.y - b.y;
28771
+ this.z = a.z - b.z;
28772
+ return this;
28773
+ }
28774
+ multiply(v) {
28775
+ this.x *= v.x;
28776
+ this.y *= v.y;
28777
+ this.z *= v.z;
28778
+ return this;
28779
+ }
28780
+ multiplyScalar(scalar) {
28781
+ this.x *= scalar;
28782
+ this.y *= scalar;
28783
+ this.z *= scalar;
28784
+ return this;
28785
+ }
28786
+ multiplyVectors(a, b) {
28787
+ this.x = a.x * b.x;
28788
+ this.y = a.y * b.y;
28789
+ this.z = a.z * b.z;
28790
+ return this;
28791
+ }
28792
+ applyEuler(euler) {
28793
+ return this.applyQuaternion(_quaternion$4.setFromEuler(euler));
28794
+ }
28795
+ applyAxisAngle(axis, angle) {
28796
+ return this.applyQuaternion(_quaternion$4.setFromAxisAngle(axis, angle));
28797
+ }
28798
+ applyMatrix3(m) {
28799
+ const x = this.x, y = this.y, z2 = this.z;
28800
+ const e = m.elements;
28801
+ this.x = e[0] * x + e[3] * y + e[6] * z2;
28802
+ this.y = e[1] * x + e[4] * y + e[7] * z2;
28803
+ this.z = e[2] * x + e[5] * y + e[8] * z2;
28804
+ return this;
28805
+ }
28806
+ applyNormalMatrix(m) {
28807
+ return this.applyMatrix3(m).normalize();
28808
+ }
28809
+ applyMatrix4(m) {
28810
+ const x = this.x, y = this.y, z2 = this.z;
28811
+ const e = m.elements;
28812
+ const w = 1 / (e[3] * x + e[7] * y + e[11] * z2 + e[15]);
28813
+ this.x = (e[0] * x + e[4] * y + e[8] * z2 + e[12]) * w;
28814
+ this.y = (e[1] * x + e[5] * y + e[9] * z2 + e[13]) * w;
28815
+ this.z = (e[2] * x + e[6] * y + e[10] * z2 + e[14]) * w;
28816
+ return this;
28817
+ }
28818
+ applyQuaternion(q) {
28819
+ const x = this.x, y = this.y, z2 = this.z;
28820
+ const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
28821
+ const ix = qw * x + qy * z2 - qz * y;
28822
+ const iy = qw * y + qz * x - qx * z2;
28823
+ const iz = qw * z2 + qx * y - qy * x;
28824
+ const iw = -qx * x - qy * y - qz * z2;
28825
+ this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
28826
+ this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
28827
+ this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
28828
+ return this;
28829
+ }
28830
+ project(camera) {
28831
+ return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);
28832
+ }
28833
+ unproject(camera) {
28834
+ return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);
28835
+ }
28836
+ transformDirection(m) {
28837
+ const x = this.x, y = this.y, z2 = this.z;
28838
+ const e = m.elements;
28839
+ this.x = e[0] * x + e[4] * y + e[8] * z2;
28840
+ this.y = e[1] * x + e[5] * y + e[9] * z2;
28841
+ this.z = e[2] * x + e[6] * y + e[10] * z2;
28842
+ return this.normalize();
28843
+ }
28844
+ divide(v) {
28845
+ this.x /= v.x;
28846
+ this.y /= v.y;
28847
+ this.z /= v.z;
28848
+ return this;
28849
+ }
28850
+ divideScalar(scalar) {
28851
+ return this.multiplyScalar(1 / scalar);
28852
+ }
28853
+ min(v) {
28854
+ this.x = Math.min(this.x, v.x);
28855
+ this.y = Math.min(this.y, v.y);
28856
+ this.z = Math.min(this.z, v.z);
28857
+ return this;
28858
+ }
28859
+ max(v) {
28860
+ this.x = Math.max(this.x, v.x);
28861
+ this.y = Math.max(this.y, v.y);
28862
+ this.z = Math.max(this.z, v.z);
28863
+ return this;
28864
+ }
28865
+ clamp(min, max) {
28866
+ this.x = Math.max(min.x, Math.min(max.x, this.x));
28867
+ this.y = Math.max(min.y, Math.min(max.y, this.y));
28868
+ this.z = Math.max(min.z, Math.min(max.z, this.z));
28869
+ return this;
28870
+ }
28871
+ clampScalar(minVal, maxVal) {
28872
+ this.x = Math.max(minVal, Math.min(maxVal, this.x));
28873
+ this.y = Math.max(minVal, Math.min(maxVal, this.y));
28874
+ this.z = Math.max(minVal, Math.min(maxVal, this.z));
28875
+ return this;
28876
+ }
28877
+ clampLength(min, max) {
28878
+ const length2 = this.length();
28879
+ return this.divideScalar(length2 || 1).multiplyScalar(Math.max(min, Math.min(max, length2)));
28880
+ }
28881
+ floor() {
28882
+ this.x = Math.floor(this.x);
28883
+ this.y = Math.floor(this.y);
28884
+ this.z = Math.floor(this.z);
28885
+ return this;
28886
+ }
28887
+ ceil() {
28888
+ this.x = Math.ceil(this.x);
28889
+ this.y = Math.ceil(this.y);
28890
+ this.z = Math.ceil(this.z);
28891
+ return this;
28892
+ }
28893
+ round() {
28894
+ this.x = Math.round(this.x);
28895
+ this.y = Math.round(this.y);
28896
+ this.z = Math.round(this.z);
28897
+ return this;
28898
+ }
28899
+ roundToZero() {
28900
+ this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);
28901
+ this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);
28902
+ this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);
28903
+ return this;
28904
+ }
28905
+ negate() {
28906
+ this.x = -this.x;
28907
+ this.y = -this.y;
28908
+ this.z = -this.z;
28909
+ return this;
28910
+ }
28911
+ dot(v) {
28912
+ return this.x * v.x + this.y * v.y + this.z * v.z;
28913
+ }
28914
+ // TODO lengthSquared?
28915
+ lengthSq() {
28916
+ return this.x * this.x + this.y * this.y + this.z * this.z;
28917
+ }
28918
+ length() {
28919
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
28920
+ }
28921
+ manhattanLength() {
28922
+ return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
28923
+ }
28924
+ normalize() {
28925
+ return this.divideScalar(this.length() || 1);
28926
+ }
28927
+ setLength(length2) {
28928
+ return this.normalize().multiplyScalar(length2);
28929
+ }
28930
+ lerp(v, alpha2) {
28931
+ this.x += (v.x - this.x) * alpha2;
28932
+ this.y += (v.y - this.y) * alpha2;
28933
+ this.z += (v.z - this.z) * alpha2;
28934
+ return this;
28935
+ }
28936
+ lerpVectors(v1, v2, alpha2) {
28937
+ this.x = v1.x + (v2.x - v1.x) * alpha2;
28938
+ this.y = v1.y + (v2.y - v1.y) * alpha2;
28939
+ this.z = v1.z + (v2.z - v1.z) * alpha2;
28940
+ return this;
28941
+ }
28942
+ cross(v) {
28943
+ return this.crossVectors(this, v);
28944
+ }
28945
+ crossVectors(a, b) {
28946
+ const ax = a.x, ay = a.y, az = a.z;
28947
+ const bx = b.x, by = b.y, bz = b.z;
28948
+ this.x = ay * bz - az * by;
28949
+ this.y = az * bx - ax * bz;
28950
+ this.z = ax * by - ay * bx;
28951
+ return this;
28952
+ }
28953
+ projectOnVector(v) {
28954
+ const denominator = v.lengthSq();
28955
+ if (denominator === 0) return this.set(0, 0, 0);
28956
+ const scalar = v.dot(this) / denominator;
28957
+ return this.copy(v).multiplyScalar(scalar);
28958
+ }
28959
+ projectOnPlane(planeNormal) {
28960
+ _vector$b.copy(this).projectOnVector(planeNormal);
28961
+ return this.sub(_vector$b);
28962
+ }
28963
+ reflect(normal) {
28964
+ return this.sub(_vector$b.copy(normal).multiplyScalar(2 * this.dot(normal)));
28965
+ }
28966
+ angleTo(v) {
28967
+ const denominator = Math.sqrt(this.lengthSq() * v.lengthSq());
28968
+ if (denominator === 0) return Math.PI / 2;
28969
+ const theta = this.dot(v) / denominator;
28970
+ return Math.acos(clamp(theta, -1, 1));
28971
+ }
28972
+ distanceTo(v) {
28973
+ return Math.sqrt(this.distanceToSquared(v));
28974
+ }
28975
+ distanceToSquared(v) {
28976
+ const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
28977
+ return dx * dx + dy * dy + dz * dz;
28978
+ }
28979
+ manhattanDistanceTo(v) {
28980
+ return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);
28981
+ }
28982
+ setFromSpherical(s) {
28983
+ return this.setFromSphericalCoords(s.radius, s.phi, s.theta);
28984
+ }
28985
+ setFromSphericalCoords(radius, phi, theta) {
28986
+ const sinPhiRadius = Math.sin(phi) * radius;
28987
+ this.x = sinPhiRadius * Math.sin(theta);
28988
+ this.y = Math.cos(phi) * radius;
28989
+ this.z = sinPhiRadius * Math.cos(theta);
28990
+ return this;
28991
+ }
28992
+ setFromCylindrical(c) {
28993
+ return this.setFromCylindricalCoords(c.radius, c.theta, c.y);
28994
+ }
28995
+ setFromCylindricalCoords(radius, theta, y) {
28996
+ this.x = radius * Math.sin(theta);
28997
+ this.y = y;
28998
+ this.z = radius * Math.cos(theta);
28999
+ return this;
29000
+ }
29001
+ setFromMatrixPosition(m) {
29002
+ const e = m.elements;
29003
+ this.x = e[12];
29004
+ this.y = e[13];
29005
+ this.z = e[14];
29006
+ return this;
29007
+ }
29008
+ setFromMatrixScale(m) {
29009
+ const sx = this.setFromMatrixColumn(m, 0).length();
29010
+ const sy = this.setFromMatrixColumn(m, 1).length();
29011
+ const sz = this.setFromMatrixColumn(m, 2).length();
29012
+ this.x = sx;
29013
+ this.y = sy;
29014
+ this.z = sz;
29015
+ return this;
29016
+ }
29017
+ setFromMatrixColumn(m, index) {
29018
+ return this.fromArray(m.elements, index * 4);
29019
+ }
29020
+ setFromMatrix3Column(m, index) {
29021
+ return this.fromArray(m.elements, index * 3);
29022
+ }
29023
+ setFromEuler(e) {
29024
+ this.x = e._x;
29025
+ this.y = e._y;
29026
+ this.z = e._z;
29027
+ return this;
29028
+ }
29029
+ setFromColor(c) {
29030
+ this.x = c.r;
29031
+ this.y = c.g;
29032
+ this.z = c.b;
29033
+ return this;
29034
+ }
29035
+ equals(v) {
29036
+ return v.x === this.x && v.y === this.y && v.z === this.z;
29037
+ }
29038
+ fromArray(array, offset2 = 0) {
29039
+ this.x = array[offset2];
29040
+ this.y = array[offset2 + 1];
29041
+ this.z = array[offset2 + 2];
29042
+ return this;
29043
+ }
29044
+ toArray(array = [], offset2 = 0) {
29045
+ array[offset2] = this.x;
29046
+ array[offset2 + 1] = this.y;
29047
+ array[offset2 + 2] = this.z;
29048
+ return array;
29049
+ }
29050
+ fromBufferAttribute(attribute, index) {
29051
+ this.x = attribute.getX(index);
29052
+ this.y = attribute.getY(index);
29053
+ this.z = attribute.getZ(index);
29054
+ return this;
29055
+ }
29056
+ random() {
29057
+ this.x = Math.random();
29058
+ this.y = Math.random();
29059
+ this.z = Math.random();
29060
+ return this;
29061
+ }
29062
+ randomDirection() {
29063
+ const u = (Math.random() - 0.5) * 2;
29064
+ const t = Math.random() * Math.PI * 2;
29065
+ const f = Math.sqrt(1 - u ** 2);
29066
+ this.x = f * Math.cos(t);
29067
+ this.y = f * Math.sin(t);
29068
+ this.z = u;
29069
+ return this;
29070
+ }
29071
+ *[Symbol.iterator]() {
29072
+ yield this.x;
29073
+ yield this.y;
29074
+ yield this.z;
29075
+ }
29076
+ }
29077
+ const _vector$b = /* @__PURE__ */ new Vector3();
29078
+ const _quaternion$4 = /* @__PURE__ */ new Quaternion();
29079
+ class Matrix4 {
29080
+ constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
29081
+ Matrix4.prototype.isMatrix4 = true;
29082
+ this.elements = [
29083
+ 1,
29084
+ 0,
29085
+ 0,
29086
+ 0,
29087
+ 0,
29088
+ 1,
29089
+ 0,
29090
+ 0,
29091
+ 0,
29092
+ 0,
29093
+ 1,
29094
+ 0,
29095
+ 0,
29096
+ 0,
29097
+ 0,
29098
+ 1
29099
+ ];
29100
+ if (n11 !== void 0) {
29101
+ this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
29102
+ }
29103
+ }
29104
+ set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
29105
+ const te = this.elements;
29106
+ te[0] = n11;
29107
+ te[4] = n12;
29108
+ te[8] = n13;
29109
+ te[12] = n14;
29110
+ te[1] = n21;
29111
+ te[5] = n22;
29112
+ te[9] = n23;
29113
+ te[13] = n24;
29114
+ te[2] = n31;
29115
+ te[6] = n32;
29116
+ te[10] = n33;
29117
+ te[14] = n34;
29118
+ te[3] = n41;
29119
+ te[7] = n42;
29120
+ te[11] = n43;
29121
+ te[15] = n44;
29122
+ return this;
29123
+ }
29124
+ identity() {
29125
+ this.set(
29126
+ 1,
29127
+ 0,
29128
+ 0,
29129
+ 0,
29130
+ 0,
29131
+ 1,
29132
+ 0,
29133
+ 0,
29134
+ 0,
29135
+ 0,
29136
+ 1,
29137
+ 0,
29138
+ 0,
29139
+ 0,
29140
+ 0,
29141
+ 1
29142
+ );
29143
+ return this;
29144
+ }
29145
+ clone() {
29146
+ return new Matrix4().fromArray(this.elements);
29147
+ }
29148
+ copy(m) {
29149
+ const te = this.elements;
29150
+ const me = m.elements;
29151
+ te[0] = me[0];
29152
+ te[1] = me[1];
29153
+ te[2] = me[2];
29154
+ te[3] = me[3];
29155
+ te[4] = me[4];
29156
+ te[5] = me[5];
29157
+ te[6] = me[6];
29158
+ te[7] = me[7];
29159
+ te[8] = me[8];
29160
+ te[9] = me[9];
29161
+ te[10] = me[10];
29162
+ te[11] = me[11];
29163
+ te[12] = me[12];
29164
+ te[13] = me[13];
29165
+ te[14] = me[14];
29166
+ te[15] = me[15];
29167
+ return this;
29168
+ }
29169
+ copyPosition(m) {
29170
+ const te = this.elements, me = m.elements;
29171
+ te[12] = me[12];
29172
+ te[13] = me[13];
29173
+ te[14] = me[14];
29174
+ return this;
29175
+ }
29176
+ setFromMatrix3(m) {
29177
+ const me = m.elements;
29178
+ this.set(
29179
+ me[0],
29180
+ me[3],
29181
+ me[6],
29182
+ 0,
29183
+ me[1],
29184
+ me[4],
29185
+ me[7],
29186
+ 0,
29187
+ me[2],
29188
+ me[5],
29189
+ me[8],
29190
+ 0,
29191
+ 0,
29192
+ 0,
29193
+ 0,
29194
+ 1
29195
+ );
29196
+ return this;
29197
+ }
29198
+ extractBasis(xAxis, yAxis, zAxis) {
29199
+ xAxis.setFromMatrixColumn(this, 0);
29200
+ yAxis.setFromMatrixColumn(this, 1);
29201
+ zAxis.setFromMatrixColumn(this, 2);
29202
+ return this;
29203
+ }
29204
+ makeBasis(xAxis, yAxis, zAxis) {
29205
+ this.set(
29206
+ xAxis.x,
29207
+ yAxis.x,
29208
+ zAxis.x,
29209
+ 0,
29210
+ xAxis.y,
29211
+ yAxis.y,
29212
+ zAxis.y,
29213
+ 0,
29214
+ xAxis.z,
29215
+ yAxis.z,
29216
+ zAxis.z,
29217
+ 0,
29218
+ 0,
29219
+ 0,
29220
+ 0,
29221
+ 1
29222
+ );
29223
+ return this;
29224
+ }
29225
+ extractRotation(m) {
29226
+ const te = this.elements;
29227
+ const me = m.elements;
29228
+ const scaleX = 1 / _v1$5.setFromMatrixColumn(m, 0).length();
29229
+ const scaleY = 1 / _v1$5.setFromMatrixColumn(m, 1).length();
29230
+ const scaleZ = 1 / _v1$5.setFromMatrixColumn(m, 2).length();
29231
+ te[0] = me[0] * scaleX;
29232
+ te[1] = me[1] * scaleX;
29233
+ te[2] = me[2] * scaleX;
29234
+ te[3] = 0;
29235
+ te[4] = me[4] * scaleY;
29236
+ te[5] = me[5] * scaleY;
29237
+ te[6] = me[6] * scaleY;
29238
+ te[7] = 0;
29239
+ te[8] = me[8] * scaleZ;
29240
+ te[9] = me[9] * scaleZ;
29241
+ te[10] = me[10] * scaleZ;
29242
+ te[11] = 0;
29243
+ te[12] = 0;
29244
+ te[13] = 0;
29245
+ te[14] = 0;
29246
+ te[15] = 1;
29247
+ return this;
29248
+ }
29249
+ makeRotationFromEuler(euler) {
29250
+ const te = this.elements;
29251
+ const x = euler.x, y = euler.y, z2 = euler.z;
29252
+ const a = Math.cos(x), b = Math.sin(x);
29253
+ const c = Math.cos(y), d = Math.sin(y);
29254
+ const e = Math.cos(z2), f = Math.sin(z2);
29255
+ if (euler.order === "XYZ") {
29256
+ const ae = a * e, af = a * f, be = b * e, bf = b * f;
29257
+ te[0] = c * e;
29258
+ te[4] = -c * f;
29259
+ te[8] = d;
29260
+ te[1] = af + be * d;
29261
+ te[5] = ae - bf * d;
29262
+ te[9] = -b * c;
29263
+ te[2] = bf - ae * d;
29264
+ te[6] = be + af * d;
29265
+ te[10] = a * c;
29266
+ } else if (euler.order === "YXZ") {
29267
+ const ce = c * e, cf = c * f, de = d * e, df = d * f;
29268
+ te[0] = ce + df * b;
29269
+ te[4] = de * b - cf;
29270
+ te[8] = a * d;
29271
+ te[1] = a * f;
29272
+ te[5] = a * e;
29273
+ te[9] = -b;
29274
+ te[2] = cf * b - de;
29275
+ te[6] = df + ce * b;
29276
+ te[10] = a * c;
29277
+ } else if (euler.order === "ZXY") {
29278
+ const ce = c * e, cf = c * f, de = d * e, df = d * f;
29279
+ te[0] = ce - df * b;
29280
+ te[4] = -a * f;
29281
+ te[8] = de + cf * b;
29282
+ te[1] = cf + de * b;
29283
+ te[5] = a * e;
29284
+ te[9] = df - ce * b;
29285
+ te[2] = -a * d;
29286
+ te[6] = b;
29287
+ te[10] = a * c;
29288
+ } else if (euler.order === "ZYX") {
29289
+ const ae = a * e, af = a * f, be = b * e, bf = b * f;
29290
+ te[0] = c * e;
29291
+ te[4] = be * d - af;
29292
+ te[8] = ae * d + bf;
29293
+ te[1] = c * f;
29294
+ te[5] = bf * d + ae;
29295
+ te[9] = af * d - be;
29296
+ te[2] = -d;
29297
+ te[6] = b * c;
29298
+ te[10] = a * c;
29299
+ } else if (euler.order === "YZX") {
29300
+ const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
29301
+ te[0] = c * e;
29302
+ te[4] = bd - ac * f;
29303
+ te[8] = bc * f + ad;
29304
+ te[1] = f;
29305
+ te[5] = a * e;
29306
+ te[9] = -b * e;
29307
+ te[2] = -d * e;
29308
+ te[6] = ad * f + bc;
29309
+ te[10] = ac - bd * f;
29310
+ } else if (euler.order === "XZY") {
29311
+ const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
29312
+ te[0] = c * e;
29313
+ te[4] = -f;
29314
+ te[8] = d * e;
29315
+ te[1] = ac * f + bd;
29316
+ te[5] = a * e;
29317
+ te[9] = ad * f - bc;
29318
+ te[2] = bc * f - ad;
29319
+ te[6] = b * e;
29320
+ te[10] = bd * f + ac;
29321
+ }
29322
+ te[3] = 0;
29323
+ te[7] = 0;
29324
+ te[11] = 0;
29325
+ te[12] = 0;
29326
+ te[13] = 0;
29327
+ te[14] = 0;
29328
+ te[15] = 1;
29329
+ return this;
29330
+ }
29331
+ makeRotationFromQuaternion(q) {
29332
+ return this.compose(_zero, q, _one);
29333
+ }
29334
+ lookAt(eye, target, up) {
29335
+ const te = this.elements;
29336
+ _z.subVectors(eye, target);
29337
+ if (_z.lengthSq() === 0) {
29338
+ _z.z = 1;
29339
+ }
29340
+ _z.normalize();
29341
+ _x.crossVectors(up, _z);
29342
+ if (_x.lengthSq() === 0) {
29343
+ if (Math.abs(up.z) === 1) {
29344
+ _z.x += 1e-4;
29345
+ } else {
29346
+ _z.z += 1e-4;
29347
+ }
29348
+ _z.normalize();
29349
+ _x.crossVectors(up, _z);
29350
+ }
29351
+ _x.normalize();
29352
+ _y.crossVectors(_z, _x);
29353
+ te[0] = _x.x;
29354
+ te[4] = _y.x;
29355
+ te[8] = _z.x;
29356
+ te[1] = _x.y;
29357
+ te[5] = _y.y;
29358
+ te[9] = _z.y;
29359
+ te[2] = _x.z;
29360
+ te[6] = _y.z;
29361
+ te[10] = _z.z;
29362
+ return this;
29363
+ }
29364
+ multiply(m) {
29365
+ return this.multiplyMatrices(this, m);
29366
+ }
29367
+ premultiply(m) {
29368
+ return this.multiplyMatrices(m, this);
29369
+ }
29370
+ multiplyMatrices(a, b) {
29371
+ const ae = a.elements;
29372
+ const be = b.elements;
29373
+ const te = this.elements;
29374
+ const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
29375
+ const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
29376
+ const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
29377
+ const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
29378
+ const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
29379
+ const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
29380
+ const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
29381
+ const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
29382
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
29383
+ te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
29384
+ te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
29385
+ te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
29386
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
29387
+ te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
29388
+ te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
29389
+ te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
29390
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
29391
+ te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
29392
+ te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
29393
+ te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
29394
+ te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
29395
+ te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
29396
+ te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
29397
+ te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
29398
+ return this;
29399
+ }
29400
+ multiplyScalar(s) {
29401
+ const te = this.elements;
29402
+ te[0] *= s;
29403
+ te[4] *= s;
29404
+ te[8] *= s;
29405
+ te[12] *= s;
29406
+ te[1] *= s;
29407
+ te[5] *= s;
29408
+ te[9] *= s;
29409
+ te[13] *= s;
29410
+ te[2] *= s;
29411
+ te[6] *= s;
29412
+ te[10] *= s;
29413
+ te[14] *= s;
29414
+ te[3] *= s;
29415
+ te[7] *= s;
29416
+ te[11] *= s;
29417
+ te[15] *= s;
29418
+ return this;
29419
+ }
29420
+ determinant() {
29421
+ const te = this.elements;
29422
+ const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
29423
+ const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
29424
+ const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
29425
+ const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
29426
+ return n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);
29427
+ }
29428
+ transpose() {
29429
+ const te = this.elements;
29430
+ let tmp;
29431
+ tmp = te[1];
29432
+ te[1] = te[4];
29433
+ te[4] = tmp;
29434
+ tmp = te[2];
29435
+ te[2] = te[8];
29436
+ te[8] = tmp;
29437
+ tmp = te[6];
29438
+ te[6] = te[9];
29439
+ te[9] = tmp;
29440
+ tmp = te[3];
29441
+ te[3] = te[12];
29442
+ te[12] = tmp;
29443
+ tmp = te[7];
29444
+ te[7] = te[13];
29445
+ te[13] = tmp;
29446
+ tmp = te[11];
29447
+ te[11] = te[14];
29448
+ te[14] = tmp;
29449
+ return this;
29450
+ }
29451
+ setPosition(x, y, z2) {
29452
+ const te = this.elements;
29453
+ if (x.isVector3) {
29454
+ te[12] = x.x;
29455
+ te[13] = x.y;
29456
+ te[14] = x.z;
29457
+ } else {
29458
+ te[12] = x;
29459
+ te[13] = y;
29460
+ te[14] = z2;
29461
+ }
29462
+ return this;
29463
+ }
29464
+ invert() {
29465
+ const te = this.elements, n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3], n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7], n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11], n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15], t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
29466
+ const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
29467
+ if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
29468
+ const detInv = 1 / det;
29469
+ te[0] = t11 * detInv;
29470
+ te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
29471
+ te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
29472
+ te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
29473
+ te[4] = t12 * detInv;
29474
+ te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
29475
+ te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
29476
+ te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
29477
+ te[8] = t13 * detInv;
29478
+ te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
29479
+ te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
29480
+ te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
29481
+ te[12] = t14 * detInv;
29482
+ te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
29483
+ te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
29484
+ te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
29485
+ return this;
29486
+ }
29487
+ scale(v) {
29488
+ const te = this.elements;
29489
+ const x = v.x, y = v.y, z2 = v.z;
29490
+ te[0] *= x;
29491
+ te[4] *= y;
29492
+ te[8] *= z2;
29493
+ te[1] *= x;
29494
+ te[5] *= y;
29495
+ te[9] *= z2;
29496
+ te[2] *= x;
29497
+ te[6] *= y;
29498
+ te[10] *= z2;
29499
+ te[3] *= x;
29500
+ te[7] *= y;
29501
+ te[11] *= z2;
29502
+ return this;
29503
+ }
29504
+ getMaxScaleOnAxis() {
29505
+ const te = this.elements;
29506
+ const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
29507
+ const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
29508
+ const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
29509
+ return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
29510
+ }
29511
+ makeTranslation(x, y, z2) {
29512
+ if (x.isVector3) {
29513
+ this.set(
29514
+ 1,
29515
+ 0,
29516
+ 0,
29517
+ x.x,
29518
+ 0,
29519
+ 1,
29520
+ 0,
29521
+ x.y,
29522
+ 0,
29523
+ 0,
29524
+ 1,
29525
+ x.z,
29526
+ 0,
29527
+ 0,
29528
+ 0,
29529
+ 1
29530
+ );
29531
+ } else {
29532
+ this.set(
29533
+ 1,
29534
+ 0,
29535
+ 0,
29536
+ x,
29537
+ 0,
29538
+ 1,
29539
+ 0,
29540
+ y,
29541
+ 0,
29542
+ 0,
29543
+ 1,
29544
+ z2,
29545
+ 0,
29546
+ 0,
29547
+ 0,
29548
+ 1
29549
+ );
29550
+ }
29551
+ return this;
29552
+ }
29553
+ makeRotationX(theta) {
29554
+ const c = Math.cos(theta), s = Math.sin(theta);
29555
+ this.set(
29556
+ 1,
29557
+ 0,
29558
+ 0,
29559
+ 0,
29560
+ 0,
29561
+ c,
29562
+ -s,
29563
+ 0,
29564
+ 0,
29565
+ s,
29566
+ c,
29567
+ 0,
29568
+ 0,
29569
+ 0,
29570
+ 0,
29571
+ 1
29572
+ );
29573
+ return this;
29574
+ }
29575
+ makeRotationY(theta) {
29576
+ const c = Math.cos(theta), s = Math.sin(theta);
29577
+ this.set(
29578
+ c,
29579
+ 0,
29580
+ s,
29581
+ 0,
29582
+ 0,
29583
+ 1,
29584
+ 0,
29585
+ 0,
29586
+ -s,
29587
+ 0,
29588
+ c,
29589
+ 0,
29590
+ 0,
29591
+ 0,
29592
+ 0,
29593
+ 1
29594
+ );
29595
+ return this;
29596
+ }
29597
+ makeRotationZ(theta) {
29598
+ const c = Math.cos(theta), s = Math.sin(theta);
29599
+ this.set(
29600
+ c,
29601
+ -s,
29602
+ 0,
29603
+ 0,
29604
+ s,
29605
+ c,
29606
+ 0,
29607
+ 0,
29608
+ 0,
29609
+ 0,
29610
+ 1,
29611
+ 0,
29612
+ 0,
29613
+ 0,
29614
+ 0,
29615
+ 1
29616
+ );
29617
+ return this;
29618
+ }
29619
+ makeRotationAxis(axis, angle) {
29620
+ const c = Math.cos(angle);
29621
+ const s = Math.sin(angle);
29622
+ const t = 1 - c;
29623
+ const x = axis.x, y = axis.y, z2 = axis.z;
29624
+ const tx = t * x, ty = t * y;
29625
+ this.set(
29626
+ tx * x + c,
29627
+ tx * y - s * z2,
29628
+ tx * z2 + s * y,
29629
+ 0,
29630
+ tx * y + s * z2,
29631
+ ty * y + c,
29632
+ ty * z2 - s * x,
29633
+ 0,
29634
+ tx * z2 - s * y,
29635
+ ty * z2 + s * x,
29636
+ t * z2 * z2 + c,
29637
+ 0,
29638
+ 0,
29639
+ 0,
29640
+ 0,
29641
+ 1
29642
+ );
29643
+ return this;
29644
+ }
29645
+ makeScale(x, y, z2) {
29646
+ this.set(
29647
+ x,
29648
+ 0,
29649
+ 0,
29650
+ 0,
29651
+ 0,
29652
+ y,
29653
+ 0,
29654
+ 0,
29655
+ 0,
29656
+ 0,
29657
+ z2,
29658
+ 0,
29659
+ 0,
29660
+ 0,
29661
+ 0,
29662
+ 1
29663
+ );
29664
+ return this;
29665
+ }
29666
+ makeShear(xy, xz, yx, yz, zx, zy) {
29667
+ this.set(
29668
+ 1,
29669
+ yx,
29670
+ zx,
29671
+ 0,
29672
+ xy,
29673
+ 1,
29674
+ zy,
29675
+ 0,
29676
+ xz,
29677
+ yz,
29678
+ 1,
29679
+ 0,
29680
+ 0,
29681
+ 0,
29682
+ 0,
29683
+ 1
29684
+ );
29685
+ return this;
29686
+ }
29687
+ compose(position2, quaternion, scale) {
29688
+ const te = this.elements;
29689
+ const x = quaternion._x, y = quaternion._y, z2 = quaternion._z, w = quaternion._w;
29690
+ const x2 = x + x, y2 = y + y, z22 = z2 + z2;
29691
+ const xx = x * x2, xy = x * y2, xz = x * z22;
29692
+ const yy = y * y2, yz = y * z22, zz = z2 * z22;
29693
+ const wx = w * x2, wy = w * y2, wz = w * z22;
29694
+ const sx = scale.x, sy = scale.y, sz = scale.z;
29695
+ te[0] = (1 - (yy + zz)) * sx;
29696
+ te[1] = (xy + wz) * sx;
29697
+ te[2] = (xz - wy) * sx;
29698
+ te[3] = 0;
29699
+ te[4] = (xy - wz) * sy;
29700
+ te[5] = (1 - (xx + zz)) * sy;
29701
+ te[6] = (yz + wx) * sy;
29702
+ te[7] = 0;
29703
+ te[8] = (xz + wy) * sz;
29704
+ te[9] = (yz - wx) * sz;
29705
+ te[10] = (1 - (xx + yy)) * sz;
29706
+ te[11] = 0;
29707
+ te[12] = position2.x;
29708
+ te[13] = position2.y;
29709
+ te[14] = position2.z;
29710
+ te[15] = 1;
29711
+ return this;
29712
+ }
29713
+ decompose(position2, quaternion, scale) {
29714
+ const te = this.elements;
29715
+ let sx = _v1$5.set(te[0], te[1], te[2]).length();
29716
+ const sy = _v1$5.set(te[4], te[5], te[6]).length();
29717
+ const sz = _v1$5.set(te[8], te[9], te[10]).length();
29718
+ const det = this.determinant();
29719
+ if (det < 0) sx = -sx;
29720
+ position2.x = te[12];
29721
+ position2.y = te[13];
29722
+ position2.z = te[14];
29723
+ _m1$2.copy(this);
29724
+ const invSX = 1 / sx;
29725
+ const invSY = 1 / sy;
29726
+ const invSZ = 1 / sz;
29727
+ _m1$2.elements[0] *= invSX;
29728
+ _m1$2.elements[1] *= invSX;
29729
+ _m1$2.elements[2] *= invSX;
29730
+ _m1$2.elements[4] *= invSY;
29731
+ _m1$2.elements[5] *= invSY;
29732
+ _m1$2.elements[6] *= invSY;
29733
+ _m1$2.elements[8] *= invSZ;
29734
+ _m1$2.elements[9] *= invSZ;
29735
+ _m1$2.elements[10] *= invSZ;
29736
+ quaternion.setFromRotationMatrix(_m1$2);
29737
+ scale.x = sx;
29738
+ scale.y = sy;
29739
+ scale.z = sz;
29740
+ return this;
29741
+ }
29742
+ makePerspective(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
29743
+ const te = this.elements;
29744
+ const x = 2 * near / (right - left);
29745
+ const y = 2 * near / (top - bottom);
29746
+ const a = (right + left) / (right - left);
29747
+ const b = (top + bottom) / (top - bottom);
29748
+ let c, d;
29749
+ if (coordinateSystem === WebGLCoordinateSystem) {
29750
+ c = -(far + near) / (far - near);
29751
+ d = -2 * far * near / (far - near);
29752
+ } else if (coordinateSystem === WebGPUCoordinateSystem) {
29753
+ c = -far / (far - near);
29754
+ d = -far * near / (far - near);
29755
+ } else {
29756
+ throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + coordinateSystem);
29757
+ }
29758
+ te[0] = x;
29759
+ te[4] = 0;
29760
+ te[8] = a;
29761
+ te[12] = 0;
29762
+ te[1] = 0;
29763
+ te[5] = y;
29764
+ te[9] = b;
29765
+ te[13] = 0;
29766
+ te[2] = 0;
29767
+ te[6] = 0;
29768
+ te[10] = c;
29769
+ te[14] = d;
29770
+ te[3] = 0;
29771
+ te[7] = 0;
29772
+ te[11] = -1;
29773
+ te[15] = 0;
29774
+ return this;
29775
+ }
29776
+ makeOrthographic(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
29777
+ const te = this.elements;
29778
+ const w = 1 / (right - left);
29779
+ const h = 1 / (top - bottom);
29780
+ const p = 1 / (far - near);
29781
+ const x = (right + left) * w;
29782
+ const y = (top + bottom) * h;
29783
+ let z2, zInv;
29784
+ if (coordinateSystem === WebGLCoordinateSystem) {
29785
+ z2 = (far + near) * p;
29786
+ zInv = -2 * p;
29787
+ } else if (coordinateSystem === WebGPUCoordinateSystem) {
29788
+ z2 = near * p;
29789
+ zInv = -1 * p;
29790
+ } else {
29791
+ throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + coordinateSystem);
29792
+ }
29793
+ te[0] = 2 * w;
29794
+ te[4] = 0;
29795
+ te[8] = 0;
29796
+ te[12] = -x;
29797
+ te[1] = 0;
29798
+ te[5] = 2 * h;
29799
+ te[9] = 0;
29800
+ te[13] = -y;
29801
+ te[2] = 0;
29802
+ te[6] = 0;
29803
+ te[10] = zInv;
29804
+ te[14] = -z2;
29805
+ te[3] = 0;
29806
+ te[7] = 0;
29807
+ te[11] = 0;
29808
+ te[15] = 1;
29809
+ return this;
29810
+ }
29811
+ equals(matrix) {
29812
+ const te = this.elements;
29813
+ const me = matrix.elements;
29814
+ for (let i = 0; i < 16; i++) {
29815
+ if (te[i] !== me[i]) return false;
29816
+ }
29817
+ return true;
29818
+ }
29819
+ fromArray(array, offset2 = 0) {
29820
+ for (let i = 0; i < 16; i++) {
29821
+ this.elements[i] = array[i + offset2];
29822
+ }
29823
+ return this;
29824
+ }
29825
+ toArray(array = [], offset2 = 0) {
29826
+ const te = this.elements;
29827
+ array[offset2] = te[0];
29828
+ array[offset2 + 1] = te[1];
29829
+ array[offset2 + 2] = te[2];
29830
+ array[offset2 + 3] = te[3];
29831
+ array[offset2 + 4] = te[4];
29832
+ array[offset2 + 5] = te[5];
29833
+ array[offset2 + 6] = te[6];
29834
+ array[offset2 + 7] = te[7];
29835
+ array[offset2 + 8] = te[8];
29836
+ array[offset2 + 9] = te[9];
29837
+ array[offset2 + 10] = te[10];
29838
+ array[offset2 + 11] = te[11];
29839
+ array[offset2 + 12] = te[12];
29840
+ array[offset2 + 13] = te[13];
29841
+ array[offset2 + 14] = te[14];
29842
+ array[offset2 + 15] = te[15];
29843
+ return array;
29844
+ }
29845
+ }
29846
+ const _v1$5 = /* @__PURE__ */ new Vector3();
29847
+ const _m1$2 = /* @__PURE__ */ new Matrix4();
29848
+ const _zero = /* @__PURE__ */ new Vector3(0, 0, 0);
29849
+ const _one = /* @__PURE__ */ new Vector3(1, 1, 1);
29850
+ const _x = /* @__PURE__ */ new Vector3();
29851
+ const _y = /* @__PURE__ */ new Vector3();
29852
+ const _z = /* @__PURE__ */ new Vector3();
29853
+ const _matrix = /* @__PURE__ */ new Matrix4();
29854
+ const _quaternion$3 = /* @__PURE__ */ new Quaternion();
29855
+ class Euler {
29856
+ constructor(x = 0, y = 0, z2 = 0, order = Euler.DEFAULT_ORDER) {
29857
+ this.isEuler = true;
29858
+ this._x = x;
29859
+ this._y = y;
29860
+ this._z = z2;
29861
+ this._order = order;
29862
+ }
29863
+ get x() {
29864
+ return this._x;
29865
+ }
29866
+ set x(value) {
29867
+ this._x = value;
29868
+ this._onChangeCallback();
29869
+ }
29870
+ get y() {
29871
+ return this._y;
29872
+ }
29873
+ set y(value) {
29874
+ this._y = value;
29875
+ this._onChangeCallback();
29876
+ }
29877
+ get z() {
29878
+ return this._z;
29879
+ }
29880
+ set z(value) {
29881
+ this._z = value;
29882
+ this._onChangeCallback();
29883
+ }
29884
+ get order() {
29885
+ return this._order;
29886
+ }
29887
+ set order(value) {
29888
+ this._order = value;
29889
+ this._onChangeCallback();
29890
+ }
29891
+ set(x, y, z2, order = this._order) {
29892
+ this._x = x;
29893
+ this._y = y;
29894
+ this._z = z2;
29895
+ this._order = order;
29896
+ this._onChangeCallback();
29897
+ return this;
29898
+ }
29899
+ clone() {
29900
+ return new this.constructor(this._x, this._y, this._z, this._order);
29901
+ }
29902
+ copy(euler) {
29903
+ this._x = euler._x;
29904
+ this._y = euler._y;
29905
+ this._z = euler._z;
29906
+ this._order = euler._order;
29907
+ this._onChangeCallback();
29908
+ return this;
29909
+ }
29910
+ setFromRotationMatrix(m, order = this._order, update2 = true) {
29911
+ const te = m.elements;
29912
+ const m11 = te[0], m12 = te[4], m13 = te[8];
29913
+ const m21 = te[1], m22 = te[5], m23 = te[9];
29914
+ const m31 = te[2], m32 = te[6], m33 = te[10];
29915
+ switch (order) {
29916
+ case "XYZ":
29917
+ this._y = Math.asin(clamp(m13, -1, 1));
29918
+ if (Math.abs(m13) < 0.9999999) {
29919
+ this._x = Math.atan2(-m23, m33);
29920
+ this._z = Math.atan2(-m12, m11);
29921
+ } else {
29922
+ this._x = Math.atan2(m32, m22);
29923
+ this._z = 0;
29924
+ }
29925
+ break;
29926
+ case "YXZ":
29927
+ this._x = Math.asin(-clamp(m23, -1, 1));
29928
+ if (Math.abs(m23) < 0.9999999) {
29929
+ this._y = Math.atan2(m13, m33);
29930
+ this._z = Math.atan2(m21, m22);
29931
+ } else {
29932
+ this._y = Math.atan2(-m31, m11);
29933
+ this._z = 0;
29934
+ }
29935
+ break;
29936
+ case "ZXY":
29937
+ this._x = Math.asin(clamp(m32, -1, 1));
29938
+ if (Math.abs(m32) < 0.9999999) {
29939
+ this._y = Math.atan2(-m31, m33);
29940
+ this._z = Math.atan2(-m12, m22);
29941
+ } else {
29942
+ this._y = 0;
29943
+ this._z = Math.atan2(m21, m11);
29944
+ }
29945
+ break;
29946
+ case "ZYX":
29947
+ this._y = Math.asin(-clamp(m31, -1, 1));
29948
+ if (Math.abs(m31) < 0.9999999) {
29949
+ this._x = Math.atan2(m32, m33);
29950
+ this._z = Math.atan2(m21, m11);
29951
+ } else {
29952
+ this._x = 0;
29953
+ this._z = Math.atan2(-m12, m22);
29954
+ }
29955
+ break;
29956
+ case "YZX":
29957
+ this._z = Math.asin(clamp(m21, -1, 1));
29958
+ if (Math.abs(m21) < 0.9999999) {
29959
+ this._x = Math.atan2(-m23, m22);
29960
+ this._y = Math.atan2(-m31, m11);
29961
+ } else {
29962
+ this._x = 0;
29963
+ this._y = Math.atan2(m13, m33);
29964
+ }
29965
+ break;
29966
+ case "XZY":
29967
+ this._z = Math.asin(-clamp(m12, -1, 1));
29968
+ if (Math.abs(m12) < 0.9999999) {
29969
+ this._x = Math.atan2(m32, m22);
29970
+ this._y = Math.atan2(m13, m11);
29971
+ } else {
29972
+ this._x = Math.atan2(-m23, m33);
29973
+ this._y = 0;
29974
+ }
29975
+ break;
29976
+ default:
29977
+ console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + order);
29978
+ }
29979
+ this._order = order;
29980
+ if (update2 === true) this._onChangeCallback();
29981
+ return this;
29982
+ }
29983
+ setFromQuaternion(q, order, update2) {
29984
+ _matrix.makeRotationFromQuaternion(q);
29985
+ return this.setFromRotationMatrix(_matrix, order, update2);
29986
+ }
29987
+ setFromVector3(v, order = this._order) {
29988
+ return this.set(v.x, v.y, v.z, order);
29989
+ }
29990
+ reorder(newOrder) {
29991
+ _quaternion$3.setFromEuler(this);
29992
+ return this.setFromQuaternion(_quaternion$3, newOrder);
29993
+ }
29994
+ equals(euler) {
29995
+ return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;
29996
+ }
29997
+ fromArray(array) {
29998
+ this._x = array[0];
29999
+ this._y = array[1];
30000
+ this._z = array[2];
30001
+ if (array[3] !== void 0) this._order = array[3];
30002
+ this._onChangeCallback();
30003
+ return this;
30004
+ }
30005
+ toArray(array = [], offset2 = 0) {
30006
+ array[offset2] = this._x;
30007
+ array[offset2 + 1] = this._y;
30008
+ array[offset2 + 2] = this._z;
30009
+ array[offset2 + 3] = this._order;
30010
+ return array;
30011
+ }
30012
+ _onChange(callback) {
30013
+ this._onChangeCallback = callback;
30014
+ return this;
30015
+ }
30016
+ _onChangeCallback() {
30017
+ }
30018
+ *[Symbol.iterator]() {
30019
+ yield this._x;
30020
+ yield this._y;
30021
+ yield this._z;
30022
+ yield this._order;
30023
+ }
30024
+ }
30025
+ Euler.DEFAULT_ORDER = "XYZ";
30026
+ if (typeof __THREE_DEVTOOLS__ !== "undefined") {
30027
+ __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
30028
+ revision: REVISION
30029
+ } }));
30030
+ }
30031
+ if (typeof window !== "undefined") {
30032
+ if (window.__THREE__) {
30033
+ console.warn("WARNING: Multiple instances of Three.js being imported.");
30034
+ } else {
30035
+ window.__THREE__ = REVISION;
30036
+ }
28544
30037
  }
28545
- function quaternionToEuler([x, y, z2, w]) {
28546
- const thetaX = Math.atan2(2 * (w * x + y * z2), 1 - 2 * (x * x + y * y));
28547
- const sinp = 2 * (w * y - z2 * x);
28548
- const thetaY = Math.abs(sinp) >= 1 ? Math.sign(sinp) * (Math.PI / 2) : Math.asin(sinp);
28549
- return [thetaX * (180 / Math.PI), thetaY * (180 / Math.PI)];
28550
- }
28551
- function eulerToQuaternion(thetaX, thetaY) {
28552
- const halfThetaX = thetaX / 2;
28553
- const halfThetaY = thetaY / 2;
28554
- const sinX = Math.sin(halfThetaX);
28555
- const cosX = Math.cos(halfThetaX);
28556
- const sinY = Math.sin(halfThetaY);
28557
- const cosY = Math.cos(halfThetaY);
30038
+ const EPSILON_KEYS_MAPPING_NG = {
30039
+ projectionScale: 100,
30040
+ projectionOrientation: 0.02,
30041
+ position: 1
30042
+ };
30043
+ const SOFT_POS_FACTOR = 0.15;
30044
+ const Q_Y_UP = [1, 0, 0, 0];
30045
+ const multiplyQuat = (a, b) => {
30046
+ const [ax, ay, az, aw] = a;
30047
+ const [bx, by, bz, bw] = b;
28558
30048
  return [
28559
- sinX * cosY,
28560
- cosX * sinY,
28561
- sinX * sinY,
28562
- cosX * cosY
30049
+ aw * bx + ax * bw + ay * bz - az * by,
30050
+ aw * by - ax * bz + ay * bw + az * bx,
30051
+ aw * bz + ax * by - ay * bx + az * bw,
30052
+ aw * bw - ax * bx - ay * by - az * bz
28563
30053
  ];
30054
+ };
30055
+ const conjQuat = (q) => [-q[0], -q[1], -q[2], q[3]];
30056
+ const rad2deg = (r) => r * 180 / Math.PI;
30057
+ const deg2rad = (d) => d * Math.PI / 180;
30058
+ function isValidState(viewerState) {
30059
+ const { projectionScale, projectionOrientation, position: position2, dimensions } = viewerState || {};
30060
+ return dimensions !== void 0 && typeof projectionScale === "number" && Array.isArray(projectionOrientation) && projectionOrientation.length === 4 && Array.isArray(position2) && position2.length === 3;
28564
30061
  }
28565
- function normalizeQuaternion(q) {
28566
- const length2 = Math.sqrt(q[0] ** 2 + q[1] ** 2 + q[2] ** 2 + q[3] ** 2);
28567
- return q.map((value) => value / length2);
30062
+ function valueGreaterThanEpsilon(a, b, epsilon) {
30063
+ if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {
30064
+ return a.some((val, i) => Math.abs(val - b[i]) > epsilon);
30065
+ }
30066
+ if (typeof a === "number" && typeof b === "number") {
30067
+ return Math.abs(a - b) > epsilon;
30068
+ }
30069
+ return void 0;
30070
+ }
30071
+ const nearEq = (a, b, epsilon) => Number.isFinite(a) && Number.isFinite(b) ? Math.abs(a - b) <= epsilon : a === b;
30072
+ function diffCameraState(prev2, next2) {
30073
+ if (!isValidState(next2)) return { changed: false, scale: false, pos: false, rot: false };
30074
+ const eps = EPSILON_KEYS_MAPPING_NG;
30075
+ const scale = valueGreaterThanEpsilon(
30076
+ prev2 == null ? void 0 : prev2.projectionScale,
30077
+ next2 == null ? void 0 : next2.projectionScale,
30078
+ eps.projectionScale
30079
+ );
30080
+ const posHard = valueGreaterThanEpsilon(prev2 == null ? void 0 : prev2.position, next2 == null ? void 0 : next2.position, eps.position);
30081
+ const rot = valueGreaterThanEpsilon(
30082
+ prev2 == null ? void 0 : prev2.projectionOrientation,
30083
+ next2 == null ? void 0 : next2.projectionOrientation,
30084
+ eps.projectionOrientation
30085
+ );
30086
+ const posSoft = !posHard && scale && valueGreaterThanEpsilon(prev2 == null ? void 0 : prev2.position, next2 == null ? void 0 : next2.position, SOFT_POS_FACTOR);
30087
+ const pos = posHard || posSoft;
30088
+ return { changed: scale || pos || rot, scale, pos, rot };
30089
+ }
30090
+ function quaternionToEuler([x, y, z2, w]) {
30091
+ const quaternion = new Quaternion(x, y, z2, w);
30092
+ const euler = new Euler().setFromQuaternion(quaternion, "YXZ");
30093
+ const pitch = euler.x;
30094
+ const yaw = euler.y;
30095
+ return [pitch, yaw];
30096
+ }
30097
+ function eulerToQuaternion(pitch, yaw, roll = 0) {
30098
+ const euler = new Euler(pitch, yaw, roll, "YXZ");
30099
+ const quaternion = new Quaternion().setFromEuler(euler);
30100
+ return [quaternion.x, quaternion.y, quaternion.z, quaternion.w];
30101
+ }
30102
+ function makeVitNgZoomCalibrator(initialNgProjectionScale, initialDeckZoom = 0) {
30103
+ const base = initialNgProjectionScale / 2 ** -initialDeckZoom;
30104
+ return {
30105
+ base,
30106
+ vitToNgZoom(z2) {
30107
+ return base * 2 ** -z2;
30108
+ },
30109
+ ngToVitZoom(sNg) {
30110
+ return Math.log2(base / sNg);
30111
+ }
30112
+ };
30113
+ }
30114
+ const VITESSCE_INTERACTION_DELAY = 50;
30115
+ const INIT_VIT_ZOOM = -3.6;
30116
+ const ZOOM_EPS = 0.01;
30117
+ const ROTATION_EPS = 1e-3;
30118
+ const TARGET_EPS = 0.5;
30119
+ const NG_ROT_COOLDOWN_MS = 120;
30120
+ const LAST_INTERACTION_SOURCE = {
30121
+ vitessce: "vitessce",
30122
+ neuroglancer: "neuroglancer"
30123
+ };
30124
+ function rgbToHex(rgb) {
30125
+ return typeof rgb === "string" ? rgb : `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}`;
28568
30126
  }
28569
30127
  function NeuroglancerSubscriber(props) {
28570
30128
  const {
@@ -28587,13 +30145,13 @@ function NeuroglancerSubscriber(props) {
28587
30145
  spatialTargetY,
28588
30146
  spatialRotationX,
28589
30147
  spatialRotationY,
28590
- // spatialRotationZ,
28591
- // spatialRotationOrbit,
28592
- // spatialOrbitAxis,
30148
+ spatialRotationZ,
30149
+ spatialRotationOrbit,
30150
+ // spatialOrbitAxis, // always along Y-axis - not used in conversion
28593
30151
  embeddingType: mapping,
30152
+ obsSetColor: cellSetColor,
28594
30153
  obsSetSelection: cellSetSelection,
28595
- additionalObsSets: additionalCellSets,
28596
- obsSetColor: cellSetColor
30154
+ additionalObsSets: additionalCellSets
28597
30155
  }, {
28598
30156
  setAdditionalObsSets: setAdditionalCellSets,
28599
30157
  setObsSetColor: setCellSetColor,
@@ -28603,11 +30161,13 @@ function NeuroglancerSubscriber(props) {
28603
30161
  setSpatialTargetX: setTargetX,
28604
30162
  setSpatialTargetY: setTargetY,
28605
30163
  setSpatialRotationX: setRotationX,
28606
- setSpatialRotationY: setRotationY,
30164
+ // setSpatialRotationY: setRotationY,
28607
30165
  // setSpatialRotationZ: setRotationZ,
28608
- // setSpatialRotationOrbit: setRotationOrbit,
30166
+ setSpatialRotationOrbit: setRotationOrbit,
28609
30167
  setSpatialZoom: setZoom
28610
30168
  }] = useCoordination(COMPONENT_COORDINATION_TYPES[ViewType$1.NEUROGLANCER], coordinationScopes);
30169
+ const latestViewerStateRef = useRef(initialViewerState);
30170
+ const initialRotationPushedRef = useRef(false);
28611
30171
  const { classes } = useStyles();
28612
30172
  const [{ obsSets: cellSets }] = useObsSetsData(
28613
30173
  loaders,
@@ -28625,18 +30185,128 @@ function NeuroglancerSubscriber(props) {
28625
30185
  {},
28626
30186
  { obsType, embeddingType: mapping }
28627
30187
  );
30188
+ const ngRotPushAtRef = useRef(0);
30189
+ const lastInteractionSource = useRef(null);
30190
+ const applyNgUpdateTimeoutRef = useRef(null);
30191
+ const lastNgPushOrientationRef = useRef(null);
30192
+ const initialRenderCalibratorRef = useRef(null);
30193
+ const translationOffsetRef = useRef([0, 0, 0]);
30194
+ const zoomRafRef = useRef(null);
30195
+ const lastNgQuatRef = useRef([0, 0, 0, 1]);
30196
+ const lastNgScaleRef = useRef(null);
30197
+ const lastVitessceRotationRef = useRef({
30198
+ x: spatialRotationX,
30199
+ y: spatialRotationY,
30200
+ z: spatialRotationZ,
30201
+ orbit: spatialRotationOrbit
30202
+ });
30203
+ const prevCoordsRef = useRef({
30204
+ zoom: spatialZoom,
30205
+ rx: spatialRotationX,
30206
+ ry: spatialRotationY,
30207
+ rz: spatialRotationZ,
30208
+ orbit: spatialRotationOrbit,
30209
+ tx: spatialTargetX,
30210
+ ty: spatialTargetY
30211
+ });
30212
+ const mergedCellSets = useMemo(() => mergeObsSets(
30213
+ cellSets,
30214
+ additionalCellSets
30215
+ ), [cellSets, additionalCellSets]);
30216
+ const cellColors = useMemo(() => getCellColors({
30217
+ cellSets: mergedCellSets,
30218
+ cellSetSelection,
30219
+ cellSetColor,
30220
+ obsIndex,
30221
+ theme
30222
+ }), [
30223
+ mergedCellSets,
30224
+ theme,
30225
+ cellSetColor,
30226
+ cellSetSelection,
30227
+ obsIndex
30228
+ ]);
28628
30229
  const handleStateUpdate = useCallback((newState) => {
30230
+ lastInteractionSource.current = LAST_INTERACTION_SOURCE.neuroglancer;
28629
30231
  const { projectionScale, projectionOrientation, position: position2 } = newState;
28630
- setZoom(mapNeuroglancerToVitessce(projectionScale));
28631
- const vitessceEularMapping = quaternionToEuler(projectionOrientation);
28632
- setRotationX(vitessceEularMapping[0]);
28633
- setRotationY(vitessceEularMapping[1]);
28634
- setTargetX(position2[0]);
28635
- setTargetY(position2[1]);
28636
- }, [setZoom, setTargetX, setTargetY, setRotationX, setRotationY]);
30232
+ if (!initialRenderCalibratorRef.current) {
30233
+ if (!Number.isFinite(projectionScale) || projectionScale <= 0) return;
30234
+ const zRef = Number.isFinite(spatialZoom) ? spatialZoom : 0;
30235
+ initialRenderCalibratorRef.current = makeVitNgZoomCalibrator(projectionScale, zRef);
30236
+ const [px = 0, py = 0, pz = 0] = Array.isArray(position2) ? position2 : [0, 0, 0];
30237
+ const tX = Number.isFinite(spatialTargetX) ? spatialTargetX : 0;
30238
+ const tY = Number.isFinite(spatialTargetY) ? spatialTargetY : 0;
30239
+ translationOffsetRef.current = [px - tX, py - tY, pz];
30240
+ const syncedZoom = initialRenderCalibratorRef.current.vitToNgZoom(INIT_VIT_ZOOM);
30241
+ latestViewerStateRef.current = {
30242
+ ...latestViewerStateRef.current,
30243
+ projectionScale: syncedZoom
30244
+ };
30245
+ if (!Number.isFinite(spatialZoom) || Math.abs(spatialZoom - INIT_VIT_ZOOM) > ZOOM_EPS) {
30246
+ setZoom(INIT_VIT_ZOOM);
30247
+ }
30248
+ return;
30249
+ }
30250
+ if (Number.isFinite(projectionScale) && projectionScale > 0) {
30251
+ const vitZoomFromNg = initialRenderCalibratorRef.current.ngToVitZoom(projectionScale);
30252
+ const scaleChanged = lastNgScaleRef.current == null || Math.abs(projectionScale - lastNgScaleRef.current) > 1e-6 * Math.max(1, projectionScale);
30253
+ if (scaleChanged && Number.isFinite(vitZoomFromNg) && Math.abs(vitZoomFromNg - (spatialZoom ?? 0)) > ZOOM_EPS) {
30254
+ if (zoomRafRef.current) cancelAnimationFrame(zoomRafRef.current);
30255
+ zoomRafRef.current = requestAnimationFrame(() => {
30256
+ setZoom(vitZoomFromNg);
30257
+ zoomRafRef.current = null;
30258
+ });
30259
+ }
30260
+ lastNgScaleRef.current = projectionScale;
30261
+ }
30262
+ if (Array.isArray(position2) && position2.length >= 2) {
30263
+ const [px, py] = position2;
30264
+ const [ox, oy] = translationOffsetRef.current;
30265
+ const tx = px - ox;
30266
+ const ty = py - oy;
30267
+ if (Number.isFinite(tx) && Math.abs(tx - (spatialTargetX ?? tx)) > TARGET_EPS) setTargetX(tx);
30268
+ if (Number.isFinite(ty) && Math.abs(ty - (spatialTargetY ?? ty)) > TARGET_EPS) setTargetY(ty);
30269
+ }
30270
+ const quatChanged = valueGreaterThanEpsilon(
30271
+ projectionOrientation,
30272
+ lastNgQuatRef.current,
30273
+ ROTATION_EPS
30274
+ );
30275
+ if (quatChanged) {
30276
+ if (applyNgUpdateTimeoutRef.current) clearTimeout(applyNgUpdateTimeoutRef.current);
30277
+ lastNgPushOrientationRef.current = projectionOrientation;
30278
+ applyNgUpdateTimeoutRef.current = setTimeout(() => {
30279
+ const qVit = multiplyQuat(conjQuat(Q_Y_UP), projectionOrientation);
30280
+ const [pitchRad, yawRad] = quaternionToEuler(qVit);
30281
+ const currPitchRad = deg2rad(spatialRotationX ?? 0);
30282
+ const currYawRad = deg2rad(spatialRotationOrbit ?? 0);
30283
+ if (Math.abs(pitchRad - currPitchRad) > ROTATION_EPS || Math.abs(yawRad - currYawRad) > ROTATION_EPS) {
30284
+ const pitchDeg = rad2deg(pitchRad);
30285
+ const yawDeg = rad2deg(yawRad);
30286
+ lastInteractionSource.current = LAST_INTERACTION_SOURCE.vitessce;
30287
+ setRotationX(pitchDeg);
30288
+ setRotationOrbit(yawDeg);
30289
+ ngRotPushAtRef.current = performance.now();
30290
+ }
30291
+ }, VITESSCE_INTERACTION_DELAY);
30292
+ lastNgQuatRef.current = projectionOrientation;
30293
+ }
30294
+ latestViewerStateRef.current = {
30295
+ ...latestViewerStateRef.current,
30296
+ projectionOrientation,
30297
+ projectionScale,
30298
+ position: position2
30299
+ };
30300
+ }, []);
28637
30301
  const onSegmentClick = useCallback((value) => {
30302
+ var _a;
28638
30303
  if (value) {
28639
- const selectedCellIds = [String(value)];
30304
+ const id = String(value);
30305
+ const selectedCellIds = [id];
30306
+ const alreadySelectedId = (_a = cellSetSelection == null ? void 0 : cellSetSelection.flat()) == null ? void 0 : _a.some((sel) => sel.includes(id));
30307
+ if (alreadySelectedId) {
30308
+ return;
30309
+ }
28640
30310
  setObsSelection(
28641
30311
  selectedCellIds,
28642
30312
  additionalCellSets,
@@ -28657,61 +30327,124 @@ function NeuroglancerSubscriber(props) {
28657
30327
  setCellSetColor,
28658
30328
  setCellSetSelection
28659
30329
  ]);
28660
- const mergedCellSets = useMemo(() => mergeObsSets(
28661
- cellSets,
28662
- additionalCellSets
28663
- ), [cellSets, additionalCellSets]);
28664
- const cellColors = useMemo(() => getCellColors({
28665
- cellSets: mergedCellSets,
28666
- cellSetSelection,
28667
- cellSetColor,
28668
- obsIndex,
28669
- theme
28670
- }), [
28671
- mergedCellSets,
28672
- theme,
28673
- cellSetColor,
28674
- cellSetSelection,
28675
- obsIndex
28676
- ]);
28677
- const rgbToHex = useCallback((rgb) => typeof rgb === "string" ? rgb : `#${rgb.map((c) => c.toString(16).padStart(2, "0")).join("")}`, []);
30330
+ const batchedUpdateTimeoutRef = useRef(null);
30331
+ const [batchedCellColors, setBatchedCellColors] = useState(cellColors);
30332
+ useEffect(() => {
30333
+ if (batchedUpdateTimeoutRef.current) {
30334
+ clearTimeout(batchedUpdateTimeoutRef.current);
30335
+ }
30336
+ batchedUpdateTimeoutRef.current = setTimeout(() => {
30337
+ setBatchedCellColors(cellColors);
30338
+ }, 100);
30339
+ }, [cellColors]);
28678
30340
  const cellColorMapping = useMemo(() => {
28679
- const colorCellMapping = {};
28680
- cellColors.forEach((color2, cell) => {
28681
- colorCellMapping[cell] = rgbToHex(color2);
30341
+ const colorMapping = {};
30342
+ batchedCellColors.forEach((color2, cell) => {
30343
+ colorMapping[cell] = rgbToHex(color2);
28682
30344
  });
28683
- return colorCellMapping;
28684
- }, [cellColors, rgbToHex]);
28685
- const derivedViewerState = useMemo(() => ({
28686
- ...initialViewerState,
28687
- layers: initialViewerState.layers.map((layer, index) => index === 0 ? {
28688
- ...layer,
28689
- segments: Object.keys(cellColorMapping).map(String),
28690
- segmentColors: cellColorMapping
28691
- } : layer)
28692
- }), [cellColorMapping, initialViewerState]);
28693
- const derivedViewerState2 = useMemo(() => {
28694
- if (typeof spatialZoom === "number" && typeof spatialTargetX === "number") {
28695
- const projectionScale = mapVitessceToNeuroglancer(spatialZoom);
28696
- const position2 = [spatialTargetX, spatialTargetY, derivedViewerState.position[2]];
28697
- const projectionOrientation = normalizeQuaternion(
28698
- eulerToQuaternion(spatialRotationX, spatialRotationY)
30345
+ return colorMapping;
30346
+ }, [batchedCellColors]);
30347
+ const derivedViewerState = useMemo(() => {
30348
+ var _a, _b, _c, _d;
30349
+ const { current } = latestViewerStateRef;
30350
+ const nextSegments = Object.keys(cellColorMapping);
30351
+ const prevLayer = ((_a = current == null ? void 0 : current.layers) == null ? void 0 : _a[0]) || {};
30352
+ const prevSegments = prevLayer.segments || [];
30353
+ const { projectionScale, projectionOrientation, position: position2 } = current;
30354
+ const rotChangedNow = !nearEq(spatialRotationX, prevCoordsRef.current.rx, ROTATION_EPS) || !nearEq(spatialRotationY, prevCoordsRef.current.ry, ROTATION_EPS) || !nearEq(spatialRotationZ, prevCoordsRef.current.rz, ROTATION_EPS) || !nearEq(spatialRotationOrbit, prevCoordsRef.current.orbit, ROTATION_EPS);
30355
+ const zoomChangedNow = !nearEq(spatialZoom, prevCoordsRef.current.zoom, ROTATION_EPS);
30356
+ const transChangedNow = !nearEq(spatialTargetX, prevCoordsRef.current.tx, ROTATION_EPS) || !nearEq(spatialTargetY, prevCoordsRef.current.ty, ROTATION_EPS);
30357
+ let nextProjectionScale = projectionScale;
30358
+ let nextPosition = position2;
30359
+ if (typeof spatialZoom === "number" && initialRenderCalibratorRef.current && lastInteractionSource.current !== LAST_INTERACTION_SOURCE.neuroglancer && zoomChangedNow) {
30360
+ const s = initialRenderCalibratorRef.current.vitToNgZoom(spatialZoom);
30361
+ if (Number.isFinite(s) && s > 0) {
30362
+ nextProjectionScale = s;
30363
+ }
30364
+ }
30365
+ const [ox, oy, oz] = translationOffsetRef.current;
30366
+ const [px = 0, py = 0, pz = ((_b = current.position) == null ? void 0 : _b[2]) ?? oz] = current.position || [];
30367
+ const hasVitessceSpatialTarget = Number.isFinite(spatialTargetX) && Number.isFinite(spatialTargetY);
30368
+ if (hasVitessceSpatialTarget && lastInteractionSource.current !== LAST_INTERACTION_SOURCE.neuroglancer && transChangedNow) {
30369
+ const nx = spatialTargetX + ox;
30370
+ const ny = spatialTargetY + oy;
30371
+ if (Math.abs(nx - px) > TARGET_EPS || Math.abs(ny - py) > TARGET_EPS) {
30372
+ nextPosition = [nx, ny, pz];
30373
+ }
30374
+ }
30375
+ const vitessceRotationRaw = eulerToQuaternion(
30376
+ deg2rad(spatialRotationX ?? 0),
30377
+ deg2rad(spatialRotationOrbit ?? 0),
30378
+ deg2rad(spatialRotationZ ?? 0)
30379
+ );
30380
+ const vitessceRotation = multiplyQuat(Q_Y_UP, vitessceRotationRaw);
30381
+ const shouldForceInitialVitPush = !initialRotationPushedRef.current && valueGreaterThanEpsilon(vitessceRotation, projectionOrientation, ROTATION_EPS);
30382
+ const ngFresh = performance.now() - (ngRotPushAtRef.current || 0) < NG_ROT_COOLDOWN_MS;
30383
+ const changedNowOrIInitialVitPush = rotChangedNow || zoomChangedNow || transChangedNow || shouldForceInitialVitPush;
30384
+ const src = ngFresh ? LAST_INTERACTION_SOURCE.neuroglancer : lastInteractionSource.current ?? (changedNowOrIInitialVitPush ? LAST_INTERACTION_SOURCE.vitessce : null);
30385
+ let nextOrientation = projectionOrientation;
30386
+ if (src === LAST_INTERACTION_SOURCE.vitessce) {
30387
+ const rotDiffers = valueGreaterThanEpsilon(
30388
+ vitessceRotation,
30389
+ projectionOrientation,
30390
+ ROTATION_EPS
28699
30391
  );
28700
- return {
28701
- ...derivedViewerState,
28702
- projectionScale,
28703
- position: position2,
28704
- projectionOrientation
28705
- };
28706
- }
28707
- return derivedViewerState;
30392
+ if (rotDiffers) {
30393
+ nextOrientation = vitessceRotation;
30394
+ lastVitessceRotationRef.current = {
30395
+ x: spatialRotationX,
30396
+ y: spatialRotationY,
30397
+ z: spatialRotationZ,
30398
+ orbit: spatialRotationOrbit
30399
+ };
30400
+ initialRotationPushedRef.current = true;
30401
+ const [
30402
+ cx = 0,
30403
+ cy = 0,
30404
+ cz = (nextPosition == null ? void 0 : nextPosition[2]) ?? ((_c = current.position) == null ? void 0 : _c[2]) ?? 0
30405
+ ] = nextPosition || current.position || [];
30406
+ const tX = Number.isFinite(spatialTargetX) ? spatialTargetX : 0;
30407
+ const tY = Number.isFinite(spatialTargetY) ? spatialTargetY : 0;
30408
+ translationOffsetRef.current = [cx - tX, cy - tY, cz];
30409
+ }
30410
+ if (lastInteractionSource.current === LAST_INTERACTION_SOURCE.vitessce) {
30411
+ lastInteractionSource.current = null;
30412
+ }
30413
+ } else if (src === LAST_INTERACTION_SOURCE.neuroglancer) {
30414
+ nextOrientation = lastNgPushOrientationRef.current ?? projectionOrientation;
30415
+ lastInteractionSource.current = null;
30416
+ }
30417
+ const newLayer0 = {
30418
+ ...prevLayer,
30419
+ segments: nextSegments,
30420
+ segmentColors: cellColorMapping
30421
+ };
30422
+ const updated = {
30423
+ ...current,
30424
+ projectionScale: nextProjectionScale,
30425
+ projectionOrientation: nextOrientation,
30426
+ position: nextPosition,
30427
+ layers: prevSegments.length === 0 ? [newLayer0, ...((_d = current == null ? void 0 : current.layers) == null ? void 0 : _d.slice(1)) || []] : current == null ? void 0 : current.layers
30428
+ };
30429
+ latestViewerStateRef.current = updated;
30430
+ prevCoordsRef.current = {
30431
+ zoom: spatialZoom,
30432
+ rx: spatialRotationX,
30433
+ ry: spatialRotationY,
30434
+ rz: spatialRotationZ,
30435
+ orbit: spatialRotationOrbit,
30436
+ tx: spatialTargetX,
30437
+ ty: spatialTargetY
30438
+ };
30439
+ return updated;
28708
30440
  }, [
28709
- derivedViewerState,
30441
+ cellColorMapping,
28710
30442
  spatialZoom,
28711
- spatialTargetX,
28712
- spatialTargetY,
28713
30443
  spatialRotationX,
28714
- spatialRotationY
30444
+ spatialRotationY,
30445
+ spatialRotationZ,
30446
+ spatialTargetX,
30447
+ spatialTargetY
28715
30448
  ]);
28716
30449
  const onSegmentHighlight = useCallback((obsId) => {
28717
30450
  setCellHighlight(String(obsId));
@@ -28730,12 +30463,13 @@ function NeuroglancerSubscriber(props) {
28730
30463
  withPadding: false
28731
30464
  },
28732
30465
  /* @__PURE__ */ React__default.createElement(
28733
- Neuroglancer,
30466
+ NeuroglancerComp,
28734
30467
  {
28735
30468
  classes,
28736
30469
  onSegmentClick,
28737
30470
  onSelectHoveredCoords: onSegmentHighlight,
28738
- viewerState: derivedViewerState2,
30471
+ viewerState: derivedViewerState,
30472
+ cellColorMapping,
28739
30473
  setViewerState: handleStateUpdate
28740
30474
  }
28741
30475
  )
@@ -28743,8 +30477,7 @@ function NeuroglancerSubscriber(props) {
28743
30477
  }
28744
30478
  export {
28745
30479
  NeuroglancerSubscriber as N,
28746
- getAugmentedNamespace as a,
28747
30480
  commonjsGlobal as c,
28748
- getDefaultExportFromCjs as g,
28749
- requirePropTypes as r
30481
+ diffCameraState as d,
30482
+ getDefaultExportFromCjs as g
28750
30483
  };