Skip to content

Commit

Permalink
fix: demo switch
Browse files Browse the repository at this point in the history
  • Loading branch information
deepkolos committed Jan 20, 2021
1 parent 288d1d7 commit 622cda5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 6 additions & 5 deletions miniprogram/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51333,10 +51333,12 @@ class DemoDeviceOrientationControls extends Demo {
}

dispose() {
this.control.disconnect();
this.control.dispose();
this.deps.camera.position.set(0, 0, 0);
this.deps.camera.quaternion.set(0, 0, 0, 1);
this.deps.scene.remove(this.mesh);
this.deps.scene.remove(this.helper);
this.control.disconnect();
this.control.dispose();
this.mesh.material.dispose();
this.helper.material.dispose();
this.mesh = null;
Expand Down Expand Up @@ -51398,14 +51400,13 @@ Page({

async onMenuItemClick(e) {
if (this.switchingItem) return
_optionalChain$2([(this.currDemo ), 'optionalAccess', _ => _.dispose, 'call', _2 => _2()]);
this.switchingItem = true;
this.currDemo = null ;

const { i, item } = e.currentTarget.dataset;

const demo = new (DEMO_MAP[item])(this.deps) ;
await demo.init();

_optionalChain$2([(this.currDemo ), 'optionalAccess', _ => _.dispose, 'call', _2 => _2()]);
this.currDemo = demo;
this.setData({ currItem: i });
this.onMenuClick();
Expand Down
7 changes: 3 additions & 4 deletions miniprogram/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ Page({

async onMenuItemClick(e) {
if (this.switchingItem) return
this.switchingItem = true
(this.currDemo as Demo)?.dispose();
this.switchingItem = true;
this.currDemo = null as unknown as Demo;

const { i, item } = e.currentTarget.dataset;

const demo = new (DEMO_MAP[item])(this.deps) as Demo;
await demo.init();

(this.currDemo as Demo)?.dispose()
this.currDemo = demo;
this.setData({ currItem: i })
this.onMenuClick()
Expand Down

0 comments on commit 622cda5

Please sign in to comment.