@@ -17,27 +17,6 @@ import * as THREE from 'three';
1717import { RoundedBoxGeometry } from 'three-stdlib' ;
1818import { injectSuzanne } from '../suzanne' ;
1919
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-
4120@Component ( {
4221 selector : 'app-cute-box' ,
4322 template : `
@@ -254,13 +233,29 @@ export class Suzanne {
254233} )
255234export default class AllCollidersExample {
256235 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 ;
262236
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 ) ;
263248 protected capsuleGeometry = new THREE . CapsuleGeometry ( 0.5 , 1 , 4 , 8 ) ;
264249 protected cylinderGeometry = new THREE . CylinderGeometry ( 0.5 , 0.5 , 2 ) ;
265250 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+ }
266261}
0 commit comments