@@ -7,14 +7,16 @@ import {
7
7
Application , AssetTypes , CameraFactory , components , GeometryFactory , LightFactory ,
8
8
MaterialFactory
9
9
} from "../../src" ;
10
+ import { HoverBehaviour } from "./HoverBehaviour" ;
10
11
import { MyBehaviour } from "./MyBehaviour" ;
11
12
12
13
( window as any ) . THREE = THREE ;
13
14
14
15
@Component ( {
15
16
components : {
16
17
...components ,
17
- MyBehaviour
18
+ MyBehaviour,
19
+ HoverBehaviour
18
20
}
19
21
} )
20
22
export default class About extends Vue {
@@ -42,10 +44,10 @@ export default class About extends Vue {
42
44
public cameraFactory : CameraFactory | null = null ;
43
45
44
46
public canvas : HTMLCanvasElement | null = null ;
47
+ public canvas2 : HTMLCanvasElement | null = null ;
45
48
46
49
public scene1 = {
47
- name : "First scene" ,
48
- active : true ,
50
+ name : "scene1" ,
49
51
camera : {
50
52
position : {
51
53
x : 0 ,
@@ -58,34 +60,18 @@ export default class About extends Vue {
58
60
z : 0
59
61
}
60
62
} ,
61
-
62
- fields : [
63
- {
64
- id : "someId-0" ,
65
- x : 0 ,
66
- y : 0
67
- } ,
68
- {
69
- id : "someId-1" ,
70
- x : 1 ,
71
- y : 0
72
- } ,
73
- {
74
- id : "someId-2" ,
75
- x : 2 ,
76
- y : 0
77
- }
78
- ]
63
+ fields : new Array ( )
79
64
} ;
80
65
public scene2 = {
81
- name : "Second scene" ,
82
- active : true
66
+ name : "scene2"
83
67
} ;
84
68
85
69
public isLoading = true ;
86
70
public loadingAmount = 0 ;
87
71
public loadingTotal = 0 ;
88
72
73
+ public activeScene = this . scene1 . name ;
74
+
89
75
public scenes = [ this . scene1 , this . scene2 ] ;
90
76
91
77
public startLoading ( ) {
@@ -103,15 +89,27 @@ export default class About extends Vue {
103
89
}
104
90
105
91
public changeScene ( pScene : any ) {
106
- this . scenes . forEach ( scene => {
107
- scene . active = false ;
108
- } ) ;
109
- pScene . active = true ;
92
+ this . activeScene = pScene . name ;
93
+ // this.scenes.forEach(scene => {
94
+ // scene.active = false;
95
+ // });
96
+ // pScene.active = true;
110
97
console . log ( "about scene change" , this . scenes ) ;
111
98
}
112
99
113
100
public created ( ) {
114
- console . log ( this . scene1 ) ;
101
+ let idx = 0 ;
102
+ for ( let x = 0 ; x < 5 ; ++ x ) {
103
+ for ( let z = 0 ; z < 5 ; ++ z ) {
104
+ this . scene1 . fields . push ( {
105
+ x,
106
+ z,
107
+ id : `field_${ idx } ` ,
108
+ y : 0
109
+ } ) ;
110
+ ++ idx ;
111
+ }
112
+ }
115
113
116
114
this . cubeFactory = async ( ) => {
117
115
// await new Promise(r => setTimeout(r, 2000));
@@ -158,13 +156,13 @@ export default class About extends Vue {
158
156
return light ;
159
157
} ;
160
158
161
- this . cameraFactory = async ( { width , height } ) => {
159
+ this . cameraFactory = async ( ) => {
162
160
const viewAngle = 60 ;
163
161
const nearClipping = 0.1 ;
164
162
const farClipping = 1000 ;
165
163
return new THREE . PerspectiveCamera (
166
164
viewAngle ,
167
- width / height ,
165
+ window . innerWidth / window . innerHeight ,
168
166
nearClipping ,
169
167
farClipping
170
168
) ;
@@ -173,5 +171,25 @@ export default class About extends Vue {
173
171
174
172
public mounted ( ) {
175
173
this . canvas = this . $refs . canvas as HTMLCanvasElement ;
174
+ this . canvas2 = this . $refs . canvas2 as HTMLCanvasElement ;
176
175
}
177
176
}
177
+
178
+ // <!-- Asset management update ideas: allow to split up and depend on asset bundles (that can be either preloaded or loaded during runtime) -->
179
+ // <!-- <assets-bundle name="PolygonMini" preload>
180
+ // <texture name="PolygonMini_Tex" src="/assets/textures/PolygonMinis_Texture_01.png"/>
181
+ // <material name="PolygonMini_Mat" :factory="polygonMaterialFactory"/>
182
+
183
+ // <model name="grassModel" src="/assets/models/SM_Env_Grass_01.fbx" materials="PolygonMini_Mat"/>
184
+ // <model name="PM_column" src="/assets/models/SM_Tile_Hex_Column_02.fbx" materials="PolygonMini_Mat"/>
185
+ // <model name="PM_flat" src="/assets/models/SM_Tile_Hex_Flat_01.fbx" materials="PolygonMini_Mat"/>
186
+ // </assets-bundle>
187
+
188
+ // <assets-bundle name="crate" preload>
189
+ // <texture name="crateTex" src="/assets/textures/crate.jpg"/>
190
+ // </assets-bundle>
191
+
192
+ // <assets-bundle name="Scene1" dependencies="crate" preload>
193
+ // <geometry name="cube" :factory="cubeFactory"/>
194
+ // <material name="cubeMat" :factory="cubeMaterialFactory"/>
195
+ // </assets-bundle> -->
0 commit comments