I am trying to learn webxr and basic concept of it.
For it, I am doing this:
function buildControllers() {
const controllerModelFactory = new XRControllerModelFactory()
const controllers: Array<any> = []
const rayGeometry = new BufferGeometry().setFromPoints([
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 0, -1),
])
const line = new Line(rayGeometry)
line.scale.z = 10
for (let i = 0; i < 2; i++) {
const _controller = renderer.xr.getController(i)
_controller.name = 'controller' + (i + 1)
_controller.userData.selectPressed = false
_controller.userData.selectPressedPrev = false
// add ray in it
scene.add(_controller)
controllers.push(_controller)
const grip = renderer.xr.getControllerGrip(i)
grip.add(controllerModelFactory.createControllerModel(grip))
scene.add(grip)
}
return controllers
}
function selectStartHandler() {
;(this as THREE.XRTargetRaySpace).children[0].scale.z = 10
:(this as THREE.XRTargetRaySpace).userData.selectPressed = true
}
function selectEndHandler() {
this.children[0].scale.z = 0
this.userData.selectPressed = false
}
function initVR() {
controllers = buildControllers()
controllers.forEach(function (controller, index) {
controller.addEventListener('selectstart', selectStartHandler)
controller.addEventListener('selectend', selectEndHandler)
})
}
initVR()
and I am getting this error:
and when i hover over it show its this:
i thought it might be because of ts
type in this
;(this as THREE.XRTargetRaySpace).children[0].scale.z = 10
PS: My code is in ts file.
what can i do to get rid of this?
Thank you