Skip to content

Commit 86f5ea1

Browse files
author
Max Carlson
committed
Revert "Don demo tweaks (#68)"
This reverts commit b2c304f.
1 parent b2c304f commit 86f5ea1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+23113
-950
lines changed

Unity/SpaceCraft/Assets/Editor/Build.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public static void WebGL_Prod()
9292
}
9393
// --- End Force ---
9494

95-
// Default prod output (match Development build location)
96-
string buildPath = Path.Combine("..", "..", "WebSites", "SpaceCraft");
95+
// Default prod output (existing behavior)
96+
string buildPath = Path.Combine("Builds", "SpaceCraft");
9797
// Allow CI override via env var or CLI
9898
buildPath = ResolveOutputPath(buildPath);
9999
Debug.Log($"[Build] Output path: {buildPath}");

Unity/SpaceCraft/Assets/Resources/Prefabs/MagnetView.prefab

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,11 @@ MonoBehaviour:
118118
magnetSoftness: 0
119119
magnetHoleRadius: 0
120120
magnetHoleStrength: 0
121-
_scoreMin: 0.8
121+
_scoreMin: 0
122122
_scoreMax: 1
123123
viewScale: 1
124124
viewScaleInitial: 0.01
125125
magnetMaterial: {fileID: 2100000, guid: 2610998a9e1a94c63a3d4e941db2602e, type: 2}
126-
orbitForce: 0
127-
orbitWidth: 4
128-
orbitEjectStrength: 10
129-
orbitEjectRadius: 10
130-
orbitDeflectStrength: 2
131-
orbitDeflectRadius: 7
132126
--- !u!1 &7411782117926916970
133127
GameObject:
134128
m_ObjectHideFlags: 0

Unity/SpaceCraft/Assets/Scripts/Core/InputManager.cs

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public class InputManager : MonoBehaviour
128128
[ExposedParameter(
129129
"View Mode",
130130
Category = "View",
131-
Description = "Current view mode (tab id): about, arrange, view, select, inspect",
132-
Default = "arrange",
131+
Description = "Current view mode: magnets, selection, manual, or attract",
132+
Default = "magnets",
133133
Visible = true
134134
)]
135-
public string viewMode = "arrange";
135+
public string viewMode = "magnets";
136136

137137
[ExposedParameter(
138138
"View Seek Position Speed",
@@ -391,28 +391,24 @@ void FixedUpdate()
391391
ApplyContinuousThrust();
392392

393393

394-
// Use tab ids only: about, arrange, view, select, inspect
395-
string _mode = (viewMode ?? "").ToLowerInvariant();
394+
switch (viewMode) {
396395

397-
switch (_mode) {
398-
399-
case "about":
396+
case "attract":
400397
viewSeekEnabled = true;
401398
ViewSeekAttract();
402399
break;
403400

404-
case "arrange":
401+
case "magnets":
405402
viewSeekEnabled = true;
406403
ViewSeekMagnets();
407404
break;
408405

409-
case "select":
410-
case "inspect":
406+
case "selection":
411407
viewSeekEnabled = true;
412408
ViewSeekSelection();
413409
break;
414410

415-
case "view":
411+
case "manual":
416412
default:
417413
viewSeekEnabled = false;
418414
break;
@@ -868,40 +864,29 @@ private void ApplyMagnetForces()
868864
ItemView[] allItems = FindObjectsByType<ItemView>(FindObjectsSortMode.None);
869865
if (allItems.Length == 0) return;
870866

871-
// Precompute, for each item, whether any magnet (other than the one applying force)
872-
// would attract/affect it. This lets MagnetView modulate ejection using orbitDeflectStrength.
873-
Dictionary<ItemView, bool> itemAffected = new Dictionary<ItemView, bool>(allItems.Length);
874-
foreach (var itemView in allItems)
875-
{
876-
bool affected = false;
877-
Vector3 pos = itemView.transform.position;
878-
foreach (var m in allMagnets)
879-
{
880-
if (m == null || !m.magnetEnabled) continue;
881-
if (m.WouldAttract(itemView, pos)) { affected = true; break; }
882-
}
883-
itemAffected[itemView] = affected;
884-
}
885-
886867
foreach (MagnetView magnet in allMagnets)
887868
{
888869
if (magnet == null || !magnet.magnetEnabled) continue;
870+
889871
foreach (ItemView itemView in allItems)
890872
{
891873
if (itemView?.GetComponent<Rigidbody>() == null) continue;
874+
892875
Rigidbody rb = itemView.GetComponent<Rigidbody>();
893-
if (rb.isKinematic) continue;
894-
895-
bool affectedElsewhere = false;
896-
if (itemAffected.TryGetValue(itemView, out bool v)) affectedElsewhere = v;
897-
// If this magnet alone is affecting, we still pass the global flag;
898-
// MagnetView will choose orbitDeflectStrength only for repulsion.
899-
Vector3 magneticForce = magnet.CalculateMagneticForce(itemView, itemView.transform.position, affectedElsewhere);
900-
if (magneticForce.magnitude > 0.001f)
901-
{
902-
rb.AddForce(magneticForce, ForceMode.Force);
903-
if (rb.IsSleeping() && magneticForce.magnitude > 0.1f) rb.WakeUp();
904-
}
876+
if (rb.isKinematic) continue;
877+
878+
Vector3 magneticForce = magnet.CalculateMagneticForce(itemView, itemView.transform.position);
879+
880+
if (magneticForce.magnitude > 0.001f)
881+
{
882+
rb.AddForce(magneticForce, ForceMode.Force);
883+
884+
if (rb.IsSleeping() && magneticForce.magnitude > 0.1f)
885+
{
886+
rb.WakeUp();
887+
}
888+
}
889+
905890
if (rb.linearVelocity.magnitude > maxItemVelocity)
906891
{
907892
rb.linearVelocity = rb.linearVelocity.normalized * maxItemVelocity;

Unity/SpaceCraft/Assets/Scripts/Core/SpaceCraft.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,19 +1208,4 @@ public void PushCameraVelocity(string controllerId, string controllerName, float
12081208
{
12091209
inputManager.PushCameraVelocity(controllerId, controllerName, panXDelta, panYDelta);
12101210
}
1211-
1212-
/// <summary>
1213-
/// Public API to push an item by id with a small delta in world units.
1214-
/// Exposed to JS via bridge.updateObject(this.spaceCraft, { "method:PushItem": [itemId, dx, dy] })
1215-
/// </summary>
1216-
public void PushItem(string itemId, float dx, float dy)
1217-
{
1218-
if (string.IsNullOrEmpty(itemId)) return;
1219-
var itemView = FindItemSafe(itemId);
1220-
if (itemView == null) return;
1221-
var rb = itemView.GetComponent<Rigidbody>();
1222-
if (rb == null) return;
1223-
Vector3 newPosition = itemView.transform.position + new Vector3(dx, 0f, dy);
1224-
rb.MovePosition(newPosition);
1225-
}
12261211
}

Unity/SpaceCraft/Assets/Scripts/Views/MagnetView.cs

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -218,41 +218,17 @@ public string searchType
218218
)]
219219
[SerializeField] public float orbitEjectStrength = 10f;
220220

221-
[ExposedParameter(
222-
"Orbit Deflect Strength",
223-
Category = "Magnetic Field",
224-
Description = "Reduced outward force applied to items already influenced by one or more magnets.",
225-
Default = 2f,
226-
Visible = true,
227-
Min = 0f,
228-
Max = 100f,
229-
Step = 0.1f
230-
)]
231-
[SerializeField] public float orbitDeflectStrength = 2f;
232-
233221
[ExposedParameter(
234222
"Orbit Eject Radius",
235223
Category = "Magnetic Field",
236224
Description = "Outward force applied to items with scores below the minimum threshold.",
237-
Default = 10f,
238-
Visible = true,
239-
Min = 0f,
240-
Max = 100f,
241-
Step = 0.1f
242-
)]
243-
[SerializeField] public float orbitEjectRadius= 10f;
244-
245-
[ExposedParameter(
246-
"Orbit Deflect Radius",
247-
Category = "Magnetic Field",
248-
Description = "Radius for reduced repulsion when item is influenced by other magnets.",
249-
Default = 7f,
225+
Default = 15f,
250226
Visible = true,
251227
Min = 0f,
252228
Max = 100f,
253229
Step = 0.1f
254230
)]
255-
[SerializeField] public float orbitDeflectRadius = 7f;
231+
[SerializeField] public float orbitEjectRadius= 7f;
256232

257233
[SerializeField] private float _scoreMin = 0.8f;
258234
[ExposedParameter(
@@ -459,16 +435,6 @@ public bool IsItemEligible(Item item)
459435
/// Apply magnetic force to an item based on distance and relevance
460436
/// </summary>
461437
public Vector3 CalculateMagneticForce(ItemView itemView, Vector3 itemPosition)
462-
{
463-
// Backwards-compat overload: default no deflection knowledge
464-
return CalculateMagneticForce(itemView, itemPosition, false);
465-
}
466-
467-
/// <summary>
468-
/// Calculates magnetic force. If itemAffectedByOtherMagnets is true, repulsion inside eject radius
469-
/// will use orbitDeflectStrength instead of orbitEjectStrength.
470-
/// </summary>
471-
public Vector3 CalculateMagneticForce(ItemView itemView, Vector3 itemPosition, bool itemAffectedByOtherMagnets)
472438
{
473439
if (!magnetEnabled || itemView?.Model == null) return Vector3.zero;
474440

@@ -488,17 +454,15 @@ public Vector3 CalculateMagneticForce(ItemView itemView, Vector3 itemPosition, b
488454
// EJECTION LOGIC for items that don't meet the minimum score
489455
if (score < scoreMin)
490456
{
491-
// Only apply ejection/deflection inside the appropriate radius
492-
float radius = itemAffectedByOtherMagnets ? orbitDeflectRadius : orbitEjectRadius;
493-
float strengthParam = itemAffectedByOtherMagnets ? orbitDeflectStrength : orbitEjectStrength;
494-
if (strengthParam <= 0.001f || distance >= radius) return Vector3.zero;
457+
// Only apply ejection inside the orbitEjectRadius
458+
if (orbitEjectStrength <= 0.001f || distance >= orbitEjectRadius) return Vector3.zero;
495459

496460
// Ejection force is strongest for items with score 0, and falls to 0 as score approaches scoreMin
497461
float scoreFactor = 1f - (score / Mathf.Max(scoreMin, 0.0001f));
498462
scoreFactor = Mathf.Clamp01(scoreFactor);
499463

500464
// Have the ejection force fall off towards the edge of the ejection radius
501-
float ejectU = distance / Mathf.Max(radius, 0.0001f); // 0 at center, 1 at edge
465+
float ejectU = distance / Mathf.Max(orbitEjectRadius, 0.0001f); // 0 at center, 1 at eject edge
502466
float s = Mathf.Clamp01(magnetSoftness);
503467
float ejectEdgeWidth = 0.5f * s;
504468
float ejectEdgeFactor;
@@ -513,7 +477,7 @@ public Vector3 CalculateMagneticForce(ItemView itemView, Vector3 itemPosition, b
513477
ejectEdgeFactor = (ejectU < 1f) ? 1f : 0f;
514478
}
515479

516-
float forceStrength = strengthParam * scoreFactor * ejectEdgeFactor;
480+
float forceStrength = orbitEjectStrength * scoreFactor * ejectEdgeFactor;
517481

518482
// Return outward force (away from magnet)
519483
return -toMagnet.normalized * forceStrength;
@@ -620,22 +584,6 @@ public Vector3 CalculateMagneticForce(ItemView itemView, Vector3 itemPosition, b
620584
return Vector3.zero;
621585
}
622586

623-
/// <summary>
624-
/// Returns true if this magnet would attract or orbit the item (meets score threshold
625-
/// and lies within the magnet's influence radius).
626-
/// </summary>
627-
public bool WouldAttract(ItemView itemView, Vector3 itemPosition)
628-
{
629-
if (!magnetEnabled || itemView?.Model == null) return false;
630-
float score = CalculateItemScore(itemView.Model);
631-
if (score < scoreMin || score > scoreMax) return false;
632-
Vector3 toMagnet = transform.position - itemPosition;
633-
float distance = toMagnet.magnitude;
634-
float innerR = Mathf.Max(0f, magnetHoleRadius);
635-
float outerR = Mathf.Max(innerR, magnetRadius);
636-
return distance < outerR;
637-
}
638-
639587
// Cubic Hermite smoothstep
640588
private static float SmoothStep(float edge0, float edge1, float x)
641589
{

Unity/SpaceCraft/Assets/StreamingAssets/SpaceCraft/spacecraft.js

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,47 +1093,6 @@ class SpaceCraftSim {
10931093
}
10941094
})
10951095

1096-
// Push a single item by ID in simulator world space (from controller Select tab joystick)
1097-
.on('broadcast', { event: 'pushItem' }, (data) => {
1098-
try {
1099-
const payload = data && data.payload || {};
1100-
try { console.log('[Sim] pushItem event received', JSON.parse(JSON.stringify(payload))); } catch {}
1101-
1102-
// Respect targeting if provided
1103-
if (payload.targetSimulatorId && payload.targetSimulatorId !== this.identity.clientId) {
1104-
try { console.log('[Sim] pushItem ignored: targeted for other simulator', { targetSimulatorId: payload.targetSimulatorId, myId: this.identity.clientId }); } catch {}
1105-
return;
1106-
}
1107-
1108-
const itemId = payload.itemId;
1109-
const dx = Number(payload.deltaX);
1110-
const dy = Number(payload.deltaY);
1111-
1112-
if (!itemId || !isFinite(dx) || !isFinite(dy)) {
1113-
try { console.warn('[Sim] pushItem invalid payload', { itemId, dx, dy }); } catch {}
1114-
return;
1115-
}
1116-
1117-
if (!this.spaceCraft) {
1118-
try { console.warn('[Sim] pushItem aborted: this.spaceCraft is not ready'); } catch {}
1119-
return;
1120-
}
1121-
1122-
// Prefer calling the exposed C# method via bridge updateObject (explicit)
1123-
try { console.log('[Sim] pushItem invoking bridge.updateObject → method:PushItem', { itemId, dx, dy }); } catch {}
1124-
try {
1125-
bridge.updateObject(this.spaceCraft, {
1126-
"method:PushItem": [itemId, dx, dy]
1127-
});
1128-
try { console.log('[Sim] pushItem dispatched to Unity'); } catch {}
1129-
} catch (e) {
1130-
try { console.error('[Sim] pushItem bridge call failed', e); } catch {}
1131-
}
1132-
} catch (outer) {
1133-
try { console.error('[Sim] pushItem handler error', outer); } catch {}
1134-
}
1135-
})
1136-
11371096
.on('broadcast', { event: 'setViewMode' }, (data) => {
11381097
if (data.payload.targetSimulatorId && data.payload.targetSimulatorId !== this.identity.clientId) {
11391098
return;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:b9b71d9c6fcc86c5939f58d2ff22949148cbd4f462044f18ae6c6ce53b9e174d
3-
size 10191020
2+
oid sha256:3483f278d8f9e6dccbba597fafd8a8889d577dbbcf0f97fe25884352d27be1a5
3+
size 10232378

WebSites/SpaceCraft/Build/SpaceCraft.framework.js

Lines changed: 21540 additions & 2 deletions
Large diffs are not rendered by default.

WebSites/SpaceCraft/Build/SpaceCraft.loader.js

Lines changed: 1431 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c14990b35415a431a38356127f6d79104bd1de17d3119c01911a1569eeaf4c3a
3-
size 56758754
2+
oid sha256:3e02e84271a7445c890b5c81a24acab2c1cda71d9ab5321a618f11bc56e5abbc
3+
size 82677590

0 commit comments

Comments
 (0)