angular-three-soba 4.1.1 → 4.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/fesm2022/angular-three-soba-misc.mjs +15 -6
- package/fesm2022/angular-three-soba-misc.mjs.map +1 -1
- package/fesm2022/angular-three-soba-performances.mjs +107 -3
- package/fesm2022/angular-three-soba-performances.mjs.map +1 -1
- package/package.json +2 -2
- package/performances/README.md +47 -0
- package/types/angular-three-soba-abstractions.d.ts +33 -45
- package/types/angular-three-soba-gizmos.d.ts +1 -1
- package/types/angular-three-soba-materials.d.ts +2 -2
- package/types/angular-three-soba-misc.d.ts +6 -0
- package/types/angular-three-soba-performances.d.ts +49 -3
- package/types/angular-three-soba-staging.d.ts +4 -8
|
@@ -767,17 +767,26 @@ function objectScale(el, camera) {
|
|
|
767
767
|
* @param el - The object to calculate z-index for
|
|
768
768
|
* @param camera - The camera reference (must be Perspective or Orthographic)
|
|
769
769
|
* @param zIndexRange - `[max, min]` range to map distance to
|
|
770
|
+
* @param logarithmicDepth - Computes the z-index logarithmicly to enable a wider camera range
|
|
770
771
|
* @returns Calculated z-index, or `undefined` for unsupported camera types
|
|
771
772
|
*/
|
|
772
|
-
function objectZIndex(el, camera, zIndexRange) {
|
|
773
|
+
function objectZIndex(el, camera, zIndexRange, logarithmicDepth = false) {
|
|
773
774
|
if (is.three(camera, 'isPerspectiveCamera') ||
|
|
774
775
|
is.three(camera, 'isOrthographicCamera')) {
|
|
775
776
|
const objectPos = v1.setFromMatrixPosition(el.matrixWorld);
|
|
776
777
|
const cameraPos = v2.setFromMatrixPosition(camera.matrixWorld);
|
|
777
778
|
const dist = objectPos.distanceTo(cameraPos);
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
779
|
+
if (logarithmicDepth) {
|
|
780
|
+
const safeNear = Math.max(camera.near, 1e-6);
|
|
781
|
+
const safeDist = Math.max(dist, 1e-6);
|
|
782
|
+
const depth = Math.log(safeDist / safeNear) / Math.log(camera.far / safeNear);
|
|
783
|
+
return Math.round(zIndexRange[0] + depth * (zIndexRange[1] - zIndexRange[0]));
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
const A = (zIndexRange[1] - zIndexRange[0]) / (camera.far - camera.near);
|
|
787
|
+
const B = zIndexRange[1] - A * camera.far;
|
|
788
|
+
return Math.round(A * dist + B);
|
|
789
|
+
}
|
|
781
790
|
}
|
|
782
791
|
return undefined;
|
|
783
792
|
}
|
|
@@ -987,7 +996,7 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
987
996
|
let oldZoom = 0;
|
|
988
997
|
let oldPosition = [0, 0];
|
|
989
998
|
beforeRender(({ camera: rootCamera }) => {
|
|
990
|
-
const [hostEl, transformOuterEl, transformInnerEl, group, occlusionMesh, occlusionGeometry, isRaycastOcclusion, { camera, size, viewport, raycaster, scene }, { calculatePosition, eps, zIndexRange, sprite, distanceFactor }, { transform, occlude, scale },] = [
|
|
999
|
+
const [hostEl, transformOuterEl, transformInnerEl, group, occlusionMesh, occlusionGeometry, isRaycastOcclusion, { camera, size, viewport, raycaster, scene }, { calculatePosition, eps, zIndexRange, logarithmicDepth, sprite, distanceFactor }, { transform, occlude, scale },] = [
|
|
991
1000
|
this.host.nativeElement,
|
|
992
1001
|
this.transformOuterRef()?.nativeElement,
|
|
993
1002
|
this.transformInnerRef()?.nativeElement,
|
|
@@ -1058,7 +1067,7 @@ class NgtsHTMLContent extends NgtHTML {
|
|
|
1058
1067
|
? [zIndexRange[0], halfRange]
|
|
1059
1068
|
: [halfRange - 1, 0]
|
|
1060
1069
|
: zIndexRange;
|
|
1061
|
-
renderer.setStyle(hostEl, 'z-index', `${objectZIndex(group, camera, zRange)}`);
|
|
1070
|
+
renderer.setStyle(hostEl, 'z-index', `${objectZIndex(group, camera, zRange, logarithmicDepth)}`);
|
|
1062
1071
|
if (transform) {
|
|
1063
1072
|
const [widthHalf, heightHalf] = [size.width / 2, size.height / 2];
|
|
1064
1073
|
const fov = camera.projectionMatrix.elements[5] * heightHalf;
|