1 module libwasm.bindings.VRDisplay;
2 
3 import libwasm.types;
4 
5 import memutils.ct: tuple;
6 import libwasm.bindings.EventTarget;
7 import libwasm.bindings.HTMLCanvasElement;
8 import libwasm.bindings.OffscreenCanvas;
9 import libwasm.bindings.Performance;
10 import libwasm.bindings.Window;
11 
12 @safe:
13 nothrow:
14 
15 struct VRDisplay {
16   nothrow:
17   libwasm.bindings.EventTarget.EventTarget _parent;
18   alias _parent this;
19   this(Handle h) {
20     _parent = .EventTarget(h);
21   }
22   uint presentingGroups()() {
23     return Object_Getter__uint(this._parent, "presentingGroups");
24   }
25   void groupMask()(uint groupMask) {
26     Object_Call_uint__void(this._parent, "groupMask", groupMask);
27   }
28   uint groupMask()() {
29     return Object_Getter__uint(this._parent, "groupMask");
30   }
31   bool isConnected()() {
32     return Object_Getter__bool(this._parent, "isConnected");
33   }
34   bool isPresenting()() {
35     return Object_Getter__bool(this._parent, "isPresenting");
36   }
37   auto capabilities()() {
38     return VRDisplayCapabilities(Object_Getter__Handle(this._parent, "capabilities"));
39   }
40   auto stageParameters()() {
41     return recastOpt!(VRStageParameters)(Object_Getter__OptionalHandle(this._parent, "stageParameters"));
42   }
43   auto getEyeParameters()(VREye whichEye) {
44     return VREyeParameters(Object_Call_int__Handle(this._parent, "getEyeParameters", whichEye));
45   }
46   uint displayId()() {
47     return Object_Getter__uint(this._parent, "displayId");
48   }
49   string displayName()() {
50     return Object_Getter__string(this._parent, "displayName");
51   }
52   bool getFrameData()(scope ref VRFrameData frameData) {
53     return Serialize_Object_VarArgCall!bool(this._parent, "getFrameData", "Handle", tuple(cast(Handle)frameData.handle));
54   }
55   auto getPose()() {
56     return VRPose(Object_Getter__Handle(this._parent, "getPose"));
57   }
58   bool getSubmitFrameResult()(scope ref VRSubmitFrameResult result) {
59     return Serialize_Object_VarArgCall!bool(this._parent, "getSubmitFrameResult", "Handle", tuple(cast(Handle)result.handle));
60   }
61   void resetPose()() {
62     Object_Call__void(this._parent, "resetPose");
63   }
64   void depthNear()(double depthNear) {
65     Object_Call_double__void(this._parent, "depthNear", depthNear);
66   }
67   double depthNear()() {
68     return Object_Getter__double(this._parent, "depthNear");
69   }
70   void depthFar()(double depthFar) {
71     Object_Call_double__void(this._parent, "depthFar", depthFar);
72   }
73   double depthFar()() {
74     return Object_Getter__double(this._parent, "depthFar");
75   }
76   int requestAnimationFrame()(FrameRequestCallback callback) {
77     return VRDisplay_requestAnimationFrame(this._parent, callback);
78   }
79   void cancelAnimationFrame()(int handle) {
80     Object_Call_int__void(this._parent, "cancelAnimationFrame", handle);
81   }
82   auto requestPresent()(scope ref Sequence!(VRLayer) layers) {
83     return JsPromise!(void)(Object_Call_Handle__Handle(this._parent, "requestPresent", layers.handle));
84   }
85   auto exitPresent()() {
86     return JsPromise!(void)(Object_Getter__Handle(this._parent, "exitPresent"));
87   }
88   auto getLayers()() {
89     return Sequence!(VRLayer)(Object_Getter__Handle(this._parent, "getLayers"));
90   }
91   void submitFrame()() {
92     Object_Call__void(this._parent, "submitFrame");
93   }
94 }
95 struct VRDisplayCapabilities {
96   nothrow:
97   JsHandle handle;
98   alias handle this;
99   this(Handle h) {
100     this.handle = JsHandle(h);
101   }
102   bool hasPosition()() {
103     return Object_Getter__bool(this.handle, "hasPosition");
104   }
105   bool hasOrientation()() {
106     return Object_Getter__bool(this.handle, "hasOrientation");
107   }
108   bool hasExternalDisplay()() {
109     return Object_Getter__bool(this.handle, "hasExternalDisplay");
110   }
111   bool canPresent()() {
112     return Object_Getter__bool(this.handle, "canPresent");
113   }
114   uint maxLayers()() {
115     return Object_Getter__uint(this.handle, "maxLayers");
116   }
117 }
118 enum VREye {
119   left,
120   right
121 }
122 struct VREyeParameters {
123   nothrow:
124   JsHandle handle;
125   alias handle this;
126   this(Handle h) {
127     this.handle = JsHandle(h);
128   }
129   auto offset()() {
130     return Float32Array(Object_Getter__Handle(this.handle, "offset"));
131   }
132   auto fieldOfView()() {
133     return VRFieldOfView(Object_Getter__Handle(this.handle, "fieldOfView"));
134   }
135   uint renderWidth()() {
136     return Object_Getter__uint(this.handle, "renderWidth");
137   }
138   uint renderHeight()() {
139     return Object_Getter__uint(this.handle, "renderHeight");
140   }
141 }
142 struct VRFieldOfView {
143   nothrow:
144   JsHandle handle;
145   alias handle this;
146   this(Handle h) {
147     this.handle = JsHandle(h);
148   }
149   double upDegrees()() {
150     return Object_Getter__double(this.handle, "upDegrees");
151   }
152   double rightDegrees()() {
153     return Object_Getter__double(this.handle, "rightDegrees");
154   }
155   double downDegrees()() {
156     return Object_Getter__double(this.handle, "downDegrees");
157   }
158   double leftDegrees()() {
159     return Object_Getter__double(this.handle, "leftDegrees");
160   }
161 }
162 struct VRFrameData {
163   nothrow:
164   JsHandle handle;
165   alias handle this;
166   this(Handle h) {
167     this.handle = JsHandle(h);
168   }
169   double timestamp()() {
170     return Object_Getter__double(this.handle, "timestamp");
171   }
172   auto leftProjectionMatrix()() {
173     return Float32Array(Object_Getter__Handle(this.handle, "leftProjectionMatrix"));
174   }
175   auto leftViewMatrix()() {
176     return Float32Array(Object_Getter__Handle(this.handle, "leftViewMatrix"));
177   }
178   auto rightProjectionMatrix()() {
179     return Float32Array(Object_Getter__Handle(this.handle, "rightProjectionMatrix"));
180   }
181   auto rightViewMatrix()() {
182     return Float32Array(Object_Getter__Handle(this.handle, "rightViewMatrix"));
183   }
184   auto pose()() {
185     return VRPose(Object_Getter__Handle(this.handle, "pose"));
186   }
187 }
188 struct VRLayer {
189   nothrow:
190   JsHandle handle;
191   alias handle this;
192   this(Handle h) {
193     this.handle = JsHandle(h);
194   }
195   static auto create() {
196     return VRLayer(libwasm_add__object());
197   }
198   void source(T0)(scope auto ref Optional!(T0) source) if (isTOrPointer!(T0, HTMLCanvasElement)) {
199     Serialize_Object_VarArgCall!void(this.handle, "source", "Optional!Handle", tuple(!source.empty, cast(Handle)source.front._parent));
200   }
201   auto source()() {
202     return recastOpt!(HTMLCanvasElement)(Object_Getter__OptionalHandle(this.handle, "source"));
203   }
204   void leftBounds()(scope ref Sequence!(float) leftBounds) {
205     Object_Call_Handle__void(this.handle, "leftBounds", leftBounds.handle);
206   }
207   auto leftBounds()() {
208     return Sequence!(float)(Object_Getter__Handle(this.handle, "leftBounds"));
209   }
210   void rightBounds()(scope ref Sequence!(float) rightBounds) {
211     Object_Call_Handle__void(this.handle, "rightBounds", rightBounds.handle);
212   }
213   auto rightBounds()() {
214     return Sequence!(float)(Object_Getter__Handle(this.handle, "rightBounds"));
215   }
216 }
217 struct VRPose {
218   nothrow:
219   JsHandle handle;
220   alias handle this;
221   this(Handle h) {
222     this.handle = JsHandle(h);
223   }
224   auto position()() {
225     return recastOpt!(Float32Array)(Object_Getter__OptionalHandle(this.handle, "position"));
226   }
227   auto linearVelocity()() {
228     return recastOpt!(Float32Array)(Object_Getter__OptionalHandle(this.handle, "linearVelocity"));
229   }
230   auto linearAcceleration()() {
231     return recastOpt!(Float32Array)(Object_Getter__OptionalHandle(this.handle, "linearAcceleration"));
232   }
233   auto orientation()() {
234     return recastOpt!(Float32Array)(Object_Getter__OptionalHandle(this.handle, "orientation"));
235   }
236   auto angularVelocity()() {
237     return recastOpt!(Float32Array)(Object_Getter__OptionalHandle(this.handle, "angularVelocity"));
238   }
239   auto angularAcceleration()() {
240     return recastOpt!(Float32Array)(Object_Getter__OptionalHandle(this.handle, "angularAcceleration"));
241   }
242 }
243 alias VRSource = SumType!(HTMLCanvasElement, OffscreenCanvas);
244 struct VRStageParameters {
245   nothrow:
246   JsHandle handle;
247   alias handle this;
248   this(Handle h) {
249     this.handle = JsHandle(h);
250   }
251   auto sittingToStandingTransform()() {
252     return Float32Array(Object_Getter__Handle(this.handle, "sittingToStandingTransform"));
253   }
254   float sizeX()() {
255     return Object_Getter__float(this.handle, "sizeX");
256   }
257   float sizeZ()() {
258     return Object_Getter__float(this.handle, "sizeZ");
259   }
260 }
261 struct VRSubmitFrameResult {
262   nothrow:
263   JsHandle handle;
264   alias handle this;
265   this(Handle h) {
266     this.handle = JsHandle(h);
267   }
268   uint frameNum()() {
269     return Object_Getter__uint(this.handle, "frameNum");
270   }
271   Optional!(string) base64Image()() {
272     return Object_Getter__OptionalString(this.handle, "base64Image");
273   }
274 }
275 
276 
277 extern (C) int VRDisplay_requestAnimationFrame(Handle, FrameRequestCallback);