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

add virtual option when creating a scene to avoid impacting engine #6295

Merged
merged 1 commit into from May 1, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Behaviors/Meshes/pointerDragBehavior.ts
Expand Up @@ -144,9 +144,8 @@ export class PointerDragBehavior implements Behavior<AbstractMesh> {
if (this._debugMode) {
PointerDragBehavior._planeScene = this._scene;
} else {
PointerDragBehavior._planeScene = new Scene(this._scene.getEngine());
PointerDragBehavior._planeScene = new Scene(this._scene.getEngine(), {virtual: true});
PointerDragBehavior._planeScene.detachControl();
this._scene.getEngine().scenes.pop();
this._scene.onDisposeObservable.addOnce(() => {
PointerDragBehavior._planeScene.dispose();
(<any>PointerDragBehavior._planeScene) = null;
Expand Down
3 changes: 1 addition & 2 deletions src/Rendering/utilityLayerRenderer.ts
Expand Up @@ -100,10 +100,9 @@ export class UtilityLayerRenderer implements IDisposable {
public originalScene: Scene,
handleEvents: boolean = true) {
// Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
this.utilityLayerScene = new Scene(originalScene.getEngine());
this.utilityLayerScene = new Scene(originalScene.getEngine(), {virtual: true});
this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
this.utilityLayerScene._allowPostProcessClearColor = false;
originalScene.getEngine().scenes.pop();

// Detach controls on utility scene, events will be fired by logic below to handle picking priority
this.utilityLayerScene.detachControl();
Expand Down
13 changes: 10 additions & 3 deletions src/scene.ts
Expand Up @@ -85,6 +85,9 @@ export interface SceneOptions {
* It will improve performance when the number of mesh becomes important, but might consume a bit more memory
*/
useClonedMeshhMap?: boolean;

/** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
virtual?: boolean;
}

/**
Expand Down Expand Up @@ -1300,9 +1303,11 @@ export class Scene extends AbstractScene implements IAnimatable {
constructor(engine: Engine, options?: SceneOptions) {
super();
this._engine = engine || EngineStore.LastCreatedEngine;
EngineStore._LastCreatedScene = this;
if (!options || !options.virtual) {
EngineStore._LastCreatedScene = this;
this._engine.scenes.push(this);
}

this._engine.scenes.push(this);
this._uid = null;

this._renderingManager = new RenderingManager(this);
Expand Down Expand Up @@ -1332,7 +1337,9 @@ export class Scene extends AbstractScene implements IAnimatable {
this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;

this._engine.onNewSceneAddedObservable.notifyObservers(this);
if (!options || !options.virtual) {
this._engine.onNewSceneAddedObservable.notifyObservers(this);
}
}

/**
Expand Down