hilbert-chart-3d 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // Version 0.1.0 hilbert-chart-3d - https://github.com/vasturiano/hilbert-chart-3d
1
+ // Version 0.2.0 hilbert-chart-3d - https://github.com/vasturiano/hilbert-chart-3d
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -486,23 +486,23 @@
486
486
  return debounced;
487
487
  }
488
488
 
489
- function _arrayLikeToArray$2(r, a) {
489
+ function _arrayLikeToArray$1(r, a) {
490
490
  (null == a || a > r.length) && (a = r.length);
491
491
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
492
492
  return n;
493
493
  }
494
- function _arrayWithHoles$2(r) {
494
+ function _arrayWithHoles$1(r) {
495
495
  if (Array.isArray(r)) return r;
496
496
  }
497
- function _classCallCheck$2(a, n) {
497
+ function _classCallCheck$1(a, n) {
498
498
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
499
499
  }
500
- function _createClass$2(e, r, t) {
500
+ function _createClass$1(e, r, t) {
501
501
  return Object.defineProperty(e, "prototype", {
502
502
  writable: false
503
503
  }), e;
504
504
  }
505
- function _iterableToArrayLimit$2(r, l) {
505
+ function _iterableToArrayLimit$1(r, l) {
506
506
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
507
507
  if (null != t) {
508
508
  var e,
@@ -526,28 +526,28 @@
526
526
  return a;
527
527
  }
528
528
  }
529
- function _nonIterableRest$2() {
529
+ function _nonIterableRest$1() {
530
530
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
531
531
  }
532
- function _slicedToArray$2(r, e) {
533
- return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest$2();
532
+ function _slicedToArray$1(r, e) {
533
+ return _arrayWithHoles$1(r) || _iterableToArrayLimit$1(r, e) || _unsupportedIterableToArray$1(r, e) || _nonIterableRest$1();
534
534
  }
535
- function _unsupportedIterableToArray$2(r, a) {
535
+ function _unsupportedIterableToArray$1(r, a) {
536
536
  if (r) {
537
- if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
537
+ if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
538
538
  var t = {}.toString.call(r).slice(8, -1);
539
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
539
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0;
540
540
  }
541
541
  }
542
542
 
543
- var Prop = /*#__PURE__*/_createClass$2(function Prop(name, _ref) {
543
+ var Prop = /*#__PURE__*/_createClass$1(function Prop(name, _ref) {
544
544
  var _ref$default = _ref["default"],
545
545
  defaultVal = _ref$default === void 0 ? null : _ref$default,
546
546
  _ref$triggerUpdate = _ref.triggerUpdate,
547
547
  triggerUpdate = _ref$triggerUpdate === void 0 ? true : _ref$triggerUpdate,
548
548
  _ref$onChange = _ref.onChange,
549
549
  onChange = _ref$onChange === void 0 ? function (newVal, state) {} : _ref$onChange;
550
- _classCallCheck$2(this, Prop);
550
+ _classCallCheck$1(this, Prop);
551
551
  this.name = name;
552
552
  this.defaultVal = defaultVal;
553
553
  this.triggerUpdate = triggerUpdate;
@@ -653,7 +653,7 @@
653
653
 
654
654
  // Link aliases
655
655
  Object.entries(aliases).forEach(function (_ref4) {
656
- var _ref5 = _slicedToArray$2(_ref4, 2),
656
+ var _ref5 = _slicedToArray$1(_ref4, 2),
657
657
  alias = _ref5[0],
658
658
  target = _ref5[1];
659
659
  return comp[alias] = comp[target];
@@ -22410,261 +22410,6 @@
22410
22410
 
22411
22411
  }
22412
22412
 
22413
- let _geometry$2;
22414
-
22415
- const _intersectPoint = /*@__PURE__*/ new Vector3();
22416
- const _worldScale = /*@__PURE__*/ new Vector3();
22417
- const _mvPosition = /*@__PURE__*/ new Vector3();
22418
-
22419
- const _alignedPosition = /*@__PURE__*/ new Vector2();
22420
- const _rotatedPosition = /*@__PURE__*/ new Vector2();
22421
- const _viewWorldMatrix = /*@__PURE__*/ new Matrix4();
22422
-
22423
- const _vA$1 = /*@__PURE__*/ new Vector3();
22424
- const _vB$1 = /*@__PURE__*/ new Vector3();
22425
- const _vC$1 = /*@__PURE__*/ new Vector3();
22426
-
22427
- const _uvA = /*@__PURE__*/ new Vector2();
22428
- const _uvB = /*@__PURE__*/ new Vector2();
22429
- const _uvC = /*@__PURE__*/ new Vector2();
22430
-
22431
- /**
22432
- * A sprite is a plane that always faces towards the camera, generally with a
22433
- * partially transparent texture applied.
22434
- *
22435
- * Sprites do not cast shadows, setting {@link Object3D#castShadow} to `true` will
22436
- * have no effect.
22437
- *
22438
- * ```js
22439
- * const map = new THREE.TextureLoader().load( 'sprite.png' );
22440
- * const material = new THREE.SpriteMaterial( { map: map } );
22441
- *
22442
- * const sprite = new THREE.Sprite( material );
22443
- * scene.add( sprite );
22444
- * ```
22445
- *
22446
- * @augments Object3D
22447
- */
22448
- class Sprite extends Object3D {
22449
-
22450
- /**
22451
- * Constructs a new sprite.
22452
- *
22453
- * @param {(SpriteMaterial|SpriteNodeMaterial)} [material] - The sprite material.
22454
- */
22455
- constructor( material = new SpriteMaterial() ) {
22456
-
22457
- super();
22458
-
22459
- /**
22460
- * This flag can be used for type testing.
22461
- *
22462
- * @type {boolean}
22463
- * @readonly
22464
- * @default true
22465
- */
22466
- this.isSprite = true;
22467
-
22468
- this.type = 'Sprite';
22469
-
22470
- if ( _geometry$2 === undefined ) {
22471
-
22472
- _geometry$2 = new BufferGeometry();
22473
-
22474
- const float32Array = new Float32Array( [
22475
- -0.5, -0.5, 0, 0, 0,
22476
- 0.5, -0.5, 0, 1, 0,
22477
- 0.5, 0.5, 0, 1, 1,
22478
- -0.5, 0.5, 0, 0, 1
22479
- ] );
22480
-
22481
- const interleavedBuffer = new InterleavedBuffer( float32Array, 5 );
22482
-
22483
- _geometry$2.setIndex( [ 0, 1, 2, 0, 2, 3 ] );
22484
- _geometry$2.setAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );
22485
- _geometry$2.setAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) );
22486
-
22487
- }
22488
-
22489
- /**
22490
- * The sprite geometry.
22491
- *
22492
- * @type {BufferGeometry}
22493
- */
22494
- this.geometry = _geometry$2;
22495
-
22496
- /**
22497
- * The sprite material.
22498
- *
22499
- * @type {(SpriteMaterial|SpriteNodeMaterial)}
22500
- */
22501
- this.material = material;
22502
-
22503
- /**
22504
- * The sprite's anchor point, and the point around which the sprite rotates.
22505
- * A value of `(0.5, 0.5)` corresponds to the midpoint of the sprite. A value
22506
- * of `(0, 0)` corresponds to the lower left corner of the sprite.
22507
- *
22508
- * @type {Vector2}
22509
- * @default (0.5,0.5)
22510
- */
22511
- this.center = new Vector2( 0.5, 0.5 );
22512
-
22513
- /**
22514
- * The number of instances of this sprite.
22515
- * Can only be used with {@link WebGPURenderer}.
22516
- *
22517
- * @type {number}
22518
- * @default 1
22519
- */
22520
- this.count = 1;
22521
-
22522
- }
22523
-
22524
- /**
22525
- * Returns `true` if this sprite intersects the given frustum.
22526
- *
22527
- * @param {Frustum|FrustumArray} frustum - The frustum to test.
22528
- * @return {boolean} Whether this sprite intersects the given frustum or not.
22529
- */
22530
- intersectsFrustum( frustum ) {
22531
-
22532
- return frustum.intersectsSprite( this );
22533
-
22534
- }
22535
-
22536
- /**
22537
- * Computes intersection points between a casted ray and this sprite.
22538
- *
22539
- * @param {Raycaster} raycaster - The raycaster.
22540
- * @param {Array<Object>} intersects - The target array that holds the intersection points.
22541
- */
22542
- raycast( raycaster, intersects ) {
22543
-
22544
- if ( raycaster.camera === null ) {
22545
-
22546
- error( 'Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
22547
-
22548
- }
22549
-
22550
- _worldScale.setFromMatrixScale( this.matrixWorld );
22551
-
22552
- _viewWorldMatrix.copy( raycaster.camera.matrixWorld );
22553
- this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld );
22554
-
22555
- _mvPosition.setFromMatrixPosition( this.modelViewMatrix );
22556
-
22557
- if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) {
22558
-
22559
- _worldScale.multiplyScalar( - _mvPosition.z );
22560
-
22561
- }
22562
-
22563
- const rotation = this.material.rotation;
22564
- let sin, cos;
22565
-
22566
- if ( rotation !== 0 ) {
22567
-
22568
- cos = Math.cos( rotation );
22569
- sin = Math.sin( rotation );
22570
-
22571
- }
22572
-
22573
- const center = this.center;
22574
-
22575
- transformVertex( _vA$1.set( -0.5, -0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
22576
- transformVertex( _vB$1.set( 0.5, -0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
22577
- transformVertex( _vC$1.set( 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
22578
-
22579
- _uvA.set( 0, 0 );
22580
- _uvB.set( 1, 0 );
22581
- _uvC.set( 1, 1 );
22582
-
22583
- // check first triangle
22584
- let intersect = raycaster.ray.intersectTriangle( _vA$1, _vB$1, _vC$1, false, _intersectPoint );
22585
-
22586
- if ( intersect === null ) {
22587
-
22588
- // check second triangle
22589
- transformVertex( _vB$1.set( -0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
22590
- _uvB.set( 0, 1 );
22591
-
22592
- intersect = raycaster.ray.intersectTriangle( _vA$1, _vC$1, _vB$1, false, _intersectPoint );
22593
- if ( intersect === null ) {
22594
-
22595
- return;
22596
-
22597
- }
22598
-
22599
- }
22600
-
22601
- const distance = raycaster.ray.origin.distanceTo( _intersectPoint );
22602
-
22603
- if ( distance < raycaster.near || distance > raycaster.far ) return;
22604
-
22605
- intersects.push( {
22606
-
22607
- distance: distance,
22608
- point: _intersectPoint.clone(),
22609
- uv: Triangle.getInterpolation( _intersectPoint, _vA$1, _vB$1, _vC$1, _uvA, _uvB, _uvC, new Vector2() ),
22610
- face: null,
22611
- object: this
22612
-
22613
- } );
22614
-
22615
- }
22616
-
22617
- copy( source, recursive ) {
22618
-
22619
- super.copy( source, recursive );
22620
-
22621
- if ( source.center !== undefined ) this.center.copy( source.center );
22622
-
22623
- this.material = source.material;
22624
-
22625
- return this;
22626
-
22627
- }
22628
-
22629
- toJSON( meta ) {
22630
-
22631
- const data = super.toJSON( meta );
22632
-
22633
- data.object.center = this.center.toArray();
22634
-
22635
- return data;
22636
-
22637
- }
22638
-
22639
- }
22640
-
22641
- function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) {
22642
-
22643
- // compute position in camera space
22644
- _alignedPosition.subVectors( vertexPosition, center ).addScalar( 0.5 ).multiply( scale );
22645
-
22646
- // to check if rotation is not zero
22647
- if ( sin !== undefined ) {
22648
-
22649
- _rotatedPosition.x = ( cos * _alignedPosition.x ) - ( sin * _alignedPosition.y );
22650
- _rotatedPosition.y = ( sin * _alignedPosition.x ) + ( cos * _alignedPosition.y );
22651
-
22652
- } else {
22653
-
22654
- _rotatedPosition.copy( _alignedPosition );
22655
-
22656
- }
22657
-
22658
-
22659
- vertexPosition.copy( mvPosition );
22660
- vertexPosition.x += _rotatedPosition.x;
22661
- vertexPosition.y += _rotatedPosition.y;
22662
-
22663
- // transform to world space
22664
- vertexPosition.applyMatrix4( _viewWorldMatrix );
22665
-
22666
- }
22667
-
22668
22413
  const _vector$7 = /*@__PURE__*/ new Vector3();
22669
22414
  const _segCenter = /*@__PURE__*/ new Vector3();
22670
22415
  const _segDir = /*@__PURE__*/ new Vector3();
@@ -24222,6 +23967,481 @@
24222
23967
 
24223
23968
  }
24224
23969
 
23970
+ /**
23971
+ * An instanced version of a buffer attribute.
23972
+ *
23973
+ * @augments BufferAttribute
23974
+ */
23975
+ class InstancedBufferAttribute extends BufferAttribute {
23976
+
23977
+ /**
23978
+ * Constructs a new instanced buffer attribute.
23979
+ *
23980
+ * @param {TypedArray} array - The array holding the attribute data.
23981
+ * @param {number} itemSize - The item size.
23982
+ * @param {boolean} [normalized=false] - Whether the data are normalized or not.
23983
+ * @param {number} [meshPerAttribute=1] - How often a value of this buffer attribute should be repeated.
23984
+ */
23985
+ constructor( array, itemSize, normalized, meshPerAttribute = 1 ) {
23986
+
23987
+ super( array, itemSize, normalized );
23988
+
23989
+ /**
23990
+ * This flag can be used for type testing.
23991
+ *
23992
+ * @type {boolean}
23993
+ * @readonly
23994
+ * @default true
23995
+ */
23996
+ this.isInstancedBufferAttribute = true;
23997
+
23998
+ /**
23999
+ * Defines how often a value of this buffer attribute should be repeated. A
24000
+ * value of one means that each value of the instanced attribute is used for
24001
+ * a single instance. A value of two means that each value is used for two
24002
+ * consecutive instances (and so on).
24003
+ *
24004
+ * @type {number}
24005
+ * @default 1
24006
+ */
24007
+ this.meshPerAttribute = meshPerAttribute;
24008
+
24009
+ }
24010
+
24011
+ copy( source ) {
24012
+
24013
+ super.copy( source );
24014
+
24015
+ this.meshPerAttribute = source.meshPerAttribute;
24016
+
24017
+ return this;
24018
+
24019
+ }
24020
+
24021
+ toJSON() {
24022
+
24023
+ const data = super.toJSON();
24024
+
24025
+ data.meshPerAttribute = this.meshPerAttribute;
24026
+
24027
+ data.isInstancedBufferAttribute = true;
24028
+
24029
+ return data;
24030
+
24031
+ }
24032
+
24033
+ }
24034
+
24035
+ const _instanceLocalMatrix = /*@__PURE__*/ new Matrix4();
24036
+ const _instanceWorldMatrix = /*@__PURE__*/ new Matrix4();
24037
+
24038
+ const _instanceIntersects = [];
24039
+
24040
+ const _box3 = /*@__PURE__*/ new Box3();
24041
+ const _identity = /*@__PURE__*/ new Matrix4();
24042
+ const _mesh$1 = /*@__PURE__*/ new Mesh();
24043
+ const _sphere$4 = /*@__PURE__*/ new Sphere();
24044
+
24045
+ /**
24046
+ * A special version of a mesh with instanced rendering support. Use
24047
+ * this class if you have to render a large number of objects with the same
24048
+ * geometry and material(s) but with different world transformations. The usage
24049
+ * of 'InstancedMesh' will help you to reduce the number of draw calls and thus
24050
+ * improve the overall rendering performance in your application.
24051
+ *
24052
+ * @augments Mesh
24053
+ */
24054
+ class InstancedMesh extends Mesh {
24055
+
24056
+ /**
24057
+ * Constructs a new instanced mesh.
24058
+ *
24059
+ * @param {BufferGeometry} [geometry] - The mesh geometry.
24060
+ * @param {Material|Array<Material>} [material] - The mesh material.
24061
+ * @param {number} count - The number of instances.
24062
+ */
24063
+ constructor( geometry, material, count ) {
24064
+
24065
+ super( geometry, material );
24066
+
24067
+ /**
24068
+ * This flag can be used for type testing.
24069
+ *
24070
+ * @type {boolean}
24071
+ * @readonly
24072
+ * @default true
24073
+ */
24074
+ this.isInstancedMesh = true;
24075
+
24076
+ /**
24077
+ * Represents the local transformation of all instances. You have to set its
24078
+ * {@link BufferAttribute#needsUpdate} flag to true if you modify instanced data
24079
+ * via {@link InstancedMesh#setMatrixAt}.
24080
+ *
24081
+ * @type {InstancedBufferAttribute}
24082
+ */
24083
+ this.instanceMatrix = new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 );
24084
+
24085
+ /**
24086
+ * Represents the color of all instances. You have to set its
24087
+ * {@link BufferAttribute#needsUpdate} flag to true if you modify instanced data
24088
+ * via {@link InstancedMesh#setColorAt}.
24089
+ *
24090
+ * @type {?InstancedBufferAttribute}
24091
+ * @default null
24092
+ */
24093
+ this.instanceColor = null;
24094
+
24095
+ /**
24096
+ * Represents the morph target weights of all instances. You have to set its
24097
+ * {@link Texture#needsUpdate} flag to true if you modify instanced data
24098
+ * via {@link InstancedMesh#setMorphAt}.
24099
+ *
24100
+ * @type {?DataTexture}
24101
+ * @default null
24102
+ */
24103
+ this.morphTexture = null;
24104
+
24105
+ /**
24106
+ * The number of instances.
24107
+ *
24108
+ * @type {number}
24109
+ */
24110
+ this.count = count;
24111
+
24112
+ /**
24113
+ * The bounding box of the instanced mesh. Can be computed via {@link InstancedMesh#computeBoundingBox}.
24114
+ *
24115
+ * @type {?Box3}
24116
+ * @default null
24117
+ */
24118
+ this.boundingBox = null;
24119
+
24120
+ /**
24121
+ * The bounding sphere of the instanced mesh. Can be computed via {@link InstancedMesh#computeBoundingSphere}.
24122
+ *
24123
+ * @type {?Sphere}
24124
+ * @default null
24125
+ */
24126
+ this.boundingSphere = null;
24127
+
24128
+ for ( let i = 0; i < count; i ++ ) {
24129
+
24130
+ this.setMatrixAt( i, _identity );
24131
+
24132
+ }
24133
+
24134
+ }
24135
+
24136
+ /**
24137
+ * Computes the bounding box of the instanced mesh, and updates {@link InstancedMesh#boundingBox}.
24138
+ * The bounding box is not automatically computed by the engine; this method must be called by your app.
24139
+ * You may need to recompute the bounding box if an instance is transformed via {@link InstancedMesh#setMatrixAt}.
24140
+ */
24141
+ computeBoundingBox() {
24142
+
24143
+ const geometry = this.geometry;
24144
+ const count = this.count;
24145
+
24146
+ if ( this.boundingBox === null ) {
24147
+
24148
+ this.boundingBox = new Box3();
24149
+
24150
+ }
24151
+
24152
+ if ( geometry.boundingBox === null ) {
24153
+
24154
+ geometry.computeBoundingBox();
24155
+
24156
+ }
24157
+
24158
+ this.boundingBox.makeEmpty();
24159
+
24160
+ for ( let i = 0; i < count; i ++ ) {
24161
+
24162
+ this.getMatrixAt( i, _instanceLocalMatrix );
24163
+
24164
+ _box3.copy( geometry.boundingBox ).applyMatrix4( _instanceLocalMatrix );
24165
+
24166
+ this.boundingBox.union( _box3 );
24167
+
24168
+ }
24169
+
24170
+ }
24171
+
24172
+ /**
24173
+ * Computes the bounding sphere of the instanced mesh, and updates {@link InstancedMesh#boundingSphere}
24174
+ * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.
24175
+ * You may need to recompute the bounding sphere if an instance is transformed via {@link InstancedMesh#setMatrixAt}.
24176
+ */
24177
+ computeBoundingSphere() {
24178
+
24179
+ const geometry = this.geometry;
24180
+ const count = this.count;
24181
+
24182
+ if ( this.boundingSphere === null ) {
24183
+
24184
+ this.boundingSphere = new Sphere();
24185
+
24186
+ }
24187
+
24188
+ if ( geometry.boundingSphere === null ) {
24189
+
24190
+ geometry.computeBoundingSphere();
24191
+
24192
+ }
24193
+
24194
+ this.boundingSphere.makeEmpty();
24195
+
24196
+ for ( let i = 0; i < count; i ++ ) {
24197
+
24198
+ this.getMatrixAt( i, _instanceLocalMatrix );
24199
+
24200
+ _sphere$4.copy( geometry.boundingSphere ).applyMatrix4( _instanceLocalMatrix );
24201
+
24202
+ this.boundingSphere.union( _sphere$4 );
24203
+
24204
+ }
24205
+
24206
+ }
24207
+
24208
+ copy( source, recursive ) {
24209
+
24210
+ super.copy( source, recursive );
24211
+
24212
+ this.instanceMatrix.copy( source.instanceMatrix );
24213
+
24214
+ this.morphTexture = source.morphTexture !== null ? source.morphTexture.clone() : null;
24215
+ this.instanceColor = source.instanceColor !== null ? source.instanceColor.clone() : null;
24216
+
24217
+ this.count = source.count;
24218
+
24219
+ this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
24220
+ this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;
24221
+
24222
+ return this;
24223
+
24224
+ }
24225
+
24226
+ /**
24227
+ * Gets the color of the defined instance.
24228
+ *
24229
+ * @param {number} index - The instance index.
24230
+ * @param {Color} color - The target object that is used to store the method's result.
24231
+ * @return {Color} A reference to the target color.
24232
+ */
24233
+ getColorAt( index, color ) {
24234
+
24235
+ if ( this.instanceColor === null ) {
24236
+
24237
+ return color.setRGB( 1, 1, 1 );
24238
+
24239
+ } else {
24240
+
24241
+ return color.fromArray( this.instanceColor.array, index * 3 );
24242
+
24243
+ }
24244
+
24245
+ }
24246
+
24247
+ /**
24248
+ * Gets the local transformation matrix of the defined instance.
24249
+ *
24250
+ * @param {number} index - The instance index.
24251
+ * @param {Matrix4} matrix - The target object that is used to store the method's result.
24252
+ * @return {Matrix4} A reference to the target matrix.
24253
+ */
24254
+ getMatrixAt( index, matrix ) {
24255
+
24256
+ return matrix.fromArray( this.instanceMatrix.array, index * 16 );
24257
+
24258
+ }
24259
+
24260
+ /**
24261
+ * Gets the morph target weights of the defined instance.
24262
+ *
24263
+ * @param {number} index - The instance index.
24264
+ * @param {Mesh} object - The target object that is used to store the method's result.
24265
+ */
24266
+ getMorphAt( index, object ) {
24267
+
24268
+ const objectInfluences = object.morphTargetInfluences;
24269
+
24270
+ const array = this.morphTexture.source.data.data;
24271
+
24272
+ const len = objectInfluences.length + 1; // All influences + the baseInfluenceSum
24273
+
24274
+ const dataIndex = index * len + 1; // Skip the baseInfluenceSum at the beginning
24275
+
24276
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
24277
+
24278
+ objectInfluences[ i ] = array[ dataIndex + i ];
24279
+
24280
+ }
24281
+
24282
+ }
24283
+
24284
+ raycast( raycaster, intersects ) {
24285
+
24286
+ const matrixWorld = this.matrixWorld;
24287
+ const raycastTimes = this.count;
24288
+
24289
+ _mesh$1.geometry = this.geometry;
24290
+ _mesh$1.material = this.material;
24291
+
24292
+ if ( _mesh$1.material === undefined ) return;
24293
+
24294
+ // test with bounding sphere first
24295
+
24296
+ if ( this.boundingSphere === null ) this.computeBoundingSphere();
24297
+
24298
+ _sphere$4.copy( this.boundingSphere );
24299
+ _sphere$4.applyMatrix4( matrixWorld );
24300
+
24301
+ if ( raycaster.ray.intersectsSphere( _sphere$4 ) === false ) return;
24302
+
24303
+ // now test each instance
24304
+
24305
+ for ( let instanceId = 0; instanceId < raycastTimes; instanceId ++ ) {
24306
+
24307
+ // calculate the world matrix for each instance
24308
+
24309
+ this.getMatrixAt( instanceId, _instanceLocalMatrix );
24310
+
24311
+ _instanceWorldMatrix.multiplyMatrices( matrixWorld, _instanceLocalMatrix );
24312
+
24313
+ // the mesh represents this single instance
24314
+
24315
+ _mesh$1.matrixWorld = _instanceWorldMatrix;
24316
+
24317
+ _mesh$1.raycast( raycaster, _instanceIntersects );
24318
+
24319
+ // process the result of raycast
24320
+
24321
+ for ( let i = 0, l = _instanceIntersects.length; i < l; i ++ ) {
24322
+
24323
+ const intersect = _instanceIntersects[ i ];
24324
+ intersect.instanceId = instanceId;
24325
+ intersect.object = this;
24326
+ intersects.push( intersect );
24327
+
24328
+ }
24329
+
24330
+ _instanceIntersects.length = 0;
24331
+
24332
+ }
24333
+
24334
+ }
24335
+
24336
+ /**
24337
+ * Sets the given color to the defined instance. Make sure you set the `needsUpdate` flag of
24338
+ * {@link InstancedMesh#instanceColor} to `true` after updating all the colors.
24339
+ *
24340
+ * @param {number} index - The instance index.
24341
+ * @param {Color} color - The instance color.
24342
+ * @return {InstancedMesh} A reference to this instanced mesh.
24343
+ */
24344
+ setColorAt( index, color ) {
24345
+
24346
+ if ( this.instanceColor === null ) {
24347
+
24348
+ this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ).fill( 1 ), 3 );
24349
+
24350
+ }
24351
+
24352
+ color.toArray( this.instanceColor.array, index * 3 );
24353
+ return this;
24354
+
24355
+ }
24356
+
24357
+ /**
24358
+ * Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of
24359
+ * {@link InstancedMesh#instanceMatrix} to `true` after updating all the matrices.
24360
+ *
24361
+ * @param {number} index - The instance index.
24362
+ * @param {Matrix4} matrix - The local transformation.
24363
+ * @return {InstancedMesh} A reference to this instanced mesh.
24364
+ */
24365
+ setMatrixAt( index, matrix ) {
24366
+
24367
+ matrix.toArray( this.instanceMatrix.array, index * 16 );
24368
+ return this;
24369
+
24370
+ }
24371
+
24372
+ /**
24373
+ * Sets the morph target weights to the defined instance. Make sure you set the `needsUpdate` flag of
24374
+ * {@link InstancedMesh#morphTexture} to `true` after updating all the influences.
24375
+ *
24376
+ * @param {number} index - The instance index.
24377
+ * @param {Mesh} object - A mesh which `morphTargetInfluences` property containing the morph target weights
24378
+ * of a single instance.
24379
+ * @return {InstancedMesh} A reference to this instanced mesh.
24380
+ */
24381
+ setMorphAt( index, object ) {
24382
+
24383
+ const objectInfluences = object.morphTargetInfluences;
24384
+
24385
+ const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
24386
+
24387
+ if ( this.morphTexture === null ) {
24388
+
24389
+ this.morphTexture = new DataTexture( new Float32Array( len * this.count ), len, this.count, RedFormat, FloatType );
24390
+
24391
+ }
24392
+
24393
+ const array = this.morphTexture.source.data.data;
24394
+
24395
+ let morphInfluencesSum = 0;
24396
+
24397
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
24398
+
24399
+ morphInfluencesSum += objectInfluences[ i ];
24400
+
24401
+ }
24402
+
24403
+ const morphBaseInfluence = this.geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
24404
+
24405
+ const dataIndex = len * index;
24406
+
24407
+ array[ dataIndex ] = morphBaseInfluence;
24408
+
24409
+ array.set( objectInfluences, dataIndex + 1 );
24410
+ return this;
24411
+
24412
+ }
24413
+
24414
+ updateMorphTargets() {
24415
+
24416
+ }
24417
+
24418
+ /**
24419
+ * Frees the GPU-related resources allocated by this instance. Call this
24420
+ * method whenever this instance is no longer used in your app.
24421
+ */
24422
+ dispose() {
24423
+
24424
+ super.dispose();
24425
+
24426
+ this.instanceMatrix.dispose();
24427
+
24428
+ if ( this.instanceColor !== null ) {
24429
+
24430
+ this.instanceColor.dispose();
24431
+
24432
+ }
24433
+
24434
+ if ( this.morphTexture !== null ) {
24435
+
24436
+ this.morphTexture.dispose();
24437
+ this.morphTexture = null;
24438
+
24439
+ }
24440
+
24441
+ }
24442
+
24443
+ }
24444
+
24225
24445
  const _sphere$3 = /*@__PURE__*/ new Sphere();
24226
24446
  const _defaultSpriteCenter = /*@__PURE__*/ new Vector2( 0.5, 0.5 );
24227
24447
  const _vector$6 = /*@__PURE__*/ new Vector3();
@@ -25175,48 +25395,6 @@
25175
25395
 
25176
25396
  }
25177
25397
 
25178
- /**
25179
- * Creates a texture from a canvas element.
25180
- *
25181
- * This is almost the same as the base texture class, except that it sets {@link Texture#needsUpdate}
25182
- * to `true` immediately since a canvas can directly be used for rendering.
25183
- *
25184
- * @augments Texture
25185
- */
25186
- class CanvasTexture extends Texture {
25187
-
25188
- /**
25189
- * Constructs a new texture.
25190
- *
25191
- * @param {HTMLCanvasElement} [canvas] - The HTML canvas element.
25192
- * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
25193
- * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
25194
- * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
25195
- * @param {number} [magFilter=LinearFilter] - The mag filter value.
25196
- * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
25197
- * @param {number} [format=RGBAFormat] - The texture format.
25198
- * @param {number} [type=UnsignedByteType] - The texture type.
25199
- * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
25200
- */
25201
- constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
25202
-
25203
- super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
25204
-
25205
- /**
25206
- * This flag can be used for type testing.
25207
- *
25208
- * @type {boolean}
25209
- * @readonly
25210
- * @default true
25211
- */
25212
- this.isCanvasTexture = true;
25213
-
25214
- this.needsUpdate = true;
25215
-
25216
- }
25217
-
25218
- }
25219
-
25220
25398
  /**
25221
25399
  * This class can be used to automatically save the depth information of a
25222
25400
  * rendering into a texture.
@@ -140200,25 +140378,25 @@ var<${access}> ${ name } : ${ structName };`;
140200
140378
  }, _extends.apply(null, arguments);
140201
140379
  }
140202
140380
 
140203
- function _assertThisInitialized$1(e) {
140381
+ function _assertThisInitialized(e) {
140204
140382
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
140205
140383
  return e;
140206
140384
  }
140207
140385
 
140208
- function _setPrototypeOf$1(t, e) {
140209
- return _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
140386
+ function _setPrototypeOf(t, e) {
140387
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
140210
140388
  return t.__proto__ = e, t;
140211
- }, _setPrototypeOf$1(t, e);
140389
+ }, _setPrototypeOf(t, e);
140212
140390
  }
140213
140391
 
140214
140392
  function _inheritsLoose(t, o) {
140215
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf$1(t, o);
140393
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
140216
140394
  }
140217
140395
 
140218
- function _getPrototypeOf$1(t) {
140219
- return _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
140396
+ function _getPrototypeOf(t) {
140397
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
140220
140398
  return t.__proto__ || Object.getPrototypeOf(t);
140221
- }, _getPrototypeOf$1(t);
140399
+ }, _getPrototypeOf(t);
140222
140400
  }
140223
140401
 
140224
140402
  function _isNativeFunction(t) {
@@ -140229,21 +140407,21 @@ var<${access}> ${ name } : ${ structName };`;
140229
140407
  }
140230
140408
  }
140231
140409
 
140232
- function _isNativeReflectConstruct$1() {
140410
+ function _isNativeReflectConstruct() {
140233
140411
  try {
140234
140412
  var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
140235
140413
  } catch (t) {}
140236
- return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct() {
140414
+ return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
140237
140415
  return !!t;
140238
140416
  })();
140239
140417
  }
140240
140418
 
140241
140419
  function _construct(t, e, r) {
140242
- if (_isNativeReflectConstruct$1()) return Reflect.construct.apply(null, arguments);
140420
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
140243
140421
  var o = [null];
140244
140422
  o.push.apply(o, e);
140245
140423
  var p = new (t.bind.apply(t, o))();
140246
- return r && _setPrototypeOf$1(p, r.prototype), p;
140424
+ return r && _setPrototypeOf(p, r.prototype), p;
140247
140425
  }
140248
140426
 
140249
140427
  function _wrapNativeSuper(t) {
@@ -140256,7 +140434,7 @@ var<${access}> ${ name } : ${ structName };`;
140256
140434
  r.set(t, Wrapper);
140257
140435
  }
140258
140436
  function Wrapper() {
140259
- return _construct(t, arguments, _getPrototypeOf$1(this).constructor);
140437
+ return _construct(t, arguments, _getPrototypeOf(this).constructor);
140260
140438
  }
140261
140439
  return Wrapper.prototype = Object.create(t.prototype, {
140262
140440
  constructor: {
@@ -140265,7 +140443,7 @@ var<${access}> ${ name } : ${ structName };`;
140265
140443
  writable: true,
140266
140444
  configurable: true
140267
140445
  }
140268
- }), _setPrototypeOf$1(Wrapper, t);
140446
+ }), _setPrototypeOf(Wrapper, t);
140269
140447
  }, _wrapNativeSuper(t);
140270
140448
  }
140271
140449
 
@@ -140392,7 +140570,7 @@ var<${access}> ${ name } : ${ structName };`;
140392
140570
  }
140393
140571
  _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
140394
140572
  }
140395
- return _assertThisInitialized$1(_this);
140573
+ return _assertThisInitialized(_this);
140396
140574
  }
140397
140575
  return PolishedError;
140398
140576
  }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -143735,7 +143913,7 @@ var<${access}> ${ name } : ${ structName };`;
143735
143913
  }
143736
143914
  };
143737
143915
 
143738
- const three$1 = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
143916
+ const three = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
143739
143917
  : {
143740
143918
  WebGLRenderer,
143741
143919
  Scene,
@@ -143934,7 +144112,7 @@ var<${access}> ${ name } : ${ structName };`;
143934
144112
  if (z !== undefined) camera.position.z = z;
143935
144113
  }
143936
144114
  function setLookAt(lookAt) {
143937
- const lookAtVect = new three$1.Vector3(lookAt.x, lookAt.y, lookAt.z);
144115
+ const lookAtVect = new three.Vector3(lookAt.x, lookAt.y, lookAt.z);
143938
144116
  if (state.controls.enabled && state.controls.target) {
143939
144117
  state.controls.target = lookAtVect;
143940
144118
  } else {
@@ -143943,7 +144121,7 @@ var<${access}> ${ name } : ${ structName };`;
143943
144121
  }
143944
144122
  }
143945
144123
  function getLookAt() {
143946
- return Object.assign(new three$1.Vector3(0, 0, -1e3).applyQuaternion(camera.quaternion).add(camera.position));
144124
+ return Object.assign(new three.Vector3(0, 0, -1e3).applyQuaternion(camera.quaternion).add(camera.position));
143947
144125
  }
143948
144126
  },
143949
144127
  zoomToFit: function (state, transitionDuration = 0, padding = 10, bboxArg, preserveLookDirection) {
@@ -143953,10 +144131,10 @@ var<${access}> ${ name } : ${ structName };`;
143953
144131
  const camera = state.camera;
143954
144132
  if (bbox) {
143955
144133
  camera.updateMatrixWorld();
143956
- const camRight = new three$1.Vector3();
143957
- const camUp = new three$1.Vector3();
143958
- const camForward = new three$1.Vector3();
143959
- const camPos = new three$1.Vector3();
144134
+ const camRight = new three.Vector3();
144135
+ const camUp = new three.Vector3();
144136
+ const camForward = new three.Vector3();
144137
+ const camPos = new three.Vector3();
143960
144138
  camera.getWorldPosition(camPos);
143961
144139
  camera.getWorldDirection(camForward);
143962
144140
  camRight.crossVectors(camForward, camera.up).normalize();
@@ -143964,9 +144142,9 @@ var<${access}> ${ name } : ${ structName };`;
143964
144142
  const paddedFov = (1 - padding * 2 / state.height) * camera.fov;
143965
144143
  const vFovHalf = paddedFov / 2 * (Math.PI / 180);
143966
144144
  const hFovHalf = Math.atan(Math.tan(vFovHalf) * camera.aspect);
143967
- const bboxCenter = new three$1.Vector3((bbox.x[0] + bbox.x[1]) / 2, (bbox.y[0] + bbox.y[1]) / 2, (bbox.z[0] + bbox.z[1]) / 2);
144145
+ const bboxCenter = new three.Vector3((bbox.x[0] + bbox.x[1]) / 2, (bbox.y[0] + bbox.y[1]) / 2, (bbox.z[0] + bbox.z[1]) / 2);
143968
144146
  const center = preserveLookDirection ? camForward.clone().multiplyScalar(camPos.distanceTo(bboxCenter)).add(camPos) : bboxCenter;
143969
- const distance = Math.max(0, ...[new three$1.Vector3(bbox.x[0], bbox.y[0], bbox.z[0]), new three$1.Vector3(bbox.x[0], bbox.y[0], bbox.z[1]), new three$1.Vector3(bbox.x[0], bbox.y[1], bbox.z[0]), new three$1.Vector3(bbox.x[0], bbox.y[1], bbox.z[1]), new three$1.Vector3(bbox.x[1], bbox.y[0], bbox.z[0]), new three$1.Vector3(bbox.x[1], bbox.y[0], bbox.z[1]), new three$1.Vector3(bbox.x[1], bbox.y[1], bbox.z[0]), new three$1.Vector3(bbox.x[1], bbox.y[1], bbox.z[1])].map(corner => {
144147
+ const distance = Math.max(0, ...[new three.Vector3(bbox.x[0], bbox.y[0], bbox.z[0]), new three.Vector3(bbox.x[0], bbox.y[0], bbox.z[1]), new three.Vector3(bbox.x[0], bbox.y[1], bbox.z[0]), new three.Vector3(bbox.x[0], bbox.y[1], bbox.z[1]), new three.Vector3(bbox.x[1], bbox.y[0], bbox.z[0]), new three.Vector3(bbox.x[1], bbox.y[0], bbox.z[1]), new three.Vector3(bbox.x[1], bbox.y[1], bbox.z[0]), new three.Vector3(bbox.x[1], bbox.y[1], bbox.z[1])].map(corner => {
143970
144148
  const localPos = corner.clone().sub(center);
143971
144149
  return Math.max(Math.abs(localPos.dot(camUp)) / Math.tan(vFovHalf), Math.abs(localPos.dot(camRight)) / Math.tan(hFovHalf)) - localPos.dot(camForward);
143972
144150
  }));
@@ -143981,7 +144159,7 @@ var<${access}> ${ name } : ${ structName };`;
143981
144159
  return this;
143982
144160
  },
143983
144161
  getBbox: function (state, objFilter = () => true) {
143984
- const box = new three$1.Box3();
144162
+ const box = new three.Box3();
143985
144163
  const objs = state.objects.filter(objFilter);
143986
144164
  if (!objs.length) return null;
143987
144165
  objs.forEach(obj => box.expandByObject(obj));
@@ -143992,7 +144170,7 @@ var<${access}> ${ name } : ${ structName };`;
143992
144170
  })));
143993
144171
  },
143994
144172
  getScreenCoords: function (state, x, y, z) {
143995
- const vec = new three$1.Vector3(x, y, z);
144173
+ const vec = new three.Vector3(x, y, z);
143996
144174
  vec.project(this.camera()); // project to the camera plane
143997
144175
  return {
143998
144176
  // align relative pos to canvas dimensions
@@ -144001,14 +144179,14 @@ var<${access}> ${ name } : ${ structName };`;
144001
144179
  };
144002
144180
  },
144003
144181
  getSceneCoords: function (state, screenX, screenY, distance = 0) {
144004
- const relCoords = new three$1.Vector2(screenX / state.width * 2 - 1, -(screenY / state.height) * 2 + 1);
144005
- const raycaster = new three$1.Raycaster();
144182
+ const relCoords = new three.Vector2(screenX / state.width * 2 - 1, -(screenY / state.height) * 2 + 1);
144183
+ const raycaster = new three.Raycaster();
144006
144184
  raycaster.setFromCamera(relCoords, state.camera);
144007
- return Object.assign({}, raycaster.ray.at(distance, new three$1.Vector3()));
144185
+ return Object.assign({}, raycaster.ray.at(distance, new three.Vector3()));
144008
144186
  },
144009
144187
  intersectingObjects: function (state, x, y) {
144010
- const relCoords = new three$1.Vector2(x / state.width * 2 - 1, -(y / state.height) * 2 + 1);
144011
- const raycaster = new three$1.Raycaster();
144188
+ const relCoords = new three.Vector2(x / state.width * 2 - 1, -(y / state.height) * 2 + 1);
144189
+ const raycaster = new three.Raycaster();
144012
144190
  raycaster.params.Line.threshold = state.lineHoverPrecision; // set linePrecision
144013
144191
  raycaster.params.Points.threshold = state.pointsHoverPrecision; // set pointsPrecision
144014
144192
  raycaster.setFromCamera(relCoords, state.camera);
@@ -144029,9 +144207,9 @@ var<${access}> ${ name } : ${ structName };`;
144029
144207
  }
144030
144208
  },
144031
144209
  stateInit: () => ({
144032
- scene: new three$1.Scene(),
144033
- camera: new three$1.PerspectiveCamera(),
144034
- timer: new three$1.Timer(),
144210
+ scene: new three.Scene(),
144211
+ camera: new three.PerspectiveCamera(),
144212
+ timer: new three.Timer(),
144035
144213
  tweenGroup: new Group(),
144036
144214
  lastRaycasterCheck: 0
144037
144215
  }),
@@ -144064,7 +144242,7 @@ var<${access}> ${ name } : ${ structName };`;
144064
144242
  state.tooltip = new index$2(state.container);
144065
144243
 
144066
144244
  // Capture pointer coords on move or touchstart
144067
- state.pointerPos = new three$1.Vector2();
144245
+ state.pointerPos = new three.Vector2();
144068
144246
  state.pointerPos.x = -2; // Initialize off canvas
144069
144247
  state.pointerPos.y = -2;
144070
144248
  ['pointermove', 'pointerdown'].forEach(evType => state.container.addEventListener(evType, ev => {
@@ -144124,7 +144302,7 @@ var<${access}> ${ name } : ${ structName };`;
144124
144302
  });
144125
144303
 
144126
144304
  // Setup renderer, camera and controls
144127
- state.renderer = new (useWebGPU ? WebGPURenderer : three$1.WebGLRenderer)(Object.assign({
144305
+ state.renderer = new (useWebGPU ? WebGPURenderer : three.WebGLRenderer)(Object.assign({
144128
144306
  antialias: true,
144129
144307
  alpha: true
144130
144308
  }, rendererConfig));
@@ -144178,7 +144356,7 @@ var<${access}> ${ name } : ${ structName };`;
144178
144356
  state.camera.position.z = 1000;
144179
144357
 
144180
144358
  // add sky
144181
- state.scene.add(state.skysphere = new three$1.Mesh());
144359
+ state.scene.add(state.skysphere = new three.Mesh());
144182
144360
  state.skysphere.visible = false;
144183
144361
  state.loadComplete = state.scene.visible = !waitForLoadComplete;
144184
144362
  window.scene = state.scene;
@@ -144206,12 +144384,12 @@ var<${access}> ${ name } : ${ structName };`;
144206
144384
  state.controls.hasOwnProperty('maxDistance') && changedProps.skyRadius && (state.controls.maxDistance = Math.min(state.controls.maxDistance, state.skyRadius));
144207
144385
  state.camera.far = state.skyRadius * 2.5;
144208
144386
  state.camera.updateProjectionMatrix();
144209
- state.skysphere.geometry = new three$1.SphereGeometry(state.skyRadius);
144387
+ state.skysphere.geometry = new three.SphereGeometry(state.skyRadius);
144210
144388
  }
144211
144389
  if (changedProps.hasOwnProperty('backgroundColor')) {
144212
144390
  let alpha = parseToRgb(state.backgroundColor).alpha;
144213
144391
  if (alpha === undefined) alpha = 1;
144214
- state.renderer.setClearColor(new three$1.Color(curriedOpacify$1(1, state.backgroundColor)), alpha);
144392
+ state.renderer.setClearColor(new three.Color(curriedOpacify$1(1, state.backgroundColor)), alpha);
144215
144393
  }
144216
144394
  if (changedProps.hasOwnProperty('backgroundImageUrl')) {
144217
144395
  if (!state.backgroundImageUrl) {
@@ -144219,11 +144397,11 @@ var<${access}> ${ name } : ${ structName };`;
144219
144397
  state.skysphere.material.map = null;
144220
144398
  !state.loadComplete && finishLoad();
144221
144399
  } else {
144222
- new three$1.TextureLoader().load(state.backgroundImageUrl, texture => {
144223
- texture.colorSpace = three$1.SRGBColorSpace;
144224
- state.skysphere.material = new three$1.MeshBasicMaterial({
144400
+ new three.TextureLoader().load(state.backgroundImageUrl, texture => {
144401
+ texture.colorSpace = three.SRGBColorSpace;
144402
+ state.skysphere.material = new three.MeshBasicMaterial({
144225
144403
  map: texture,
144226
- side: three$1.BackSide
144404
+ side: three.BackSide
144227
144405
  });
144228
144406
  state.skysphere.visible = true;
144229
144407
 
@@ -144251,14 +144429,14 @@ var<${access}> ${ name } : ${ structName };`;
144251
144429
  }
144252
144430
  });
144253
144431
 
144254
- const CHILD_PERMUTATIONS = [[0, 3, 4, 7, 6, 5, 2, 1], [0, 7, 6, 1, 2, 5, 4, 3], [0, 7, 6, 1, 2, 5, 4, 3], [2, 3, 0, 1, 6, 7, 4, 5], [2, 3, 0, 1, 6, 7, 4, 5], [4, 3, 2, 5, 6, 1, 0, 7], [4, 3, 2, 5, 6, 1, 0, 7], [6, 5, 2, 1, 0, 3, 4, 7]];
144432
+ const CHILD_PERMUTATIONS$1 = [[0, 3, 4, 7, 6, 5, 2, 1], [0, 7, 6, 1, 2, 5, 4, 3], [0, 7, 6, 1, 2, 5, 4, 3], [2, 3, 0, 1, 6, 7, 4, 5], [2, 3, 0, 1, 6, 7, 4, 5], [4, 3, 2, 5, 6, 1, 0, 7], [4, 3, 2, 5, 6, 1, 0, 7], [6, 5, 2, 1, 0, 3, 4, 7]];
144255
144433
  const ORIENTATIONS = [[0, 1, 2, 3, 4, 5, 6, 7]];
144256
144434
  const ORIENTATION_TRANSITIONS = [];
144257
144435
  const ORIENTATION_IDS = new Map([[ORIENTATIONS[0].join(''), 0]]);
144258
144436
  for (let i = 0; i < ORIENTATIONS.length; i++) {
144259
144437
  const orientation = ORIENTATIONS[i];
144260
144438
  const transitions = [];
144261
- for (const permutation of CHILD_PERMUTATIONS) {
144439
+ for (const permutation of CHILD_PERMUTATIONS$1) {
144262
144440
  const childOrientation = permutation.map(index => orientation[index]);
144263
144441
  const key = childOrientation.join('');
144264
144442
  let id = ORIENTATION_IDS.get(key);
@@ -144449,12 +144627,15 @@ var<${access}> ${ name } : ${ structName };`;
144449
144627
  this.boundingSphere = new Sphere(new Vector3(x, y, z), Math.sqrt(3) * halfWidth);
144450
144628
  return;
144451
144629
  }
144452
- const path = points.map((point, index) => {
144630
+ const path = [];
144631
+ for (let index = 0; index < points.length; index++) {
144632
+ const point = points[index];
144453
144633
  if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) {
144454
144634
  throw new TypeError(`points[${index}] must have finite x, y, and z coordinates`);
144455
144635
  }
144456
- return new Vector3(point.x, point.y, point.z);
144457
- }).filter((point, index, list) => index === 0 || point.distanceToSquared(list[index - 1]) > 0);
144636
+ const copy = new Vector3(point.x, point.y, point.z);
144637
+ if (index === 0 || copy.distanceToSquared(path[path.length - 1]) > 0) path.push(copy);
144638
+ }
144458
144639
  this.parameters = {
144459
144640
  points: path.map(point => point.clone()),
144460
144641
  width
@@ -144465,9 +144646,33 @@ var<${access}> ${ name } : ${ structName };`;
144465
144646
  this.setAttribute('uv', new Float32BufferAttribute([], 2));
144466
144647
  return;
144467
144648
  }
144468
- const directions = path.slice(1).map((point, index) => point.clone().sub(path[index]).normalize());
144649
+ if (path.length === 1) {
144650
+ const [x, y, z] = path[0].toArray();
144651
+ const halfWidth = width / 2;
144652
+ const positions = new Float32Array(24 * 3);
144653
+ let positionOffset = 0;
144654
+ for (const face of SINGLE_CUBE_FACES) {
144655
+ for (const corner of face) {
144656
+ const signs = SINGLE_CUBE_CORNERS[corner];
144657
+ positions[positionOffset++] = x + signs[0] * halfWidth;
144658
+ positions[positionOffset++] = y + signs[1] * halfWidth;
144659
+ positions[positionOffset++] = z + signs[2] * halfWidth;
144660
+ }
144661
+ }
144662
+ this.setIndex(new Uint16BufferAttribute(SINGLE_CUBE_INDICES.slice(), 1));
144663
+ this.setAttribute('position', new Float32BufferAttribute(positions, 3));
144664
+ this.setAttribute('uv', new Float32BufferAttribute(SINGLE_CUBE_UVS.slice(), 2));
144665
+ this.setAttribute('normal', new Float32BufferAttribute(SINGLE_CUBE_NORMALS.slice(), 3));
144666
+ this.computeBoundingBox();
144667
+ this.computeBoundingSphere();
144668
+ return;
144669
+ }
144670
+ const directions = new Array(path.length - 1);
144671
+ for (let i = 0; i < directions.length; i++) {
144672
+ directions[i] = path[i + 1].clone().sub(path[i]).normalize();
144673
+ }
144469
144674
  const turnTolerance = 1e-6;
144470
- let turnCount = 0;
144675
+ const isClosed = path.length > 2 && path[0].distanceToSquared(path[path.length - 1]) === 0;
144471
144676
  for (let i = 1; i < directions.length; i++) {
144472
144677
  const dot = directions[i - 1].dot(directions[i]);
144473
144678
  const isRightAngle = Math.abs(dot) <= turnTolerance;
@@ -144475,10 +144680,21 @@ var<${access}> ${ name } : ${ structName };`;
144475
144680
  if (!isRightAngle && !continuesStraight) {
144476
144681
  throw new RangeError('path turns must be 90 degrees; straight segments are also allowed');
144477
144682
  }
144478
- if (isRightAngle) turnCount++;
144479
144683
  }
144684
+ if (isClosed) {
144685
+ const dot = directions[directions.length - 1].dot(directions[0]);
144686
+ if (Math.abs(dot) > turnTolerance && dot < 1 - turnTolerance) {
144687
+ throw new RangeError('path turns must be 90 degrees; straight segments are also allowed');
144688
+ }
144689
+ }
144690
+ const pathDistances = new Float64Array(path.length);
144691
+ for (let i = 1; i < path.length; i++) {
144692
+ pathDistances[i] = pathDistances[i - 1] + path[i].distanceTo(path[i - 1]);
144693
+ }
144694
+ const pathLength = pathDistances[pathDistances.length - 1];
144480
144695
  const halfWidth = width / 2;
144481
- const frames = [];
144696
+ const totalLength = pathLength + (isClosed ? 0 : width);
144697
+ const frames = new Array(directions.length);
144482
144698
  const normal = new Vector3();
144483
144699
  const binormal = new Vector3();
144484
144700
  const rotation = new Quaternion();
@@ -144496,67 +144712,137 @@ var<${access}> ${ name } : ${ structName };`;
144496
144712
  normal.addScaledVector(directions[i], -normal.dot(directions[i])).normalize();
144497
144713
  }
144498
144714
  binormal.crossVectors(directions[i], normal).normalize();
144499
- frames.push({
144715
+ frames[i] = {
144500
144716
  normal: normal.clone(),
144501
144717
  binormal: binormal.clone()
144502
- });
144718
+ };
144503
144719
  }
144504
- const faces = [[0, 1, 5, 4], [1, 2, 6, 5], [2, 3, 7, 6], [3, 0, 4, 7], [0, 3, 2, 1], [4, 5, 6, 7]];
144505
- const solidCount = path.length === 1 ? 1 : directions.length + turnCount;
144506
- const positions = new Float32Array(solidCount * 24 * 3);
144507
- const uvs = new Float32Array(solidCount * 24 * 2);
144508
- const use32BitIndices = solidCount * 24 > 65535;
144720
+ const sideQuadCount = directions.length * 4;
144721
+ const capQuadCount = isClosed ? 0 : 2;
144722
+ const quadCount = sideQuadCount + capQuadCount;
144723
+ const vertexCount = quadCount * 4;
144724
+ const positions = new Float32Array(vertexCount * 3);
144725
+ const uvs = new Float32Array(vertexCount * 2);
144726
+ const use32BitIndices = vertexCount > 65535;
144509
144727
  const IndexAttribute = use32BitIndices ? Uint32BufferAttribute : Uint16BufferAttribute;
144510
- const indices = use32BitIndices ? new Uint32Array(solidCount * 36) : new Uint16Array(solidCount * 36);
144728
+ const indices = use32BitIndices ? new Uint32Array(quadCount * 6) : new Uint16Array(quadCount * 6);
144729
+ const faceCorners = [0, 1, 2, 3];
144730
+ const startRing = Array.from({
144731
+ length: 4
144732
+ }, () => new Vector3());
144733
+ const endRing = Array.from({
144734
+ length: 4
144735
+ }, () => new Vector3());
144736
+ const firstRing = Array.from({
144737
+ length: 4
144738
+ }, () => new Vector3());
144739
+ const edge1 = new Vector3();
144740
+ const edge2 = new Vector3();
144741
+ const faceNormal = new Vector3();
144742
+ const outward = new Vector3();
144743
+ const miterNormal = new Vector3();
144744
+ const offset = new Vector3();
144745
+ const segmentCenter = new Vector3();
144746
+ const quadPoints = [null, null, null, null];
144747
+ const sideUVs = new Float32Array(8);
144748
+ const startCapUVs = new Float32Array([0, 0, 0.75, 0, 0.5, 0, 0.25, 0]);
144749
+ const endCapUVs = new Float32Array([0, 1, 0.25, 1, 0.5, 1, 0.75, 1]);
144511
144750
  let positionOffset = 0;
144512
144751
  let uvOffset = 0;
144513
144752
  let vertexOffset = 0;
144514
144753
  let indexOffset = 0;
144515
- function addSolid(corners) {
144516
- for (const face of faces) {
144517
- for (const cornerIndex of face) {
144518
- const point = corners[cornerIndex];
144519
- positions[positionOffset++] = point.x;
144520
- positions[positionOffset++] = point.y;
144521
- positions[positionOffset++] = point.z;
144522
- uvs[uvOffset++] = cornerIndex % 2;
144523
- uvs[uvOffset++] = Math.floor(cornerIndex / 2) % 2;
144754
+ function getRing(center, frame, direction, nextDirection, ring, extension = 0) {
144755
+ for (let i = 0; i < 4; i++) {
144756
+ const normalSign = i === 0 || i === 3 ? 1 : -1;
144757
+ const binormalSign = i < 2 ? 1 : -1;
144758
+ ring[i].copy(center).addScaledVector(direction, extension * halfWidth).addScaledVector(frame.normal, normalSign * halfWidth).addScaledVector(frame.binormal, binormalSign * halfWidth);
144759
+ }
144760
+ if (nextDirection) {
144761
+ miterNormal.copy(direction).add(nextDirection).normalize();
144762
+ const denominator = miterNormal.dot(direction);
144763
+ for (const corner of ring) {
144764
+ offset.copy(corner).sub(center);
144765
+ corner.addScaledVector(direction, -miterNormal.dot(offset) / denominator);
144524
144766
  }
144525
- indices[indexOffset++] = vertexOffset;
144526
- indices[indexOffset++] = vertexOffset + 1;
144527
- indices[indexOffset++] = vertexOffset + 2;
144528
- indices[indexOffset++] = vertexOffset;
144529
- indices[indexOffset++] = vertexOffset + 2;
144530
- indices[indexOffset++] = vertexOffset + 3;
144531
- vertexOffset += 4;
144532
144767
  }
144533
144768
  }
144534
- if (path.length === 1) {
144535
- const [x, y, z] = path[0].toArray();
144536
- addSolid([new Vector3(x - halfWidth, y - halfWidth, z - halfWidth), new Vector3(x + halfWidth, y - halfWidth, z - halfWidth), new Vector3(x + halfWidth, y + halfWidth, z - halfWidth), new Vector3(x - halfWidth, y + halfWidth, z - halfWidth), new Vector3(x - halfWidth, y - halfWidth, z + halfWidth), new Vector3(x + halfWidth, y - halfWidth, z + halfWidth), new Vector3(x + halfWidth, y + halfWidth, z + halfWidth), new Vector3(x - halfWidth, y + halfWidth, z + halfWidth)]);
144537
- this.setIndex(new IndexAttribute(indices, 1));
144538
- this.setAttribute('position', new Float32BufferAttribute(positions, 3));
144539
- this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));
144540
- this.computeVertexNormals();
144541
- this.computeBoundingBox();
144542
- this.computeBoundingSphere();
144543
- return;
144769
+ function addQuad(corner0, corner1, corner2, corner3, outward, customUVs) {
144770
+ const hasCustomUVs = customUVs !== undefined;
144771
+ edge1.copy(corner1).sub(corner0);
144772
+ edge2.copy(corner2).sub(corner0);
144773
+ if (faceNormal.crossVectors(edge1, edge2).dot(outward) < 0) {
144774
+ const temp = corner1;
144775
+ corner1 = corner3;
144776
+ corner3 = temp;
144777
+ if (hasCustomUVs) {
144778
+ const tempU = customUVs[2];
144779
+ const tempV = customUVs[3];
144780
+ customUVs[2] = customUVs[6];
144781
+ customUVs[3] = customUVs[7];
144782
+ customUVs[6] = tempU;
144783
+ customUVs[7] = tempV;
144784
+ }
144785
+ }
144786
+ quadPoints[0] = corner0;
144787
+ quadPoints[1] = corner1;
144788
+ quadPoints[2] = corner2;
144789
+ quadPoints[3] = corner3;
144790
+ for (let i = 0; i < 4; i++) {
144791
+ const point = quadPoints[i];
144792
+ positions[positionOffset++] = point.x;
144793
+ positions[positionOffset++] = point.y;
144794
+ positions[positionOffset++] = point.z;
144795
+ if (hasCustomUVs) {
144796
+ uvs[uvOffset++] = customUVs[i * 2];
144797
+ uvs[uvOffset++] = customUVs[i * 2 + 1];
144798
+ } else {
144799
+ uvs[uvOffset++] = i === 1 || i === 2 ? 1 : 0;
144800
+ uvs[uvOffset++] = i >= 2 ? 1 : 0;
144801
+ }
144802
+ }
144803
+ indices[indexOffset++] = vertexOffset;
144804
+ indices[indexOffset++] = vertexOffset + 1;
144805
+ indices[indexOffset++] = vertexOffset + 2;
144806
+ indices[indexOffset++] = vertexOffset;
144807
+ indices[indexOffset++] = vertexOffset + 2;
144808
+ indices[indexOffset++] = vertexOffset + 3;
144809
+ vertexOffset += 4;
144544
144810
  }
144545
144811
  for (let i = 0; i < directions.length; i++) {
144546
144812
  const direction = directions[i];
144547
- const start = path[i].clone();
144548
- const end = path[i + 1].clone();
144549
- if (i === 0) start.addScaledVector(direction, -halfWidth);
144550
- if (i === directions.length - 1) end.addScaledVector(direction, halfWidth);
144551
- const sectionCorners = center => [center.clone().addScaledVector(frames[i].normal, halfWidth).addScaledVector(frames[i].binormal, halfWidth), center.clone().addScaledVector(frames[i].normal, -halfWidth).addScaledVector(frames[i].binormal, halfWidth), center.clone().addScaledVector(frames[i].normal, -halfWidth).addScaledVector(frames[i].binormal, -halfWidth), center.clone().addScaledVector(frames[i].normal, halfWidth).addScaledVector(frames[i].binormal, -halfWidth)];
144552
- addSolid([...sectionCorners(start), ...sectionCorners(end)]);
144553
- }
144554
- for (let i = 1; i < path.length - 1; i++) {
144555
- if (Math.abs(directions[i - 1].dot(directions[i])) <= turnTolerance) {
144556
- const [x, y, z] = path[i].toArray();
144557
- addSolid([new Vector3(x - halfWidth, y - halfWidth, z - halfWidth), new Vector3(x + halfWidth, y - halfWidth, z - halfWidth), new Vector3(x + halfWidth, y + halfWidth, z - halfWidth), new Vector3(x - halfWidth, y + halfWidth, z - halfWidth), new Vector3(x - halfWidth, y - halfWidth, z + halfWidth), new Vector3(x + halfWidth, y - halfWidth, z + halfWidth), new Vector3(x + halfWidth, y + halfWidth, z + halfWidth), new Vector3(x - halfWidth, y + halfWidth, z + halfWidth)]);
144813
+ const previousDirection = i > 0 ? directions[i - 1] : isClosed ? directions[directions.length - 1] : undefined;
144814
+ const nextDirection = i < directions.length - 1 ? directions[i + 1] : isClosed ? directions[0] : undefined;
144815
+ const startTurn = previousDirection && Math.abs(previousDirection.dot(direction)) <= turnTolerance ? previousDirection : undefined;
144816
+ const endTurn = nextDirection && Math.abs(direction.dot(nextDirection)) <= turnTolerance ? nextDirection : undefined;
144817
+ getRing(path[i], frames[i], direction, startTurn, startRing, i === 0 && !isClosed ? -1 : 0);
144818
+ getRing(path[i + 1], frames[i], direction, endTurn, endRing, i === directions.length - 1 && !isClosed ? 1 : 0);
144819
+ if (i === 0) {
144820
+ for (let corner = 0; corner < 4; corner++) firstRing[corner].copy(startRing[corner]);
144821
+ }
144822
+ segmentCenter.copy(path[i]).add(path[i + 1]).multiplyScalar(0.5);
144823
+ const startV = i === 0 && !isClosed ? 0 : (pathDistances[i] + (isClosed ? 0 : halfWidth)) / totalLength;
144824
+ const endV = i === directions.length - 1 && !isClosed ? 1 : (pathDistances[i + 1] + (isClosed ? 0 : halfWidth)) / totalLength;
144825
+ for (const a of faceCorners) {
144826
+ const b = (a + 1) % 4;
144827
+ const startU = a / 4;
144828
+ const endU = (a + 1) / 4;
144829
+ sideUVs[0] = startU;
144830
+ sideUVs[1] = startV;
144831
+ sideUVs[2] = endU;
144832
+ sideUVs[3] = startV;
144833
+ sideUVs[4] = endU;
144834
+ sideUVs[5] = endV;
144835
+ sideUVs[6] = startU;
144836
+ sideUVs[7] = endV;
144837
+ outward.copy(startRing[a]).add(startRing[b]).add(endRing[a]).add(endRing[b]).multiplyScalar(0.25).sub(segmentCenter);
144838
+ addQuad(startRing[a], startRing[b], endRing[b], endRing[a], outward, sideUVs);
144558
144839
  }
144559
144840
  }
144841
+ if (!isClosed) {
144842
+ offset.copy(directions[0]).negate();
144843
+ addQuad(firstRing[0], firstRing[3], firstRing[2], firstRing[1], offset, startCapUVs);
144844
+ addQuad(endRing[0], endRing[1], endRing[2], endRing[3], directions[directions.length - 1], endCapUVs);
144845
+ }
144560
144846
  this.setIndex(new IndexAttribute(indices, 1));
144561
144847
  this.setAttribute('position', new Float32BufferAttribute(positions, 3));
144562
144848
  this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));
@@ -144581,6 +144867,15 @@ var<${access}> ${ name } : ${ structName };`;
144581
144867
  } = {}) {
144582
144868
  super(...getSuperParams());
144583
144869
  this.type = 'HilbertGeometry';
144870
+ const superParams = this.parameters;
144871
+ this.parameters = {
144872
+ ...superParams,
144873
+ order,
144874
+ start,
144875
+ length,
144876
+ padding,
144877
+ simplifyCurves
144878
+ };
144584
144879
  function getSuperParams() {
144585
144880
  typeof start !== 'bigint' && (start = Math.round(start));
144586
144881
  typeof length !== 'bigint' && (length = Math.round(length));
@@ -144598,482 +144893,18 @@ var<${access}> ${ name } : ${ structName };`;
144598
144893
  return [points, lineWidth];
144599
144894
  }
144600
144895
  }
144601
- }
144602
-
144603
- function _arrayLikeToArray$1(r, a) {
144604
- (null == a || a > r.length) && (a = r.length);
144605
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
144606
- return n;
144607
- }
144608
- function _arrayWithHoles$1(r) {
144609
- if (Array.isArray(r)) return r;
144610
- }
144611
- function _arrayWithoutHoles$1(r) {
144612
- if (Array.isArray(r)) return _arrayLikeToArray$1(r);
144613
- }
144614
- function _assertThisInitialized(e) {
144615
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
144616
- return e;
144617
- }
144618
- function _callSuper(t, o, e) {
144619
- return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
144620
- }
144621
- function _classCallCheck$1(a, n) {
144622
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
144623
- }
144624
- function _defineProperties$1(e, r) {
144625
- for (var t = 0; t < r.length; t++) {
144626
- var o = r[t];
144627
- o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$1(o.key), o);
144896
+ clone() {
144897
+ return new this.constructor(0, 1, 0).copy(this);
144628
144898
  }
144629
- }
144630
- function _createClass$1(e, r, t) {
144631
- return r && _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", {
144632
- writable: false
144633
- }), e;
144634
- }
144635
- function _getPrototypeOf(t) {
144636
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
144637
- return t.__proto__ || Object.getPrototypeOf(t);
144638
- }, _getPrototypeOf(t);
144639
- }
144640
- function _inherits(t, e) {
144641
- if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
144642
- t.prototype = Object.create(e && e.prototype, {
144643
- constructor: {
144644
- value: t,
144645
- writable: true,
144646
- configurable: true
144647
- }
144648
- }), Object.defineProperty(t, "prototype", {
144649
- writable: false
144650
- }), e && _setPrototypeOf(t, e);
144651
- }
144652
- function _isNativeReflectConstruct() {
144653
- try {
144654
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
144655
- } catch (t) {}
144656
- return (_isNativeReflectConstruct = function () {
144657
- return !!t;
144658
- })();
144659
- }
144660
- function _iterableToArray$1(r) {
144661
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
144662
- }
144663
- function _iterableToArrayLimit$1(r, l) {
144664
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
144665
- if (null != t) {
144666
- var e,
144667
- n,
144668
- i,
144669
- u,
144670
- a = [],
144671
- f = true,
144672
- o = false;
144673
- try {
144674
- if (i = (t = t.call(r)).next, 0 === l) {
144675
- if (Object(t) !== t) return;
144676
- f = !1;
144677
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
144678
- } catch (r) {
144679
- o = true, n = r;
144680
- } finally {
144681
- try {
144682
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
144683
- } finally {
144684
- if (o) throw n;
144685
- }
144686
- }
144687
- return a;
144688
- }
144689
- }
144690
- function _nonIterableRest$1() {
144691
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
144692
- }
144693
- function _nonIterableSpread$1() {
144694
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
144695
- }
144696
- function _possibleConstructorReturn(t, e) {
144697
- if (e && ("object" == typeof e || "function" == typeof e)) return e;
144698
- if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
144699
- return _assertThisInitialized(t);
144700
- }
144701
- function _setPrototypeOf(t, e) {
144702
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
144703
- return t.__proto__ = e, t;
144704
- }, _setPrototypeOf(t, e);
144705
- }
144706
- function _slicedToArray$1(r, e) {
144707
- return _arrayWithHoles$1(r) || _iterableToArrayLimit$1(r, e) || _unsupportedIterableToArray$1(r, e) || _nonIterableRest$1();
144708
- }
144709
- function _toConsumableArray$1(r) {
144710
- return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread$1();
144711
- }
144712
- function _toPrimitive$1(t, r) {
144713
- if ("object" != typeof t || !t) return t;
144714
- var e = t[Symbol.toPrimitive];
144715
- if (void 0 !== e) {
144716
- var i = e.call(t, r);
144717
- if ("object" != typeof i) return i;
144718
- throw new TypeError("@@toPrimitive must return a primitive value.");
144719
- }
144720
- return (String )(t);
144721
- }
144722
- function _toPropertyKey$1(t) {
144723
- var i = _toPrimitive$1(t, "string");
144724
- return "symbol" == typeof i ? i : i + "";
144725
- }
144726
- function _unsupportedIterableToArray$1(r, a) {
144727
- if (r) {
144728
- if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
144729
- var t = {}.toString.call(r).slice(8, -1);
144730
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0;
144899
+ copy(source) {
144900
+ super.copy(source);
144901
+ this.parameters = Object.assign({}, source.parameters, {
144902
+ points: source.parameters.points.map(point => point.clone())
144903
+ });
144904
+ return this;
144731
144905
  }
144732
144906
  }
144733
144907
 
144734
- var three = typeof window !== 'undefined' && window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
144735
- : {
144736
- CanvasTexture: CanvasTexture,
144737
- Sprite: Sprite,
144738
- SpriteMaterial: SpriteMaterial,
144739
- SRGBColorSpace: SRGBColorSpace
144740
- };
144741
- /*#__PURE__*/(function (_three$Sprite) {
144742
- function _default() {
144743
- var _this;
144744
- var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
144745
- var textHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
144746
- var color = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'rgba(255, 255, 255, 1)';
144747
- _classCallCheck$1(this, _default);
144748
- _this = _callSuper(this, _default, [new three.SpriteMaterial()]);
144749
- _this._text = "".concat(text);
144750
- _this._textHeight = textHeight;
144751
- _this._color = color;
144752
- _this._backgroundColor = false; // no background color
144753
-
144754
- _this._padding = 0;
144755
- _this._borderWidth = 0;
144756
- _this._borderRadius = 0;
144757
- _this._borderColor = 'white';
144758
- _this._offsetX = 0;
144759
- _this._offsetY = 0;
144760
- _this._strokeWidth = 0;
144761
- _this._strokeColor = 'white';
144762
- _this._fontFace = 'system-ui';
144763
- _this._fontSize = 90; // defines text resolution
144764
- _this._fontWeight = 'normal';
144765
- _this._canvas = document.createElement('canvas');
144766
- _this._genCanvas();
144767
- return _this;
144768
- }
144769
- _inherits(_default, _three$Sprite);
144770
- return _createClass$1(_default, [{
144771
- key: "text",
144772
- get: function get() {
144773
- return this._text;
144774
- },
144775
- set: function set(text) {
144776
- this._text = text;
144777
- this._genCanvas();
144778
- }
144779
- }, {
144780
- key: "textHeight",
144781
- get: function get() {
144782
- return this._textHeight;
144783
- },
144784
- set: function set(textHeight) {
144785
- this._textHeight = textHeight;
144786
- this._genCanvas();
144787
- }
144788
- }, {
144789
- key: "color",
144790
- get: function get() {
144791
- return this._color;
144792
- },
144793
- set: function set(color) {
144794
- this._color = color;
144795
- this._genCanvas();
144796
- }
144797
- }, {
144798
- key: "backgroundColor",
144799
- get: function get() {
144800
- return this._backgroundColor;
144801
- },
144802
- set: function set(color) {
144803
- this._backgroundColor = color;
144804
- this._genCanvas();
144805
- }
144806
- }, {
144807
- key: "padding",
144808
- get: function get() {
144809
- return this._padding;
144810
- },
144811
- set: function set(padding) {
144812
- this._padding = padding;
144813
- this._genCanvas();
144814
- }
144815
- }, {
144816
- key: "borderWidth",
144817
- get: function get() {
144818
- return this._borderWidth;
144819
- },
144820
- set: function set(borderWidth) {
144821
- this._borderWidth = borderWidth;
144822
- this._genCanvas();
144823
- }
144824
- }, {
144825
- key: "borderRadius",
144826
- get: function get() {
144827
- return this._borderRadius;
144828
- },
144829
- set: function set(borderRadius) {
144830
- this._borderRadius = borderRadius;
144831
- this._genCanvas();
144832
- }
144833
- }, {
144834
- key: "borderColor",
144835
- get: function get() {
144836
- return this._borderColor;
144837
- },
144838
- set: function set(borderColor) {
144839
- this._borderColor = borderColor;
144840
- this._genCanvas();
144841
- }
144842
- }, {
144843
- key: "offsetX",
144844
- get: function get() {
144845
- return this._offsetX;
144846
- },
144847
- set: function set(offset) {
144848
- this._offsetX = offset;
144849
- this._genCanvas();
144850
- }
144851
- }, {
144852
- key: "offsetY",
144853
- get: function get() {
144854
- return this._offsetY;
144855
- },
144856
- set: function set(offset) {
144857
- this._offsetY = offset;
144858
- this._genCanvas();
144859
- }
144860
- }, {
144861
- key: "fontFace",
144862
- get: function get() {
144863
- return this._fontFace;
144864
- },
144865
- set: function set(fontFace) {
144866
- this._fontFace = fontFace;
144867
- this._genCanvas();
144868
- }
144869
- }, {
144870
- key: "fontSize",
144871
- get: function get() {
144872
- return this._fontSize;
144873
- },
144874
- set: function set(fontSize) {
144875
- this._fontSize = fontSize;
144876
- this._genCanvas();
144877
- }
144878
- }, {
144879
- key: "fontWeight",
144880
- get: function get() {
144881
- return this._fontWeight;
144882
- },
144883
- set: function set(fontWeight) {
144884
- this._fontWeight = fontWeight;
144885
- this._genCanvas();
144886
- }
144887
- }, {
144888
- key: "strokeWidth",
144889
- get: function get() {
144890
- return this._strokeWidth;
144891
- },
144892
- set: function set(strokeWidth) {
144893
- this._strokeWidth = strokeWidth;
144894
- this._genCanvas();
144895
- }
144896
- }, {
144897
- key: "strokeColor",
144898
- get: function get() {
144899
- return this._strokeColor;
144900
- },
144901
- set: function set(strokeColor) {
144902
- this._strokeColor = strokeColor;
144903
- this._genCanvas();
144904
- }
144905
- }, {
144906
- key: "_genCanvas",
144907
- value: function _genCanvas() {
144908
- var _this2 = this;
144909
- var canvas = this._canvas;
144910
- var ctx = canvas.getContext('2d');
144911
- var relFactor = 1 / this.textHeight;
144912
- var border = Array.isArray(this.borderWidth) ? this.borderWidth : [this.borderWidth, this.borderWidth]; // x,y border
144913
- var relBorder = border.map(function (b) {
144914
- return b * _this2.fontSize * relFactor;
144915
- }); // border in canvas units
144916
-
144917
- var borderRadius = Array.isArray(this.borderRadius) ? this.borderRadius : [this.borderRadius, this.borderRadius, this.borderRadius, this.borderRadius]; // tl tr br bl corners
144918
- var relBorderRadius = borderRadius.map(function (b) {
144919
- return b * _this2.fontSize * relFactor;
144920
- }); // border radius in canvas units
144921
-
144922
- var padding = Array.isArray(this.padding) ? this.padding : [this.padding, this.padding]; // x,y padding
144923
- var relPadding = padding.map(function (p) {
144924
- return p * _this2.fontSize * relFactor;
144925
- }); // padding in canvas units
144926
-
144927
- var relOffset = [this.offsetX, this.offsetY].map(function (o) {
144928
- return o * _this2.fontSize * relFactor;
144929
- }); // offset in canvas units
144930
-
144931
- var lines = this.text.split('\n');
144932
- var font = "".concat(this.fontWeight, " ").concat(this.fontSize, "px ").concat(this.fontFace);
144933
- ctx.font = font; // measure canvas with appropriate font
144934
- var innerWidth = Math.max.apply(Math, _toConsumableArray$1(lines.map(function (line) {
144935
- return ctx.measureText(line).width;
144936
- })));
144937
- var innerHeight = this.fontSize * lines.length;
144938
- var boxWidth = innerWidth + relBorder[0] * 2 + relPadding[0] * 2;
144939
- var boxHeight = innerHeight + relBorder[1] * 2 + relPadding[1] * 2;
144940
- canvas.width = boxWidth + Math.abs(relOffset[0]);
144941
- canvas.height = boxHeight + Math.abs(relOffset[1]);
144942
-
144943
- // offset transform (only needed for positive values)
144944
- ctx.translate.apply(ctx, _toConsumableArray$1(relOffset.map(function (o) {
144945
- return Math.max(0, o);
144946
- })));
144947
-
144948
- // paint border
144949
- if (this.borderWidth) {
144950
- ctx.strokeStyle = this.borderColor;
144951
- if (relBorder[0]) {
144952
- // left + right borders
144953
- var hb = relBorder[0] / 2;
144954
- ctx.lineWidth = relBorder[0];
144955
- ctx.beginPath();
144956
- ctx.moveTo(hb, relBorderRadius[0]);
144957
- ctx.lineTo(hb, boxHeight - relBorderRadius[3]);
144958
- ctx.moveTo(boxWidth - hb, relBorderRadius[1]);
144959
- ctx.lineTo(boxWidth - hb, boxHeight - relBorderRadius[2]);
144960
- ctx.stroke();
144961
- }
144962
- if (relBorder[1]) {
144963
- // top + bottom borders
144964
- var _hb = relBorder[1] / 2;
144965
- ctx.lineWidth = relBorder[1];
144966
- ctx.beginPath();
144967
- ctx.moveTo(Math.max(relBorder[0], relBorderRadius[0]), _hb);
144968
- ctx.lineTo(boxWidth - Math.max(relBorder[0], relBorderRadius[1]), _hb);
144969
- ctx.moveTo(Math.max(relBorder[0], relBorderRadius[3]), boxHeight - _hb);
144970
- ctx.lineTo(boxWidth - Math.max(relBorder[0], relBorderRadius[2]), boxHeight - _hb);
144971
- ctx.stroke();
144972
- }
144973
- if (this.borderRadius) {
144974
- // strike rounded corners
144975
- var cornerWidth = Math.max.apply(Math, _toConsumableArray$1(relBorder));
144976
- var _hb2 = cornerWidth / 2;
144977
- ctx.lineWidth = cornerWidth;
144978
- ctx.beginPath();
144979
- [!!relBorderRadius[0] && [relBorderRadius[0], _hb2, _hb2, relBorderRadius[0]], !!relBorderRadius[1] && [boxWidth - relBorderRadius[1], boxWidth - _hb2, _hb2, relBorderRadius[1]], !!relBorderRadius[2] && [boxWidth - relBorderRadius[2], boxWidth - _hb2, boxHeight - _hb2, boxHeight - relBorderRadius[2]], !!relBorderRadius[3] && [relBorderRadius[3], _hb2, boxHeight - _hb2, boxHeight - relBorderRadius[3]]].filter(function (d) {
144980
- return d;
144981
- }).forEach(function (_ref) {
144982
- var _ref2 = _slicedToArray$1(_ref, 4),
144983
- x0 = _ref2[0],
144984
- x1 = _ref2[1],
144985
- y0 = _ref2[2],
144986
- y1 = _ref2[3];
144987
- ctx.moveTo(x0, y0);
144988
- ctx.quadraticCurveTo(x1, y0, x1, y1);
144989
- });
144990
- ctx.stroke();
144991
- }
144992
- }
144993
-
144994
- // paint background
144995
- if (this.backgroundColor) {
144996
- ctx.fillStyle = this.backgroundColor;
144997
- if (!this.borderRadius) {
144998
- ctx.fillRect(relBorder[0], relBorder[1], boxWidth - relBorder[0] * 2, boxHeight - relBorder[1] * 2);
144999
- } else {
145000
- // fill with rounded corners
145001
- ctx.beginPath();
145002
- ctx.moveTo(relBorder[0], relBorderRadius[0]);
145003
- [[relBorder[0], relBorderRadius[0], boxWidth - relBorderRadius[1], relBorder[1], relBorder[1], relBorder[1]],
145004
- // t
145005
- [boxWidth - relBorder[0], boxWidth - relBorder[0], boxWidth - relBorder[0], relBorder[1], relBorderRadius[1], boxHeight - relBorderRadius[2]],
145006
- // r
145007
- [boxWidth - relBorder[0], boxWidth - relBorderRadius[2], relBorderRadius[3], boxHeight - relBorder[1], boxHeight - relBorder[1], boxHeight - relBorder[1]],
145008
- // b
145009
- [relBorder[0], relBorder[0], relBorder[0], boxHeight - relBorder[1], boxHeight - relBorderRadius[3], relBorderRadius[0]] // t
145010
- ].forEach(function (_ref3) {
145011
- var _ref4 = _slicedToArray$1(_ref3, 6),
145012
- x0 = _ref4[0],
145013
- x1 = _ref4[1],
145014
- x2 = _ref4[2],
145015
- y0 = _ref4[3],
145016
- y1 = _ref4[4],
145017
- y2 = _ref4[5];
145018
- ctx.quadraticCurveTo(x0, y0, x1, y1);
145019
- ctx.lineTo(x2, y2);
145020
- });
145021
- ctx.closePath();
145022
- ctx.fill();
145023
- }
145024
- }
145025
- ctx.translate.apply(ctx, _toConsumableArray$1(relBorder));
145026
- ctx.translate.apply(ctx, _toConsumableArray$1(relPadding));
145027
-
145028
- // paint text
145029
- ctx.font = font; // Set font again after canvas is resized, as context properties are reset
145030
- ctx.fillStyle = this.color;
145031
- ctx.textBaseline = 'bottom';
145032
- var drawTextStroke = this.strokeWidth > 0;
145033
- if (drawTextStroke) {
145034
- ctx.lineWidth = this.strokeWidth * this.fontSize / 10;
145035
- ctx.strokeStyle = this.strokeColor;
145036
- }
145037
- lines.forEach(function (line, index) {
145038
- var lineX = (innerWidth - ctx.measureText(line).width) / 2;
145039
- var lineY = (index + 1) * _this2.fontSize;
145040
- drawTextStroke && ctx.strokeText(line, lineX, lineY);
145041
- ctx.fillText(line, lineX, lineY);
145042
- });
145043
-
145044
- // Inject canvas into sprite
145045
- if (this.material.map) this.material.map.dispose(); // gc previous texture
145046
- var texture = this.material.map = new three.CanvasTexture(canvas);
145047
- texture.colorSpace = three.SRGBColorSpace;
145048
- var yScale = this.textHeight * lines.length + border[1] * 2 + padding[1] * 2 + Math.abs(this.offsetY);
145049
- this.scale.set(yScale * canvas.width / canvas.height, yScale, 0);
145050
- }
145051
- }, {
145052
- key: "clone",
145053
- value: function clone() {
145054
- return new this.constructor(this.text, this.textHeight, this.color).copy(this);
145055
- }
145056
- }, {
145057
- key: "copy",
145058
- value: function copy(source) {
145059
- three.Sprite.prototype.copy.call(this, source);
145060
- this.color = source.color;
145061
- this.backgroundColor = source.backgroundColor;
145062
- this.padding = source.padding;
145063
- this.borderWidth = source.borderWidth;
145064
- this.borderColor = source.borderColor;
145065
- this.offsetX = source.offsetX;
145066
- this.offsetY = source.offsetY;
145067
- this.fontFace = source.fontFace;
145068
- this.fontSize = source.fontSize;
145069
- this.fontWeight = source.fontWeight;
145070
- this.strokeWidth = source.strokeWidth;
145071
- this.strokeColor = source.strokeColor;
145072
- return this;
145073
- }
145074
- }]);
145075
- })(three.Sprite);
145076
-
145077
144908
  // https://d3js.org/d3-array/ v3.2.5 Copyright 2010-2026 Mike Bostock
145078
144909
  function ascending(a, b) {
145079
144910
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -147884,6 +147715,278 @@ var<${access}> ${ name } : ${ structName };`;
147884
147715
  const colorStr2Hex = str => isNaN(str) ? parseInt(tinycolor(str).toHex(), 16) : str;
147885
147716
  const colorAlpha = str => str && isNaN(str) ? color(str).opacity : 1;
147886
147717
 
147718
+ const CHILD_PERMUTATIONS = [[0, 3, 4, 7, 6, 5, 2, 1], [0, 7, 6, 1, 2, 5, 4, 3], [0, 7, 6, 1, 2, 5, 4, 3], [2, 3, 0, 1, 6, 7, 4, 5], [2, 3, 0, 1, 6, 7, 4, 5], [4, 3, 2, 5, 6, 1, 0, 7], [4, 3, 2, 5, 6, 1, 0, 7], [6, 5, 2, 1, 0, 3, 4, 7]];
147719
+ const {
147720
+ orientations: HILBERT_ORIENTATIONS,
147721
+ transitions: HILBERT_ORIENTATION_TRANSITIONS
147722
+ } = createOrientationTables();
147723
+ function createOrientationTables() {
147724
+ const orientations = [[0, 1, 2, 3, 4, 5, 6, 7]];
147725
+ const transitions = [];
147726
+ const orientationIds = new Map([[orientations[0].join(''), 0]]);
147727
+ for (let i = 0; i < orientations.length; i++) {
147728
+ const orientation = orientations[i];
147729
+ const childTransitions = [];
147730
+ for (const permutation of CHILD_PERMUTATIONS) {
147731
+ const childOrientation = permutation.map(index => orientation[index]);
147732
+ const key = childOrientation.join('');
147733
+ let id = orientationIds.get(key);
147734
+ if (id === undefined) {
147735
+ id = orientations.length;
147736
+ orientations.push(childOrientation);
147737
+ orientationIds.set(key, id);
147738
+ }
147739
+ childTransitions.push(id);
147740
+ }
147741
+ transitions.push(childTransitions);
147742
+ }
147743
+ return {
147744
+ orientations,
147745
+ transitions
147746
+ };
147747
+ }
147748
+ function createInstancedHilbertMeshes({
147749
+ useInstancing = true,
147750
+ data,
147751
+ order,
147752
+ paddingAccessor,
147753
+ colorAccessor,
147754
+ labelAccessor,
147755
+ defaultColorScale,
147756
+ simplifyCurves,
147757
+ SCALE
147758
+ }) {
147759
+ const instanceMaterialCache = new Map();
147760
+ const geometryCache = new Map();
147761
+ const geometries = new WeakMap();
147762
+ const fallbackData = [];
147763
+ const batches = new Map();
147764
+ const usedGeometryKeys = new Set();
147765
+ data.forEach(d => {
147766
+ const padding = paddingAccessor(d);
147767
+ if (!useInstancing) {
147768
+ geometries.set(d, createGeometry(order, d, padding, simplifyCurves));
147769
+ fallbackData.push(d);
147770
+ return;
147771
+ }
147772
+ const description = getSimpleHilbertGeometry(order, d.start, d.length, padding, simplifyCurves);
147773
+ if (!description) {
147774
+ geometries.set(d, createGeometry(order, d, padding, simplifyCurves));
147775
+ fallbackData.push(d);
147776
+ return;
147777
+ }
147778
+ const color = colorAccessor?.(d) || defaultColorScale(labelAccessor(d) || '');
147779
+ const {
147780
+ points,
147781
+ width,
147782
+ scale
147783
+ } = description;
147784
+ const key = getCurvePath(points);
147785
+ const geometryKey = `${key}|${width / scale}`;
147786
+ usedGeometryKeys.add(geometryKey);
147787
+ let templateGeometry = geometryCache.get(geometryKey);
147788
+ if (!templateGeometry) {
147789
+ const geometry = createGeometry(order, d, padding, simplifyCurves);
147790
+ templateGeometry = createTemplateGeometry(geometry, points[0], scale);
147791
+ geometryCache.set(geometryKey, templateGeometry);
147792
+ geometry.dispose();
147793
+ }
147794
+ let material = instanceMaterialCache.get(color);
147795
+ if (!material) {
147796
+ const opacity = colorAlpha(color);
147797
+ material = new MeshLambertMaterial();
147798
+ material.color.set(colorStr2Hex(color));
147799
+ material.transparent = opacity < 1;
147800
+ material.opacity = opacity;
147801
+ instanceMaterialCache.set(color, material);
147802
+ }
147803
+ let colorBatches = batches.get(geometryKey);
147804
+ if (!colorBatches) {
147805
+ colorBatches = new Map();
147806
+ batches.set(geometryKey, colorBatches);
147807
+ }
147808
+ let batch = colorBatches.get(color);
147809
+ if (!batch) {
147810
+ batch = {
147811
+ geometry: templateGeometry,
147812
+ material,
147813
+ transforms: new Float32Array(256),
147814
+ count: 0,
147815
+ data: []
147816
+ };
147817
+ colorBatches.set(color, batch);
147818
+ }
147819
+ const instanceScale = scale * SCALE;
147820
+ let transforms = batch.transforms;
147821
+ if (batch.count * 4 === transforms.length) {
147822
+ const expandedTransforms = new Float32Array(transforms.length * 2);
147823
+ expandedTransforms.set(transforms);
147824
+ transforms = batch.transforms = expandedTransforms;
147825
+ }
147826
+ const transformOffset = batch.count * 4;
147827
+ transforms[transformOffset] = instanceScale;
147828
+ transforms[transformOffset + 1] = points[0].x * SCALE;
147829
+ transforms[transformOffset + 2] = points[0].y * SCALE;
147830
+ transforms[transformOffset + 3] = points[0].z * SCALE;
147831
+ batch.count++;
147832
+ batch.data.push(d);
147833
+ });
147834
+ geometryCache.forEach((geometry, key) => {
147835
+ if (!usedGeometryKeys.has(key)) {
147836
+ geometry.dispose();
147837
+ geometryCache.delete(key);
147838
+ }
147839
+ });
147840
+ const meshes = [];
147841
+ batches.forEach(colorBatches => {
147842
+ colorBatches.forEach(batch => {
147843
+ const mesh = new InstancedMesh(batch.geometry, batch.material, batch.count);
147844
+ const matrices = mesh.instanceMatrix.array;
147845
+ for (let i = 0; i < batch.count; i++) {
147846
+ const transformOffset = i * 4;
147847
+ const matrixOffset = i * 16;
147848
+ const scale = batch.transforms[transformOffset];
147849
+ matrices[matrixOffset] = scale;
147850
+ matrices[matrixOffset + 5] = scale;
147851
+ matrices[matrixOffset + 10] = scale;
147852
+ matrices[matrixOffset + 12] = batch.transforms[transformOffset + 1];
147853
+ matrices[matrixOffset + 13] = batch.transforms[transformOffset + 2];
147854
+ matrices[matrixOffset + 14] = batch.transforms[transformOffset + 3];
147855
+ matrices[matrixOffset + 15] = 1;
147856
+ }
147857
+ mesh.instanceMatrix.needsUpdate = true;
147858
+ mesh.computeBoundingSphere();
147859
+ mesh.userData.data = batch.data;
147860
+ meshes.push(mesh);
147861
+ });
147862
+ });
147863
+ return {
147864
+ fallbackData,
147865
+ geometries,
147866
+ meshes
147867
+ };
147868
+ }
147869
+ function createGeometry(order, datum, padding, simplifyCurves) {
147870
+ return new ThreeHilbertGeometry(order, datum.start, datum.length, {
147871
+ padding,
147872
+ simplifyCurves
147873
+ });
147874
+ }
147875
+ function createTemplateGeometry(geometry, origin, scale) {
147876
+ const templateGeometry = new BufferGeometry();
147877
+ Object.entries(geometry.attributes).forEach(([name, attribute]) => {
147878
+ templateGeometry.setAttribute(name, attribute.clone());
147879
+ });
147880
+ if (geometry.index) templateGeometry.setIndex(geometry.index.clone());
147881
+ geometry.groups.forEach(group => templateGeometry.addGroup(group.start, group.count, group.materialIndex));
147882
+ templateGeometry.setDrawRange(geometry.drawRange.start, geometry.drawRange.count);
147883
+ const positions = templateGeometry.getAttribute('position');
147884
+ for (let i = 0; i < positions.count; i++) {
147885
+ positions.setXYZ(i, (positions.getX(i) - origin.x) / scale, (positions.getY(i) - origin.y) / scale, (positions.getZ(i) - origin.z) / scale);
147886
+ }
147887
+ positions.needsUpdate = true;
147888
+ templateGeometry.computeBoundingBox();
147889
+ templateGeometry.computeBoundingSphere();
147890
+ return templateGeometry;
147891
+ }
147892
+ function getSimpleHilbertGeometry(order, start, length, padding, simplifyCurves) {
147893
+ const isBigInt = typeof start === 'bigint' && typeof length === 'bigint';
147894
+ if (!Number.isInteger(order) || typeof start === 'bigint' !== (typeof length === 'bigint')) return null;
147895
+ if (!isBigInt && (!Number.isFinite(start) || !Number.isFinite(length))) return null;
147896
+ let pointOrder = order;
147897
+ let first = isBigInt ? start : Math.round(start);
147898
+ let pointCount = isBigInt ? length : Math.round(length);
147899
+ const unit = isBigInt ? 8n : 8;
147900
+ if (simplifyCurves) {
147901
+ while (pointOrder > 0 && first % unit === 0 && pointCount % unit === 0) {
147902
+ first /= unit;
147903
+ pointCount /= unit;
147904
+ pointOrder--;
147905
+ }
147906
+ }
147907
+ const cellSize = 1 / 2 ** (pointOrder - 1);
147908
+ const width = cellSize * (1 - Math.min(1, padding));
147909
+ if (!(width > 0) || !Number.isFinite(width)) return null;
147910
+ if (pointOrder <= 0) {
147911
+ const points = [{
147912
+ x: 0,
147913
+ y: 0,
147914
+ z: 0
147915
+ }];
147916
+ return {
147917
+ points,
147918
+ width,
147919
+ scale: width
147920
+ };
147921
+ }
147922
+ let rangeStart;
147923
+ let rangeEnd;
147924
+ if (isBigInt) {
147925
+ const curveLength = 8n ** BigInt(pointOrder);
147926
+ rangeStart = first < 0n ? 0n : first;
147927
+ rangeEnd = rangeStart + (pointCount > 0n ? pointCount : 0n);
147928
+ if (rangeEnd > curveLength) rangeEnd = curveLength;
147929
+ if (rangeStart >= rangeEnd || rangeEnd - rangeStart > 4n) return null;
147930
+ } else {
147931
+ const curveLength = 8 ** pointOrder;
147932
+ if (!Number.isSafeInteger(first) || !Number.isSafeInteger(pointCount) || !Number.isFinite(curveLength)) return null;
147933
+ rangeStart = Math.max(0, first);
147934
+ rangeEnd = Math.min(curveLength, rangeStart + Math.max(0, pointCount));
147935
+ if (rangeStart >= rangeEnd || rangeEnd - rangeStart > 4) return null;
147936
+ }
147937
+ const points = [];
147938
+ for (let index = rangeStart; index < rangeEnd; index = isBigInt ? index + 1n : index + 1) {
147939
+ points.push(getHilbertPoint(index, pointOrder));
147940
+ }
147941
+ const scale = points.length === 1 ? width : Math.abs(points[1].x - points[0].x) + Math.abs(points[1].y - points[0].y) + Math.abs(points[1].z - points[0].z);
147942
+ return {
147943
+ points,
147944
+ width,
147945
+ scale
147946
+ };
147947
+ }
147948
+ function getHilbertPoint(index, order) {
147949
+ const isBigInt = typeof index === 'bigint';
147950
+ let divisor = isBigInt ? 8n ** BigInt(order - 1) : 8 ** (order - 1);
147951
+ let x = 0;
147952
+ let y = 0;
147953
+ let z = 0;
147954
+ let size = 1;
147955
+ let orientation = 0;
147956
+ for (let i = 0; i < order; i++) {
147957
+ const digit = isBigInt ? Number(index / divisor % 8n) : Math.floor(index / divisor) % 8;
147958
+ const corner = HILBERT_ORIENTATIONS[orientation][digit];
147959
+ const half = size / 2;
147960
+ x += corner < 4 ? -half : half;
147961
+ y += corner < 2 || corner > 5 ? half : -half;
147962
+ z += corner % 4 === 1 || corner % 4 === 2 ? half : -half;
147963
+ size = half;
147964
+ orientation = HILBERT_ORIENTATION_TRANSITIONS[orientation][digit];
147965
+ divisor = isBigInt ? divisor / 8n : divisor / 8;
147966
+ }
147967
+ return {
147968
+ x,
147969
+ y,
147970
+ z
147971
+ };
147972
+ }
147973
+ function getCurvePath(points) {
147974
+ const path = [];
147975
+ let prevPnt = points[0];
147976
+ for (let i = 1; i < points.length; i++) {
147977
+ const pnt = points[i];
147978
+ for (const c of ['x', 'y', 'z']) {
147979
+ const dist = pnt[c] - prevPnt[c];
147980
+ if (dist) {
147981
+ path.push(c === 'x' ? dist > 0 ? 'R' : 'L' : c === 'y' ? dist > 0 ? 'U' : 'D' : dist > 0 ? 'B' : 'F');
147982
+ break;
147983
+ }
147984
+ }
147985
+ prevPnt = pnt;
147986
+ }
147987
+ return path.join('');
147988
+ }
147989
+
147887
147990
  const SCALE = 100;
147888
147991
  const ThreeHilbert = index$4({
147889
147992
  props: {
@@ -147906,14 +148009,16 @@ var<${access}> ${ name } : ${ structName };`;
147906
148009
  },
147907
148010
  simplifyCurves: {
147908
148011
  default: true
148012
+ },
148013
+ useInstancedMeshes: {
148014
+ default: false
147909
148015
  }
147910
148016
  },
147911
148017
  methods: {
147912
- getVectorAtVal: (state, val) => {
148018
+ getPositionAtVal: (state, val) => {
147913
148019
  const g = new ThreeHilbertGeometry(state.order, val, 1);
147914
148020
  g.computeBoundingSphere();
147915
- const vec = g.boundingSphere.center.clone().multiplyScalar(SCALE);
147916
- return vec;
148021
+ return g.boundingSphere.center.clone().multiplyScalar(SCALE);
147917
148022
  },
147918
148023
  getRangeBbox: (state, start, length) => {
147919
148024
  const g = new ThreeHilbertGeometry(state.order, start, length);
@@ -147926,7 +148031,8 @@ var<${access}> ${ name } : ${ structName };`;
147926
148031
  },
147927
148032
  stateInit() {
147928
148033
  return {
147929
- defaultColorScale: ordinal(Paired)
148034
+ defaultColorScale: ordinal(Paired),
148035
+ instancedMeshes: []
147930
148036
  };
147931
148037
  },
147932
148038
  init: function (threeObj, state) {
@@ -147939,7 +148045,6 @@ var<${access}> ${ name } : ${ structName };`;
147939
148045
  }).onCreateObj(() => {
147940
148046
  const obj = new Group$1(); // container
147941
148047
  obj.add(new Mesh()); // hilbert curve
147942
- // obj.add(new SpriteText()); // label
147943
148048
 
147944
148049
  obj.scale.set(SCALE, SCALE, SCALE);
147945
148050
  return obj;
@@ -147951,38 +148056,46 @@ var<${access}> ${ name } : ${ structName };`;
147951
148056
  const colorAccessor = index$3(state.color);
147952
148057
  const labelAccessor = index$3(state.label);
147953
148058
  index$3(state.labelColor);
147954
- const materialCache = {};
148059
+ const {
148060
+ fallbackData,
148061
+ geometries,
148062
+ meshes: instancedMeshes
148063
+ } = createInstancedHilbertMeshes({
148064
+ useInstancing: state.useInstancedMeshes,
148065
+ data: state.data,
148066
+ order: state.order,
148067
+ paddingAccessor,
148068
+ colorAccessor,
148069
+ labelAccessor,
148070
+ defaultColorScale: state.defaultColorScale,
148071
+ simplifyCurves: state.simplifyCurves,
148072
+ SCALE
148073
+ });
148074
+ state.instancedMeshes.forEach(mesh => {
148075
+ state.scene.remove(mesh);
148076
+ deallocate(mesh);
148077
+ });
148078
+ state.instancedMeshes = instancedMeshes;
148079
+ instancedMeshes.forEach(mesh => state.scene.add(mesh));
148080
+ const materialCache = new Map();
147955
148081
  state.dataMapper.onUpdateObj((obj, d) => {
147956
- const [hilbertObj, labelObj] = obj.children;
148082
+ const [hilbertObj] = obj.children;
147957
148083
 
147958
148084
  // update color
147959
148085
  const color = colorAccessor?.(d) || state.defaultColorScale(labelAccessor(d) || '');
147960
- if (!materialCache[color]) {
148086
+ let material = materialCache.get(color);
148087
+ if (!material) {
147961
148088
  const opacity = colorAlpha(color);
147962
- const material = materialCache[color] = new MeshLambertMaterial();
148089
+ material = new MeshLambertMaterial();
147963
148090
  material.color.set(colorStr2Hex(color));
147964
148091
  material.transparent = opacity < 1;
147965
148092
  material.opacity = opacity;
148093
+ materialCache.set(color, material);
147966
148094
  }
147967
- hilbertObj.material?.dispose();
147968
- hilbertObj.material = materialCache[color];
148095
+ hilbertObj.material = material;
147969
148096
  hilbertObj.geometry?.dispose();
147970
- hilbertObj.geometry = new ThreeHilbertGeometry(state.order, d.start, d.length, {
147971
- padding: paddingAccessor(d),
147972
- simplifyCurves: state.simplifyCurves
147973
- });
147974
-
147975
- // console.log(getCurvePath(hilbertObj.geometry.parameters.points), hilbertObj.geometry.parameters.points);
147976
-
147977
- /*
147978
- // update label
147979
- labelObj.text = labelAccessor?.(d) || '';
147980
- labelObj.color = labelColorAccessor(d);
147981
- labelObj.textHeight = 0.8 * d.length / Math.pow(8, state.order);
147982
- hilbertObj.geometry.computeBoundingSphere();
147983
- labelObj.position.copy(hilbertObj.geometry.boundingSphere.center);
147984
- */
147985
- }).digest(state.data);
148097
+ hilbertObj.geometry = geometries.get(d);
148098
+ }).digest(fallbackData);
147986
148099
  }
147987
148100
  });
147988
148101
 
@@ -148072,6 +148185,13 @@ var<${access}> ${ name } : ${ structName };`;
148072
148185
  },
148073
148186
  triggerUpdate: false
148074
148187
  },
148188
+ useInstancedMeshes: {
148189
+ default: false,
148190
+ onChange(v, state) {
148191
+ state.hilbert.useInstancedMeshes(v);
148192
+ },
148193
+ triggerUpdate: false
148194
+ },
148075
148195
  valFormatter: {
148076
148196
  default: d => d
148077
148197
  },