Spaces:
Running
Running
Update orbit-camera.js
Browse files- orbit-camera.js +4 -0
orbit-camera.js
CHANGED
|
@@ -11,6 +11,8 @@ OrbitCamera.attributes.add('pitchAngleMax', { type: 'number', default: 90, title
|
|
| 11 |
OrbitCamera.attributes.add('pitchAngleMin', { type: 'number', default: 0, title: 'Pitch Angle Min (degrees)' });
|
| 12 |
OrbitCamera.attributes.add('yawAngleMax', { type: 'number', default: 360, title: 'Yaw Angle Max (degrees)' });
|
| 13 |
OrbitCamera.attributes.add('yawAngleMin', { type: 'number', default: -360, title: 'Yaw Angle Min (degrees)' });
|
|
|
|
|
|
|
| 14 |
|
| 15 |
OrbitCamera.attributes.add('inertiaFactor', {
|
| 16 |
type: 'number',
|
|
@@ -227,6 +229,8 @@ OrbitCamera.prototype._updatePosition = function () {
|
|
| 227 |
position.copy(this.entity.forward);
|
| 228 |
position.mulScalar(-this._distance);
|
| 229 |
position.add(this.pivotPoint);
|
|
|
|
|
|
|
| 230 |
this.entity.setPosition(position);
|
| 231 |
};
|
| 232 |
|
|
|
|
| 11 |
OrbitCamera.attributes.add('pitchAngleMin', { type: 'number', default: 0, title: 'Pitch Angle Min (degrees)' });
|
| 12 |
OrbitCamera.attributes.add('yawAngleMax', { type: 'number', default: 360, title: 'Yaw Angle Max (degrees)' });
|
| 13 |
OrbitCamera.attributes.add('yawAngleMin', { type: 'number', default: -360, title: 'Yaw Angle Min (degrees)' });
|
| 14 |
+
// NEW: Added minY attribute to define the minimum allowed Y value for the camera.
|
| 15 |
+
OrbitCamera.attributes.add('minY', { type: 'number', default: 0, title: 'Minimum Y', description: 'Minimum Y value for the camera during orbiting or translation' });
|
| 16 |
|
| 17 |
OrbitCamera.attributes.add('inertiaFactor', {
|
| 18 |
type: 'number',
|
|
|
|
| 229 |
position.copy(this.entity.forward);
|
| 230 |
position.mulScalar(-this._distance);
|
| 231 |
position.add(this.pivotPoint);
|
| 232 |
+
// NEW: Clamp the camera's Y position so it never goes below the specified minY value.
|
| 233 |
+
position.y = Math.max(position.y, this.minY);
|
| 234 |
this.entity.setPosition(position);
|
| 235 |
};
|
| 236 |
|