@playcanvas/supersplat-viewer 1.14.1 → 1.14.2
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/public/index.js +10 -11
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -70318,7 +70318,7 @@ class Annotation extends Script {
|
|
|
70318
70318
|
return;
|
|
70319
70319
|
}
|
|
70320
70320
|
this._updatePositions(screenPos);
|
|
70321
|
-
this._updateRotationAndScale();
|
|
70321
|
+
this._updateRotationAndScale(-vec$2.z);
|
|
70322
70322
|
// update material opacity and also directly on the uniform so we
|
|
70323
70323
|
// can avoid a full material update
|
|
70324
70324
|
this.materials[0].opacity = Annotation.opacity;
|
|
@@ -70425,14 +70425,15 @@ class Annotation extends Script {
|
|
|
70425
70425
|
}
|
|
70426
70426
|
/**
|
|
70427
70427
|
* Update 3D rotation and scale of hotspot planes.
|
|
70428
|
+
* @param {number} viewDepth - The view-space depth (positive distance along the camera's forward direction)
|
|
70428
70429
|
* @private
|
|
70429
70430
|
*/
|
|
70430
|
-
_updateRotationAndScale() {
|
|
70431
|
+
_updateRotationAndScale(viewDepth) {
|
|
70431
70432
|
// Copy camera rotation to align with view plane
|
|
70432
70433
|
const cameraRotation = Annotation.camera.getRotation();
|
|
70433
70434
|
this._updateHotspotTransform(this.entity, cameraRotation);
|
|
70434
|
-
// Calculate scale based on
|
|
70435
|
-
const scale = this._calculateScreenSpaceScale();
|
|
70435
|
+
// Calculate scale based on view depth to maintain constant screen size
|
|
70436
|
+
const scale = this._calculateScreenSpaceScale(viewDepth);
|
|
70436
70437
|
this.entity.setLocalScale(scale, scale, scale);
|
|
70437
70438
|
}
|
|
70438
70439
|
/**
|
|
@@ -70447,19 +70448,17 @@ class Annotation extends Script {
|
|
|
70447
70448
|
}
|
|
70448
70449
|
/**
|
|
70449
70450
|
* Calculate scale factor to maintain constant screen-space size.
|
|
70451
|
+
* @param {number} viewDepth - The view-space depth (positive distance along the camera's forward direction)
|
|
70450
70452
|
* @returns {number} The scale to apply to hotspot entities
|
|
70451
70453
|
* @private
|
|
70452
70454
|
*/
|
|
70453
|
-
_calculateScreenSpaceScale() {
|
|
70454
|
-
const cameraPos = Annotation.camera.getPosition();
|
|
70455
|
-
const toAnnotation = this.entity.getPosition().sub(cameraPos);
|
|
70456
|
-
const distance = toAnnotation.length();
|
|
70455
|
+
_calculateScreenSpaceScale(viewDepth) {
|
|
70457
70456
|
// Use the canvas's CSS/client height instead of graphics device height
|
|
70458
70457
|
const canvas = this.app.graphicsDevice.canvas;
|
|
70459
70458
|
const screenHeight = canvas.clientHeight;
|
|
70460
|
-
//
|
|
70459
|
+
// Use view-space depth (not Euclidean distance) to match the projection matrix
|
|
70461
70460
|
const projMatrix = Annotation.camera.camera.projectionMatrix;
|
|
70462
|
-
const worldSize = (Annotation.hotspotSize / screenHeight) * (2 *
|
|
70461
|
+
const worldSize = (Annotation.hotspotSize / screenHeight) * (2 * viewDepth / projMatrix.data[5]);
|
|
70463
70462
|
return worldSize;
|
|
70464
70463
|
}
|
|
70465
70464
|
}
|
|
@@ -72741,7 +72740,7 @@ const initXr = (global) => {
|
|
|
72741
72740
|
});
|
|
72742
72741
|
};
|
|
72743
72742
|
|
|
72744
|
-
var version = "1.14.
|
|
72743
|
+
var version = "1.14.2";
|
|
72745
72744
|
|
|
72746
72745
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
72747
72746
|
const { contents, contentUrl, unified, aa } = config;
|