Skip to content

Commit

Permalink
Merge pull request #881 from ptcrealitylab/Add-measurement-tool-liste…
Browse files Browse the repository at this point in the history
…ners

Update object.js
  • Loading branch information
Steve-KX-RL authored Oct 27, 2023
2 parents 7d775be + 15a4e8b commit c3c6032
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions libraries/objectDefaultFiles/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@
if (typeof eventData.worldIntersectPoint !== 'undefined') {
event.worldIntersectPoint = eventData.worldIntersectPoint;
}
if (typeof eventData.threejsIntersectPoint !== 'undefined') {
event.threejsIntersectPoint = eventData.threejsIntersectPoint;
}

// send unacceptedTouch message if this interface wants touches to pass through it
if (spatialObject.touchDeciderRegistered && eventData.type === 'pointerdown') {
Expand Down Expand Up @@ -753,6 +756,13 @@
this.getUserDetails = makeSendStub('getUserDetails');
this.getAreaTargetMesh = makeSendStub('getAreaTargetMesh');
this.getSpatialCursorEvent = makeSendStub('getSpatialCursorEvent');
this.spatialCursorToggleMeasureMode = makeSendStub('spatialCursorToggleMeasureMode'); // when open/close a measure app, change spatial cursor center visual to "+" or ".", to indicate user to add a measure point
this.spatialCursorToggleCrossRotation = makeSendStub('spatialCursorToggleCrossRotation'); // after not adding a measure point for a while, rotate the center "+" on spatial cursor twice, to prompt user action
this.spatialCursorToggleCloseLoop = makeSendStub('spatialCursorToggleCloseLoop'); // when it's able to close a loop for an area / volume, change spatial cursor center visual to "o", to indicate close loop
this.measureAppTurnMapUI = makeSendStub('measureAppTurnMapUI'); // measure app turn on / off the map settings UI
this.measureAppToggleMapUI = makeSendStub('measureAppToggleMapUI'); // measure app toggle on / off the map settings UI
this.measureAppSetPathPoint = makeSendStub('measureAppSetPathPoint'); // in line measure mode, set a path start / end point, send the info to user interface
this.measureAppSetClothPos = makeSendStub('measureAppSetClothPos'); // in area measure mode, set a cloth bounding box, send the info to user interface

this.profilerStartTimeProcess = makeSendStub('profilerStartTimeProcess');
this.profilerStopTimeProcess = makeSendStub('profilerStopTimeProcess');
Expand Down Expand Up @@ -794,6 +804,10 @@
this.addVisibilityListener = makeSendStub('addVisibilityListener');
this.addInterfaceListener = makeSendStub('addInterfaceListener');
this.addIsMovingListener = makeSendStub('addIsMovingListener');
this.addMeasureAppCloseAppListener = makeSendStub('addMeasureAppCloseAppListener'); // triggered a specific measure app is closed
this.addMeasureAppHeightMapChangeListener = makeSendStub('addMeasureAppHeightMapChangeListener'); // triggered when user interface change to height map
this.addMeasureAppFindPathListener = makeSendStub('addMeasureAppFindPathListener'); // triggered when user interface pathfinding.js finds a path
this.addMeasureAppClothInfoListener = makeSendStub('addMeasureAppClothInfoListener'); // triggered when user interface clothSimulation.js finishes computing the cloth volume
// deprecated or unimplemented methods
this.addAccelerationListener = makeSendStub('addAccelerationListener');
}
Expand Down Expand Up @@ -2328,6 +2342,55 @@
});
};

this.spatialCursorToggleMeasureMode = function(boolean) {
postDataToParent({
spatialCursorToggleMeasureMode: boolean
});
};

this.spatialCursorToggleCrossRotation = function(boolean) {
postDataToParent({
spatialCursorToggleCrossRotation: boolean
});
};

this.spatialCursorToggleCloseLoop = function(boolean) {
postDataToParent({
spatialCursorToggleCloseLoop: boolean
});
};

this.measureAppTurnMapUI = function(boolean) {
postDataToParent({
measureAppTurnMapUI: boolean
});
};

this.measureAppToggleMapUI = function() {
postDataToParent({
measureAppToggleMapUI: true
});
};

this.measureAppSetPathPoint = function(type, startPosArr) {
postDataToParent({
measureAppSetPathPoint: {
type: type,
point: startPosArr
}
});
};

this.measureAppSetClothPos = function(uuid, boundingBoxMin, boundingBoxMax) {
postDataToParent({
measureAppSetClothPos: {
uuid: uuid,
boundingBoxMin: boundingBoxMin,
boundingBoxMax: boundingBoxMax
}
});
};

/**
* Stubbed here for backwards compatibility of API. In previous versions:
* Hides the frame itself and instead populates a background context within the editor with this frame's contents
Expand Down Expand Up @@ -2497,6 +2560,38 @@
}
};
};

this.addMeasureAppCloseAppListener = function(callback) {
spatialObject.messageCallBacks.closeAppCall = function (msgContent) {
if (typeof msgContent.isAppClosed !== 'undefined') {
callback();
}
};
};

this.addMeasureAppHeightMapChangeListener = function(callback) {
spatialObject.messageCallBacks.heightMapCall = function (msgContent) {
if (typeof msgContent.isHeightMapOn !== 'undefined' && typeof msgContent.isSteepnessMapOn !== 'undefined') {
callback(msgContent.isHeightMapOn, msgContent.isSteepnessMapOn);
}
};
};

this.addMeasureAppFindPathListener = function(callback) {
spatialObject.messageCallBacks.findPathCall = function (msgContent) {
if (typeof msgContent.pathArr !== 'undefined' && typeof msgContent.pathLength !== 'undefined') {
callback(msgContent.cellSize, msgContent.pathArr, msgContent.pathLength, msgContent.offset);
}
};
};

this.addMeasureAppClothInfoListener = function(callback) {
spatialObject.messageCallBacks.clothInfoCall = function (msgContent) {
if (typeof msgContent.uuid !== 'undefined' && typeof msgContent.clothMesh !== 'undefined' && typeof msgContent.volume !== 'undefined' && typeof msgContent.labelPos !== 'undefined' ) {
callback(msgContent.uuid, msgContent.clothMesh, msgContent.volume, msgContent.labelPos);
}
};
};
};

SpatialInterface.prototype.injectSetterGetterAPI = function() {
Expand Down

0 comments on commit c3c6032

Please sign in to comment.