Skip to content

Commit

Permalink
Support (vertical) camera target limitation (#16125)
Browse files Browse the repository at this point in the history
* Create unique morph target manager ids when loading content from .babylon file (#15668)

* Add display name property for textures

* Add getter for tagged entities in asset container

* Add generics to internal `_getByTags` functions

* Fix typo in `getMaterialsByTags`

* Consider `ImageProcessingConfiguration` when cloning material

* Copy image processing configuration by reference anytime

* Implement vertical camera target limit

* Simplify lower target y limit check
  • Loading branch information
HoferMarkus authored Feb 3, 2025
1 parent 9133a15 commit 8536ece
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/dev/core/src/Cameras/arcRotateCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ export class ArcRotateCamera extends TargetCamera {
@serialize()
public upperRadiusLimit: Nullable<number> = null;

/**
* Minimum allowed vertical target position of the camera.
* Use this setting in combination with `upperRadiusLimit` to set a global limit for the Cameras vertical position.
*/
@serialize()
public lowerTargetYLimit: number = -Infinity;

/**
* Defines the current inertia value used during panning of the camera along the X axis.
*/
Expand Down Expand Up @@ -895,6 +902,7 @@ export class ArcRotateCamera extends TargetCamera {
alpha = Clamp(alpha, this.lowerAlphaLimit ?? -Infinity, this.upperAlphaLimit ?? Infinity);
beta = Clamp(beta, this.lowerBetaLimit ?? -Infinity, this.upperBetaLimit ?? Infinity);
radius = Clamp(radius, this.lowerRadiusLimit ?? -Infinity, this.upperRadiusLimit ?? Infinity);
target.y = Clamp(target.y, this.lowerTargetYLimit ?? -Infinity, Infinity);

this._goalAlpha = alpha;
this._goalBeta = beta;
Expand Down Expand Up @@ -1158,6 +1166,8 @@ export class ArcRotateCamera extends TargetCamera {
this.radius = this.upperRadiusLimit;
this.inertialRadiusOffset = 0;
}

this.target.y = Math.max(this.target.y, this.lowerTargetYLimit);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ export class ArcRotateCameraPropertyGridComponent extends React.Component<IArcRo
propertyName="upperRadiusLimit"
onPropertyChangedObservable={this.props.onPropertyChangedObservable}
/>
<FloatLineComponent
lockObject={this.props.lockObject}
label="Lower target Y limit"
target={camera}
propertyName="lowerTargetYLimit"
onPropertyChangedObservable={this.props.onPropertyChangedObservable}
/>
</LineContainerComponent>
<LineContainerComponent title="BEHAVIORS" closed={true} selection={this.props.globalState}>
<CheckBoxLineComponent
Expand Down

0 comments on commit 8536ece

Please sign in to comment.