1
1
import * as AFRAME from 'aframe' ;
2
2
import * as THREE from 'three' ;
3
- import { strict } from 'aframe-typescript' ;
4
3
import { MotionController , VisualResponse } from '@webxr-input-profiles/motion-controllers' ;
5
4
import { hologramMaterialFromStandardMaterial , occluderMaterialFromStandardMaterial , phongMaterialFromStandardMaterial } from './utils' ;
6
5
import { HAND_JOINT_NAMES } from './hand-joint-names' ;
@@ -17,21 +16,22 @@ type EnhancedVisualResponse = VisualResponse & {
17
16
maxNode ?: THREE . Object3D
18
17
} ;
19
18
20
- const MotionControllerModelComponent = AFRAME . registerComponent ( 'motion-controller-model' , strict < {
21
- motionControllerSystem : AFRAME . Systems [ 'motion-controller' ] ,
22
- inputSourceRecord : InputSourceRecord | null ,
23
- motionController : MotionController | null ,
24
- componentMeshes : Map < string , Array < { mesh : THREE . Mesh , originalColor : THREE . Color } > > ,
25
- // Only relevant for hand tracking models
26
- handJoints : Array < THREE . Object3D | undefined >
27
- } > ( ) . component ( {
19
+ const MotionControllerModelComponent = AFRAME . registerComponent ( 'motion-controller-model' , {
28
20
schema : {
29
21
hand : { type : 'string' , oneOf : [ 'left' , 'right' ] , default : 'left' } ,
30
22
overrideMaterial : { type : 'string' , oneOf : [ 'none' , 'phong' , 'occluder' ] , default : 'phong' } ,
31
23
overrideHandMaterial : { type : 'string' , oneOf : [ 'none' , 'phong' , 'occluder' , 'hologram' ] , default : 'hologram' } ,
32
24
buttonTouchColor : { type : 'color' , default : '#8AB' } ,
33
25
buttonPressColor : { type : 'color' , default : '#2DF' }
34
26
} ,
27
+ __fields : { } as {
28
+ motionControllerSystem : AFRAME . Systems [ 'motion-controller' ] ,
29
+ inputSourceRecord : InputSourceRecord | null ,
30
+ motionController : MotionController | null ,
31
+ componentMeshes : Map < string , Array < { mesh : THREE . Mesh , originalColor : THREE . Color } > > ,
32
+ // Only relevant for hand tracking models
33
+ handJoints : Array < THREE . Object3D | undefined >
34
+ } ,
35
35
init : function ( ) {
36
36
this . motionControllerSystem = this . el . sceneEl . systems [ 'motion-controller' ] ;
37
37
this . componentMeshes = new Map ( ) ;
@@ -47,7 +47,7 @@ const MotionControllerModelComponent = AFRAME.registerComponent('motion-controll
47
47
return ;
48
48
}
49
49
this . el . setObject3D ( 'mesh' , gltf . scene ) ;
50
- const isHandModel = this . motionController . id === 'generic-hand' ;
50
+ const isHandModel = this . motionController ? .id === 'generic-hand' ;
51
51
52
52
// Traverse the mesh to change materials and extract references to hand joints
53
53
gltf . scene . traverse ( child => {
@@ -87,7 +87,7 @@ const MotionControllerModelComponent = AFRAME.registerComponent('motion-controll
87
87
} ) ;
88
88
89
89
this . componentMeshes . clear ( ) ;
90
- Object . values ( this . motionController . components ) . forEach ( ( component ) => {
90
+ Object . values ( this . motionController ! . components ) . forEach ( ( component ) => {
91
91
// Can't traverse the rootNodes of the components, as these are hardly ever correct.
92
92
// See: https://github.com/immersive-web/webxr-input-profiles/issues/249
93
93
const componentMeshes : Array < { mesh : THREE . Mesh , originalColor : THREE . Color } > = [ ] ;
@@ -203,7 +203,7 @@ const MotionControllerModelComponent = AFRAME.registerComponent('motion-controll
203
203
} ) ;
204
204
}
205
205
}
206
- } ) ) ;
206
+ } ) ;
207
207
208
208
declare module "aframe" {
209
209
export interface Components {
0 commit comments