hilbert-chart-3d 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/hilbert-chart-3d.d.ts +2 -0
- package/dist/hilbert-chart-3d.js +1093 -933
- package/dist/hilbert-chart-3d.js.map +1 -1
- package/dist/hilbert-chart-3d.min.js +3 -3
- package/dist/hilbert-chart-3d.mjs +62 -19
- package/package.json +1 -1
package/dist/hilbert-chart-3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 0.1
|
|
1
|
+
// Version 0.2.1 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$
|
|
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$
|
|
494
|
+
function _arrayWithHoles$1(r) {
|
|
495
495
|
if (Array.isArray(r)) return r;
|
|
496
496
|
}
|
|
497
|
-
function _classCallCheck$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
533
|
-
return _arrayWithHoles$
|
|
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$
|
|
535
|
+
function _unsupportedIterableToArray$1(r, a) {
|
|
536
536
|
if (r) {
|
|
537
|
-
if ("string" == typeof r) return _arrayLikeToArray$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
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
|
|
140209
|
-
return _setPrototypeOf
|
|
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
|
|
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
|
|
140393
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
140216
140394
|
}
|
|
140217
140395
|
|
|
140218
|
-
function _getPrototypeOf
|
|
140219
|
-
return _getPrototypeOf
|
|
140396
|
+
function _getPrototypeOf(t) {
|
|
140397
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
140220
140398
|
return t.__proto__ || Object.getPrototypeOf(t);
|
|
140221
|
-
}, _getPrototypeOf
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
140573
|
+
return _assertThisInitialized(_this);
|
|
140396
140574
|
}
|
|
140397
140575
|
return PolishedError;
|
|
140398
140576
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -143571,7 +143749,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
143571
143749
|
Q(reactElement2VNode(jsx), domEl);
|
|
143572
143750
|
};
|
|
143573
143751
|
|
|
143574
|
-
function styleInject$
|
|
143752
|
+
function styleInject$2(css, ref) {
|
|
143575
143753
|
if (ref === void 0) ref = {};
|
|
143576
143754
|
var insertAt = ref.insertAt;
|
|
143577
143755
|
if (typeof document === 'undefined') {
|
|
@@ -143596,8 +143774,8 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
143596
143774
|
}
|
|
143597
143775
|
}
|
|
143598
143776
|
|
|
143599
|
-
var css_248z$
|
|
143600
|
-
styleInject$
|
|
143777
|
+
var css_248z$2 = ".float-tooltip-kap {\n position: absolute;\n width: max-content; /* prevent shrinking near right edge */\n max-width: max(50%, 150px);\n padding: 3px 5px;\n border-radius: 3px;\n font: 12px sans-serif;\n color: #eee;\n background: rgba(0,0,0,0.6);\n pointer-events: none;\n}\n";
|
|
143778
|
+
styleInject$2(css_248z$2);
|
|
143601
143779
|
|
|
143602
143780
|
var index$2 = index$4({
|
|
143603
143781
|
props: {
|
|
@@ -143675,7 +143853,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
143675
143853
|
}
|
|
143676
143854
|
});
|
|
143677
143855
|
|
|
143678
|
-
function styleInject(css, ref) {
|
|
143856
|
+
function styleInject$1(css, ref) {
|
|
143679
143857
|
if (ref === void 0) ref = {};
|
|
143680
143858
|
var insertAt = ref.insertAt;
|
|
143681
143859
|
if (typeof document === 'undefined') {
|
|
@@ -143700,8 +143878,8 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
143700
143878
|
}
|
|
143701
143879
|
}
|
|
143702
143880
|
|
|
143703
|
-
var css_248z = ".scene-nav-info {\n position: absolute;\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n font-family: sans-serif;\n pointer-events: none;\n user-select: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
143704
|
-
styleInject(css_248z);
|
|
143881
|
+
var css_248z$1 = ".scene-nav-info {\n position: absolute;\n bottom: 5px;\n width: 100%;\n text-align: center;\n color: slategrey;\n opacity: 0.7;\n font-size: 10px;\n font-family: sans-serif;\n pointer-events: none;\n user-select: none;\n}\n\n.scene-container canvas:focus {\n outline: none;\n}";
|
|
143882
|
+
styleInject$1(css_248z$1);
|
|
143705
143883
|
|
|
143706
143884
|
const materialDispose$1 = material => {
|
|
143707
143885
|
if (material instanceof Array) {
|
|
@@ -143735,7 +143913,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
143735
143913
|
}
|
|
143736
143914
|
};
|
|
143737
143915
|
|
|
143738
|
-
const three
|
|
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
|
|
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
|
|
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
|
|
143957
|
-
const camUp = new three
|
|
143958
|
-
const camForward = new three
|
|
143959
|
-
const camPos = new three
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
144005
|
-
const raycaster = new three
|
|
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
|
|
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
|
|
144011
|
-
const raycaster = new three
|
|
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
|
|
144033
|
-
camera: new three
|
|
144034
|
-
timer: new three
|
|
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
|
|
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
|
|
144305
|
+
state.renderer = new (useWebGPU ? WebGPURenderer : three.WebGLRenderer)(Object.assign({
|
|
144128
144306
|
antialias: true,
|
|
144129
144307
|
alpha: true
|
|
144130
144308
|
}, rendererConfig));
|
|
@@ -144171,6 +144349,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144171
144349
|
state.controlsEngaged = false;
|
|
144172
144350
|
state.controlsDragging = false;
|
|
144173
144351
|
});
|
|
144352
|
+
state.renderer.domElement.style.cursor = null; // remove cursor: auto property on canvas
|
|
144174
144353
|
}
|
|
144175
144354
|
[state.renderer, state.postProcessingComposer, ...state.extraRenderers].forEach(r => r.setSize(state.width, state.height));
|
|
144176
144355
|
state.camera.aspect = state.width / state.height;
|
|
@@ -144178,7 +144357,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144178
144357
|
state.camera.position.z = 1000;
|
|
144179
144358
|
|
|
144180
144359
|
// add sky
|
|
144181
|
-
state.scene.add(state.skysphere = new three
|
|
144360
|
+
state.scene.add(state.skysphere = new three.Mesh());
|
|
144182
144361
|
state.skysphere.visible = false;
|
|
144183
144362
|
state.loadComplete = state.scene.visible = !waitForLoadComplete;
|
|
144184
144363
|
window.scene = state.scene;
|
|
@@ -144206,12 +144385,12 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144206
144385
|
state.controls.hasOwnProperty('maxDistance') && changedProps.skyRadius && (state.controls.maxDistance = Math.min(state.controls.maxDistance, state.skyRadius));
|
|
144207
144386
|
state.camera.far = state.skyRadius * 2.5;
|
|
144208
144387
|
state.camera.updateProjectionMatrix();
|
|
144209
|
-
state.skysphere.geometry = new three
|
|
144388
|
+
state.skysphere.geometry = new three.SphereGeometry(state.skyRadius);
|
|
144210
144389
|
}
|
|
144211
144390
|
if (changedProps.hasOwnProperty('backgroundColor')) {
|
|
144212
144391
|
let alpha = parseToRgb(state.backgroundColor).alpha;
|
|
144213
144392
|
if (alpha === undefined) alpha = 1;
|
|
144214
|
-
state.renderer.setClearColor(new three
|
|
144393
|
+
state.renderer.setClearColor(new three.Color(curriedOpacify$1(1, state.backgroundColor)), alpha);
|
|
144215
144394
|
}
|
|
144216
144395
|
if (changedProps.hasOwnProperty('backgroundImageUrl')) {
|
|
144217
144396
|
if (!state.backgroundImageUrl) {
|
|
@@ -144219,11 +144398,11 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144219
144398
|
state.skysphere.material.map = null;
|
|
144220
144399
|
!state.loadComplete && finishLoad();
|
|
144221
144400
|
} else {
|
|
144222
|
-
new three
|
|
144223
|
-
texture.colorSpace = three
|
|
144224
|
-
state.skysphere.material = new three
|
|
144401
|
+
new three.TextureLoader().load(state.backgroundImageUrl, texture => {
|
|
144402
|
+
texture.colorSpace = three.SRGBColorSpace;
|
|
144403
|
+
state.skysphere.material = new three.MeshBasicMaterial({
|
|
144225
144404
|
map: texture,
|
|
144226
|
-
side: three
|
|
144405
|
+
side: three.BackSide
|
|
144227
144406
|
});
|
|
144228
144407
|
state.skysphere.visible = true;
|
|
144229
144408
|
|
|
@@ -144251,14 +144430,14 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144251
144430
|
}
|
|
144252
144431
|
});
|
|
144253
144432
|
|
|
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]];
|
|
144433
|
+
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
144434
|
const ORIENTATIONS = [[0, 1, 2, 3, 4, 5, 6, 7]];
|
|
144256
144435
|
const ORIENTATION_TRANSITIONS = [];
|
|
144257
144436
|
const ORIENTATION_IDS = new Map([[ORIENTATIONS[0].join(''), 0]]);
|
|
144258
144437
|
for (let i = 0; i < ORIENTATIONS.length; i++) {
|
|
144259
144438
|
const orientation = ORIENTATIONS[i];
|
|
144260
144439
|
const transitions = [];
|
|
144261
|
-
for (const permutation of CHILD_PERMUTATIONS) {
|
|
144440
|
+
for (const permutation of CHILD_PERMUTATIONS$1) {
|
|
144262
144441
|
const childOrientation = permutation.map(index => orientation[index]);
|
|
144263
144442
|
const key = childOrientation.join('');
|
|
144264
144443
|
let id = ORIENTATION_IDS.get(key);
|
|
@@ -144449,12 +144628,15 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144449
144628
|
this.boundingSphere = new Sphere(new Vector3(x, y, z), Math.sqrt(3) * halfWidth);
|
|
144450
144629
|
return;
|
|
144451
144630
|
}
|
|
144452
|
-
const path =
|
|
144631
|
+
const path = [];
|
|
144632
|
+
for (let index = 0; index < points.length; index++) {
|
|
144633
|
+
const point = points[index];
|
|
144453
144634
|
if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) {
|
|
144454
144635
|
throw new TypeError(`points[${index}] must have finite x, y, and z coordinates`);
|
|
144455
144636
|
}
|
|
144456
|
-
|
|
144457
|
-
|
|
144637
|
+
const copy = new Vector3(point.x, point.y, point.z);
|
|
144638
|
+
if (index === 0 || copy.distanceToSquared(path[path.length - 1]) > 0) path.push(copy);
|
|
144639
|
+
}
|
|
144458
144640
|
this.parameters = {
|
|
144459
144641
|
points: path.map(point => point.clone()),
|
|
144460
144642
|
width
|
|
@@ -144465,9 +144647,33 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144465
144647
|
this.setAttribute('uv', new Float32BufferAttribute([], 2));
|
|
144466
144648
|
return;
|
|
144467
144649
|
}
|
|
144468
|
-
|
|
144650
|
+
if (path.length === 1) {
|
|
144651
|
+
const [x, y, z] = path[0].toArray();
|
|
144652
|
+
const halfWidth = width / 2;
|
|
144653
|
+
const positions = new Float32Array(24 * 3);
|
|
144654
|
+
let positionOffset = 0;
|
|
144655
|
+
for (const face of SINGLE_CUBE_FACES) {
|
|
144656
|
+
for (const corner of face) {
|
|
144657
|
+
const signs = SINGLE_CUBE_CORNERS[corner];
|
|
144658
|
+
positions[positionOffset++] = x + signs[0] * halfWidth;
|
|
144659
|
+
positions[positionOffset++] = y + signs[1] * halfWidth;
|
|
144660
|
+
positions[positionOffset++] = z + signs[2] * halfWidth;
|
|
144661
|
+
}
|
|
144662
|
+
}
|
|
144663
|
+
this.setIndex(new Uint16BufferAttribute(SINGLE_CUBE_INDICES.slice(), 1));
|
|
144664
|
+
this.setAttribute('position', new Float32BufferAttribute(positions, 3));
|
|
144665
|
+
this.setAttribute('uv', new Float32BufferAttribute(SINGLE_CUBE_UVS.slice(), 2));
|
|
144666
|
+
this.setAttribute('normal', new Float32BufferAttribute(SINGLE_CUBE_NORMALS.slice(), 3));
|
|
144667
|
+
this.computeBoundingBox();
|
|
144668
|
+
this.computeBoundingSphere();
|
|
144669
|
+
return;
|
|
144670
|
+
}
|
|
144671
|
+
const directions = new Array(path.length - 1);
|
|
144672
|
+
for (let i = 0; i < directions.length; i++) {
|
|
144673
|
+
directions[i] = path[i + 1].clone().sub(path[i]).normalize();
|
|
144674
|
+
}
|
|
144469
144675
|
const turnTolerance = 1e-6;
|
|
144470
|
-
|
|
144676
|
+
const isClosed = path.length > 2 && path[0].distanceToSquared(path[path.length - 1]) === 0;
|
|
144471
144677
|
for (let i = 1; i < directions.length; i++) {
|
|
144472
144678
|
const dot = directions[i - 1].dot(directions[i]);
|
|
144473
144679
|
const isRightAngle = Math.abs(dot) <= turnTolerance;
|
|
@@ -144475,10 +144681,21 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144475
144681
|
if (!isRightAngle && !continuesStraight) {
|
|
144476
144682
|
throw new RangeError('path turns must be 90 degrees; straight segments are also allowed');
|
|
144477
144683
|
}
|
|
144478
|
-
if (isRightAngle) turnCount++;
|
|
144479
144684
|
}
|
|
144685
|
+
if (isClosed) {
|
|
144686
|
+
const dot = directions[directions.length - 1].dot(directions[0]);
|
|
144687
|
+
if (Math.abs(dot) > turnTolerance && dot < 1 - turnTolerance) {
|
|
144688
|
+
throw new RangeError('path turns must be 90 degrees; straight segments are also allowed');
|
|
144689
|
+
}
|
|
144690
|
+
}
|
|
144691
|
+
const pathDistances = new Float64Array(path.length);
|
|
144692
|
+
for (let i = 1; i < path.length; i++) {
|
|
144693
|
+
pathDistances[i] = pathDistances[i - 1] + path[i].distanceTo(path[i - 1]);
|
|
144694
|
+
}
|
|
144695
|
+
const pathLength = pathDistances[pathDistances.length - 1];
|
|
144480
144696
|
const halfWidth = width / 2;
|
|
144481
|
-
const
|
|
144697
|
+
const totalLength = pathLength + (isClosed ? 0 : width);
|
|
144698
|
+
const frames = new Array(directions.length);
|
|
144482
144699
|
const normal = new Vector3();
|
|
144483
144700
|
const binormal = new Vector3();
|
|
144484
144701
|
const rotation = new Quaternion();
|
|
@@ -144496,66 +144713,136 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144496
144713
|
normal.addScaledVector(directions[i], -normal.dot(directions[i])).normalize();
|
|
144497
144714
|
}
|
|
144498
144715
|
binormal.crossVectors(directions[i], normal).normalize();
|
|
144499
|
-
frames
|
|
144716
|
+
frames[i] = {
|
|
144500
144717
|
normal: normal.clone(),
|
|
144501
144718
|
binormal: binormal.clone()
|
|
144502
|
-
}
|
|
144719
|
+
};
|
|
144503
144720
|
}
|
|
144504
|
-
const
|
|
144505
|
-
const
|
|
144506
|
-
const
|
|
144507
|
-
const
|
|
144508
|
-
const
|
|
144721
|
+
const sideQuadCount = directions.length * 4;
|
|
144722
|
+
const capQuadCount = isClosed ? 0 : 2;
|
|
144723
|
+
const quadCount = sideQuadCount + capQuadCount;
|
|
144724
|
+
const vertexCount = quadCount * 4;
|
|
144725
|
+
const positions = new Float32Array(vertexCount * 3);
|
|
144726
|
+
const uvs = new Float32Array(vertexCount * 2);
|
|
144727
|
+
const use32BitIndices = vertexCount > 65535;
|
|
144509
144728
|
const IndexAttribute = use32BitIndices ? Uint32BufferAttribute : Uint16BufferAttribute;
|
|
144510
|
-
const indices = use32BitIndices ? new Uint32Array(
|
|
144729
|
+
const indices = use32BitIndices ? new Uint32Array(quadCount * 6) : new Uint16Array(quadCount * 6);
|
|
144730
|
+
const faceCorners = [0, 1, 2, 3];
|
|
144731
|
+
const startRing = Array.from({
|
|
144732
|
+
length: 4
|
|
144733
|
+
}, () => new Vector3());
|
|
144734
|
+
const endRing = Array.from({
|
|
144735
|
+
length: 4
|
|
144736
|
+
}, () => new Vector3());
|
|
144737
|
+
const firstRing = Array.from({
|
|
144738
|
+
length: 4
|
|
144739
|
+
}, () => new Vector3());
|
|
144740
|
+
const edge1 = new Vector3();
|
|
144741
|
+
const edge2 = new Vector3();
|
|
144742
|
+
const faceNormal = new Vector3();
|
|
144743
|
+
const outward = new Vector3();
|
|
144744
|
+
const miterNormal = new Vector3();
|
|
144745
|
+
const offset = new Vector3();
|
|
144746
|
+
const segmentCenter = new Vector3();
|
|
144747
|
+
const quadPoints = [null, null, null, null];
|
|
144748
|
+
const sideUVs = new Float32Array(8);
|
|
144749
|
+
const startCapUVs = new Float32Array([0, 0, 0.75, 0, 0.5, 0, 0.25, 0]);
|
|
144750
|
+
const endCapUVs = new Float32Array([0, 1, 0.25, 1, 0.5, 1, 0.75, 1]);
|
|
144511
144751
|
let positionOffset = 0;
|
|
144512
144752
|
let uvOffset = 0;
|
|
144513
144753
|
let vertexOffset = 0;
|
|
144514
144754
|
let indexOffset = 0;
|
|
144515
|
-
function
|
|
144516
|
-
for (
|
|
144517
|
-
|
|
144518
|
-
|
|
144519
|
-
|
|
144520
|
-
|
|
144521
|
-
|
|
144522
|
-
|
|
144523
|
-
|
|
144755
|
+
function getRing(center, frame, direction, nextDirection, ring, extension = 0) {
|
|
144756
|
+
for (let i = 0; i < 4; i++) {
|
|
144757
|
+
const normalSign = i === 0 || i === 3 ? 1 : -1;
|
|
144758
|
+
const binormalSign = i < 2 ? 1 : -1;
|
|
144759
|
+
ring[i].copy(center).addScaledVector(direction, extension * halfWidth).addScaledVector(frame.normal, normalSign * halfWidth).addScaledVector(frame.binormal, binormalSign * halfWidth);
|
|
144760
|
+
}
|
|
144761
|
+
if (nextDirection) {
|
|
144762
|
+
miterNormal.copy(direction).add(nextDirection).normalize();
|
|
144763
|
+
const denominator = miterNormal.dot(direction);
|
|
144764
|
+
for (const corner of ring) {
|
|
144765
|
+
offset.copy(corner).sub(center);
|
|
144766
|
+
corner.addScaledVector(direction, -miterNormal.dot(offset) / denominator);
|
|
144524
144767
|
}
|
|
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
144768
|
}
|
|
144533
144769
|
}
|
|
144534
|
-
|
|
144535
|
-
const
|
|
144536
|
-
|
|
144537
|
-
|
|
144538
|
-
|
|
144539
|
-
|
|
144540
|
-
|
|
144541
|
-
|
|
144542
|
-
|
|
144543
|
-
|
|
144770
|
+
function addQuad(corner0, corner1, corner2, corner3, outward, customUVs) {
|
|
144771
|
+
const hasCustomUVs = customUVs !== undefined;
|
|
144772
|
+
edge1.copy(corner1).sub(corner0);
|
|
144773
|
+
edge2.copy(corner2).sub(corner0);
|
|
144774
|
+
if (faceNormal.crossVectors(edge1, edge2).dot(outward) < 0) {
|
|
144775
|
+
const temp = corner1;
|
|
144776
|
+
corner1 = corner3;
|
|
144777
|
+
corner3 = temp;
|
|
144778
|
+
if (hasCustomUVs) {
|
|
144779
|
+
const tempU = customUVs[2];
|
|
144780
|
+
const tempV = customUVs[3];
|
|
144781
|
+
customUVs[2] = customUVs[6];
|
|
144782
|
+
customUVs[3] = customUVs[7];
|
|
144783
|
+
customUVs[6] = tempU;
|
|
144784
|
+
customUVs[7] = tempV;
|
|
144785
|
+
}
|
|
144786
|
+
}
|
|
144787
|
+
quadPoints[0] = corner0;
|
|
144788
|
+
quadPoints[1] = corner1;
|
|
144789
|
+
quadPoints[2] = corner2;
|
|
144790
|
+
quadPoints[3] = corner3;
|
|
144791
|
+
for (let i = 0; i < 4; i++) {
|
|
144792
|
+
const point = quadPoints[i];
|
|
144793
|
+
positions[positionOffset++] = point.x;
|
|
144794
|
+
positions[positionOffset++] = point.y;
|
|
144795
|
+
positions[positionOffset++] = point.z;
|
|
144796
|
+
if (hasCustomUVs) {
|
|
144797
|
+
uvs[uvOffset++] = customUVs[i * 2];
|
|
144798
|
+
uvs[uvOffset++] = customUVs[i * 2 + 1];
|
|
144799
|
+
} else {
|
|
144800
|
+
uvs[uvOffset++] = i === 1 || i === 2 ? 1 : 0;
|
|
144801
|
+
uvs[uvOffset++] = i >= 2 ? 1 : 0;
|
|
144802
|
+
}
|
|
144803
|
+
}
|
|
144804
|
+
indices[indexOffset++] = vertexOffset;
|
|
144805
|
+
indices[indexOffset++] = vertexOffset + 1;
|
|
144806
|
+
indices[indexOffset++] = vertexOffset + 2;
|
|
144807
|
+
indices[indexOffset++] = vertexOffset;
|
|
144808
|
+
indices[indexOffset++] = vertexOffset + 2;
|
|
144809
|
+
indices[indexOffset++] = vertexOffset + 3;
|
|
144810
|
+
vertexOffset += 4;
|
|
144544
144811
|
}
|
|
144545
144812
|
for (let i = 0; i < directions.length; i++) {
|
|
144546
144813
|
const direction = directions[i];
|
|
144547
|
-
const
|
|
144548
|
-
const
|
|
144549
|
-
|
|
144550
|
-
|
|
144551
|
-
|
|
144552
|
-
|
|
144553
|
-
|
|
144554
|
-
|
|
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)]);
|
|
144814
|
+
const previousDirection = i > 0 ? directions[i - 1] : isClosed ? directions[directions.length - 1] : undefined;
|
|
144815
|
+
const nextDirection = i < directions.length - 1 ? directions[i + 1] : isClosed ? directions[0] : undefined;
|
|
144816
|
+
const startTurn = previousDirection && Math.abs(previousDirection.dot(direction)) <= turnTolerance ? previousDirection : undefined;
|
|
144817
|
+
const endTurn = nextDirection && Math.abs(direction.dot(nextDirection)) <= turnTolerance ? nextDirection : undefined;
|
|
144818
|
+
getRing(path[i], frames[i], direction, startTurn, startRing, i === 0 && !isClosed ? -1 : 0);
|
|
144819
|
+
getRing(path[i + 1], frames[i], direction, endTurn, endRing, i === directions.length - 1 && !isClosed ? 1 : 0);
|
|
144820
|
+
if (i === 0) {
|
|
144821
|
+
for (let corner = 0; corner < 4; corner++) firstRing[corner].copy(startRing[corner]);
|
|
144558
144822
|
}
|
|
144823
|
+
segmentCenter.copy(path[i]).add(path[i + 1]).multiplyScalar(0.5);
|
|
144824
|
+
const startV = i === 0 && !isClosed ? 0 : (pathDistances[i] + (isClosed ? 0 : halfWidth)) / totalLength;
|
|
144825
|
+
const endV = i === directions.length - 1 && !isClosed ? 1 : (pathDistances[i + 1] + (isClosed ? 0 : halfWidth)) / totalLength;
|
|
144826
|
+
for (const a of faceCorners) {
|
|
144827
|
+
const b = (a + 1) % 4;
|
|
144828
|
+
const startU = a / 4;
|
|
144829
|
+
const endU = (a + 1) / 4;
|
|
144830
|
+
sideUVs[0] = startU;
|
|
144831
|
+
sideUVs[1] = startV;
|
|
144832
|
+
sideUVs[2] = endU;
|
|
144833
|
+
sideUVs[3] = startV;
|
|
144834
|
+
sideUVs[4] = endU;
|
|
144835
|
+
sideUVs[5] = endV;
|
|
144836
|
+
sideUVs[6] = startU;
|
|
144837
|
+
sideUVs[7] = endV;
|
|
144838
|
+
outward.copy(startRing[a]).add(startRing[b]).add(endRing[a]).add(endRing[b]).multiplyScalar(0.25).sub(segmentCenter);
|
|
144839
|
+
addQuad(startRing[a], startRing[b], endRing[b], endRing[a], outward, sideUVs);
|
|
144840
|
+
}
|
|
144841
|
+
}
|
|
144842
|
+
if (!isClosed) {
|
|
144843
|
+
offset.copy(directions[0]).negate();
|
|
144844
|
+
addQuad(firstRing[0], firstRing[3], firstRing[2], firstRing[1], offset, startCapUVs);
|
|
144845
|
+
addQuad(endRing[0], endRing[1], endRing[2], endRing[3], directions[directions.length - 1], endCapUVs);
|
|
144559
144846
|
}
|
|
144560
144847
|
this.setIndex(new IndexAttribute(indices, 1));
|
|
144561
144848
|
this.setAttribute('position', new Float32BufferAttribute(positions, 3));
|
|
@@ -144581,6 +144868,15 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144581
144868
|
} = {}) {
|
|
144582
144869
|
super(...getSuperParams());
|
|
144583
144870
|
this.type = 'HilbertGeometry';
|
|
144871
|
+
const superParams = this.parameters;
|
|
144872
|
+
this.parameters = {
|
|
144873
|
+
...superParams,
|
|
144874
|
+
order,
|
|
144875
|
+
start,
|
|
144876
|
+
length,
|
|
144877
|
+
padding,
|
|
144878
|
+
simplifyCurves
|
|
144879
|
+
};
|
|
144584
144880
|
function getSuperParams() {
|
|
144585
144881
|
typeof start !== 'bigint' && (start = Math.round(start));
|
|
144586
144882
|
typeof length !== 'bigint' && (length = Math.round(length));
|
|
@@ -144598,482 +144894,18 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
144598
144894
|
return [points, lineWidth];
|
|
144599
144895
|
}
|
|
144600
144896
|
}
|
|
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);
|
|
144628
|
-
}
|
|
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;
|
|
144897
|
+
clone() {
|
|
144898
|
+
return new this.constructor(0, 1, 0).copy(this);
|
|
144688
144899
|
}
|
|
144689
|
-
|
|
144690
|
-
|
|
144691
|
-
|
|
144692
|
-
|
|
144693
|
-
|
|
144694
|
-
|
|
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;
|
|
144900
|
+
copy(source) {
|
|
144901
|
+
super.copy(source);
|
|
144902
|
+
this.parameters = Object.assign({}, source.parameters, {
|
|
144903
|
+
points: source.parameters.points.map(point => point.clone())
|
|
144904
|
+
});
|
|
144905
|
+
return this;
|
|
144731
144906
|
}
|
|
144732
144907
|
}
|
|
144733
144908
|
|
|
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
144909
|
// https://d3js.org/d3-array/ v3.2.5 Copyright 2010-2026 Mike Bostock
|
|
145078
144910
|
function ascending(a, b) {
|
|
145079
144911
|
return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
@@ -147884,6 +147716,279 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
147884
147716
|
const colorStr2Hex = str => isNaN(str) ? parseInt(tinycolor(str).toHex(), 16) : str;
|
|
147885
147717
|
const colorAlpha = str => str && isNaN(str) ? color(str).opacity : 1;
|
|
147886
147718
|
|
|
147719
|
+
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]];
|
|
147720
|
+
const {
|
|
147721
|
+
orientations: HILBERT_ORIENTATIONS,
|
|
147722
|
+
transitions: HILBERT_ORIENTATION_TRANSITIONS
|
|
147723
|
+
} = createOrientationTables();
|
|
147724
|
+
function createOrientationTables() {
|
|
147725
|
+
const orientations = [[0, 1, 2, 3, 4, 5, 6, 7]];
|
|
147726
|
+
const transitions = [];
|
|
147727
|
+
const orientationIds = new Map([[orientations[0].join(''), 0]]);
|
|
147728
|
+
for (let i = 0; i < orientations.length; i++) {
|
|
147729
|
+
const orientation = orientations[i];
|
|
147730
|
+
const childTransitions = [];
|
|
147731
|
+
for (const permutation of CHILD_PERMUTATIONS) {
|
|
147732
|
+
const childOrientation = permutation.map(index => orientation[index]);
|
|
147733
|
+
const key = childOrientation.join('');
|
|
147734
|
+
let id = orientationIds.get(key);
|
|
147735
|
+
if (id === undefined) {
|
|
147736
|
+
id = orientations.length;
|
|
147737
|
+
orientations.push(childOrientation);
|
|
147738
|
+
orientationIds.set(key, id);
|
|
147739
|
+
}
|
|
147740
|
+
childTransitions.push(id);
|
|
147741
|
+
}
|
|
147742
|
+
transitions.push(childTransitions);
|
|
147743
|
+
}
|
|
147744
|
+
return {
|
|
147745
|
+
orientations,
|
|
147746
|
+
transitions
|
|
147747
|
+
};
|
|
147748
|
+
}
|
|
147749
|
+
function createInstancedHilbertMeshes({
|
|
147750
|
+
useInstancing = true,
|
|
147751
|
+
data,
|
|
147752
|
+
order,
|
|
147753
|
+
paddingAccessor,
|
|
147754
|
+
colorAccessor,
|
|
147755
|
+
labelAccessor,
|
|
147756
|
+
defaultColorScale,
|
|
147757
|
+
simplifyCurves,
|
|
147758
|
+
SCALE
|
|
147759
|
+
}) {
|
|
147760
|
+
const instanceMaterialCache = new Map();
|
|
147761
|
+
const geometryCache = new Map();
|
|
147762
|
+
const geometries = new WeakMap();
|
|
147763
|
+
const fallbackData = [];
|
|
147764
|
+
const batches = new Map();
|
|
147765
|
+
const usedGeometryKeys = new Set();
|
|
147766
|
+
data.forEach(d => {
|
|
147767
|
+
const padding = paddingAccessor(d);
|
|
147768
|
+
if (!useInstancing) {
|
|
147769
|
+
geometries.set(d, createGeometry(order, d, padding, simplifyCurves));
|
|
147770
|
+
fallbackData.push(d);
|
|
147771
|
+
return;
|
|
147772
|
+
}
|
|
147773
|
+
const description = getSimpleHilbertGeometry(order, d.start, d.length, padding, simplifyCurves);
|
|
147774
|
+
if (!description) {
|
|
147775
|
+
geometries.set(d, createGeometry(order, d, padding, simplifyCurves));
|
|
147776
|
+
fallbackData.push(d);
|
|
147777
|
+
return;
|
|
147778
|
+
}
|
|
147779
|
+
const color = colorAccessor?.(d) || defaultColorScale(labelAccessor(d) || '');
|
|
147780
|
+
const {
|
|
147781
|
+
points,
|
|
147782
|
+
width,
|
|
147783
|
+
scale
|
|
147784
|
+
} = description;
|
|
147785
|
+
const key = getCurvePath(points);
|
|
147786
|
+
const geometryKey = `${key}|${width / scale}`;
|
|
147787
|
+
usedGeometryKeys.add(geometryKey);
|
|
147788
|
+
let templateGeometry = geometryCache.get(geometryKey);
|
|
147789
|
+
if (!templateGeometry) {
|
|
147790
|
+
const geometry = createGeometry(order, d, padding, simplifyCurves);
|
|
147791
|
+
templateGeometry = createTemplateGeometry(geometry, points[0], scale);
|
|
147792
|
+
geometryCache.set(geometryKey, templateGeometry);
|
|
147793
|
+
geometry.dispose();
|
|
147794
|
+
}
|
|
147795
|
+
let material = instanceMaterialCache.get(color);
|
|
147796
|
+
if (!material) {
|
|
147797
|
+
const opacity = colorAlpha(color);
|
|
147798
|
+
material = new MeshLambertMaterial();
|
|
147799
|
+
material.color.set(colorStr2Hex(color));
|
|
147800
|
+
material.transparent = opacity < 1;
|
|
147801
|
+
material.opacity = opacity;
|
|
147802
|
+
instanceMaterialCache.set(color, material);
|
|
147803
|
+
}
|
|
147804
|
+
let colorBatches = batches.get(geometryKey);
|
|
147805
|
+
if (!colorBatches) {
|
|
147806
|
+
colorBatches = new Map();
|
|
147807
|
+
batches.set(geometryKey, colorBatches);
|
|
147808
|
+
}
|
|
147809
|
+
let batch = colorBatches.get(color);
|
|
147810
|
+
if (!batch) {
|
|
147811
|
+
batch = {
|
|
147812
|
+
geometry: templateGeometry,
|
|
147813
|
+
material,
|
|
147814
|
+
transforms: new Float32Array(256),
|
|
147815
|
+
count: 0,
|
|
147816
|
+
data: []
|
|
147817
|
+
};
|
|
147818
|
+
colorBatches.set(color, batch);
|
|
147819
|
+
}
|
|
147820
|
+
const instanceScale = scale * SCALE;
|
|
147821
|
+
let transforms = batch.transforms;
|
|
147822
|
+
if (batch.count * 4 === transforms.length) {
|
|
147823
|
+
const expandedTransforms = new Float32Array(transforms.length * 2);
|
|
147824
|
+
expandedTransforms.set(transforms);
|
|
147825
|
+
transforms = batch.transforms = expandedTransforms;
|
|
147826
|
+
}
|
|
147827
|
+
const transformOffset = batch.count * 4;
|
|
147828
|
+
transforms[transformOffset] = instanceScale;
|
|
147829
|
+
transforms[transformOffset + 1] = points[0].x * SCALE;
|
|
147830
|
+
transforms[transformOffset + 2] = points[0].y * SCALE;
|
|
147831
|
+
transforms[transformOffset + 3] = points[0].z * SCALE;
|
|
147832
|
+
batch.count++;
|
|
147833
|
+
batch.data.push(d);
|
|
147834
|
+
});
|
|
147835
|
+
geometryCache.forEach((geometry, key) => {
|
|
147836
|
+
if (!usedGeometryKeys.has(key)) {
|
|
147837
|
+
geometry.dispose();
|
|
147838
|
+
geometryCache.delete(key);
|
|
147839
|
+
}
|
|
147840
|
+
});
|
|
147841
|
+
const meshes = [];
|
|
147842
|
+
batches.forEach(colorBatches => {
|
|
147843
|
+
colorBatches.forEach(batch => {
|
|
147844
|
+
const mesh = new InstancedMesh(batch.geometry, batch.material, batch.count);
|
|
147845
|
+
const matrices = mesh.instanceMatrix.array;
|
|
147846
|
+
for (let i = 0; i < batch.count; i++) {
|
|
147847
|
+
const transformOffset = i * 4;
|
|
147848
|
+
const matrixOffset = i * 16;
|
|
147849
|
+
const scale = batch.transforms[transformOffset];
|
|
147850
|
+
matrices[matrixOffset] = scale;
|
|
147851
|
+
matrices[matrixOffset + 5] = scale;
|
|
147852
|
+
matrices[matrixOffset + 10] = scale;
|
|
147853
|
+
matrices[matrixOffset + 12] = batch.transforms[transformOffset + 1];
|
|
147854
|
+
matrices[matrixOffset + 13] = batch.transforms[transformOffset + 2];
|
|
147855
|
+
matrices[matrixOffset + 14] = batch.transforms[transformOffset + 3];
|
|
147856
|
+
matrices[matrixOffset + 15] = 1;
|
|
147857
|
+
}
|
|
147858
|
+
mesh.instanceMatrix.needsUpdate = true;
|
|
147859
|
+
mesh.computeBoundingSphere();
|
|
147860
|
+
mesh.userData.data = batch.data;
|
|
147861
|
+
meshes.push(mesh);
|
|
147862
|
+
});
|
|
147863
|
+
});
|
|
147864
|
+
return {
|
|
147865
|
+
fallbackData,
|
|
147866
|
+
geometries,
|
|
147867
|
+
meshes
|
|
147868
|
+
};
|
|
147869
|
+
}
|
|
147870
|
+
function createGeometry(order, datum, padding, simplifyCurves) {
|
|
147871
|
+
return new ThreeHilbertGeometry(order, datum.start, datum.length, {
|
|
147872
|
+
padding,
|
|
147873
|
+
simplifyCurves
|
|
147874
|
+
});
|
|
147875
|
+
}
|
|
147876
|
+
function createTemplateGeometry(geometry, origin, scale) {
|
|
147877
|
+
const templateGeometry = new BufferGeometry();
|
|
147878
|
+
Object.entries(geometry.attributes).forEach(([name, attribute]) => {
|
|
147879
|
+
templateGeometry.setAttribute(name, attribute.clone());
|
|
147880
|
+
});
|
|
147881
|
+
if (geometry.index) templateGeometry.setIndex(geometry.index.clone());
|
|
147882
|
+
geometry.groups.forEach(group => templateGeometry.addGroup(group.start, group.count, group.materialIndex));
|
|
147883
|
+
templateGeometry.setDrawRange(geometry.drawRange.start, geometry.drawRange.count);
|
|
147884
|
+
const positions = templateGeometry.getAttribute('position');
|
|
147885
|
+
for (let i = 0; i < positions.count; i++) {
|
|
147886
|
+
positions.setXYZ(i, (positions.getX(i) - origin.x) / scale, (positions.getY(i) - origin.y) / scale, (positions.getZ(i) - origin.z) / scale);
|
|
147887
|
+
}
|
|
147888
|
+
positions.needsUpdate = true;
|
|
147889
|
+
templateGeometry.computeBoundingBox();
|
|
147890
|
+
templateGeometry.computeBoundingSphere();
|
|
147891
|
+
return templateGeometry;
|
|
147892
|
+
}
|
|
147893
|
+
function getSimpleHilbertGeometry(order, start, length, padding, simplifyCurves) {
|
|
147894
|
+
const isBigInt = typeof start === 'bigint' && typeof length === 'bigint';
|
|
147895
|
+
if (!Number.isInteger(order) || typeof start === 'bigint' !== (typeof length === 'bigint')) return null;
|
|
147896
|
+
if (!isBigInt && (!Number.isFinite(start) || !Number.isFinite(length))) return null;
|
|
147897
|
+
let pointOrder = order;
|
|
147898
|
+
let first = isBigInt ? start : Math.round(start);
|
|
147899
|
+
let pointCount = isBigInt ? length : Math.round(length);
|
|
147900
|
+
const unit = isBigInt ? 8n : 8;
|
|
147901
|
+
const zero = isBigInt ? 0n : 0;
|
|
147902
|
+
if (simplifyCurves) {
|
|
147903
|
+
while (pointOrder > 0 && first % unit === zero && pointCount % unit === zero) {
|
|
147904
|
+
first /= unit;
|
|
147905
|
+
pointCount /= unit;
|
|
147906
|
+
pointOrder--;
|
|
147907
|
+
}
|
|
147908
|
+
}
|
|
147909
|
+
const cellSize = 1 / 2 ** (pointOrder - 1);
|
|
147910
|
+
const width = cellSize * (1 - Math.min(1, padding));
|
|
147911
|
+
if (!(width > 0) || !Number.isFinite(width)) return null;
|
|
147912
|
+
if (pointOrder <= 0) {
|
|
147913
|
+
const points = [{
|
|
147914
|
+
x: 0,
|
|
147915
|
+
y: 0,
|
|
147916
|
+
z: 0
|
|
147917
|
+
}];
|
|
147918
|
+
return {
|
|
147919
|
+
points,
|
|
147920
|
+
width,
|
|
147921
|
+
scale: width
|
|
147922
|
+
};
|
|
147923
|
+
}
|
|
147924
|
+
let rangeStart;
|
|
147925
|
+
let rangeEnd;
|
|
147926
|
+
if (isBigInt) {
|
|
147927
|
+
const curveLength = 8n ** BigInt(pointOrder);
|
|
147928
|
+
rangeStart = first < 0n ? 0n : first;
|
|
147929
|
+
rangeEnd = rangeStart + (pointCount > 0n ? pointCount : 0n);
|
|
147930
|
+
if (rangeEnd > curveLength) rangeEnd = curveLength;
|
|
147931
|
+
if (rangeStart >= rangeEnd || rangeEnd - rangeStart > 4n) return null;
|
|
147932
|
+
} else {
|
|
147933
|
+
const curveLength = 8 ** pointOrder;
|
|
147934
|
+
if (!Number.isSafeInteger(first) || !Number.isSafeInteger(pointCount) || !Number.isFinite(curveLength)) return null;
|
|
147935
|
+
rangeStart = Math.max(0, first);
|
|
147936
|
+
rangeEnd = Math.min(curveLength, rangeStart + Math.max(0, pointCount));
|
|
147937
|
+
if (rangeStart >= rangeEnd || rangeEnd - rangeStart > 4) return null;
|
|
147938
|
+
}
|
|
147939
|
+
const points = [];
|
|
147940
|
+
for (let index = rangeStart; index < rangeEnd; index = isBigInt ? index + 1n : index + 1) {
|
|
147941
|
+
points.push(getHilbertPoint(index, pointOrder));
|
|
147942
|
+
}
|
|
147943
|
+
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);
|
|
147944
|
+
return {
|
|
147945
|
+
points,
|
|
147946
|
+
width,
|
|
147947
|
+
scale
|
|
147948
|
+
};
|
|
147949
|
+
}
|
|
147950
|
+
function getHilbertPoint(index, order) {
|
|
147951
|
+
const isBigInt = typeof index === 'bigint';
|
|
147952
|
+
let divisor = isBigInt ? 8n ** BigInt(order - 1) : 8 ** (order - 1);
|
|
147953
|
+
let x = 0;
|
|
147954
|
+
let y = 0;
|
|
147955
|
+
let z = 0;
|
|
147956
|
+
let size = 1;
|
|
147957
|
+
let orientation = 0;
|
|
147958
|
+
for (let i = 0; i < order; i++) {
|
|
147959
|
+
const digit = isBigInt ? Number(index / divisor % 8n) : Math.floor(index / divisor) % 8;
|
|
147960
|
+
const corner = HILBERT_ORIENTATIONS[orientation][digit];
|
|
147961
|
+
const half = size / 2;
|
|
147962
|
+
x += corner < 4 ? -half : half;
|
|
147963
|
+
y += corner < 2 || corner > 5 ? half : -half;
|
|
147964
|
+
z += corner % 4 === 1 || corner % 4 === 2 ? half : -half;
|
|
147965
|
+
size = half;
|
|
147966
|
+
orientation = HILBERT_ORIENTATION_TRANSITIONS[orientation][digit];
|
|
147967
|
+
divisor = isBigInt ? divisor / 8n : divisor / 8;
|
|
147968
|
+
}
|
|
147969
|
+
return {
|
|
147970
|
+
x,
|
|
147971
|
+
y,
|
|
147972
|
+
z
|
|
147973
|
+
};
|
|
147974
|
+
}
|
|
147975
|
+
function getCurvePath(points) {
|
|
147976
|
+
const path = [];
|
|
147977
|
+
let prevPnt = points[0];
|
|
147978
|
+
for (let i = 1; i < points.length; i++) {
|
|
147979
|
+
const pnt = points[i];
|
|
147980
|
+
for (const c of ['x', 'y', 'z']) {
|
|
147981
|
+
const dist = pnt[c] - prevPnt[c];
|
|
147982
|
+
if (dist) {
|
|
147983
|
+
path.push(c === 'x' ? dist > 0 ? 'R' : 'L' : c === 'y' ? dist > 0 ? 'U' : 'D' : dist > 0 ? 'B' : 'F');
|
|
147984
|
+
break;
|
|
147985
|
+
}
|
|
147986
|
+
}
|
|
147987
|
+
prevPnt = pnt;
|
|
147988
|
+
}
|
|
147989
|
+
return path.join('');
|
|
147990
|
+
}
|
|
147991
|
+
|
|
147887
147992
|
const SCALE = 100;
|
|
147888
147993
|
const ThreeHilbert = index$4({
|
|
147889
147994
|
props: {
|
|
@@ -147906,14 +148011,16 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
147906
148011
|
},
|
|
147907
148012
|
simplifyCurves: {
|
|
147908
148013
|
default: true
|
|
148014
|
+
},
|
|
148015
|
+
useInstancedMeshes: {
|
|
148016
|
+
default: false
|
|
147909
148017
|
}
|
|
147910
148018
|
},
|
|
147911
148019
|
methods: {
|
|
147912
|
-
|
|
148020
|
+
getPositionAtVal: (state, val) => {
|
|
147913
148021
|
const g = new ThreeHilbertGeometry(state.order, val, 1);
|
|
147914
148022
|
g.computeBoundingSphere();
|
|
147915
|
-
|
|
147916
|
-
return vec;
|
|
148023
|
+
return g.boundingSphere.center.clone().multiplyScalar(SCALE);
|
|
147917
148024
|
},
|
|
147918
148025
|
getRangeBbox: (state, start, length) => {
|
|
147919
148026
|
const g = new ThreeHilbertGeometry(state.order, start, length);
|
|
@@ -147926,7 +148033,8 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
147926
148033
|
},
|
|
147927
148034
|
stateInit() {
|
|
147928
148035
|
return {
|
|
147929
|
-
defaultColorScale: ordinal(Paired)
|
|
148036
|
+
defaultColorScale: ordinal(Paired),
|
|
148037
|
+
instancedMeshes: []
|
|
147930
148038
|
};
|
|
147931
148039
|
},
|
|
147932
148040
|
init: function (threeObj, state) {
|
|
@@ -147939,7 +148047,6 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
147939
148047
|
}).onCreateObj(() => {
|
|
147940
148048
|
const obj = new Group$1(); // container
|
|
147941
148049
|
obj.add(new Mesh()); // hilbert curve
|
|
147942
|
-
// obj.add(new SpriteText()); // label
|
|
147943
148050
|
|
|
147944
148051
|
obj.scale.set(SCALE, SCALE, SCALE);
|
|
147945
148052
|
return obj;
|
|
@@ -147951,38 +148058,46 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
147951
148058
|
const colorAccessor = index$3(state.color);
|
|
147952
148059
|
const labelAccessor = index$3(state.label);
|
|
147953
148060
|
index$3(state.labelColor);
|
|
147954
|
-
const
|
|
148061
|
+
const {
|
|
148062
|
+
fallbackData,
|
|
148063
|
+
geometries,
|
|
148064
|
+
meshes: instancedMeshes
|
|
148065
|
+
} = createInstancedHilbertMeshes({
|
|
148066
|
+
useInstancing: state.useInstancedMeshes,
|
|
148067
|
+
data: state.data,
|
|
148068
|
+
order: state.order,
|
|
148069
|
+
paddingAccessor,
|
|
148070
|
+
colorAccessor,
|
|
148071
|
+
labelAccessor,
|
|
148072
|
+
defaultColorScale: state.defaultColorScale,
|
|
148073
|
+
simplifyCurves: state.simplifyCurves,
|
|
148074
|
+
SCALE
|
|
148075
|
+
});
|
|
148076
|
+
state.instancedMeshes.forEach(mesh => {
|
|
148077
|
+
state.scene.remove(mesh);
|
|
148078
|
+
deallocate(mesh);
|
|
148079
|
+
});
|
|
148080
|
+
state.instancedMeshes = instancedMeshes;
|
|
148081
|
+
instancedMeshes.forEach(mesh => state.scene.add(mesh));
|
|
148082
|
+
const materialCache = new Map();
|
|
147955
148083
|
state.dataMapper.onUpdateObj((obj, d) => {
|
|
147956
|
-
const [hilbertObj
|
|
148084
|
+
const [hilbertObj] = obj.children;
|
|
147957
148085
|
|
|
147958
148086
|
// update color
|
|
147959
148087
|
const color = colorAccessor?.(d) || state.defaultColorScale(labelAccessor(d) || '');
|
|
147960
|
-
|
|
148088
|
+
let material = materialCache.get(color);
|
|
148089
|
+
if (!material) {
|
|
147961
148090
|
const opacity = colorAlpha(color);
|
|
147962
|
-
|
|
148091
|
+
material = new MeshLambertMaterial();
|
|
147963
148092
|
material.color.set(colorStr2Hex(color));
|
|
147964
148093
|
material.transparent = opacity < 1;
|
|
147965
148094
|
material.opacity = opacity;
|
|
148095
|
+
materialCache.set(color, material);
|
|
147966
148096
|
}
|
|
147967
|
-
hilbertObj.material
|
|
147968
|
-
hilbertObj.material = materialCache[color];
|
|
148097
|
+
hilbertObj.material = material;
|
|
147969
148098
|
hilbertObj.geometry?.dispose();
|
|
147970
|
-
hilbertObj.geometry =
|
|
147971
|
-
|
|
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);
|
|
148099
|
+
hilbertObj.geometry = geometries.get(d);
|
|
148100
|
+
}).digest(fallbackData);
|
|
147986
148101
|
}
|
|
147987
148102
|
});
|
|
147988
148103
|
|
|
@@ -148007,6 +148122,36 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
148007
148122
|
|
|
148008
148123
|
var index$1 = fromKapsule(ThreeHilbert, Group$1, true);
|
|
148009
148124
|
|
|
148125
|
+
function styleInject(css, ref) {
|
|
148126
|
+
if ( ref === void 0 ) ref = {};
|
|
148127
|
+
var insertAt = ref.insertAt;
|
|
148128
|
+
|
|
148129
|
+
if (typeof document === 'undefined') { return; }
|
|
148130
|
+
|
|
148131
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
148132
|
+
var style = document.createElement('style');
|
|
148133
|
+
style.type = 'text/css';
|
|
148134
|
+
|
|
148135
|
+
if (insertAt === 'top') {
|
|
148136
|
+
if (head.firstChild) {
|
|
148137
|
+
head.insertBefore(style, head.firstChild);
|
|
148138
|
+
} else {
|
|
148139
|
+
head.appendChild(style);
|
|
148140
|
+
}
|
|
148141
|
+
} else {
|
|
148142
|
+
head.appendChild(style);
|
|
148143
|
+
}
|
|
148144
|
+
|
|
148145
|
+
if (style.styleSheet) {
|
|
148146
|
+
style.styleSheet.cssText = css;
|
|
148147
|
+
} else {
|
|
148148
|
+
style.appendChild(document.createTextNode(css));
|
|
148149
|
+
}
|
|
148150
|
+
}
|
|
148151
|
+
|
|
148152
|
+
var css_248z = ".hilbert-scene-container .clickable {\n cursor: pointer;\n}";
|
|
148153
|
+
styleInject(css_248z);
|
|
148154
|
+
|
|
148010
148155
|
var index = index$4({
|
|
148011
148156
|
props: {
|
|
148012
148157
|
width: {
|
|
@@ -148072,6 +148217,13 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
148072
148217
|
},
|
|
148073
148218
|
triggerUpdate: false
|
|
148074
148219
|
},
|
|
148220
|
+
useInstancedMeshes: {
|
|
148221
|
+
default: false,
|
|
148222
|
+
onChange(v, state) {
|
|
148223
|
+
state.hilbert.useInstancedMeshes(v);
|
|
148224
|
+
},
|
|
148225
|
+
triggerUpdate: false
|
|
148226
|
+
},
|
|
148075
148227
|
valFormatter: {
|
|
148076
148228
|
default: d => d
|
|
148077
148229
|
},
|
|
@@ -148143,36 +148295,44 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
148143
148295
|
|
|
148144
148296
|
// Add renderObjs
|
|
148145
148297
|
const roDomNode = document.createElement('div');
|
|
148298
|
+
roDomNode.className = 'hilbert-scene-container';
|
|
148146
148299
|
el.appendChild(roDomNode);
|
|
148147
|
-
const
|
|
148148
|
-
|
|
148149
|
-
|
|
148150
|
-
|
|
148151
|
-
|
|
148300
|
+
const getHilbertObjData = (obj, intersection) => {
|
|
148301
|
+
if (!obj) return null;
|
|
148302
|
+
if (intersection && obj.isInstancedMesh) {
|
|
148303
|
+
return obj.userData.data?.[intersection.instanceId] || null;
|
|
148304
|
+
}
|
|
148305
|
+
const hilbertObj = getHilbertObj(obj);
|
|
148306
|
+
return hilbertObj?.__data || null;
|
|
148307
|
+
function getHilbertObj(object) {
|
|
148308
|
+
let obj = object;
|
|
148309
|
+
// recurse up object chain until finding the globe object
|
|
148310
|
+
while (obj && !obj.hasOwnProperty('__data')) {
|
|
148311
|
+
obj = obj.parent;
|
|
148312
|
+
}
|
|
148313
|
+
return obj;
|
|
148152
148314
|
}
|
|
148153
|
-
return obj;
|
|
148154
148315
|
};
|
|
148155
|
-
state.renderObjs(roDomNode).tooltipContent(obj => {
|
|
148156
|
-
const
|
|
148157
|
-
return !
|
|
148316
|
+
state.renderObjs(roDomNode).tooltipContent((obj, intersection) => {
|
|
148317
|
+
const d = getHilbertObjData(obj, intersection);
|
|
148318
|
+
return !d ? '' : state.tooltipContent ? index$3(state.tooltipContent)(d) || '' : (() => {
|
|
148158
148319
|
// default content
|
|
148159
|
-
const d = o.__data;
|
|
148160
148320
|
const label = index$3(state.label)(d);
|
|
148161
148321
|
return `${label ? `<b>${label}</b>: ` : ''}${state.valFormatter(d.start) + (d.length > 1 ? ' - ' + state.valFormatter(d.start + d.length - (typeof d.start === 'bigint' ? 1n : 1)) : '')}`;
|
|
148162
148322
|
})();
|
|
148163
|
-
}).onHover(obj => {
|
|
148323
|
+
}).onHover((obj, _, intersection) => {
|
|
148164
148324
|
// Update tooltip and trigger onHover events
|
|
148165
|
-
const
|
|
148166
|
-
if (
|
|
148167
|
-
state.onHover?.(
|
|
148325
|
+
const hoverD = getHilbertObjData(obj, intersection);
|
|
148326
|
+
if (hoverD !== state.hoverD) {
|
|
148327
|
+
state.onHover?.(hoverD, state.hoverD || null);
|
|
148168
148328
|
|
|
148169
148329
|
// set pointer if hovered object is clickable
|
|
148170
|
-
state.renderObjs.renderer().domElement.classList[
|
|
148171
|
-
state.
|
|
148330
|
+
state.renderObjs.renderer().domElement.classList[hoverD && state.onClick || !hoverD && state.onBackgroundClick ? 'add' : 'remove']('clickable');
|
|
148331
|
+
state.hoverD = hoverD;
|
|
148172
148332
|
}
|
|
148173
|
-
}).onClick((obj, ev) => {
|
|
148174
|
-
const
|
|
148175
|
-
|
|
148333
|
+
}).onClick((obj, ev, intersection) => {
|
|
148334
|
+
const d = getHilbertObjData(obj, intersection);
|
|
148335
|
+
d ? state.onClick?.(d, ev) : state.onBackgroundClick?.(ev);
|
|
148176
148336
|
});
|
|
148177
148337
|
state.renderObjs.camera().position.z = 500;
|
|
148178
148338
|
|