mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 15:47:02 +02:00
V8-related JS fixes
This commit is contained in:
parent
022bf6de8c
commit
6f92cf0330
6 changed files with 33 additions and 27 deletions
|
@ -567,6 +567,8 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
if (this.distanceHolding) {
|
if (this.distanceHolding) {
|
||||||
var targetProps = Entities.getEntityProperties(this.targetObject.entityID,
|
var targetProps = Entities.getEntityProperties(this.targetObject.entityID,
|
||||||
["position", "rotation", "registrationPoint", "dimensions"]);
|
["position", "rotation", "registrationPoint", "dimensions"]);
|
||||||
|
if (controllerData.rayPicks[this.hand].intersection == null)
|
||||||
|
return undefined;
|
||||||
return worldPositionToRegistrationFrameMatrix(targetProps, controllerData.rayPicks[this.hand].intersection);
|
return worldPositionToRegistrationFrameMatrix(targetProps, controllerData.rayPicks[this.hand].intersection);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
@ -216,15 +216,21 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
avatarSensorPosition.y = 0;
|
avatarSensorPosition.y = 0;
|
||||||
|
|
||||||
var targetRotation = Entities.getEntityProperties(_this.targetOverlayID, ["rotation"]).rotation;
|
var targetRotation = Entities.getEntityProperties(_this.targetOverlayID, ["rotation"]).rotation;
|
||||||
var relativePlayAreaCenterOffset =
|
if (targetRotation != null) {
|
||||||
Vec3.sum(_this.playAreaCenterOffset, { x: 0, y: -TARGET_MODEL_DIMENSIONS.y / 2, z: 0 });
|
var relativePlayAreaCenterOffset =
|
||||||
var localPosition = Vec3.multiplyQbyV(Quat.inverse(targetRotation),
|
Vec3.sum(_this.playAreaCenterOffset, {x: 0, y: -TARGET_MODEL_DIMENSIONS.y / 2, z: 0});
|
||||||
Vec3.multiplyQbyV(sensorToWorldRotation,
|
var localPosition = Vec3.multiplyQbyV(Quat.inverse(targetRotation),
|
||||||
Vec3.multiply(avatarScale, Vec3.subtract(relativePlayAreaCenterOffset, avatarSensorPosition))));
|
Vec3.multiplyQbyV(sensorToWorldRotation,
|
||||||
localPosition.y = _this.teleportScaleFactor * localPosition.y;
|
Vec3.multiply(avatarScale, Vec3.subtract(relativePlayAreaCenterOffset, avatarSensorPosition))));
|
||||||
|
localPosition.y = _this.teleportScaleFactor * localPosition.y;
|
||||||
|
} else {
|
||||||
|
print("");
|
||||||
|
}
|
||||||
|
|
||||||
playAreaOverlayProperties.parentID = _this.targetOverlayID;
|
playAreaOverlayProperties.parentID = _this.targetOverlayID;
|
||||||
playAreaOverlayProperties.localPosition = localPosition;
|
if (targetRotation != null) {
|
||||||
|
playAreaOverlayProperties.localPosition = localPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlays.editOverlay(_this.playAreaOverlay, playAreaOverlayProperties);
|
Overlays.editOverlay(_this.playAreaOverlay, playAreaOverlayProperties);
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
var selectionDisplay = SelectionDisplay;
|
var selectionDisplay = SelectionDisplay;
|
||||||
selectionDisplay.createApp = createApp;
|
selectionDisplay.createApp = createApp;
|
||||||
var selectionManager = SelectionManager;
|
var selectionManager = SelectionManager;
|
||||||
|
selectionManager.createApp = createApp;
|
||||||
|
|
||||||
var PARTICLE_SYSTEM_URL = Script.resolvePath("assets/images/icon-particles.svg");
|
var PARTICLE_SYSTEM_URL = Script.resolvePath("assets/images/icon-particles.svg");
|
||||||
var POINT_LIGHT_URL = Script.resolvePath("assets/images/icon-point-light.svg");
|
var POINT_LIGHT_URL = Script.resolvePath("assets/images/icon-point-light.svg");
|
||||||
|
@ -114,8 +115,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var hmdMultiSelectMode = false;
|
createApp.hmdMultiSelectMode = false;
|
||||||
var expectingRotateAsClickedSurface = false;
|
createApp.expectingRotateAsClickedSurface = false;
|
||||||
var keepSelectedOnNextClick = false;
|
var keepSelectedOnNextClick = false;
|
||||||
|
|
||||||
var copiedPosition;
|
var copiedPosition;
|
||||||
|
@ -1236,11 +1237,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var result;
|
var result;
|
||||||
if (expectingRotateAsClickedSurface) {
|
if (createApp.expectingRotateAsClickedSurface) {
|
||||||
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
audioFeedback.rejection();
|
audioFeedback.rejection();
|
||||||
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
expectingRotateAsClickedSurface = false;
|
createApp.expectingRotateAsClickedSurface = false;
|
||||||
} else {
|
} else {
|
||||||
//Rotate Selection according the Surface Normal
|
//Rotate Selection according the Surface Normal
|
||||||
var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(entityResult.surfaceNormal, -1));
|
var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(entityResult.surfaceNormal, -1));
|
||||||
|
@ -1255,7 +1256,7 @@
|
||||||
selectionDisplay.moveSelection(Vec3.sum(entityResult.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
|
selectionDisplay.moveSelection(Vec3.sum(entityResult.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
|
||||||
selectionManager._update(false, this);
|
selectionManager._update(false, this);
|
||||||
createApp.pushCommandForSelections();
|
createApp.pushCommandForSelections();
|
||||||
expectingRotateAsClickedSurface = false;
|
createApp.expectingRotateAsClickedSurface = false;
|
||||||
audioFeedback.action();
|
audioFeedback.action();
|
||||||
}
|
}
|
||||||
keepSelectedOnNextClick = true;
|
keepSelectedOnNextClick = true;
|
||||||
|
@ -1299,7 +1300,7 @@
|
||||||
var entity = entityIconOverlayManager.findEntity(data.overlayID);
|
var entity = entityIconOverlayManager.findEntity(data.overlayID);
|
||||||
|
|
||||||
if (entity !== null) {
|
if (entity !== null) {
|
||||||
if (hmdMultiSelectMode) {
|
if (createApp.hmdMultiSelectMode) {
|
||||||
selectionManager.addEntity(entity, true, this);
|
selectionManager.addEntity(entity, true, this);
|
||||||
} else {
|
} else {
|
||||||
selectionManager.setSelections([entity], this);
|
selectionManager.setSelections([entity], this);
|
||||||
|
@ -2510,7 +2511,7 @@
|
||||||
webView.setLandscape(true);
|
webView.setLandscape(true);
|
||||||
} else {
|
} else {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
hmdMultiSelectMode = false;
|
createApp.hmdMultiSelectMode = false;
|
||||||
webView.setLandscape(false);
|
webView.setLandscape(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3278,9 +3279,9 @@
|
||||||
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
audioFeedback.rejection();
|
audioFeedback.rejection();
|
||||||
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
expectingRotateAsClickedSurface = false;
|
createApp.expectingRotateAsClickedSurface = false;
|
||||||
} else {
|
} else {
|
||||||
expectingRotateAsClickedSurface = true;
|
createApp.expectingRotateAsClickedSurface = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ var EntityListTool = function(shouldUseEditTabletApp, selectionManager) {
|
||||||
} else if (data.type === 'unparent') {
|
} else if (data.type === 'unparent') {
|
||||||
that.createApp.unparentSelectedEntities();
|
that.createApp.unparentSelectedEntities();
|
||||||
} else if (data.type === 'hmdMultiSelectMode') {
|
} else if (data.type === 'hmdMultiSelectMode') {
|
||||||
hmdMultiSelectMode = data.value;
|
that.createApp.hmdMultiSelectMode = data.value;
|
||||||
} else if (data.type === 'selectAllInBox') {
|
} else if (data.type === 'selectAllInBox') {
|
||||||
that.createApp.selectAllEntitiesInCurrentSelectionBox(false);
|
that.createApp.selectAllEntitiesInCurrentSelectionBox(false);
|
||||||
} else if (data.type === 'selectAllTouchingBox') {
|
} else if (data.type === 'selectAllTouchingBox') {
|
||||||
|
|
|
@ -88,11 +88,9 @@ SelectionManager = (function() {
|
||||||
if (channel !== 'entityToolUpdates') {
|
if (channel !== 'entityToolUpdates') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("handleEntitySelectionToolUpdates entityToolUpdates");
|
|
||||||
if (sender !== MyAvatar.sessionUUID) {
|
if (sender !== MyAvatar.sessionUUID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("handleEntitySelectionToolUpdates MyAvatar.sessionUUID");
|
|
||||||
|
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
var messageParsed;
|
var messageParsed;
|
||||||
|
@ -112,11 +110,11 @@ SelectionManager = (function() {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("setting selection to " + messageParsed.entityID);
|
print("setting selection to " + messageParsed.entityID);
|
||||||
}
|
}
|
||||||
if (expectingRotateAsClickedSurface) {
|
if (that.createApp.expectingRotateAsClickedSurface) {
|
||||||
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
audioFeedback.rejection();
|
audioFeedback.rejection();
|
||||||
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
expectingRotateAsClickedSurface = false;
|
that.createApp.expectingRotateAsClickedSurface = false;
|
||||||
} else {
|
} else {
|
||||||
//Rotate Selection according the Surface Normal
|
//Rotate Selection according the Surface Normal
|
||||||
var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(messageParsed.surfaceNormal, -1));
|
var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(messageParsed.surfaceNormal, -1));
|
||||||
|
@ -131,7 +129,7 @@ SelectionManager = (function() {
|
||||||
selectionDisplay.moveSelection(Vec3.sum(messageParsed.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
|
selectionDisplay.moveSelection(Vec3.sum(messageParsed.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
|
||||||
that._update(false, this);
|
that._update(false, this);
|
||||||
that.createApp.pushCommandForSelections();
|
that.createApp.pushCommandForSelections();
|
||||||
expectingRotateAsClickedSurface = false;
|
that.createApp.expectingRotateAsClickedSurface = false;
|
||||||
audioFeedback.action();
|
audioFeedback.action();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,7 +138,7 @@ SelectionManager = (function() {
|
||||||
if (intersectObj.intersects) {
|
if (intersectObj.intersects) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hmdMultiSelectMode) {
|
if (that.createApp.hmdMultiSelectMode) {
|
||||||
that.addEntity(messageParsed.entityID, true, that);
|
that.addEntity(messageParsed.entityID, true, that);
|
||||||
} else {
|
} else {
|
||||||
that.setSelections([messageParsed.entityID], that);
|
that.setSelections([messageParsed.entityID], that);
|
||||||
|
@ -152,7 +150,6 @@ SelectionManager = (function() {
|
||||||
that.clearSelections();
|
that.clearSelections();
|
||||||
}
|
}
|
||||||
} else if (messageParsed.method === "pointingAt") {
|
} else if (messageParsed.method === "pointingAt") {
|
||||||
print("handleEntitySelectionToolUpdates pointingAt");
|
|
||||||
if (messageParsed.hand === Controller.Standard.RightHand) {
|
if (messageParsed.hand === Controller.Standard.RightHand) {
|
||||||
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
|
that.pointingAtDesktopWindowRight = messageParsed.desktopWindow;
|
||||||
that.pointingAtTabletRight = messageParsed.tablet;
|
that.pointingAtTabletRight = messageParsed.tablet;
|
||||||
|
|
|
@ -563,8 +563,8 @@ var distanceBetweenPointAndEntityBoundingBox = function(point, entityProps) {
|
||||||
var localPoint = entityXform.inv().xformPoint(point);
|
var localPoint = entityXform.inv().xformPoint(point);
|
||||||
var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions);
|
var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions);
|
||||||
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
|
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
|
||||||
var localMin = Vec3.subtract(entityXform.trans, minOffset);
|
var localMin = Vec3.subtract(entityXform.pos, minOffset);
|
||||||
var localMax = Vec3.sum(entityXform.trans, maxOffset);
|
var localMax = Vec3.sum(entityXform.pos, maxOffset);
|
||||||
|
|
||||||
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
|
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
|
||||||
v.x = Math.max(v.x, localMin.x);
|
v.x = Math.max(v.x, localMin.x);
|
||||||
|
@ -589,7 +589,7 @@ var worldPositionToRegistrationFrameMatrix = function(wptrProps, pos) {
|
||||||
// get world matrix for intersection point
|
// get world matrix for intersection point
|
||||||
var intersectionMat = new Xform({ x: 0, y: 0, z:0, w: 1 }, pos);
|
var intersectionMat = new Xform({ x: 0, y: 0, z:0, w: 1 }, pos);
|
||||||
|
|
||||||
// calculate world matrix for registrationPoint addjusted entity
|
// calculate world matrix for registrationPoint adjusted entity
|
||||||
var DEFAULT_REGISTRATION_POINT = { x: 0.5, y: 0.5, z: 0.5 };
|
var DEFAULT_REGISTRATION_POINT = { x: 0.5, y: 0.5, z: 0.5 };
|
||||||
var regRatio = Vec3.subtract(DEFAULT_REGISTRATION_POINT, wptrProps.registrationPoint);
|
var regRatio = Vec3.subtract(DEFAULT_REGISTRATION_POINT, wptrProps.registrationPoint);
|
||||||
var regOffset = Vec3.multiplyVbyV(regRatio, wptrProps.dimensions);
|
var regOffset = Vec3.multiplyVbyV(regRatio, wptrProps.dimensions);
|
||||||
|
|
Loading…
Reference in a new issue