@@ -12,12 +12,13 @@ function initList(){
12
12
models . forEach ( function ( modelInfo ) {
13
13
var name = modelInfo . name ;
14
14
var id = modelInfo . id ;
15
+ var index = parseInt ( id ) - 1 ;
15
16
var elem = document . createElement ( 'div' ) ;
16
17
var modelPath = `../models/${ id } /` ;
17
18
elem . className = 'modelContainer' ;
18
19
elem . setAttribute ( 'data-id' , id ) ;
19
20
elem . innerHTML = `
20
- <div data-id='${ id } ' class='modelIcon' style='background-size:74px 63px ;background-image:url(./ ${ modelPath } icon.png );width:74px;height:63px;'></div>
21
+ <div data-id='${ id } ' class='modelIcon' style='background-position: ${ - ( 148 + 4 ) / 2 * ( index % 13 ) } px ${ - ( 125 + 4 ) / 2 * ( Math . floor ( index / 13 ) ) + 0.5 } px;background- size:988px 838px ;background-image:url(//wx4.sinaimg.cn/mw1024/6a4fa2d0ly1fxo333fivdj20rg0na0wo.jpg );width:74px;height:63px;'></div>
21
22
<div data-id='${ id } ' class='modelInfo'>${ id } ${ name } </div>
22
23
` ;
23
24
listContainerElem . appendChild ( elem ) ;
@@ -55,42 +56,43 @@ function initStage(){
55
56
56
57
orbitControls = new OrbitControls ( stage , {
57
58
isLockMove :true ,
58
- isLockZ :true
59
+ isLockZ :true ,
60
+ rotationXLimit :true
59
61
} ) ;
60
62
61
63
glTFLoader = new Hilo3d . GLTFLoader ( ) ;
62
64
63
65
closeBtnElem . onclick = function ( ) {
64
- hideStage ( ) ;
66
+ hideModel ( ) ;
65
67
}
66
68
}
67
69
68
- function hideStage ( ) {
70
+ function hideModel ( ) {
69
71
modelViewerContainerElem . style . display = 'none' ;
70
- mainContainerElem . appendChild ( listContainerElem ) ;
72
+ listContainerElem . style . display = 'flex' ;
71
73
72
74
// reset resource
73
75
Hilo3d . BasicLoader . cache . clear ( ) ;
74
76
stage . destroy ( ) ;
75
77
stage . matrix . identity ( ) ;
78
+ orbitControls . reset ( ) ;
76
79
77
80
titleElem . innerHTML = 'Pokémon Viewer' ;
78
- }
79
-
80
- function showStage ( ) {
81
- modelViewerContainerElem . style . display = 'block' ;
82
- mainContainerElem . removeChild ( listContainer ) ;
81
+ location . hash = '' ;
83
82
}
84
83
85
84
function onShowModelError ( ) {
86
85
alert ( 'Someting Error!' ) ;
87
- hideStage ( ) ;
86
+ hideModel ( ) ;
88
87
}
89
88
90
89
function showModel ( id ) {
91
- showStage ( ) ;
90
+ modelViewerContainerElem . style . display = 'block' ;
91
+ listContainerElem . style . display = 'none' ;
92
+
92
93
loadingElem . style . display = 'block' ;
93
94
titleElem . innerHTML = `${ id } ${ modelDict [ id ] . name } ` ;
95
+
94
96
var glTFUrl = `../models/${ id } /glTF/model.gltf` ;
95
97
glTFLoader . load ( {
96
98
src : glTFUrl ,
0 commit comments