@@ -17,27 +17,6 @@ import * as THREE from 'three';
17
17
import { RoundedBoxGeometry } from 'three-stdlib' ;
18
18
import { injectSuzanne } from '../suzanne' ;
19
19
20
- const heightFieldHeight = 10 ;
21
- const heightFieldWidth = 10 ;
22
- const heightField = Array . from ( { length : heightFieldHeight * heightFieldWidth } , ( ) => Math . random ( ) ) ;
23
-
24
- const heightFieldGeometry = new THREE . PlaneGeometry (
25
- heightFieldWidth ,
26
- heightFieldHeight ,
27
- heightFieldWidth - 1 ,
28
- heightFieldHeight - 1 ,
29
- ) ;
30
-
31
- heightField . forEach ( ( v , index ) => {
32
- heightFieldGeometry . attributes [ 'position' ] . array [ index * 3 + 2 ] = v ;
33
- } ) ;
34
- heightFieldGeometry . scale ( 1 , - 1 , 1 ) ;
35
- heightFieldGeometry . rotateX ( - Math . PI / 2 ) ;
36
- heightFieldGeometry . rotateY ( - Math . PI / 2 ) ;
37
- heightFieldGeometry . computeVertexNormals ( ) ;
38
-
39
- const roundBoxGeometry = new RoundedBoxGeometry ( 1.4 , 1.4 , 1.4 , 8 , 0.2 ) ;
40
-
41
20
@Component ( {
42
21
selector : 'app-cute-box' ,
43
22
template : `
@@ -254,13 +233,29 @@ export class Suzanne {
254
233
} )
255
234
export default class AllCollidersExample {
256
235
protected readonly DoubleSide = THREE . DoubleSide ;
257
- protected readonly roundBoxGeometry = roundBoxGeometry ;
258
- protected readonly heightFieldGeometry = heightFieldGeometry ;
259
- protected readonly heightFieldWidth = heightFieldWidth ;
260
- protected readonly heightFieldHeight = heightFieldHeight ;
261
- protected readonly heightField = heightField ;
262
236
237
+ protected heightFieldHeight = 10 ;
238
+ protected heightFieldWidth = 10 ;
239
+ protected heightField = Array . from ( { length : this . heightFieldHeight * this . heightFieldWidth } , ( ) => Math . random ( ) ) ;
240
+ protected heightFieldGeometry = new THREE . PlaneGeometry (
241
+ this . heightFieldWidth ,
242
+ this . heightFieldHeight ,
243
+ this . heightFieldWidth - 1 ,
244
+ this . heightFieldHeight - 1 ,
245
+ ) ;
246
+
247
+ protected roundBoxGeometry = new RoundedBoxGeometry ( 1.4 , 1.4 , 1.4 , 8 , 0.2 ) ;
263
248
protected capsuleGeometry = new THREE . CapsuleGeometry ( 0.5 , 1 , 4 , 8 ) ;
264
249
protected cylinderGeometry = new THREE . CylinderGeometry ( 0.5 , 0.5 , 2 ) ;
265
250
protected coneGeometry = new THREE . ConeGeometry ( 0.5 , 2 ) ;
251
+
252
+ constructor ( ) {
253
+ this . heightField . forEach ( ( v , index ) => {
254
+ this . heightFieldGeometry . attributes [ 'position' ] . array [ index * 3 + 2 ] = v ;
255
+ } ) ;
256
+ this . heightFieldGeometry . scale ( 1 , - 1 , 1 ) ;
257
+ this . heightFieldGeometry . rotateX ( - Math . PI / 2 ) ;
258
+ this . heightFieldGeometry . rotateY ( - Math . PI / 2 ) ;
259
+ this . heightFieldGeometry . computeVertexNormals ( ) ;
260
+ }
266
261
}
0 commit comments