WebXRHandController.js 848 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {
  2. XRHandSpheresModel
  3. } from "./XRHandSpheresModel.js";
  4. var XRHandModelFactory = ( function () {
  5. function XRHandModelFactory() {}
  6. XRHandModelFactory.prototype = {
  7. constructor: XRHandModelFactory,
  8. createHandModel: function ( controller, profile ) {
  9. const handModel = new XRHandSpheresModel( controller );
  10. let scene = null;
  11. controller.addEventListener( 'connected', ( event ) => {
  12. const xrInputSource = event.data;
  13. console.log( "Connected!", xrInputSource );
  14. if ( xrInputSource.hand ) {
  15. handModel.xrInputSource = xrInputSource;
  16. }
  17. } );
  18. controller.addEventListener( 'disconnected', () => {
  19. handModel.motionController = null;
  20. handModel.remove( scene );
  21. scene = null;
  22. } );
  23. return handModel;
  24. }
  25. };
  26. return XRHandModelFactory;
  27. } )();
  28. export { XRHandModelFactory };