Skip to content

Commit e6d52d3

Browse files
committed
some cleanup
1 parent 51c2088 commit e6d52d3

File tree

2 files changed

+1
-378
lines changed

2 files changed

+1
-378
lines changed
Lines changed: 0 additions & 377 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#if UNITY_WEBGL && !UNITY_EDITOR
2-
using AOT;
3-
using System;
4-
using System.Runtime.InteropServices;
5-
#endif
6-
using System;
7-
using UnityEngine;
81

92
namespace WebXR
103
{
@@ -72,375 +65,5 @@ private void LateUpdate()
7265
{
7366
subsystem.OnLateUpdate();
7467
}
75-
76-
// [Tooltip("Preserve the manager across scenes changes.")]
77-
// public bool dontDestroyOnLoad = true;
78-
// [Header("Tracking")]
79-
// [Tooltip("Default height of camera if no room-scale transform is present.")]
80-
// public float DefaultHeight = 1.2f;
81-
//
82-
// private static WebXRManager instance;
83-
// [HideInInspector]
84-
// public WebXRState xrState = WebXRState.NORMAL;
85-
//
86-
// public delegate void XRCapabilitiesUpdate(WebXRDisplayCapabilities capabilities);
87-
// public event XRCapabilitiesUpdate OnXRCapabilitiesUpdate;
88-
//
89-
// public delegate void XRChange(WebXRState state, int viewsCount, Rect leftRect, Rect rightRect);
90-
// public event XRChange OnXRChange;
91-
//
92-
// public delegate void HeadsetUpdate(
93-
// Matrix4x4 leftProjectionMatrix,
94-
// Matrix4x4 leftViewMatrix,
95-
// Matrix4x4 rightProjectionMatrix,
96-
// Matrix4x4 rightViewMatrix,
97-
// Matrix4x4 sitStandMatrix);
98-
// public event HeadsetUpdate OnHeadsetUpdate;
99-
//
100-
// public delegate void ControllerUpdate(WebXRControllerData controllerData);
101-
// public event ControllerUpdate OnControllerUpdate;
102-
//
103-
// public delegate void HandUpdate(WebXRHandData handData);
104-
// public event HandUpdate OnHandUpdate;
105-
//
106-
// public delegate void HitTestUpdate(WebXRHitPoseData hitPoseData);
107-
// public event HitTestUpdate OnViewerHitTestUpdate;
108-
//
109-
// #if UNITY_WEBGL && !UNITY_EDITOR
110-
// [DllImport("__Internal")]
111-
// private static extern void InitXRSharedArray(float[] array, int length);
112-
//
113-
// [DllImport("__Internal")]
114-
// private static extern void InitControllersArray(float[] array, int length);
115-
//
116-
// [DllImport("__Internal")]
117-
// private static extern void InitHandsArray(float[] array, int length);
118-
//
119-
// [DllImport("__Internal")]
120-
// private static extern void InitViewerHitTestPoseArray(float[] array, int length);
121-
//
122-
// [DllImport("__Internal")]
123-
// private static extern void ToggleViewerHitTest();
124-
//
125-
// [DllImport("__Internal")]
126-
// private static extern void ControllerPulse(int controller, float intensity, float duration);
127-
//
128-
// [DllImport("__Internal")]
129-
// private static extern void ListenWebXRData();
130-
//
131-
// [DllImport("__Internal")]
132-
// private static extern void set_webxr_events(Action<int, float, float, float, float, float, float, float, float> on_start_ar,
133-
// Action<int> on_start_vr,
134-
// Action on_end_xr,
135-
// Action<string> on_xr_capabilities);
136-
// #endif
137-
//
138-
// // Shared array which we will load headset data in from webxr.jslib
139-
// // Array stores 5 matrices, each 16 values, stored linearly.
140-
// float[] sharedArray = new float[5 * 16];
141-
//
142-
// // Shared array for controllers data
143-
// float[] controllersArray = new float[2 * 20];
144-
//
145-
// // Shared array for hands data
146-
// float[] handsArray = new float[2 * (25 * 9 + 5)];
147-
//
148-
// // Shared array for hit-test pose data
149-
// float[] viewerHitTestPoseArray = new float[9];
150-
//
151-
// bool viewerHitTestOn = false;
152-
//
153-
// private WebXRHandData leftHand = new WebXRHandData();
154-
// private WebXRHandData rightHand = new WebXRHandData();
155-
//
156-
// private WebXRControllerData controller1 = new WebXRControllerData();
157-
// private WebXRControllerData controller2 = new WebXRControllerData();
158-
//
159-
// private WebXRHitPoseData viewerHitTestPose = new WebXRHitPoseData();
160-
//
161-
// private WebXRDisplayCapabilities capabilities = new WebXRDisplayCapabilities();
162-
//
163-
// public static WebXRManager Instance
164-
// {
165-
// get
166-
// {
167-
// if (instance == null)
168-
// {
169-
// var managerInScene = FindObjectOfType<WebXRManager>();
170-
//
171-
// if (managerInScene != null)
172-
// {
173-
// instance = managerInScene;
174-
// }
175-
// else
176-
// {
177-
// GameObject go = new GameObject("WebXRCameraSet");
178-
// go.AddComponent<WebXRManager>();
179-
// }
180-
// }
181-
// return instance;
182-
// }
183-
// }
184-
//
185-
// private void Awake()
186-
// {
187-
// Debug.Log("Active Graphics Tier: " + Graphics.activeTier);
188-
// if (null == instance) {
189-
// instance = this;
190-
// } else if (instance != this) {
191-
// Destroy(gameObject);
192-
// }
193-
//
194-
// if (instance.dontDestroyOnLoad)
195-
// {
196-
// DontDestroyOnLoad(instance);
197-
// }
198-
// xrState = WebXRState.NORMAL;
199-
// }
200-
//
201-
// // Handles WebXR capabilities from browser
202-
// #if UNITY_WEBGL && !UNITY_EDITOR
203-
// [MonoPInvokeCallback(typeof(Action<string>))]
204-
// #endif
205-
// public static void OnXRCapabilities(string json)
206-
// {
207-
// WebXRDisplayCapabilities capabilities = JsonUtility.FromJson<WebXRDisplayCapabilities>(json);
208-
// instance.OnXRCapabilities(capabilities);
209-
// }
210-
//
211-
// public void OnXRCapabilities(WebXRDisplayCapabilities capabilities)
212-
// {
213-
// #if !UNITY_EDITOR && UNITY_WEBGL
214-
// this.capabilities = capabilities;
215-
// #endif
216-
//
217-
// if (OnXRCapabilitiesUpdate != null)
218-
// OnXRCapabilitiesUpdate(capabilities);
219-
// }
220-
//
221-
// public void setXrState(WebXRState state, int viewsCount, Rect leftRect, Rect rightRect)
222-
// {
223-
// this.xrState = state;
224-
// viewerHitTestOn = false;
225-
// if (OnXRChange != null)
226-
// OnXRChange(state, viewsCount, leftRect, rightRect);
227-
// }
228-
//
229-
// // received start VR from WebVR browser
230-
// #if UNITY_WEBGL && !UNITY_EDITOR
231-
// [MonoPInvokeCallback(typeof(Action<int, float, float, float, float, float, float, float, float>))]
232-
// #endif
233-
// public static void OnStartAR(int viewsCount,
234-
// float left_x, float left_y, float left_w, float left_h,
235-
// float right_x, float right_y, float right_w, float right_h)
236-
// {
237-
// Instance.setXrState(WebXRState.AR, viewsCount,
238-
// new Rect(left_x, left_y, left_w, left_h),
239-
// new Rect(right_x, right_y, right_w, right_h));
240-
// }
241-
//
242-
// #if UNITY_WEBGL && !UNITY_EDITOR
243-
// [MonoPInvokeCallback(typeof(Action<int>))]
244-
// #endif
245-
// public static void OnStartVR(int viewsCount)
246-
// {
247-
// Instance.setXrState(WebXRState.VR, viewsCount, new Rect(), new Rect());
248-
// }
249-
//
250-
// // receive end VR from WebVR browser
251-
// #if UNITY_WEBGL && !UNITY_EDITOR
252-
// [MonoPInvokeCallback(typeof(Action))]
253-
// #endif
254-
// public static void OnEndXR()
255-
// {
256-
// Instance.setXrState(WebXRState.NORMAL, 1, new Rect(), new Rect());
257-
// }
258-
//
259-
// public void StartViewerHitTest()
260-
// {
261-
// if (xrState == WebXRState.AR && !viewerHitTestOn)
262-
// {
263-
// viewerHitTestOn = true;
264-
// #if UNITY_WEBGL && !UNITY_EDITOR
265-
// ToggleViewerHitTest();
266-
// #endif
267-
// }
268-
// }
269-
//
270-
// public void StopViewerHitTest()
271-
// {
272-
// if (xrState == WebXRState.AR && viewerHitTestOn)
273-
// {
274-
// viewerHitTestOn = false;
275-
// #if UNITY_WEBGL && !UNITY_EDITOR
276-
// ToggleViewerHitTest();
277-
// #endif
278-
// }
279-
// }
280-
//
281-
// public void HapticPulse(WebXRControllerHand hand, float intensity, float duration)
282-
// {
283-
// #if UNITY_WEBGL && !UNITY_EDITOR
284-
// ControllerPulse((int)hand, intensity, duration);
285-
// #endif
286-
// }
287-
//
288-
// float[] GetMatrixFromSharedArray(int index)
289-
// {
290-
// float[] newArray = new float[16];
291-
// for (int i = 0; i < newArray.Length; i++)
292-
// {
293-
// newArray[i] = sharedArray[index * 16 + i];
294-
// }
295-
// return newArray;
296-
// }
297-
//
298-
// bool GetGamepadFromControllersArray(int controllerIndex, ref WebXRControllerData newControllerData)
299-
// {
300-
// int arrayPosition = controllerIndex * 20;
301-
// int frameNumber = (int)controllersArray[arrayPosition++];
302-
// if (newControllerData.frame == frameNumber)
303-
// {
304-
// return false;
305-
// }
306-
// newControllerData.frame = frameNumber;
307-
// newControllerData.enabled = controllersArray[arrayPosition++] != 0;
308-
// newControllerData.hand = (int)controllersArray[arrayPosition++];
309-
// if (!newControllerData.enabled)
310-
// {
311-
// return true;
312-
// }
313-
// newControllerData.position = new Vector3(controllersArray[arrayPosition++], controllersArray[arrayPosition++], controllersArray[arrayPosition++]);
314-
// newControllerData.rotation = new Quaternion(controllersArray[arrayPosition++], controllersArray[arrayPosition++], controllersArray[arrayPosition++], controllersArray[arrayPosition++]);
315-
// newControllerData.trigger = controllersArray[arrayPosition++];
316-
// newControllerData.squeeze = controllersArray[arrayPosition++];
317-
// newControllerData.thumbstick = controllersArray[arrayPosition++];
318-
// newControllerData.thumbstickX = controllersArray[arrayPosition++];
319-
// newControllerData.thumbstickY = controllersArray[arrayPosition++];
320-
// newControllerData.touchpad = controllersArray[arrayPosition++];
321-
// newControllerData.touchpadX = controllersArray[arrayPosition++];
322-
// newControllerData.touchpadY = controllersArray[arrayPosition++];
323-
// newControllerData.buttonA = controllersArray[arrayPosition++];
324-
// newControllerData.buttonB = controllersArray[arrayPosition];
325-
// return true;
326-
// }
327-
//
328-
// bool GetHandFromHandsArray(int handIndex, ref WebXRHandData handObject)
329-
// {
330-
// int arrayPosition = handIndex * 230;
331-
// int frameNumber = (int)handsArray[arrayPosition++];
332-
// if (handObject.frame == frameNumber)
333-
// {
334-
// return false;
335-
// }
336-
// handObject.frame = frameNumber;
337-
// handObject.enabled = handsArray[arrayPosition++] != 0;
338-
// handObject.hand = (int)handsArray[arrayPosition++];
339-
// handObject.trigger = handsArray[arrayPosition++];
340-
// handObject.squeeze = handsArray[arrayPosition++];
341-
// if (!handObject.enabled)
342-
// {
343-
// return true;
344-
// }
345-
// for (int i=0; i<=WebXRHandData.LITTLE_PHALANX_TIP; i++)
346-
// {
347-
// handObject.joints[i].enabled = handsArray[arrayPosition++] != 0;
348-
// handObject.joints[i].position = new Vector3(handsArray[arrayPosition++], handsArray[arrayPosition++], handsArray[arrayPosition++]);
349-
// handObject.joints[i].rotation = new Quaternion(handsArray[arrayPosition++], handsArray[arrayPosition++], handsArray[arrayPosition++], handsArray[arrayPosition++]);
350-
// handObject.joints[i].radius = handsArray[arrayPosition++];
351-
// }
352-
// return true;
353-
// }
354-
//
355-
// bool GetHitTestPoseFromViewerHitTestPoseArray(ref WebXRHitPoseData hitPoseData)
356-
// {
357-
// int arrayPosition = 0;
358-
// int frameNumber = (int)viewerHitTestPoseArray[arrayPosition++];
359-
// if (hitPoseData.frame == frameNumber)
360-
// {
361-
// return false;
362-
// }
363-
// hitPoseData.frame = frameNumber;
364-
// hitPoseData.available = viewerHitTestPoseArray[arrayPosition++] != 0;
365-
// if (!hitPoseData.available)
366-
// {
367-
// return true;
368-
// }
369-
// hitPoseData.position = new Vector3(viewerHitTestPoseArray[arrayPosition++], viewerHitTestPoseArray[arrayPosition++], viewerHitTestPoseArray[arrayPosition++]);
370-
// hitPoseData.rotation = new Quaternion(viewerHitTestPoseArray[arrayPosition++], viewerHitTestPoseArray[arrayPosition++], viewerHitTestPoseArray[arrayPosition++], viewerHitTestPoseArray[arrayPosition++]);
371-
// return true;
372-
// }
373-
//
374-
// void Start()
375-
// {
376-
// #if !UNITY_EDITOR && UNITY_WEBGL
377-
// set_webxr_events(OnStartAR, OnStartVR, OnEndXR, OnXRCapabilities);
378-
// InitControllersArray(controllersArray, controllersArray.Length);
379-
// InitHandsArray(handsArray, handsArray.Length);
380-
// InitViewerHitTestPoseArray(viewerHitTestPoseArray, viewerHitTestPoseArray.Length);
381-
// InitXRSharedArray(sharedArray, sharedArray.Length);
382-
// ListenWebXRData();
383-
// #endif
384-
// }
385-
//
386-
// void Update()
387-
// {
388-
// bool hasHandsData = false;
389-
// if (OnHandUpdate != null && this.xrState != WebXRState.NORMAL)
390-
// {
391-
// if (GetHandFromHandsArray(0, ref leftHand))
392-
// {
393-
// OnHandUpdate(leftHand);
394-
// }
395-
// if (GetHandFromHandsArray(1, ref rightHand))
396-
// {
397-
// OnHandUpdate(rightHand);
398-
// }
399-
// hasHandsData = leftHand.enabled || rightHand.enabled;
400-
// }
401-
//
402-
// if (!hasHandsData && OnControllerUpdate != null && this.xrState != WebXRState.NORMAL)
403-
// {
404-
// if (GetGamepadFromControllersArray(0, ref controller1))
405-
// {
406-
// OnControllerUpdate(controller1);
407-
// }
408-
// if (GetGamepadFromControllersArray(1, ref controller2))
409-
// {
410-
// OnControllerUpdate(controller2);
411-
// }
412-
// }
413-
//
414-
// if (OnViewerHitTestUpdate != null && this.xrState == WebXRState.AR)
415-
// {
416-
// if (GetHitTestPoseFromViewerHitTestPoseArray(ref viewerHitTestPose))
417-
// {
418-
// OnViewerHitTestUpdate(viewerHitTestPose);
419-
// }
420-
// }
421-
// }
422-
//
423-
// void LateUpdate()
424-
// {
425-
// if (OnHeadsetUpdate != null && this.xrState != WebXRState.NORMAL)
426-
// {
427-
// Matrix4x4 leftProjectionMatrix = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(0));
428-
// Matrix4x4 rightProjectionMatrix = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(1));
429-
// Matrix4x4 leftViewMatrix = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(2));
430-
// Matrix4x4 rightViewMatrix = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(3));
431-
// Matrix4x4 sitStandMatrix = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(4));
432-
// if (!this.capabilities.hasPosition)
433-
// {
434-
// sitStandMatrix = Matrix4x4.Translate(new Vector3(0, this.DefaultHeight, 0));
435-
// }
436-
//
437-
// OnHeadsetUpdate(
438-
// leftProjectionMatrix,
439-
// rightProjectionMatrix,
440-
// leftViewMatrix,
441-
// rightViewMatrix,
442-
// sitStandMatrix);
443-
// }
444-
// }
44568
}
44669
}

Packages/webxr/Runtime/XRPlugin/WebXRSubsystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void InternalStart()
130130
Native.ListenWebXRData();
131131
}
132132

133-
private class Native
133+
private static class Native
134134
{
135135
[DllImport("__Internal")]
136136
public static extern void InitXRSharedArray(float[] array, int length);

0 commit comments

Comments
 (0)