mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 18:55:01 +02:00
remove conversion code from equipEntity.js
This commit is contained in:
parent
c5aafd4644
commit
b93807b1a7
1 changed files with 9 additions and 84 deletions
|
@ -167,16 +167,6 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
|
|||
};
|
||||
|
||||
|
||||
var alreadyWarned = {};
|
||||
function warnAboutUserData(props) {
|
||||
if (alreadyWarned[props.id]) {
|
||||
return;
|
||||
}
|
||||
print("Warning -- overriding grab properties with userData for " + props.id + " / " + props.name);
|
||||
alreadyWarned[props.id] = true;
|
||||
}
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
var ATTACH_POINT_SETTINGS = "io.highfidelity.attachPoints";
|
||||
|
@ -199,80 +189,15 @@ function warnAboutUserData(props) {
|
|||
var UNEQUIP_KEY = "u";
|
||||
|
||||
function getWearableData(props) {
|
||||
if (props.grab.equippable) {
|
||||
// if equippable is true, we know this was already converted from the old userData style to properties
|
||||
return {
|
||||
joints: {
|
||||
LeftHand: [ props.grab.equippableLeftPosition, props.grab.equippableLeftRotation ],
|
||||
RightHand: [ props.grab.equippableRightPosition, props.grab.equippableRightRotation ]
|
||||
},
|
||||
indicatorURL: props.grab.equippableIndicatorURL,
|
||||
indicatorScale: props.grab.equippableIndicatorScale,
|
||||
indicatorOffset: props.grab.equippableIndicatorOffset
|
||||
};
|
||||
} else {
|
||||
// check for old userData equippability. The JSON reader will convert userData to properties
|
||||
// in EntityTree.cpp, but this won't catch things created from scripts or some items in
|
||||
// the market. Eventually we'll remove this section.
|
||||
try {
|
||||
if (!props.userDataParsed) {
|
||||
props.userDataParsed = JSON.parse(props.userData);
|
||||
}
|
||||
var userDataParsed = props.userDataParsed;
|
||||
|
||||
// userData: { wearable: { joints: { LeftHand: {...}, RightHand: {...} } } }
|
||||
if (userDataParsed.wearable && userDataParsed.wearable.joints) {
|
||||
warnAboutUserData(props);
|
||||
userDataParsed.wearable.indicatorURL = "";
|
||||
userDataParsed.wearable.indicatorScale = { x: 1, y: 1, z: 1 };
|
||||
userDataParsed.wearable.indicatorOffset = { x: 0, y: 0, z: 0 };
|
||||
return userDataParsed.wearable;
|
||||
}
|
||||
|
||||
// userData: { equipHotspots: { joints: { LeftHand: {...}, RightHand: {...} } } }
|
||||
// https://highfidelity.atlassian.net/wiki/spaces/HOME/pages/51085337/Authoring+Equippable+Entities
|
||||
if (userDataParsed.equipHotspots &&
|
||||
userDataParsed.equipHotspots.length > 0 &&
|
||||
userDataParsed.equipHotspots[0].joints) {
|
||||
warnAboutUserData(props);
|
||||
var hotSpot = userDataParsed.equipHotspots[0];
|
||||
|
||||
var indicatorScale = { x: hotSpot.radius, y: hotSpot.radius, z: hotSpot.radius };
|
||||
if (hotSpot.modelURL && hotSpot.modelURL !== "") {
|
||||
indicatorScale = hotSpot.modelScale;
|
||||
}
|
||||
|
||||
return {
|
||||
joints: hotSpot.joints,
|
||||
indicatorURL: hotSpot.modelURL,
|
||||
indicatorScale: indicatorScale,
|
||||
indicatorOffset: hotSpot.position,
|
||||
};
|
||||
}
|
||||
|
||||
// userData:{grabbableKey:{spatialKey:{leftRelativePosition:{...},rightRelativePosition:{...}}}}
|
||||
if (userDataParsed.grabbableKey &&
|
||||
userDataParsed.grabbableKey.spatialKey) {
|
||||
warnAboutUserData(props);
|
||||
var joints = {};
|
||||
joints.LeftHand = [ { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0, w: 1 } ];
|
||||
joints.RightHand = [ { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0, w: 1 } ];
|
||||
if (userDataParsed.grabbableKey.spatialKey.leftRelativePosition) {
|
||||
joints.LeftHand = [userDataParsed.grabbableKey.spatialKey.leftRelativePosition,
|
||||
userDataParsed.grabbableKey.spatialKey.relativeRotation];
|
||||
}
|
||||
if (userDataParsed.grabbableKey.spatialKey.rightRelativePosition) {
|
||||
joints.RightHand = [userDataParsed.grabbableKey.spatialKey.rightRelativePosition,
|
||||
userDataParsed.grabbableKey.spatialKey.relativeRotation];
|
||||
}
|
||||
return { joints: joints };
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
// don't spam logs
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
joints: {
|
||||
LeftHand: [ props.grab.equippableLeftPosition, props.grab.equippableLeftRotation ],
|
||||
RightHand: [ props.grab.equippableRightPosition, props.grab.equippableRightRotation ]
|
||||
},
|
||||
indicatorURL: props.grab.equippableIndicatorURL,
|
||||
indicatorScale: props.grab.equippableIndicatorScale,
|
||||
indicatorOffset: props.grab.equippableIndicatorOffset
|
||||
};
|
||||
}
|
||||
|
||||
function getAttachPointSettings() {
|
||||
|
|
Loading…
Reference in a new issue