Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3D slider observables and visibility #12759

Merged
merged 6 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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