@@ -55,14 +55,19 @@ AFRAME.registerComponent("super-spawner", {
5555 centerSpawnedObject : { default : false } ,
5656
5757 /**
58- * Optional event to listen for to spawn an object on the defaultHand
58+ * Optional event to listen for to spawn an object on the preferred superHand
5959 */
6060 spawnEvent : { type : "string" } ,
6161
6262 /**
63- * The hand to use if an object is spawned via spawnEvent
63+ * The superHand to use if an object is spawned via spawnEvent
6464 */
65- defaultHand : { type : "selector" }
65+ superHand : { type : "selector" } ,
66+
67+ /**
68+ * The cursor superHand to use if an object is spawned via spawnEvent
69+ */
70+ cursorSuperHand : { type : "selector" }
6671 } ,
6772
6873 init ( ) {
@@ -103,31 +108,38 @@ AFRAME.registerComponent("super-spawner", {
103108 this . heldEntities . clear ( ) ;
104109 } ,
105110
106- async onSpawnEvent ( ) {
107- const hand = this . data . defaultHand ;
111+ onSpawnEvent : ( ( ) => {
112+ const spawnOffset = new THREE . Vector3 ( ) ;
113+ return async function ( ) {
114+ const controllerCount = this . el . sceneEl . components [ "input-configurator" ] . controllerQueue . length ;
115+ const using6DOF = controllerCount > 1 && this . el . sceneEl . is ( "vr-mode" ) ;
116+ const hand = using6DOF ? this . data . superHand : this . data . cursorSuperHand ;
108117
109- if ( this . cooldownTimeout || ! hand ) {
110- return ;
111- }
118+ if ( this . cooldownTimeout || ! hand ) {
119+ return ;
120+ }
112121
113- const entity = addMedia ( this . data . src , this . data . template , ObjectContentOrigins . SPAWNER ) . entity ;
122+ const entity = addMedia ( this . data . src , this . data . template , ObjectContentOrigins . SPAWNER ) . entity ;
114123
115- entity . object3D . position . copy ( hand . object3D . position ) ;
116- entity . object3D . rotation . copy ( hand . object3D . rotation ) ;
117- entity . object3D . scale . copy ( this . data . useCustomSpawnScale ? this . data . spawnScale : this . el . object3D . scale ) ;
124+ hand . object3D . getWorldPosition ( entity . object3D . position ) ;
125+ hand . object3D . getWorldQuaternion ( entity . object3D . quaternion ) ;
126+ if ( this . data . useCustomSpawnScale ) {
127+ entity . object3D . scale . copy ( this . data . spawnScale ) ;
128+ }
118129
119- this . activateCooldown ( ) ;
130+ this . activateCooldown ( ) ;
120131
121- await waitForEvent ( "body-loaded" , entity ) ;
132+ await waitForEvent ( "body-loaded" , entity ) ;
122133
123- if ( this . data . centerSpawnedObject ) {
124- entity . body . position . copy ( hand . object3D . position ) ;
125- }
134+ hand . object3D . getWorldPosition ( entity . object3D . position ) ;
126135
127- for ( let i = 0 ; i < this . data . grabEvents . length ; i ++ ) {
128- hand . emit ( this . data . grabEvents [ i ] , { targetEntity : entity } ) ;
129- }
130- } ,
136+ if ( ! using6DOF ) {
137+ for ( let i = 0 ; i < this . data . grabEvents . length ; i ++ ) {
138+ hand . emit ( this . data . grabEvents [ i ] , { targetEntity : entity } ) ;
139+ }
140+ }
141+ } ;
142+ } ) ( ) ,
131143
132144 async onGrabStart ( e ) {
133145 if ( this . cooldownTimeout ) {
0 commit comments