Fixed Create App

This commit is contained in:
ksuprynowicz 2023-02-12 15:29:47 +01:00
parent 4f263a074a
commit b78c816cab
13 changed files with 3124 additions and 3067 deletions

View file

@ -45,6 +45,7 @@
* {@link InteractiveWindow}: none, top left, top right, bottom right, or bottom left of the Interface window.
* <em>Read-only.</em>
*/
class DesktopScriptingInterface : public QObject, public Dependency {
Q_OBJECT
Q_PROPERTY(int width READ getWidth) // Physical width of screen(s) including task bars and system menus

View file

@ -129,6 +129,7 @@ public:
virtual void compileTest() = 0;
virtual QString scriptValueDebugDetails(const ScriptValue &value) = 0;
virtual QString scriptValueDebugListMembers(const ScriptValue &value) = 0;
virtual void logBacktrace(const QString &title) = 0;
public:
// helper to detect and log warnings when other code invokes QScriptEngine/BaseScriptEngine in thread-unsafe ways
bool IS_THREADSAFE_INVOCATION(const QString& method);

View file

@ -2508,3 +2508,7 @@ ScriptValue ScriptManager::evaluate(const QString& program, const QString& fileN
void ScriptManager::requestGarbageCollection() {
_engine->requestCollectGarbage();
}
void ScriptManager::logBacktrace(const QString &title) {
_engine->logBacktrace(title);
}

View file

@ -564,6 +564,13 @@ public:
*/
Q_INVOKABLE void requestGarbageCollection();
/**jsdoc
* Prints out current backtrace to the log.
* @function Script.logBacktrace
* @param {string} title - Title added to the printed out backtrace.
*/
Q_INVOKABLE void logBacktrace(const QString &title);
/*@jsdoc
* @function Script.loadEntityScript
* @param {Uuid} entityID - Entity ID.

View file

@ -1714,6 +1714,14 @@ QString ScriptEngineV8::scriptValueDebugDetailsV8(const V8ScriptValue &v8Value)
}
}*/
void ScriptEngineV8::logBacktrace(const QString &title) {
QStringList backtrace = currentContext()->backtrace();
qDebug(scriptengine) << title;
for (int n = 0; n < backtrace.length(); n++) {
qDebug(scriptengine) << backtrace[n];
}
}
QStringList ScriptEngineV8::getCurrentScriptURLs() const {
auto isolate = _v8Isolate;
v8::Locker locker(isolate);

View file

@ -136,6 +136,7 @@ public: // ScriptEngine implementation
QString scriptValueDebugDetailsV8(const V8ScriptValue &value);
virtual QString scriptValueDebugListMembers(const ScriptValue &value) override;
QString scriptValueDebugListMembersV8(const V8ScriptValue &v8Value);
virtual void logBacktrace(const QString &title) override;
// helper to detect and log warnings when other code invokes QScriptEngine/BaseScriptEngine in thread-unsafe ways
inline bool IS_THREADSAFE_INVOCATION(const QString& method) { return ScriptEngine::IS_THREADSAFE_INVOCATION(method); }

View file

@ -49,6 +49,7 @@ void ScriptEngineV8::registerCustomType(int type,
}
Q_DECLARE_METATYPE(ScriptValue);
Q_DECLARE_METATYPE(QVariantMap);
/*static V8ScriptValue ScriptValueToV8ScriptValue(ScriptEngineV8* engine, const ScriptValue& src) {
return ScriptValueV8Wrapper::fullUnwrap(static_cast<ScriptEngineV8*>(engine), src);

View file

@ -1144,10 +1144,20 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu
for (ConnectionList::iterator iter = _connections.begin(); iter != _connections.end(); ++iter) {
Connection& conn = *iter;
{
//auto functionContext = callback->CreationContext();
auto functionContext = _v8Context.Get(_engine->getIsolate());
_engine->pushContext(functionContext);
/*if (!conn.callback.get()->IsFunction()) {
auto stringV8 = conn.callback.get()->ToDetailString(context).ToLocalChecked();
QString error = *v8::String::Utf8Value(_engine->getIsolate(), stringV8);
qDebug() << error;
Q_ASSERT(false);
}
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(conn.callback.get());
auto functionContext = callback->CreationContext();
v8::Context::Scope functionContextScope(functionContext);
_engine->pushContext(functionContext);*/
/*auto functionContext = _v8Context.Get(_engine->getIsolate());
_engine->pushContext(functionContext);
v8::Context::Scope functionContextScope(functionContext);*/
auto functionContext = context;
Q_ASSERT(!conn.callback.get().IsEmpty());
Q_ASSERT(!conn.callback.get()->IsUndefined());
@ -1178,7 +1188,7 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu
<< _engine->formatErrorMessageFromTryCatch(tryCatch)
<< "\nThis provided: " << conn.thisValue.get()->IsObject();
}
_engine->popContext();
//_engine->popContext();
}
}
});

View file

@ -91,6 +91,7 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri
//qDebug() << "V8 This: " << _engine->scriptValueDebugDetailsV8(v8This);
}else{
recv = _engine->getContext()->Global();
//recv = v8::Null(isolate);
//qDebug() << "global";
}
//qDebug() << "V8 Call: " << *v8::String::Utf8Value(isolate, v8This.get()->TypeOf(isolate));

View file

@ -18,7 +18,9 @@
progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, OverlaySystemWindow,
keyUpEventFromUIWindow:true */
//(function() { // BEGIN LOCAL_SCOPE
(function() { // BEGIN LOCAL_SCOPE
//var CreateApp = function() { // BEGIN LOCAL_SCOPE
var createApp = {};
var EDIT_TOGGLE_BUTTON = "com.highfidelity.interface.system.editButton";
@ -84,6 +86,7 @@ var shouldUseEditTabletApp = function() {
var selectionDisplay = SelectionDisplay;
selectionDisplay.createApp = createApp;
var selectionManager = SelectionManager;
var PARTICLE_SYSTEM_URL = Script.resolvePath("assets/images/icon-particles.svg");
@ -121,11 +124,13 @@ var copiedRotation;
var cameraManager = new CameraManager();
var grid = new Grid();
selectionDisplay.grid = grid;
var gridTool = new GridTool({
horizontalGrid: grid,
createToolsWindow: createToolsWindow,
shouldUseEditTabletApp: shouldUseEditTabletApp
});
gridTool.selectionDisplay = selectionDisplay;
gridTool.setVisible(false);
var editTools = new EditTools({
@ -144,6 +149,7 @@ var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js')
var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"], entityShapeVisualizerSessionName);
var entityListTool = new EntityListTool(shouldUseEditTabletApp);
entityListTool.createApp = createApp;
selectionManager.addEventListener(function () {
selectionDisplay.updateHandles();
@ -667,7 +673,7 @@ var toolBar = (function () {
SelectionManager.addEntity(entityID, false, this);
SelectionManager.saveProperties();
pushCommandForSelections([{
createApp.pushCommandForSelections([{
entityID: entityID,
properties: properties
}], [], true);
@ -1124,6 +1130,7 @@ var toolBar = (function () {
Messages.sendLocalMessage("edit-events", JSON.stringify({
enabled: active
}));
print("Setting isActive: " + active);
isActive = active;
activeButton.editProperties({isActive: isActive});
undoHistory.setEnabled(isActive);
@ -1175,7 +1182,7 @@ var orientation;
var intersection;
function rayPlaneIntersection(pickRay, point, normal) { //
createApp.rayPlaneIntersection = function(pickRay, point, normal) { //
//
// This version of the test returns the intersection of a line with a plane
//
@ -1187,7 +1194,7 @@ function rayPlaneIntersection(pickRay, point, normal) { //
return Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, t));
}
function rayPlaneIntersection2(pickRay, point, normal) {
createApp.rayPlaneIntersection2 = function(pickRay, point, normal) {
//
// This version of the test returns false if the ray is directed away from the plane
//
@ -1244,7 +1251,7 @@ function findClickedEntity(event) {
}
selectionDisplay.moveSelection(Vec3.sum(entityResult.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
selectionManager._update(false, this);
pushCommandForSelections();
createApp.pushCommandForSelections();
expectingRotateAsClickedSurface = false;
audioFeedback.action();
}
@ -1389,6 +1396,7 @@ function mouseMove(event) {
}
function mouseReleaseEvent(event) {
print("mouseReleaseEvent");
mouseDown = false;
if (lastMouseMoveEvent) {
@ -1396,20 +1404,24 @@ function mouseReleaseEvent(event) {
lastMouseMoveEvent = null;
}
if (propertyMenu.mouseReleaseEvent(event)) {
print("propertyMenu.mouseReleaseEvent(event)");
return true;
}
if (isActive && selectionManager.hasSelection()) {
tooltip.show(false);
}
if (mouseCapturedByTool) {
print("mouseCapturedByTool");
return;
}
cameraManager.mouseReleaseEvent(event);
if (!mouseHasMovedSincePress) {
print("!mouseHasMovedSincePress: " + JSON.stringify(event));
mouseClickEvent(event);
} else {
print("mouseHasMovedSincePress");
}
}
@ -1429,9 +1441,11 @@ function wasTabletOrEditHandleClicked(event) {
}
function mouseClickEvent(event) {
print("mouseClickEvent isActive: " + isActive);
var wantDebug = false;
var result, properties, tabletClicked;
if (isActive && event.isLeftButton) {
print("mouseClickEvent isActive && event.isLeftButton");
result = findClickedEntity(event);
var tabletOrEditHandleClicked = wasTabletOrEditHandleClicked(event);
if (tabletOrEditHandleClicked) {
@ -1485,7 +1499,7 @@ function mouseClickEvent(event) {
if (0 < x && sizeOK && selectionManager.editEnabled) {
selectedEntityID = foundEntity;
orientation = MyAvatar.orientation;
intersection = rayPlaneIntersection(pickRay, P, Quat.getForward(orientation));
intersection = createApp.rayPlaneIntersection(pickRay, P, Quat.getForward(orientation));
if (!event.isShifted) {
selectionManager.setSelections([foundEntity], this);
@ -1904,7 +1918,7 @@ function deleteSelectedEntities() {
if (savedProperties.length > 0) {
SelectionManager.clearSelections(this);
pushCommandForSelections([], savedProperties);
createApp.pushCommandForSelections([], savedProperties);
entityListTool.deleteEntities(deletedIDs);
}
} else {
@ -2369,7 +2383,7 @@ function applyEntityProperties(data) {
// For currently selected entities, push a command to the UndoStack that uses the current entity properties for the
// redo command, and the saved properties for the undo command. Also, include create and delete entity data.
function pushCommandForSelections(createdEntityData, deletedEntityData, doNotSaveEditProperties) {
createApp.pushCommandForSelections = function (createdEntityData, deletedEntityData, doNotSaveEditProperties) {
doNotSaveEditProperties = false;
var undoData = {
editEntities: [],
@ -2620,7 +2634,7 @@ var PropertiesTool = function (opts) {
if (data.onlyUpdateEntities) {
blockPropertyUpdates = true;
} else {
pushCommandForSelections();
createApp.pushCommandForSelections();
SelectionManager.saveProperties();
}
selectionManager._update(false, this);
@ -2652,7 +2666,7 @@ var PropertiesTool = function (opts) {
position: newPosition
});
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
}
} else if (data.action === "moveAllToGrid") {
@ -2672,7 +2686,7 @@ var PropertiesTool = function (opts) {
position: newPosition
});
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
}
} else if (data.action === "resetToNaturalDimensions") {
@ -2693,7 +2707,7 @@ var PropertiesTool = function (opts) {
});
}
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
}
} else if (data.action === "previewCamera") {
@ -2711,7 +2725,7 @@ var PropertiesTool = function (opts) {
dimensions: Vec3.multiply(multiplier, properties.dimensions)
});
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
}
} else if (data.action === "reloadClientScripts") {
@ -2751,7 +2765,7 @@ var PropertiesTool = function (opts) {
position: copiedPosition
});
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
} else {
audioFeedback.rejection();
@ -2764,7 +2778,7 @@ var PropertiesTool = function (opts) {
rotation: copiedRotation
});
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
} else {
audioFeedback.rejection();
@ -2782,7 +2796,7 @@ var PropertiesTool = function (opts) {
rotation: Quat.IDENTITY
});
}
pushCommandForSelections();
createApp.pushCommandForSelections();
selectionManager._update(false, this);
} else {
audioFeedback.rejection();
@ -3181,7 +3195,8 @@ function zoneSortOrder(a, b) {
}
//print("getParentState added");
function getParentState(id) {
//function getParentState(id) {
createApp.getParentState = function(id) {
var state = "NONE";
var properties = Entities.getEntityProperties(id, ["parentID"]);
var children = getDomainOnlyChildrenIDs(id);
@ -3266,4 +3281,5 @@ function rotateAsNextClickedSurface() {
}
}
//}()); // END LOCAL_SCOPE
}()); // END LOCAL_SCOPE
//}(); // END LOCAL_SCOPE

View file

@ -218,7 +218,7 @@ var EntityListTool = function(shouldUseEditTabletApp) {
url = properties.imageURL;
}
//print("Global object before getParentState call: " + JSON.stringify(globalThis));
var parentStatus = getParentState(ids[i]);
var parentStatus = that.createApp.getParentState(ids[i]);
var parentState = "";
if (parentStatus === "PARENT") {
parentState = "A";

View file

@ -83,12 +83,15 @@ SelectionManager = (function() {
// FUNCTION: HANDLE ENTITY SELECTION TOOL UPDATES
function handleEntitySelectionToolUpdates(channel, message, sender) {
//print("Channel: " + channel + " Sender: " + sender + " Message: " + JSON.stringify(message));
if (channel !== 'entityToolUpdates') {
return;
}
print("handleEntitySelectionToolUpdates entityToolUpdates");
if (sender !== MyAvatar.sessionUUID) {
return;
}
print("handleEntitySelectionToolUpdates MyAvatar.sessionUUID");
var wantDebug = false;
var messageParsed;
@ -99,6 +102,7 @@ SelectionManager = (function() {
return;
}
print("handleEntitySelectionToolUpdates JSON.parse(message): " + messageParsed.method);
if (messageParsed.method === "selectEntity") {
if (!that.editEnabled) {
return;
@ -125,7 +129,7 @@ SelectionManager = (function() {
}
selectionDisplay.moveSelection(Vec3.sum(messageParsed.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
that._update(false, this);
pushCommandForSelections();
that.createApp.pushCommandForSelections();
expectingRotateAsClickedSurface = false;
audioFeedback.action();
}
@ -147,6 +151,7 @@ SelectionManager = (function() {
that.clearSelections();
}
} else if (messageParsed.method === "pointingAt") {
print("handleEntitySelectionToolUpdates pointingAt");
if (messageParsed.hand === Controller.Standard.RightHand) {
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
that.pointingAtTabletRight = messageParsed.tablet;
@ -232,6 +237,8 @@ SelectionManager = (function() {
};
that.setSelections = function(entityIDs, caller) {
print("setSelections: " + JSON.stringify(entityIDs));
Script.logBacktrace("setSelections");
that.selections = [];
for (var i = 0; i < entityIDs.length; i++) {
var entityID = entityIDs[i];
@ -723,7 +730,7 @@ SelectionManager = (function() {
var newPosition = Vec3.sum(relativePosition, targetPosition);
Entities.editEntity(id, { "position": newPosition });
}
pushCommandForSelections();
that.createApp.pushCommandForSelections();
that._update(false, this);
} else {
audioFeedback.rejection();
@ -2002,7 +2009,7 @@ SelectionDisplay = (function() {
var handleBoundingBoxColor = COLOR_BOUNDING_EDGE;
if (SelectionManager.selections.length === 1) {
var parentState = getParentState(SelectionManager.selections[0]);
var parentState = that.createApp.getParentState(SelectionManager.selections[0]);
if (parentState === "CHILDREN") {
handleBoundingBoxColor = COLOR_BOUNDING_EDGE_CHILDREN;
} else if (parentState === "PARENT") {
@ -2504,7 +2511,7 @@ SelectionDisplay = (function() {
}
updateSelectionsRotation(axisRotation, SelectionManager.worldPosition);
SelectionManager._update(false, this);
pushCommandForSelections();
that.createApp.pushCommandForSelections();
audioFeedback.action();
}
};
@ -2585,7 +2592,7 @@ SelectionDisplay = (function() {
print(" starting elevation: " + startingElevation);
}
initialPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
initialPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
if (debugPickPlaneEnabled) {
that.showDebugPickPlane(pickPlanePosition, pickPlaneNormal);
@ -2598,7 +2605,7 @@ SelectionDisplay = (function() {
}
},
onEnd: function(event, reason) {
pushCommandForSelections(duplicatedEntityIDs);
that.createApp.pushCommandForSelections(duplicatedEntityIDs);
if (isConstrained) {
Entities.editEntity(xRailToolEntity, {
visible: false,
@ -2617,7 +2624,7 @@ SelectionDisplay = (function() {
var wantDebug = false;
var pickRay = generalComputePickRay(event.x, event.y);
var newPick = rayPlaneIntersection2(pickRay, pickPlanePosition, pickPlaneNormal);
var newPick = that.createApp.rayPlaneIntersection2(pickRay, pickPlanePosition, pickPlaneNormal);
// If the pick ray doesn't hit the pick plane in this direction, do nothing.
// this will happen when someone drags across the horizon from the side they started on.
@ -2722,7 +2729,7 @@ SelectionDisplay = (function() {
var negateAndHalve = -0.5;
var cornerPosition = Vec3.sum(startPosition, Vec3.multiply(negateAndHalve, SelectionManager.worldDimensions));
vector = Vec3.subtract(
grid.snapToGrid(Vec3.sum(cornerPosition, vector), constrainMajorOnly),
that.grid.snapToGrid(Vec3.sum(cornerPosition, vector), constrainMajorOnly),
cornerPosition);
// editing a parent will cause all the children to automatically follow along, so don't
@ -2801,7 +2808,7 @@ SelectionDisplay = (function() {
axisVector = Vec3.multiplyQbyV(rotation, axisVector);
pickPlaneNormal = Vec3.cross(Vec3.cross(pickRay.direction, axisVector), axisVector);
pickPlanePosition = SelectionManager.worldPosition;
initialPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
initialPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
SelectionManager.saveProperties();
that.resetPreviousHandleColor();
@ -2822,7 +2829,7 @@ SelectionDisplay = (function() {
}
},
onEnd: function(event, reason) {
pushCommandForSelections(duplicatedEntityIDs);
that.createApp.pushCommandForSelections(duplicatedEntityIDs);
},
onMove: function(event) {
var pickRay = generalComputePickRay(event.x, event.y);
@ -2832,7 +2839,7 @@ SelectionDisplay = (function() {
pickRay = previousPickRay;
}
var newPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
var newPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
if (debugPickPlaneEnabled) {
that.showDebugPickPlaneHit(newPick);
}
@ -2850,8 +2857,8 @@ SelectionDisplay = (function() {
var dotVector = Vec3.dot(vector, projectionVector);
vector = Vec3.multiply(dotVector, projectionVector);
var gridOrigin = grid.getOrigin();
vector = Vec3.subtract(grid.snapToGrid(Vec3.sum(vector, gridOrigin)), gridOrigin);
var gridOrigin = that.grid.getOrigin();
vector = Vec3.subtract(that.grid.snapToGrid(Vec3.sum(vector, gridOrigin)), gridOrigin);
var wantDebug = false;
if (wantDebug) {
@ -2962,7 +2969,7 @@ SelectionDisplay = (function() {
pickPlaneNormal = Vec3.cross(Vec3.cross(pickRay.direction, axisVector), axisVector);
pickPlanePosition = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffsetWorld));
initialPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
initialPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
that.setHandleTranslateVisible(false);
that.setHandleRotateVisible(false);
@ -3009,7 +3016,7 @@ SelectionDisplay = (function() {
}
activeStretchCubePanelOffset = null;
pushCommandForSelections();
that.createApp.pushCommandForSelections();
},
onMove: function(event) {
var pickRay = generalComputePickRay(event.x, event.y);
@ -3019,7 +3026,7 @@ SelectionDisplay = (function() {
pickRay = previousPickRay;
}
var newPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
var newPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
if (debugPickPlaneEnabled) {
that.showDebugPickPlaneHit(newPick);
}
@ -3029,7 +3036,7 @@ SelectionDisplay = (function() {
changeInDimensions = Vec3.multiply(dotVector, axisVector);
changeInDimensions = Vec3.multiplyQbyV(Quat.inverse(rotation), changeInDimensions);
changeInDimensions = Vec3.multiplyVbyV(mask, changeInDimensions);
changeInDimensions = grid.snapToSpacing(changeInDimensions);
changeInDimensions = that.grid.snapToSpacing(changeInDimensions);
changeInDimensions = Vec3.multiply(NEGATE_VECTOR, Vec3.multiplyVbyV(signs, changeInDimensions));
var newDimensions = Vec3.sum(initialDimensions, changeInDimensions);
@ -3088,7 +3095,7 @@ SelectionDisplay = (function() {
pickPlanePosition = initialPosition;
pickPlaneNormal = Vec3.subtract(pickRay.origin, pickPlanePosition);
initialPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
initialPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
that.setHandleTranslateVisible(false);
that.setHandleRotateVisible(false);
@ -3121,7 +3128,7 @@ SelectionDisplay = (function() {
that.replaceCollisionsAfterStretch = false;
}
pushCommandForSelections();
that.createApp.pushCommandForSelections();
},
onMove: function(event) {
var pickRay = generalComputePickRay(event.x, event.y);
@ -3131,7 +3138,7 @@ SelectionDisplay = (function() {
pickRay = previousPickRay;
}
var newPick = rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
var newPick = that.createApp.rayPlaneIntersection(pickRay, pickPlanePosition, pickPlaneNormal);
if (debugPickPlaneEnabled) {
that.showDebugPickPlaneHit(newPick);
}
@ -3140,7 +3147,7 @@ SelectionDisplay = (function() {
var dimensionsMultiple = toCameraDistance * SCALE_DIMENSIONS_CAMERA_DISTANCE_MULTIPLE;
var changeInDimensions = Vec3.subtract(newPick, initialPick);
changeInDimensions = Vec3.multiplyQbyV(Quat.inverse(Camera.orientation), changeInDimensions);
changeInDimensions = grid.snapToSpacing(changeInDimensions);
changeInDimensions = that.grid.snapToSpacing(changeInDimensions);
changeInDimensions = Vec3.multiply(changeInDimensions, dimensionsMultiple);
var averageDimensionChange = (changeInDimensions.x + changeInDimensions.y + changeInDimensions.z) / 3;
@ -3309,7 +3316,7 @@ SelectionDisplay = (function() {
// editOverlays may not have committed rotation changes.
// Compute zero position based on where the toolEntity will be eventually.
var initialPick = rayPlaneIntersection(pickRay, rotationCenter, rotationNormal);
var initialPick = that.createApp.rayPlaneIntersection(pickRay, rotationCenter, rotationNormal);
// In case of a parallel ray, this will be null, which will cause early-out
// in the onMove helper.
rotationZero = initialPick;
@ -3343,7 +3350,7 @@ SelectionDisplay = (function() {
}
});
Entities.editEntity(handleRotateCurrentRing, { visible: false, ignorePickIntersection: true });
pushCommandForSelections();
that.createApp.pushCommandForSelections();
if (wantDebug) {
print("================== " + getMode() + "(addHandleRotateTool onEnd) <- =======================");
}
@ -3364,7 +3371,7 @@ SelectionDisplay = (function() {
}
var pickRay = generalComputePickRay(event.x, event.y);
var result = rayPlaneIntersection(pickRay, rotationCenter, rotationNormal);
var result = that.createApp.rayPlaneIntersection(pickRay, rotationCenter, rotationNormal);
if (result) {
var centerToZero = Vec3.subtract(rotationZero, rotationCenter);
var centerToIntersect = Vec3.subtract(result, rotationCenter);

View file

@ -292,8 +292,8 @@ GridTool = function(opts) {
var dataString = JSON.stringify(data);
webView.emitScriptEvent(dataString);
createToolsWindow.emitScriptEvent(dataString);
if (selectionDisplay) {
selectionDisplay.updateHandles();
if (that.selectionDisplay) {
that.selectionDisplay.updateHandles();
}
});