|
|
@@ -65,6 +65,20 @@ class ViewHelper extends Object3D {
|
|
|
*/
|
|
|
this.center = new Vector3();
|
|
|
|
|
|
+ /**
|
|
|
+ * Controls the position of the helper in the viewport.
|
|
|
+ * Use `top`/`bottom` for vertical positioning and `left`/`right` for horizontal.
|
|
|
+ * If `left` is `null`, `right` is used. If `top` is `null`, `bottom` is used.
|
|
|
+ *
|
|
|
+ * @type {{top: number|null, right: number, bottom: number, left: number|null}}
|
|
|
+ */
|
|
|
+ this.location = {
|
|
|
+ top: null,
|
|
|
+ right: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left: null
|
|
|
+ };
|
|
|
+
|
|
|
const color1 = new Color( '#ff4466' );
|
|
|
const color2 = new Color( '#88ff44' );
|
|
|
const color3 = new Color( '#4488ff' );
|
|
|
@@ -142,8 +156,8 @@ class ViewHelper extends Object3D {
|
|
|
const turnRate = 2 * Math.PI; // turn rate in angles per second
|
|
|
|
|
|
/**
|
|
|
- * Renders the helper in a separate view in the bottom-right corner
|
|
|
- * of the viewport.
|
|
|
+ * Renders the helper in a separate view in the viewport.
|
|
|
+ * Position is controlled by the `location` property.
|
|
|
*
|
|
|
* @param {WebGLRenderer|WebGPURenderer} renderer - The renderer.
|
|
|
*/
|
|
|
@@ -157,8 +171,31 @@ class ViewHelper extends Object3D {
|
|
|
|
|
|
//
|
|
|
|
|
|
- const x = domElement.offsetWidth - dim;
|
|
|
- const y = renderer.isWebGPURenderer ? domElement.offsetHeight - dim : 0;
|
|
|
+ const location = this.location;
|
|
|
+
|
|
|
+ let x, y;
|
|
|
+
|
|
|
+ if ( location.left !== null ) {
|
|
|
+
|
|
|
+ x = location.left;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ x = domElement.offsetWidth - dim - location.right;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( location.top !== null ) {
|
|
|
+
|
|
|
+ // Position from top
|
|
|
+ y = renderer.isWebGPURenderer ? location.top : domElement.offsetHeight - dim - location.top;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // Position from bottom
|
|
|
+ y = renderer.isWebGPURenderer ? domElement.offsetHeight - dim - location.bottom : location.bottom;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
renderer.clearDepth();
|
|
|
|
|
|
@@ -191,10 +228,32 @@ class ViewHelper extends Object3D {
|
|
|
if ( this.animating === true ) return false;
|
|
|
|
|
|
const rect = domElement.getBoundingClientRect();
|
|
|
- const offsetX = rect.left + ( domElement.offsetWidth - dim );
|
|
|
- const offsetY = rect.top + ( domElement.offsetHeight - dim );
|
|
|
- mouse.x = ( ( event.clientX - offsetX ) / ( rect.right - offsetX ) ) * 2 - 1;
|
|
|
- mouse.y = - ( ( event.clientY - offsetY ) / ( rect.bottom - offsetY ) ) * 2 + 1;
|
|
|
+ const location = this.location;
|
|
|
+
|
|
|
+ let offsetX, offsetY;
|
|
|
+
|
|
|
+ if ( location.left !== null ) {
|
|
|
+
|
|
|
+ offsetX = rect.left + location.left;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ offsetX = rect.left + domElement.offsetWidth - dim - location.right;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( location.top !== null ) {
|
|
|
+
|
|
|
+ offsetY = rect.top + location.top;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ offsetY = rect.top + domElement.offsetHeight - dim - location.bottom;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ mouse.x = ( ( event.clientX - offsetX ) / dim ) * 2 - 1;
|
|
|
+ mouse.y = - ( ( event.clientY - offsetY ) / dim ) * 2 + 1;
|
|
|
|
|
|
raycaster.setFromCamera( mouse, orthoCamera );
|
|
|
|