Browse Source

don't use deprecated function

Gregg Tavares 5 years ago
parent
commit
45614f8a8f

+ 3 - 13
threejs/lessons/threejs-webvr-point-to-select.md

@@ -340,8 +340,7 @@ const pickHelper = new ControllerPickHelper(scene);
 +      object: selectedObject,
 +      parent: selectedObject.parent,
 +    });
-+    SceneUtils.detach(selectedObject, selectedObject.parent, scene);
-+    SceneUtils.attach(selectedObject, scene, controller);
++    controller.attach(selectedObject);
 +  }
 +});
 +
@@ -350,8 +349,7 @@ const pickHelper = new ControllerPickHelper(scene);
 +  const selection = controllerToSelection.get(controller);
 +  if (selection) {
 +    controllerToSelection.delete(controller);
-+    SceneUtils.detach(selection.object, controller, scene);
-+    SceneUtils.attach(selection.object, scene, selection.parent);
++    selection.parent.attach(selection.object);
 +  }
 +});
 ```
@@ -359,19 +357,11 @@ const pickHelper = new ControllerPickHelper(scene);
 When an object is selected we save off that object and its
 original parent. When the user is done we can put the object back.
 
-We use the `SceneUtils.detach` and `SceneUtils.attach` to re-parent
+We use the `Object3D.attach` to re-parent
 the selected objects. These functions let us change the parent
 of an object without changing its orientation and position in the
 scene. 
 
-We need to include them.
-
-```js
-import * as THREE from './resources/three/r112/build/three.module.js';
-import {VRButton} from './resources/threejs/r112/examples/jsm/webxr/VRButton.js';
-+import {SceneUtils} from './resources/threejs/r112/examples/jsm/utils/SceneUtils.js';
-```
-
 And with that we should be able to move the objects around with a 6DOF
 controller or at least change their orientation with a 3DOF controller
 

+ 2 - 5
threejs/threejs-webvr-point-to-select-w-move.html

@@ -22,7 +22,6 @@
 <script type="module">
 import * as THREE from './resources/threejs/r112/build/three.module.js';
 import {VRButton} from './resources/threejs/r112/examples/jsm/webxr/VRButton.js';
-import {SceneUtils} from './resources/threejs/r112/examples/jsm/utils/SceneUtils.js';
 
 function main() {
   const canvas = document.querySelector('#c');
@@ -187,8 +186,7 @@ function main() {
         object: selectedObject,
         parent: selectedObject.parent,
       });
-      SceneUtils.detach(selectedObject, selectedObject.parent, scene);
-      SceneUtils.attach(selectedObject, scene, controller);
+      controller.attach(selectedObject);
     }
   });
 
@@ -197,8 +195,7 @@ function main() {
     const selection = controllerToSelection.get(controller);
     if (selection) {
       controllerToSelection.delete(controller);
-      SceneUtils.detach(selection.object, controller, scene);
-      SceneUtils.attach(selection.object, scene, selection.parent);
+      selection.parent.attach(selection.object);
     }
   });