فهرست منبع

Allow draggable groups (#3549)

* Allow draggable groups

* Add support for simultaneous grouped and ungrouped draggable objects

* move fix in DragControls.js into npm.py

---------

Co-authored-by: Andreas Voigt <andreas.voigt@optonic.com>
Co-authored-by: Falko Schindler <falko@zauberzeug.com>
Voigta 8 ماه پیش
والد
کامیت
79f9d2eb04
3فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 1 1
      nicegui/elements/lib/three/modules/DragControls.js
  2. 1 0
      nicegui/elements/scene.js
  3. 8 0
      npm.py

+ 1 - 1
nicegui/elements/lib/three/modules/DragControls.js

@@ -334,7 +334,7 @@ function onPointerDown( event ) {
 
 			// look for the outermost group in the object's upper hierarchy
 
-			_selected = findGroup( _intersections[ 0 ].object );
+			_selected = findGroup( _intersections[ 0 ].object ) || _intersections[ 0 ].object;
 
 		} else {
 

+ 1 - 0
nicegui/elements/scene.js

@@ -145,6 +145,7 @@ export default {
     }
     this.controls = new OrbitControls(this.camera, this.renderer.domElement);
     this.drag_controls = new DragControls(this.draggable_objects, this.camera, this.renderer.domElement);
+    this.drag_controls.transformGroup = true;
     const applyConstraint = (constraint, position) => {
       if (!constraint) return;
       const [variable, expression] = constraint.split("=").map((s) => s.trim());

+ 8 - 0
npm.py

@@ -131,6 +131,14 @@ for key, dependency in dependencies.items():
                 content = content.replace(MSG, 'BufferGeometryUtils')
                 newfile.write_text(content)
 
+            if 'DragControls.js' in filename:
+                content = newfile.read_text()
+                MSG = '_selected = findGroup( _intersections[ 0 ].object )'
+                if MSG not in content:
+                    raise ValueError(f'Expected to find "{MSG}" in {filename}')
+                content = content.replace(MSG, MSG + ' || _intersections[ 0 ].object')
+                newfile.write_text(content)
+
             if 'mermaid.esm.min.mjs' in filename:
                 content = newfile.read_text()
                 content = re.sub(r'"\./chunks/mermaid.esm.min/(.*?)\.mjs"', r'"\1"', content)