completed init movement for human
This commit is contained in:
@@ -60,35 +60,29 @@ function HumanUi() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedEventSphere) return;
|
||||
|
||||
const selectedHuman = getHumanById(selectedEventSphere.userData.modelUuid);
|
||||
if (!selectedHuman || !selectedHuman.point?.action) return;
|
||||
|
||||
if (selectedHuman) {
|
||||
setSelectedHumanData({
|
||||
position: selectedHuman.position,
|
||||
rotation: selectedHuman.rotation,
|
||||
});
|
||||
setSelectedHumanData({
|
||||
position: selectedHuman.position,
|
||||
rotation: selectedHuman.rotation,
|
||||
});
|
||||
|
||||
if (selectedHuman.point?.actions && selectedAction.actionId) {
|
||||
const action = selectedHuman.point.actions.find(a => a.actionUuid === selectedAction.actionId);
|
||||
const action = selectedHuman.point.action;
|
||||
|
||||
if (action?.animationSequences[0]) {
|
||||
const sequence = action.animationSequences[0];
|
||||
if (action.pickUpPoint?.position && outerGroup.current) {
|
||||
const worldPos = new Vector3(...action.pickUpPoint.position);
|
||||
const localPosition = outerGroup.current.worldToLocal(worldPos.clone());
|
||||
setStartPosition([localPosition.x, 0.5, localPosition.z]);
|
||||
setStartRotation(action.pickUpPoint.rotation || [0, 0, 0]);
|
||||
}
|
||||
|
||||
if (sequence.startPoint?.position && outerGroup.current) {
|
||||
const worldPos = new Vector3(...sequence.startPoint.position);
|
||||
const localPosition = outerGroup.current.worldToLocal(worldPos.clone());
|
||||
setStartPosition([localPosition.x, 0.5, localPosition.z]);
|
||||
setStartRotation(sequence.startPoint.rotation || [0, 0, 0]);
|
||||
}
|
||||
|
||||
if (sequence.endPoint?.position && outerGroup.current) {
|
||||
const worldPos = new Vector3(...sequence.endPoint.position);
|
||||
const localPosition = outerGroup.current.worldToLocal(worldPos.clone());
|
||||
setEndPosition([localPosition.x, 0.5, localPosition.z]);
|
||||
setEndRotation(sequence.endPoint.rotation || [0, 0, 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (action.dropPoint?.position && outerGroup.current) {
|
||||
const worldPos = new Vector3(...action.dropPoint.position);
|
||||
const localPosition = outerGroup.current.worldToLocal(worldPos.clone());
|
||||
setEndPosition([localPosition.x, 0.5, localPosition.z]);
|
||||
setEndRotation(action.dropPoint.rotation || [0, 0, 0]);
|
||||
}
|
||||
}, [selectedEventSphere, outerGroup.current, selectedAction, humans]);
|
||||
|
||||
@@ -126,29 +120,17 @@ function HumanUi() {
|
||||
const worldPosEnd = new Vector3(...endPosition);
|
||||
const globalEndPosition = outerGroup.current.localToWorld(worldPosEnd.clone());
|
||||
|
||||
const updatedActions = selectedHuman.point.actions.map(action => {
|
||||
if (action.actionUuid === selectedAction.actionId) {
|
||||
const updatedSequences = action.animationSequences.map(sequence => {
|
||||
return {
|
||||
...sequence,
|
||||
startPoint: {
|
||||
position: [globalStartPosition.x, globalStartPosition.y, globalStartPosition.z] as [number, number, number],
|
||||
rotation: startRotation
|
||||
},
|
||||
endPoint: {
|
||||
position: [globalEndPosition.x, globalEndPosition.y, globalEndPosition.z] as [number, number, number],
|
||||
rotation: endRotation
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...action,
|
||||
animationSequences: updatedSequences
|
||||
};
|
||||
const updatedAction = {
|
||||
...selectedHuman.point.action,
|
||||
pickUpPoint: {
|
||||
position: [globalStartPosition.x, globalStartPosition.y, globalStartPosition.z] as [number, number, number],
|
||||
rotation: startRotation
|
||||
},
|
||||
dropPoint: {
|
||||
position: [globalEndPosition.x, globalEndPosition.y, globalEndPosition.z] as [number, number, number],
|
||||
rotation: endRotation
|
||||
}
|
||||
return action;
|
||||
});
|
||||
};
|
||||
|
||||
const event = updateEvent(
|
||||
selectedProduct.productUuid,
|
||||
@@ -157,7 +139,7 @@ function HumanUi() {
|
||||
...selectedHuman,
|
||||
point: {
|
||||
...selectedHuman.point,
|
||||
actions: updatedActions
|
||||
action: updatedAction
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -195,8 +177,7 @@ function HumanUi() {
|
||||
const currentPointerX = state.pointer.x;
|
||||
const deltaX = currentPointerX - prevMousePos.current.x;
|
||||
prevMousePos.current.x = currentPointerX;
|
||||
const marker =
|
||||
isRotating === "start" ? startMarker.current : endMarker.current;
|
||||
const marker =isRotating === "start" ? startMarker.current : endMarker.current;
|
||||
if (marker) {
|
||||
const rotationSpeed = 10;
|
||||
marker.rotation.y += deltaX * rotationSpeed;
|
||||
|
||||
Reference in New Issue
Block a user