diff --git a/libraries/hardwareInterfaces.js b/libraries/hardwareInterfaces.js index 7c1d46faa..9a9ec9393 100644 --- a/libraries/hardwareInterfaces.js +++ b/libraries/hardwareInterfaces.js @@ -480,6 +480,23 @@ exports.removeNode = function (objectName, frameName, nodeName) { } }; +exports.attachNodeToGroundPlane = function (objectName, frameName, nodeName, shouldAttachToGroundPlane) { + var objectID = utilities.getObjectIdFromTarget(objectName, objectsPath); + var frameID = objectID + frameName; + var nodeID = objectID + frameName + nodeName; + + if (!_.isUndefined(objectID) && !_.isNull(objectID)) { + if (objects.hasOwnProperty(objectID)) { + if (objects[objectID].frames.hasOwnProperty(frameID)) { + if (objects[objectID].frames[frameID].nodes.hasOwnProperty(nodeID)) { + + objects[objectID].frames[frameID].nodes[nodeID].attachToGroundPlane = shouldAttachToGroundPlane; + console.log("attached node " + nodeName + " to ground plane"); + } + } + } + } +}; exports.pushUpdatesToDevices = function(object){ var objectID = utilities.getObjectIdFromTarget(object, objectsPath); diff --git a/libraries/objectDefaultFiles/object.js b/libraries/objectDefaultFiles/object.js index 221acac4e..db4b9c1ef 100644 --- a/libraries/objectDefaultFiles/object.js +++ b/libraries/objectDefaultFiles/object.js @@ -303,6 +303,7 @@ this.injectPostMessage(); } else { this.sendGlobalMessage = makeSendStub('sendGlobalMessage'); + this.sendResetNodes = makeSendStub('sendResetNodes'); this.sendCreateNode = makeSendStub('sendCreateNode'); this.subscribeToMatrix = makeSendStub('subscribeToMatrix'); this.subscribeToAcceleration = makeSendStub('subscribeToAcceleration'); @@ -824,13 +825,29 @@ }), '*'); }; - this.sendCreateNode = function (name) { + this.sendResetNodes = function () { + //removes all nodes from the frame parent.postMessage(JSON.stringify({ version: realityObject.version, node: realityObject.node, frame: realityObject.frame, object: realityObject.object, - createNode: {name: name} + resetNodes: true + }), '*'); + }; + + this.sendCreateNode = function (name, x, y, attachToGroundPlane) { + parent.postMessage(JSON.stringify({ + version: realityObject.version, + node: realityObject.node, + frame: realityObject.frame, + object: realityObject.object, + createNode: { + name: name, + x: x, + y: y, + attachToGroundPlane: attachToGroundPlane + } }), '*'); };