From 8144841258c7dfe29ea9fcfca4e16d54cf53618a Mon Sep 17 00:00:00 2001 From: Daniela Date: Fri, 15 Sep 2017 12:41:15 +0100 Subject: [PATCH] Add Edit.js Entities spawn up according to the orientation of the avatar. --- scripts/system/edit.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 569d4812dc..dca07a2fac 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -247,9 +247,12 @@ var toolBar = (function () { direction = MyAvatar.orientation; } direction = Vec3.multiplyQbyV(direction, Vec3.UNIT_Z); - + // Align entity with Avatar orientation. + properties.rotation = MyAvatar.orientation; + var PRE_ADJUST_ENTITY_TYPES = ["Box", "Sphere", "Shape", "Text", "Web"]; if (PRE_ADJUST_ENTITY_TYPES.indexOf(properties.type) !== -1) { + // Adjust position of entity per bounding box prior to creating it. var registration = properties.registration; if (registration === undefined) { @@ -259,7 +262,14 @@ var toolBar = (function () { var orientation = properties.orientation; if (orientation === undefined) { - var DEFAULT_ORIENTATION = Quat.fromPitchYawRollDegrees(0, 0, 0); + properties.orientation = MyAvatar.orientation; + var DEFAULT_ORIENTATION = properties.orientation; + orientation = DEFAULT_ORIENTATION; + } else { + // If the orientation is already defined, we perform the corresponding rotation assuming that + // our start referential is the avatar referential. + properties.orientation = Quat.multiply(MyAvatar.orientation, properties.orientation); + var DEFAULT_ORIENTATION = properties.orientation; orientation = DEFAULT_ORIENTATION; }