@@ -3,68 +3,54 @@ import "../FbxLoader";
3
3
import * as THREE from "three" ;
4
4
import { Component , Vue } from "vue-property-decorator" ;
5
5
6
- import {
7
- Application , AssetTypes , CameraFactory , components , GeometryFactory , LightFactory ,
8
- MaterialFactory
9
- } from "../../src" ;
6
+ import { CameraFactory , components , LightFactory , Loader } from "../../src" ;
7
+ import { cubeFactory , planeFactory } from "../factories/geometries" ;
10
8
import { HoverBehaviour } from "./HoverBehaviour" ;
11
9
import { MyBehaviour } from "./MyBehaviour" ;
10
+ import StandardMaterial from "./StandardMaterial" ;
11
+
12
+ Loader . registerExtension ( "fbx" , THREE . FBXLoader ) ;
12
13
13
14
( window as any ) . THREE = THREE ;
14
15
15
16
@Component ( {
16
17
components : {
17
18
...components ,
19
+ HoverBehaviour,
18
20
MyBehaviour,
19
- HoverBehaviour
21
+ StandardMaterial
20
22
}
21
23
} )
22
- export default class About extends Vue {
23
- public cubeFactory : GeometryFactory | null = null ;
24
- public planeFactory : GeometryFactory | null = null ;
25
- public cubeMaterialFactory : MaterialFactory | null = null ;
26
- public waterMaterialFactory : MaterialFactory | null = null ;
24
+ export default class Demo extends Vue {
25
+ public cubeFactory = cubeFactory ;
26
+ public planeFactory = planeFactory ;
27
27
28
- public polygonMaterialFactory : MaterialFactory = async ( app : Application ) => {
29
- const texture = await app . assets . get ( "PolygonMini_Tex" , AssetTypes . TEXTURE ) ;
28
+ public lightFactory : LightFactory = async ( ) => {
29
+ const light = new THREE . PointLight ( 0xffffff , 1 , 100 ) ;
30
30
31
- if ( ! texture ) {
32
- throw new Error ( "Could not find 'PolygonMini_Tex' texture" ) ;
33
- }
31
+ light . shadow . mapSize . width = 512 ; // default
32
+ light . shadow . mapSize . height = 512 ; // default
33
+ light . shadow . camera . near = 0.3 ; // default
34
+ light . shadow . camera . far = 500 ; // default
34
35
35
- const mat = new THREE . MeshStandardMaterial ( {
36
- color : "#eeeeee" ,
37
- metalness : 0.01
38
- } ) ;
39
- mat . map = texture as THREE . Texture ;
40
- return mat ;
36
+ return light ;
41
37
} ;
42
- public polygonDungeonFactory : MaterialFactory = async ( app : Application ) => {
43
- const texture = await app . assets . get (
44
- "PolygonDungeon_Tex" ,
45
- AssetTypes . TEXTURE
46
- ) ;
47
-
48
- if ( ! texture ) {
49
- throw new Error ( "Could not find 'PolygonDungeon_Tex' texture" ) ;
50
- }
51
38
52
- const mat = new THREE . MeshStandardMaterial ( {
53
- color : "#eeeeee" ,
54
- metalness : 0.01
55
- } ) ;
56
- mat . map = texture as THREE . Texture ;
57
- return mat ;
39
+ public cameraFactory : CameraFactory = async ( ) => {
40
+ const viewAngle = 60 ;
41
+ const nearClipping = 0.1 ;
42
+ const farClipping = 1000 ;
43
+ return new THREE . PerspectiveCamera (
44
+ viewAngle ,
45
+ window . innerWidth / window . innerHeight ,
46
+ nearClipping ,
47
+ farClipping
48
+ ) ;
58
49
} ;
59
50
60
- public lightFactory : LightFactory | null = null ;
61
- public cameraFactory : CameraFactory | null = null ;
62
-
63
51
public canvas : HTMLCanvasElement | null = null ;
64
- public canvas2 : HTMLCanvasElement | null = null ;
65
52
66
53
public scene1 = {
67
- name : "scene1" ,
68
54
camera : {
69
55
position : {
70
56
x : 0 ,
@@ -79,17 +65,12 @@ export default class About extends Vue {
79
65
} ,
80
66
fields : new Array ( )
81
67
} ;
82
- public scene2 = {
83
- name : "scene2"
84
- } ;
85
68
86
69
public isLoading = true ;
87
70
public loadingAmount = 0 ;
88
71
public loadingTotal = 0 ;
89
72
90
- public activeScene = this . scene1 . name ;
91
-
92
- public scenes = [ this . scene1 , this . scene2 ] ;
73
+ public activeScene = "scene1" ;
93
74
94
75
public startLoading ( ) {
95
76
this . isLoading = true ;
@@ -105,18 +86,11 @@ export default class About extends Vue {
105
86
console . log ( "loading progress" , `${ amount } / ${ total } ` ) ;
106
87
}
107
88
108
- public changeScene ( pScene : any ) {
109
- this . activeScene = pScene . name ;
110
- // this.scenes.forEach(scene => {
111
- // scene.active = false;
112
- // });
113
- // pScene.active = true;
114
- console . log ( "about scene change" , this . scenes ) ;
89
+ public changeScene ( pName : string ) {
90
+ this . activeScene = pName ;
115
91
}
116
92
117
93
public created ( ) {
118
- console . log ( "scene" , this . scene1 ) ;
119
-
120
94
let idx = 0 ;
121
95
for ( let x = 0 ; x < 5 ; ++ x ) {
122
96
for ( let z = 0 ; z < 5 ; ++ z ) {
@@ -129,88 +103,9 @@ export default class About extends Vue {
129
103
++ idx ;
130
104
}
131
105
}
132
-
133
- this . cubeFactory = async ( app : Application ) => {
134
- // await new Promise(r => setTimeout(r, 2000));
135
- // return new THREE.CylinderBufferGeometry(1, 1, 1, 6, 6);
136
-
137
- return new THREE . BoxBufferGeometry ( 1 , 1 , 1 ) ;
138
- } ;
139
- this . planeFactory = async ( ) => {
140
- // await new Promise(r => setTimeout(r, 3000));
141
- return new THREE . PlaneBufferGeometry ( 100 , 100 ) ;
142
- } ;
143
-
144
- this . cubeMaterialFactory = async ( app : Application ) => {
145
- const texture = await app . assets . get ( "crateTex" , AssetTypes . TEXTURE ) ;
146
-
147
- if ( ! texture ) {
148
- throw new Error ( "Could not find 'crateTex' texture" ) ;
149
- }
150
-
151
- const mat = new THREE . MeshPhysicalMaterial ( {
152
- color : "#eeeeee" ,
153
- metalness : 0.01
154
- } ) ;
155
- mat . map = texture as THREE . Texture ;
156
- // mat.color = new THREE.Color("#dddddd");
157
- return mat ;
158
- } ;
159
- this . waterMaterialFactory = async ( ) => {
160
- const mat = new THREE . MeshPhysicalMaterial ( {
161
- color : "#9c9cff" ,
162
- metalness : 0.01 ,
163
- fog : true
164
- } ) ;
165
- // mat.color = new THREE.Color("#dddddd");
166
- return mat ;
167
- } ;
168
-
169
- this . lightFactory = async ( ) => {
170
- const light = new THREE . PointLight ( 0xffffff , 1 , 100 ) ;
171
-
172
- light . shadow . mapSize . width = 512 ; // default
173
- light . shadow . mapSize . height = 512 ; // default
174
- light . shadow . camera . near = 0.3 ; // default
175
- light . shadow . camera . far = 500 ; // default
176
-
177
- return light ;
178
- } ;
179
-
180
- this . cameraFactory = async ( ) => {
181
- const viewAngle = 60 ;
182
- const nearClipping = 0.1 ;
183
- const farClipping = 1000 ;
184
- return new THREE . PerspectiveCamera (
185
- viewAngle ,
186
- window . innerWidth / window . innerHeight ,
187
- nearClipping ,
188
- farClipping
189
- ) ;
190
- } ;
191
106
}
192
107
193
108
public mounted ( ) {
194
109
this . canvas = this . $refs . canvas as HTMLCanvasElement ;
195
- this . canvas2 = this . $refs . canvas2 as HTMLCanvasElement ;
196
110
}
197
111
}
198
-
199
- // <!-- Asset management update ideas: allow to split up and depend on asset bundles (that can be either preloaded or loaded during runtime) -->
200
- // <!-- <assets-bundle name="PolygonMini" preload>
201
- // <texture name="PolygonMini_Tex" src="/assets/textures/PolygonMinis_Texture_01.png"/>
202
- // <material name="PolygonMini_Mat" :factory="polygonMaterialFactory"/>
203
-
204
- // <model name="grassModel" src="/assets/models/SM_Env_Grass_01.fbx" materials="PolygonMini_Mat"/>
205
- // <model name="PM_column" src="/assets/models/SM_Tile_Hex_Column_02.fbx" materials="PolygonMini_Mat"/>
206
- // <model name="PM_flat" src="/assets/models/SM_Tile_Hex_Flat_01.fbx" materials="PolygonMini_Mat"/>
207
- // </assets-bundle>
208
-
209
- // <assets-bundle name="crate" preload>
210
- // <texture name="crateTex" src="/assets/textures/crate.jpg"/>
211
- // </assets-bundle>
212
-
213
- // <assets-bundle name="Scene1" dependencies="crate" preload>
214
- // <geometry name="cube" :factory="cubeFactory"/>
215
- // <material name="cubeMat" :factory="cubeMaterialFactory"/>
216
- // </assets-bundle> -->
0 commit comments