|
@@ -629,6 +629,48 @@ class MeshSpray extends Spray {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ override function editorOnContextMenu(): Array<hide.comp.ContextMenu.MenuItem> {
|
|
|
+ var items = super.editorOnContextMenu();
|
|
|
+ items.push({
|
|
|
+ label: "Set To Ground",
|
|
|
+ click: setToGround,
|
|
|
+ });
|
|
|
+ return items;
|
|
|
+ }
|
|
|
+
|
|
|
+ function setToGround() {
|
|
|
+ var mso = cast(local3d,MeshSprayObject);
|
|
|
+ var undo = undo;
|
|
|
+ undo.change(Custom(function(undo) {
|
|
|
+ }));
|
|
|
+ for( c in this.children ) {
|
|
|
+ var obj = c.to(Object3D);
|
|
|
+ if( obj == null ) continue;
|
|
|
+ setGroundPos(obj);
|
|
|
+ obj.applyTransform();
|
|
|
+ wasEdited = true;
|
|
|
+ }
|
|
|
+ if ( this.binaryMeshes != null ) {
|
|
|
+ var pos = new h3d.col.Point(0,0,0);
|
|
|
+ for ( bm in this.binaryMeshes ) {
|
|
|
+ var pivot = mso.getAbsPos();
|
|
|
+ pos.x = bm.x + pivot.tx;
|
|
|
+ pos.y = bm.y + pivot.ty;
|
|
|
+ pos.z = bm.z + pivot.tz;
|
|
|
+ var ground = setGroundPos(null, pos);
|
|
|
+ bm.z += ground.mz;
|
|
|
+ bm.rotX = ground.rotX;
|
|
|
+ bm.rotY = ground.rotY;
|
|
|
+ bm.rotZ = ground.rotZ;
|
|
|
+ }
|
|
|
+ if ( this.binaryMeshes.length > 0) {
|
|
|
+ wasEdited = true;
|
|
|
+ binaryChanged = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mso.redraw();
|
|
|
+ }
|
|
|
+
|
|
|
override function edit( ectx : hide.prefab.EditContext ) {
|
|
|
invParent = getAbsPos().clone();
|
|
|
invParent.invert();
|
|
@@ -909,37 +951,7 @@ class MeshSpray extends Spray {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- options.find("#toground").click(function(_) {
|
|
|
- var mso = cast(local3d,MeshSprayObject);
|
|
|
- undo.change(Custom(function(undo) {
|
|
|
- }));
|
|
|
- for( c in this.children ) {
|
|
|
- var obj = c.to(Object3D);
|
|
|
- if( obj == null ) continue;
|
|
|
- setGroundPos(obj);
|
|
|
- obj.applyTransform();
|
|
|
- wasEdited = true;
|
|
|
- }
|
|
|
- if ( this.binaryMeshes != null ) {
|
|
|
- var pos = new h3d.col.Point(0,0,0);
|
|
|
- for ( bm in this.binaryMeshes ) {
|
|
|
- var pivot = mso.getAbsPos();
|
|
|
- pos.x = bm.x + pivot.tx;
|
|
|
- pos.y = bm.y + pivot.ty;
|
|
|
- pos.z = bm.z + pivot.tz;
|
|
|
- var ground = setGroundPos(null, pos);
|
|
|
- bm.z += ground.mz;
|
|
|
- bm.rotX = ground.rotX;
|
|
|
- bm.rotY = ground.rotY;
|
|
|
- bm.rotZ = ground.rotZ;
|
|
|
- }
|
|
|
- if ( this.binaryMeshes.length > 0) {
|
|
|
- wasEdited = true;
|
|
|
- binaryChanged = true;
|
|
|
- }
|
|
|
- }
|
|
|
- mso.redraw();
|
|
|
- });
|
|
|
+ options.find("#toground").click((e) -> setToGround);
|
|
|
|
|
|
options.find("#remove").click(function(_) {
|
|
|
var options = selectElement.children().elements();
|