Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
If anyone can help me would be much appreciated: I am trying to use the existing drag n drop extension but it causes the object to fall below the mouse position and jerk in mid air. I mostly cant click to drop the item also as the item is outside of the central mouse position. Any solutions to this which is due to gravity (zero gravity stops this but still some problems) ???? Help please...or suggestions to try... Existing extension code: action_Drag3DObject = function(){}; currentlyDraggingAction = null; dontRestartDraggingUntil = 0; // called when the action is executed action_Drag3DObject.prototype.execute = function(currentNode){ if (dontRestartDraggingUntil != 0){ var now = (new Date()).getTime(); if (dontRestartDraggingUntil > now) return; } if (currentlyDraggingAction){ currentlyDraggingAction.stopDragging(); return; } currentlyDraggingAction = this; var me = this; this.registeredFunction = function() { me.draggingFunc(); }; ccbRegisterOnFrameEvent(this.registeredFunction); this.currentNode = currentNode; var positionNode = ccbGetSceneNodeProperty(currentNode, "Position"); var positionCam = ccbGetSceneNodeProperty(ccbGetActiveCamera(), "Position"); this.distance = positionNode.substract(positionCam).getLength(); } action_Drag3DObject.prototype.stopDragging = function(){ this.currentNode = null; ccbUnregisterOnFrameEvent(this.registeredFunction); currentlyDraggingAction = null; dontRestartDraggingUntil = (new Date()).getTime() + 300; } action_Drag3DObject.prototype.draggingFunc = function(){ // update position var mouseX = ccbGetMousePosX(); var mouseY = ccbGetMousePosY(); var pos3d = ccbGet3DPosFrom2DPos(mouseX, mouseY); var positionCam = ccbGetSceneNodeProperty(ccbGetActiveCamera(), "Position"); var ray = pos3d.substract(positionCam); ray.normalize(); ray.x *= this.distance; ray.y *= this.distance; ray.z *= this.distance; ccbSetSceneNodeProperty(this.currentNode, "Position", ray.x + positionCam.x, ray.y + positionCam.y, ray.z + positionCam.z); } |
||||
|
Don't know what you are talking about exactly but both of the drag and drop extensions are working good for me. if your object has collide when moved behavior attached to it try disabling affected by gravity or remove that behavior... |
||||
|
wrote: Don't know what you are talking about exactly but both of the drag and drop extensions are working good for me. if your object has collide when moved behavior attached to it try disabling affected by gravity or remove that behavior... well, this is a video of what I was getting and how I fixed it.. https://youtu.be/QmCePeCeNro |
|