hilbert-chart-3d 0.8.0 → 0.9.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 +1 -1
- package/dist/hilbert-chart-3d.js +47 -27
- package/dist/hilbert-chart-3d.js.map +1 -1
- package/dist/hilbert-chart-3d.min.js +2 -2
- package/dist/hilbert-chart-3d.mjs +13 -23
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ new HilbertChart3D(<domElement>, { configOptions })
|
|
|
42
42
|
|
|
43
43
|
| Config options | Description | Default |
|
|
44
44
|
| --- | --- | :--: |
|
|
45
|
-
| <b>controlType</b>: <i>str</i> or <i>class</i> | Which type of control to use to control the camera. Choice between [trackball](https://threejs.org/examples/misc_controls_trackball.html), [arcball](https://threejs.org/examples/misc_controls_arcball.html), [orbit](https://threejs.org/examples/#misc_controls_orbit), [fly](https://threejs.org/examples/misc_controls_fly.html), or a custom [Three.js controls](https://threejs.org/docs/#Controls) class. | `
|
|
45
|
+
| <b>controlType</b>: <i>str</i> or <i>class</i> | Which type of control to use to control the camera. Choice between [trackball](https://threejs.org/examples/misc_controls_trackball.html), [arcball](https://threejs.org/examples/misc_controls_arcball.html), [orbit](https://threejs.org/examples/#misc_controls_orbit), [fly](https://threejs.org/examples/misc_controls_fly.html), or a custom [Three.js controls](https://threejs.org/docs/#Controls) class. | `trackball` |
|
|
46
46
|
| <b>rendererConfig</b>: <i>object</i> | Configuration parameters to pass to the [ThreeJS WebGLRenderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) constructor. | `{ antialias: true, alpha: true }` |
|
|
47
47
|
|
|
48
48
|
### Container
|
package/dist/hilbert-chart-3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 0.
|
|
1
|
+
// Version 0.9.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) :
|
|
@@ -152930,6 +152930,23 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
152930
152930
|
paddingAbsolute,
|
|
152931
152931
|
simplifyCurves
|
|
152932
152932
|
});
|
|
152933
|
+
if (simplifyCurves && geometry.parameters?.points.length === 4) {
|
|
152934
|
+
// Special case: simplify half-cube
|
|
152935
|
+
geometry.computeBoundingBox();
|
|
152936
|
+
const bbox = geometry.boundingBox.clone();
|
|
152937
|
+
const size = new Vector3();
|
|
152938
|
+
bbox.getSize(size);
|
|
152939
|
+
if (size.x !== size.y || size.x !== size.z) {
|
|
152940
|
+
// make sure it's half-cube
|
|
152941
|
+
const center = new Vector3();
|
|
152942
|
+
bbox.getCenter(center);
|
|
152943
|
+
const halfCube = new BoxGeometry(size.x, size.y, size.z);
|
|
152944
|
+
halfCube.translate(center.x, center.y, center.z);
|
|
152945
|
+
geometry.dispose();
|
|
152946
|
+
geometry.index = halfCube.index;
|
|
152947
|
+
geometry.attributes = halfCube.attributes;
|
|
152948
|
+
}
|
|
152949
|
+
}
|
|
152933
152950
|
mapLabelUVs(geometry);
|
|
152934
152951
|
return geometry;
|
|
152935
152952
|
}
|
|
@@ -153058,10 +153075,11 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153058
153075
|
const uvs = geometry.getAttribute('uv');
|
|
153059
153076
|
if (!uvs) return;
|
|
153060
153077
|
const positions = geometry.getAttribute('position');
|
|
153078
|
+
const index = geometry.getIndex();
|
|
153061
153079
|
const points = geometry.parameters?.points;
|
|
153062
153080
|
const labelAspects = new Float32Array(uvs.count);
|
|
153063
153081
|
const sideQuads = [];
|
|
153064
|
-
if (points?.length > 1) {
|
|
153082
|
+
if (points?.length > 1 && !(points.length === 4 && index.count === 36)) {
|
|
153065
153083
|
const sideQuadCount = (points.length - 1) * 4;
|
|
153066
153084
|
for (let vertex = 0; vertex + 3 < uvs.count && vertex / 4 < sideQuadCount; vertex += 4) {
|
|
153067
153085
|
let minU = Infinity;
|
|
@@ -153084,6 +153102,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153084
153102
|
});
|
|
153085
153103
|
}
|
|
153086
153104
|
} else {
|
|
153105
|
+
// cube or half-cube
|
|
153087
153106
|
for (let vertex = 0; vertex + 3 < uvs.count; vertex += 4) {
|
|
153088
153107
|
let minU = Infinity;
|
|
153089
153108
|
let maxU = -Infinity;
|
|
@@ -153203,12 +153222,22 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153203
153222
|
minUp = Math.min(minUp, up);
|
|
153204
153223
|
maxUp = Math.max(maxUp, up);
|
|
153205
153224
|
}
|
|
153225
|
+
const rightExtent = maxRight - minRight;
|
|
153226
|
+
const upExtent = maxUp - minUp;
|
|
153227
|
+
const useUpAsHorizontal = upExtent > rightExtent;
|
|
153228
|
+
const minHorizontal = useUpAsHorizontal ? minUp : minRight;
|
|
153229
|
+
const minVertical = useUpAsHorizontal ? minRight : minUp;
|
|
153230
|
+
const horizontalExtent = useUpAsHorizontal ? upExtent : rightExtent;
|
|
153231
|
+
const verticalExtent = useUpAsHorizontal ? rightExtent : upExtent;
|
|
153206
153232
|
for (let corner = 0; corner < 4; corner++) {
|
|
153207
153233
|
const index = vertex + corner;
|
|
153208
153234
|
const right = positions.getX(index) * rightX + positions.getZ(index) * rightZ;
|
|
153209
153235
|
const up = positions.getY(index) * upY + positions.getZ(index) * upZ;
|
|
153210
|
-
|
|
153211
|
-
|
|
153236
|
+
const horizontal = useUpAsHorizontal ? up : right;
|
|
153237
|
+
const vertical = useUpAsHorizontal ? right : up;
|
|
153238
|
+
const verticalUV = useUpAsHorizontal ? maxRight - right : vertical - minVertical;
|
|
153239
|
+
uvs.setXY(index, (horizontal - minHorizontal) / horizontalExtent, verticalUV / verticalExtent);
|
|
153240
|
+
labelAspects[index] = horizontalExtent / verticalExtent;
|
|
153212
153241
|
}
|
|
153213
153242
|
}
|
|
153214
153243
|
}
|
|
@@ -153344,6 +153373,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153344
153373
|
if (geometriesChanged) {
|
|
153345
153374
|
obj.geometry?.dispose();
|
|
153346
153375
|
obj.geometry = fallbackGeometries.get(d);
|
|
153376
|
+
obj.renderOrder = Number(d.length); // Draw larger objects later to reduce transparency issues
|
|
153347
153377
|
}
|
|
153348
153378
|
labelAtlas.tagGeometry(obj.geometry, [d], {
|
|
153349
153379
|
backgroundColorAccessor: getColor,
|
|
@@ -153412,78 +153442,68 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153412
153442
|
default: window.innerWidth,
|
|
153413
153443
|
onChange(v, state) {
|
|
153414
153444
|
state.renderObjs.width(v);
|
|
153415
|
-
}
|
|
153416
|
-
triggerUpdate: false
|
|
153445
|
+
}
|
|
153417
153446
|
},
|
|
153418
153447
|
height: {
|
|
153419
153448
|
default: window.innerHeight,
|
|
153420
153449
|
onChange(v, state) {
|
|
153421
153450
|
state.renderObjs.height(v);
|
|
153422
|
-
}
|
|
153423
|
-
triggerUpdate: false
|
|
153451
|
+
}
|
|
153424
153452
|
},
|
|
153425
153453
|
hilbertOrder: {
|
|
153426
153454
|
default: 3,
|
|
153427
153455
|
onChange(v, state) {
|
|
153428
153456
|
state.hilbert.order(v);
|
|
153429
|
-
}
|
|
153430
|
-
triggerUpdate: false
|
|
153457
|
+
}
|
|
153431
153458
|
},
|
|
153432
153459
|
// 0-4096 default
|
|
153433
153460
|
data: {
|
|
153434
153461
|
default: [],
|
|
153435
153462
|
onChange(v, state) {
|
|
153436
153463
|
state.hilbert.data(v);
|
|
153437
|
-
|
|
153438
|
-
|
|
153464
|
+
state.renderObjs.pointerRaycasterThrottleMs(v.length > 1e4 ? 200 : 50); // throttle raycaster when there's a lot of objects
|
|
153465
|
+
}
|
|
153439
153466
|
},
|
|
153440
153467
|
padding: {
|
|
153441
153468
|
default: 0,
|
|
153442
153469
|
onChange(v, state) {
|
|
153443
153470
|
state.hilbert.padding(v);
|
|
153444
|
-
}
|
|
153445
|
-
triggerUpdate: false
|
|
153471
|
+
}
|
|
153446
153472
|
},
|
|
153447
153473
|
paddingAbsolute: {
|
|
153448
153474
|
default: 0,
|
|
153449
153475
|
onChange(v, state) {
|
|
153450
153476
|
state.hilbert.paddingAbsolute(v);
|
|
153451
|
-
}
|
|
153452
|
-
triggerUpdate: false
|
|
153477
|
+
}
|
|
153453
153478
|
},
|
|
153454
153479
|
color: {
|
|
153455
153480
|
onChange(v, state) {
|
|
153456
153481
|
state.hilbert.color(v);
|
|
153457
|
-
}
|
|
153458
|
-
triggerUpdate: false
|
|
153482
|
+
}
|
|
153459
153483
|
},
|
|
153460
153484
|
label: {
|
|
153461
153485
|
default: 'name',
|
|
153462
153486
|
onChange(v, state) {
|
|
153463
153487
|
state.hilbert.label(v);
|
|
153464
|
-
}
|
|
153465
|
-
triggerUpdate: false
|
|
153488
|
+
}
|
|
153466
153489
|
},
|
|
153467
153490
|
labelColor: {
|
|
153468
153491
|
default: () => 'lavender',
|
|
153469
153492
|
onChange(v, state) {
|
|
153470
153493
|
state.hilbert.labelColor(v);
|
|
153471
|
-
}
|
|
153472
|
-
triggerUpdate: false
|
|
153494
|
+
}
|
|
153473
153495
|
},
|
|
153474
153496
|
simplifyCurves: {
|
|
153475
153497
|
default: true,
|
|
153476
153498
|
onChange(v, state) {
|
|
153477
153499
|
state.hilbert.simplifyCurves(v);
|
|
153478
|
-
}
|
|
153479
|
-
triggerUpdate: false
|
|
153500
|
+
}
|
|
153480
153501
|
},
|
|
153481
153502
|
useInstancedMeshes: {
|
|
153482
153503
|
default: false,
|
|
153483
153504
|
onChange(v, state) {
|
|
153484
153505
|
state.hilbert.useInstancedMeshes(v);
|
|
153485
|
-
}
|
|
153486
|
-
triggerUpdate: false
|
|
153506
|
+
}
|
|
153487
153507
|
},
|
|
153488
153508
|
valFormatter: {
|
|
153489
153509
|
default: d => d
|
|
@@ -153564,7 +153584,7 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153564
153584
|
}
|
|
153565
153585
|
},
|
|
153566
153586
|
stateInit({
|
|
153567
|
-
controlType = '
|
|
153587
|
+
controlType = 'trackball',
|
|
153568
153588
|
rendererConfig
|
|
153569
153589
|
}) {
|
|
153570
153590
|
const hilbert = new index$1();
|