Skip to content

Commit

Permalink
Merge pull request #12759 from sebavan/master
Browse files Browse the repository at this point in the history
Fix 3D slider observables and visibility
  • Loading branch information
sebavan committed Jul 18, 2022
2 parents 90d7251 + 5f66326 commit c29720b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/dev/gui/src/3D/controls/control3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ declare type TouchButton3D = import("./touchButton3D").TouchButton3D;
* Class used as base class for controls
*/
export class Control3D implements IDisposable, IBehaviorAware<Control3D> {
/** @hidden */
public _host: GUI3DManager;
private _node: Nullable<TransformNode>;
private _downCount = 0;
private _enterCount = -1;
private _downPointerIds: { [id: number]: number } = {}; // Store number of pointer downs per ID, from near and far interactions
private _isVisible = true;

protected _isVisible = true;

/** @hidden */
public _host: GUI3DManager;
/** @hidden */
public _isScaledByManager = false;

Expand Down
16 changes: 16 additions & 0 deletions packages/dev/gui/src/3D/controls/slider3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ export class Slider3D extends Control3D {
return this._sliderBackplateMaterial;
}

/** Sets a boolean indicating if the control is visible */
public set isVisible(value: boolean) {
if (this._isVisible === value) {
return;
}

this._isVisible = value;

this.node?.setEnabled(value);
}

// Mesh association
protected _createNode(scene: Scene): TransformNode {
const sliderBackplate = CreateBox(
Expand Down Expand Up @@ -230,6 +241,11 @@ export class Slider3D extends Control3D {
}
this._sliderThumb = sliderThumbModel;
}

this._injectGUI3DReservedDataStore(sliderBackplate).control = this;
sliderBackplate.getChildMeshes().forEach((mesh) => {
this._injectGUI3DReservedDataStore(mesh).control = this;
});
});

this._affectMaterial(sliderBackplate);
Expand Down

0 comments on commit c29720b

Please sign in to comment.