hilbert-chart-3d 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -42,7 +42,8 @@ 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
|
+
| <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 }` |
|
|
46
47
|
|
|
47
48
|
### Container
|
|
48
49
|
| Method | Description | Default |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Controls, Vector3, Scene, Camera, WebGLRenderer, Light } from 'three';
|
|
1
|
+
import { Controls, WebGLRendererParameters, Vector3, Scene, Camera, WebGLRenderer, Light } from 'three';
|
|
2
2
|
|
|
3
3
|
type Accessor<In, Out> = Out | string | ((obj: In) => Out);
|
|
4
4
|
type NumericValue = number | bigint;
|
|
@@ -12,6 +12,7 @@ type Range =
|
|
|
12
12
|
|
|
13
13
|
interface HilbertChartOptions {
|
|
14
14
|
controlType?: ControlType;
|
|
15
|
+
rendererConfig?: WebGLRendererParameters;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
type RangeBounds = { start: number; length: number } | { start: bigint; length: bigint };
|
package/dist/hilbert-chart-3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 0.
|
|
1
|
+
// Version 0.9.0 hilbert-chart-3d - https://github.com/vasturiano/hilbert-chart-3d
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -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
|
}
|
|
@@ -153564,13 +153593,15 @@ var<${access}> ${ name } : ${ structName };`;
|
|
|
153564
153593
|
}
|
|
153565
153594
|
},
|
|
153566
153595
|
stateInit({
|
|
153567
|
-
controlType = '
|
|
153596
|
+
controlType = 'trackball',
|
|
153597
|
+
rendererConfig
|
|
153568
153598
|
}) {
|
|
153569
153599
|
const hilbert = new index$1();
|
|
153570
153600
|
return {
|
|
153571
153601
|
hilbert,
|
|
153572
153602
|
renderObjs: threeRenderObjects({
|
|
153573
|
-
controlType
|
|
153603
|
+
controlType,
|
|
153604
|
+
rendererConfig
|
|
153574
153605
|
}).objects([hilbert]).lights([new AmbientLight(0xcccccc, Math.PI), new DirectionalLight(0xffffff, 0.6 * Math.PI)]),
|
|
153575
153606
|
controlType
|
|
153576
153607
|
};
|