-
-
Notifications
You must be signed in to change notification settings - Fork 36.5k
Expand file tree
/
Copy pathExtension.js
More file actions
107 lines (59 loc) · 1.98 KB
/
Copy pathExtension.js
File metadata and controls
107 lines (59 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { Tab } from 'three/addons/inspector/ui/Tab.js';
import { getItem, setItem } from './Inspector.js';
export class Extension extends Tab {
constructor( name, options = {} ) {
super( name, options );
this.isExtension = true;
}
init( inspector ) {
super.init( inspector );
if ( this._handleLayout && this._inspector ) {
this._inspector.removeEventListener( 'orientationchange', this._handleLayout );
this._inspector.removeEventListener( 'layoutchange', this._handleLayout );
this._inspector.removeEventListener( 'resize', this._handleLayout );
window.removeEventListener( 'resize', this._handleLayout );
}
this._inspector = inspector;
this._handleLayout = ( event ) => {
this.onOrientationChange( event );
this.onLayoutChange( event );
};
if ( inspector ) {
inspector.addEventListener( 'orientationchange', this._handleLayout );
inspector.addEventListener( 'layoutchange', this._handleLayout );
inspector.addEventListener( 'resize', this._handleLayout );
}
window.addEventListener( 'resize', this._handleLayout );
const data = getItem( this.name );
if ( Object.keys( data ).length > 0 ) {
this.deserialize( data );
}
}
serialize() {
return {};
}
deserialize( /* data */ ) {
}
save() {
const data = this.serialize();
if ( data === null || ( typeof data === 'object' && Object.keys( data ).length === 0 ) ) {
setItem( this.name, null );
} else {
setItem( this.name, data );
}
}
dispose() {
if ( this._handleLayout ) {
if ( this._inspector ) {
this._inspector.removeEventListener( 'orientationchange', this._handleLayout );
this._inspector.removeEventListener( 'layoutchange', this._handleLayout );
this._inspector.removeEventListener( 'resize', this._handleLayout );
}
window.removeEventListener( 'resize', this._handleLayout );
this._handleLayout = null;
}
this._inspector = null;
}
onOrientationChange( /* event */ ) { }
onLayoutChange( /* event */ ) { }
}