x_ite 11.1.1 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/X3DUOM.xml +3 -3
- package/dist/assets/components/AnnotationComponent.js +3 -3
- package/dist/assets/components/AnnotationComponent.min.js +2 -2
- package/dist/assets/components/CADGeometryComponent.js +2 -2
- package/dist/assets/components/CADGeometryComponent.min.js +2 -2
- package/dist/assets/components/CubeMapTexturingComponent.js +16 -20
- package/dist/assets/components/CubeMapTexturingComponent.min.js +2 -2
- package/dist/assets/components/DISComponent.js +3 -3
- package/dist/assets/components/DISComponent.min.js +2 -2
- package/dist/assets/components/EventUtilitiesComponent.js +2 -2
- package/dist/assets/components/EventUtilitiesComponent.min.js +2 -2
- package/dist/assets/components/Geometry2DComponent.js +2 -2
- package/dist/assets/components/Geometry2DComponent.min.js +2 -2
- package/dist/assets/components/GeospatialComponent.js +3 -3
- package/dist/assets/components/GeospatialComponent.min.js +2 -2
- package/dist/assets/components/HAnimComponent.js +7 -7
- package/dist/assets/components/HAnimComponent.min.js +2 -2
- package/dist/assets/components/KeyDeviceSensorComponent.js +2 -2
- package/dist/assets/components/KeyDeviceSensorComponent.min.js +2 -2
- package/dist/assets/components/LayoutComponent.js +14 -12
- package/dist/assets/components/LayoutComponent.min.js +2 -2
- package/dist/assets/components/NURBSComponent.js +2 -4
- package/dist/assets/components/NURBSComponent.min.js +2 -2
- package/dist/assets/components/ParticleSystemsComponent.js +4 -4
- package/dist/assets/components/ParticleSystemsComponent.min.js +2 -2
- package/dist/assets/components/PickingComponent.js +3 -3
- package/dist/assets/components/PickingComponent.min.js +2 -2
- package/dist/assets/components/RigidBodyPhysicsComponent.js +7 -7
- package/dist/assets/components/RigidBodyPhysicsComponent.min.js +2 -2
- package/dist/assets/components/ScriptingComponent.js +3 -3
- package/dist/assets/components/ScriptingComponent.min.js +2 -2
- package/dist/assets/components/TextComponent.js +5 -5
- package/dist/assets/components/TextComponent.min.js +2 -2
- package/dist/assets/components/TextureProjectionComponent.js +2 -2
- package/dist/assets/components/TextureProjectionComponent.min.js +2 -2
- package/dist/assets/components/Texturing3DComponent.js +15 -19
- package/dist/assets/components/Texturing3DComponent.min.js +2 -2
- package/dist/assets/components/VolumeRenderingComponent.js +4 -2
- package/dist/assets/components/VolumeRenderingComponent.min.js +2 -2
- package/dist/assets/components/WebXRComponent.js +1023 -0
- package/dist/assets/components/WebXRComponent.min.js +2 -0
- package/dist/assets/components/X_ITEComponent.js +8 -62
- package/dist/assets/components/X_ITEComponent.min.js +2 -2
- package/dist/assets/images/XR.svg +48 -0
- package/dist/example.html +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.d.ts +12 -13
- package/dist/x_ite.js +2188 -2074
- package/dist/x_ite.min.js +2 -2
- package/dist/x_ite.min.mjs +2 -2
- package/dist/x_ite.mjs +2259 -2145
- package/dist/x_ite.zip +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
/* X_ITE v11.2.0 */
|
|
2
|
+
const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-11.2.0")];
|
|
3
|
+
/******/ (() => { // webpackBootstrap
|
|
4
|
+
/******/ "use strict";
|
|
5
|
+
/******/ // The require scope
|
|
6
|
+
/******/ var __webpack_require__ = {};
|
|
7
|
+
/******/
|
|
8
|
+
/************************************************************************/
|
|
9
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
10
|
+
/******/ (() => {
|
|
11
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
12
|
+
/******/ __webpack_require__.n = (module) => {
|
|
13
|
+
/******/ var getter = module && module.__esModule ?
|
|
14
|
+
/******/ () => (module['default']) :
|
|
15
|
+
/******/ () => (module);
|
|
16
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
17
|
+
/******/ return getter;
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/ })();
|
|
20
|
+
/******/
|
|
21
|
+
/******/ /* webpack/runtime/define property getters */
|
|
22
|
+
/******/ (() => {
|
|
23
|
+
/******/ // define getter functions for harmony exports
|
|
24
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
25
|
+
/******/ for(var key in definition) {
|
|
26
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
27
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/ }
|
|
30
|
+
/******/ };
|
|
31
|
+
/******/ })();
|
|
32
|
+
/******/
|
|
33
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
34
|
+
/******/ (() => {
|
|
35
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
36
|
+
/******/ })();
|
|
37
|
+
/******/
|
|
38
|
+
/************************************************************************/
|
|
39
|
+
|
|
40
|
+
// UNUSED EXPORTS: default
|
|
41
|
+
|
|
42
|
+
;// external "__X_ITE_X3D__ .Components"
|
|
43
|
+
const external_X_ITE_X3D_Components_namespaceObject = __X_ITE_X3D__ .Components;
|
|
44
|
+
var external_X_ITE_X3D_Components_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Components_namespaceObject);
|
|
45
|
+
;// external "__X_ITE_X3D__ .ScreenLine"
|
|
46
|
+
const external_X_ITE_X3D_ScreenLine_namespaceObject = __X_ITE_X3D__ .ScreenLine;
|
|
47
|
+
var external_X_ITE_X3D_ScreenLine_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_ScreenLine_namespaceObject);
|
|
48
|
+
;// external "__X_ITE_X3D__ .GeometryContext"
|
|
49
|
+
const external_X_ITE_X3D_GeometryContext_namespaceObject = __X_ITE_X3D__ .GeometryContext;
|
|
50
|
+
var external_X_ITE_X3D_GeometryContext_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_GeometryContext_namespaceObject);
|
|
51
|
+
;// external "__X_ITE_X3D__ .AlphaMode"
|
|
52
|
+
const external_X_ITE_X3D_AlphaMode_namespaceObject = __X_ITE_X3D__ .AlphaMode;
|
|
53
|
+
var external_X_ITE_X3D_AlphaMode_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_AlphaMode_namespaceObject);
|
|
54
|
+
;// external "__X_ITE_X3D__ .VertexArray"
|
|
55
|
+
const external_X_ITE_X3D_VertexArray_namespaceObject = __X_ITE_X3D__ .VertexArray;
|
|
56
|
+
var external_X_ITE_X3D_VertexArray_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_VertexArray_namespaceObject);
|
|
57
|
+
;// external "__X_ITE_X3D__ .Layer"
|
|
58
|
+
const external_X_ITE_X3D_Layer_namespaceObject = __X_ITE_X3D__ .Layer;
|
|
59
|
+
var external_X_ITE_X3D_Layer_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Layer_namespaceObject);
|
|
60
|
+
;// external "__X_ITE_X3D__ .Matrix4"
|
|
61
|
+
const external_X_ITE_X3D_Matrix4_namespaceObject = __X_ITE_X3D__ .Matrix4;
|
|
62
|
+
var external_X_ITE_X3D_Matrix4_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Matrix4_namespaceObject);
|
|
63
|
+
;// external "__X_ITE_X3D__ .Namespace"
|
|
64
|
+
const external_X_ITE_X3D_Namespace_namespaceObject = __X_ITE_X3D__ .Namespace;
|
|
65
|
+
var external_X_ITE_X3D_Namespace_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Namespace_namespaceObject);
|
|
66
|
+
;// ./src/x_ite/Browser/Rendering/ScreenPoint.js
|
|
67
|
+
/*******************************************************************************
|
|
68
|
+
*
|
|
69
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
70
|
+
*
|
|
71
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
|
|
72
|
+
*
|
|
73
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
74
|
+
*
|
|
75
|
+
* The copyright notice above does not evidence any actual of intended
|
|
76
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
77
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
78
|
+
* create3000.
|
|
79
|
+
*
|
|
80
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
81
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
82
|
+
* permission of create3000.
|
|
83
|
+
*
|
|
84
|
+
* NON-MILITARY USE ONLY
|
|
85
|
+
*
|
|
86
|
+
* All create3000 software are effectively free software with a non-military use
|
|
87
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
88
|
+
* source in any way you please with the exception anything that uses it must be
|
|
89
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
90
|
+
*
|
|
91
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
92
|
+
*
|
|
93
|
+
* Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
|
|
94
|
+
*
|
|
95
|
+
* This file is part of the X_ITE Project.
|
|
96
|
+
*
|
|
97
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
98
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
99
|
+
* Free Software Foundation.
|
|
100
|
+
*
|
|
101
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
102
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
103
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
104
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
105
|
+
*
|
|
106
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
107
|
+
* along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
|
|
108
|
+
* copy of the GPLv3 License.
|
|
109
|
+
*
|
|
110
|
+
* For Silvio, Joy and Adi.
|
|
111
|
+
*
|
|
112
|
+
******************************************************************************/
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
function ScreenPoint (browser)
|
|
120
|
+
{
|
|
121
|
+
const gl = browser .getContext ();
|
|
122
|
+
|
|
123
|
+
this .browser = browser;
|
|
124
|
+
this .vertexArrayObject = new (external_X_ITE_X3D_VertexArray_default()) (gl);
|
|
125
|
+
|
|
126
|
+
// Black Circle
|
|
127
|
+
|
|
128
|
+
this .circleVertexBuffer = gl .createBuffer ();
|
|
129
|
+
this .circleGeometryContext = new (external_X_ITE_X3D_GeometryContext_default()) ({
|
|
130
|
+
renderObject: new (external_X_ITE_X3D_Layer_default()) (browser .getPrivateScene ()),
|
|
131
|
+
alphaMode: (external_X_ITE_X3D_AlphaMode_default()).BLEND,
|
|
132
|
+
geometryType: 1,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
this .circleGeometryContext .renderObject .setup ();
|
|
136
|
+
|
|
137
|
+
// Transfer circle vertices.
|
|
138
|
+
|
|
139
|
+
const circleVertexArray = browser .getCircle2DOptions () .getGeometry () .getVertices ();
|
|
140
|
+
|
|
141
|
+
this .circleNumVertices = circleVertexArray .length / 4;
|
|
142
|
+
|
|
143
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .circleVertexBuffer);
|
|
144
|
+
gl .bufferData (gl .ARRAY_BUFFER, circleVertexArray .getValue (), gl .STATIC_DRAW);
|
|
145
|
+
|
|
146
|
+
// Disk
|
|
147
|
+
|
|
148
|
+
this .diskVertexBuffer = gl .createBuffer ();
|
|
149
|
+
this .diskGeometryContext = new (external_X_ITE_X3D_GeometryContext_default()) ({
|
|
150
|
+
renderObject: this .circleGeometryContext .renderObject,
|
|
151
|
+
alphaMode: (external_X_ITE_X3D_AlphaMode_default()).BLEND,
|
|
152
|
+
geometryType: 3,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Transfer disk vertices.
|
|
156
|
+
|
|
157
|
+
const diskVertexArray = browser .getDisk2DOptions () .getDiskVertices ();
|
|
158
|
+
|
|
159
|
+
this .diskNumVertices = diskVertexArray .length / 4;
|
|
160
|
+
|
|
161
|
+
gl .bindBuffer (gl .ARRAY_BUFFER, this .diskVertexBuffer);
|
|
162
|
+
gl .bufferData (gl .ARRAY_BUFFER, diskVertexArray .getValue (), gl .STATIC_DRAW);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
Object .assign (ScreenPoint .prototype,
|
|
166
|
+
{
|
|
167
|
+
display: (() =>
|
|
168
|
+
{
|
|
169
|
+
const
|
|
170
|
+
projectionMatrixArray = new Float32Array ((external_X_ITE_X3D_Matrix4_default()).Identity),
|
|
171
|
+
modelViewMatrixArray = new Float32Array ((external_X_ITE_X3D_Matrix4_default()).Identity),
|
|
172
|
+
screenMatrix = new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
173
|
+
clipPlanes = [ ];
|
|
174
|
+
|
|
175
|
+
return function (radius, color, transparency, circle, modelViewMatrix, projectionMatrix, frameBuffer)
|
|
176
|
+
{
|
|
177
|
+
// Configure HUD
|
|
178
|
+
|
|
179
|
+
const
|
|
180
|
+
browser = this .browser,
|
|
181
|
+
gl = browser .getContext (),
|
|
182
|
+
viewport = browser .getViewport ();
|
|
183
|
+
|
|
184
|
+
frameBuffer .bind ();
|
|
185
|
+
|
|
186
|
+
// Set viewport.
|
|
187
|
+
|
|
188
|
+
gl .viewport (... viewport);
|
|
189
|
+
gl .scissor (... viewport);
|
|
190
|
+
|
|
191
|
+
// Apply screen scale to matrix.
|
|
192
|
+
|
|
193
|
+
const
|
|
194
|
+
screenScale = Math .abs (modelViewMatrix .origin .z),
|
|
195
|
+
scale = radius * screenScale;
|
|
196
|
+
|
|
197
|
+
const
|
|
198
|
+
x = modelViewMatrix .xAxis .normalize () .multiply (scale),
|
|
199
|
+
y = modelViewMatrix .yAxis .normalize () .multiply (scale),
|
|
200
|
+
z = modelViewMatrix .zAxis .normalize () .multiply (scale);
|
|
201
|
+
|
|
202
|
+
screenMatrix .set (... x, 0, ... y, 0, ... z, 0, ... modelViewMatrix .origin, 1);
|
|
203
|
+
|
|
204
|
+
// Set projection and model view matrix.
|
|
205
|
+
|
|
206
|
+
projectionMatrixArray .set (projectionMatrix);
|
|
207
|
+
modelViewMatrixArray .set (screenMatrix);
|
|
208
|
+
|
|
209
|
+
// Change state.
|
|
210
|
+
|
|
211
|
+
gl .depthMask (false);
|
|
212
|
+
gl .disable (gl .DEPTH_TEST);
|
|
213
|
+
gl .enable (gl .BLEND);
|
|
214
|
+
gl .disable (gl .CULL_FACE);
|
|
215
|
+
|
|
216
|
+
{
|
|
217
|
+
// Set uniforms and attributes.
|
|
218
|
+
|
|
219
|
+
const shaderNode = browser .getDefaultMaterial () .getShader (this .circleGeometryContext);
|
|
220
|
+
|
|
221
|
+
shaderNode .enable (gl);
|
|
222
|
+
shaderNode .setClipPlanes (gl, clipPlanes);
|
|
223
|
+
|
|
224
|
+
gl .uniformMatrix4fv (shaderNode .x3d_ProjectionMatrix, false, projectionMatrixArray);
|
|
225
|
+
gl .uniformMatrix4fv (shaderNode .x3d_ModelViewMatrix, false, modelViewMatrixArray);
|
|
226
|
+
gl .uniform3f (shaderNode .x3d_EmissiveColor, 0, 0, 0);
|
|
227
|
+
gl .uniform1f (shaderNode .x3d_Transparency, circle);
|
|
228
|
+
|
|
229
|
+
if (this .vertexArrayObject .enable (shaderNode .getProgram ()))
|
|
230
|
+
shaderNode .enableVertexAttribute (gl, this .circleVertexBuffer, 0, 0);
|
|
231
|
+
|
|
232
|
+
// Draw a black and a white point.
|
|
233
|
+
|
|
234
|
+
gl .drawArrays (gl .LINES, 0, this .circleNumVertices);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
{
|
|
238
|
+
// Set uniforms and attributes.
|
|
239
|
+
|
|
240
|
+
const shaderNode = browser .getDefaultMaterial () .getShader (this .diskGeometryContext);
|
|
241
|
+
|
|
242
|
+
shaderNode .enable (gl);
|
|
243
|
+
shaderNode .setClipPlanes (gl, clipPlanes);
|
|
244
|
+
|
|
245
|
+
gl .uniformMatrix4fv (shaderNode .x3d_ProjectionMatrix, false, projectionMatrixArray);
|
|
246
|
+
gl .uniformMatrix4fv (shaderNode .x3d_ModelViewMatrix, false, modelViewMatrixArray);
|
|
247
|
+
gl .uniform3f (shaderNode .x3d_EmissiveColor, ... color);
|
|
248
|
+
gl .uniform1f (shaderNode .x3d_Transparency, transparency);
|
|
249
|
+
|
|
250
|
+
if (this .vertexArrayObject .enable (shaderNode .getProgram ()))
|
|
251
|
+
shaderNode .enableVertexAttribute (gl, this .diskVertexBuffer, 0, 0);
|
|
252
|
+
|
|
253
|
+
// Draw a black and a white point.
|
|
254
|
+
|
|
255
|
+
gl .drawArrays (gl .TRIANGLES, 0, this .diskNumVertices);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Reset state.
|
|
259
|
+
|
|
260
|
+
gl .depthMask (true);
|
|
261
|
+
gl .enable (gl .DEPTH_TEST);
|
|
262
|
+
gl .disable (gl .BLEND);
|
|
263
|
+
};
|
|
264
|
+
})(),
|
|
265
|
+
dispose ()
|
|
266
|
+
{
|
|
267
|
+
const gl = this .browser .getContext ();
|
|
268
|
+
|
|
269
|
+
gl .deleteBuffer (this .diskVertexBuffer);
|
|
270
|
+
|
|
271
|
+
this .diskVertexArrayObject .dispose (gl);
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const __default__ = ScreenPoint;
|
|
276
|
+
;
|
|
277
|
+
|
|
278
|
+
/* harmony default export */ const Rendering_ScreenPoint = (external_X_ITE_X3D_Namespace_default().add ("ScreenPoint", __default__));
|
|
279
|
+
;// external "__X_ITE_X3D__ .ViewVolume"
|
|
280
|
+
const external_X_ITE_X3D_ViewVolume_namespaceObject = __X_ITE_X3D__ .ViewVolume;
|
|
281
|
+
var external_X_ITE_X3D_ViewVolume_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_ViewVolume_namespaceObject);
|
|
282
|
+
;// external "__X_ITE_X3D__ .Color3"
|
|
283
|
+
const external_X_ITE_X3D_Color3_namespaceObject = __X_ITE_X3D__ .Color3;
|
|
284
|
+
var external_X_ITE_X3D_Color3_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Color3_namespaceObject);
|
|
285
|
+
;// external "__X_ITE_X3D__ .Vector3"
|
|
286
|
+
const external_X_ITE_X3D_Vector3_namespaceObject = __X_ITE_X3D__ .Vector3;
|
|
287
|
+
var external_X_ITE_X3D_Vector3_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Vector3_namespaceObject);
|
|
288
|
+
;// external "__X_ITE_X3D__ .Rotation4"
|
|
289
|
+
const external_X_ITE_X3D_Rotation4_namespaceObject = __X_ITE_X3D__ .Rotation4;
|
|
290
|
+
var external_X_ITE_X3D_Rotation4_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Rotation4_namespaceObject);
|
|
291
|
+
;// external "__X_ITE_X3D__ .Lock"
|
|
292
|
+
const external_X_ITE_X3D_Lock_namespaceObject = __X_ITE_X3D__ .Lock;
|
|
293
|
+
var external_X_ITE_X3D_Lock_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Lock_namespaceObject);
|
|
294
|
+
;// external "__X_ITE_X3D__ .ExamineViewer"
|
|
295
|
+
const external_X_ITE_X3D_ExamineViewer_namespaceObject = __X_ITE_X3D__ .ExamineViewer;
|
|
296
|
+
var external_X_ITE_X3D_ExamineViewer_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_ExamineViewer_namespaceObject);
|
|
297
|
+
;// ./src/x_ite/Browser/WebXR/WebXRExamineViewer.js
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
const
|
|
302
|
+
GAMEPAD_SPIN_FACTOR = 10,
|
|
303
|
+
GAMEPAD_PAN_FACTOR = 5,
|
|
304
|
+
GAMEPAD_ZOOM_FACTOR = 1 / 200;
|
|
305
|
+
|
|
306
|
+
Object .assign ((external_X_ITE_X3D_ExamineViewer_default()).prototype,
|
|
307
|
+
{
|
|
308
|
+
gamepads (gamepads)
|
|
309
|
+
{
|
|
310
|
+
const gamepad = gamepads .find (({ axes }) => axes [2] || axes [3]);
|
|
311
|
+
|
|
312
|
+
if (!gamepad)
|
|
313
|
+
{
|
|
314
|
+
if (gamepads .action)
|
|
315
|
+
{
|
|
316
|
+
gamepads .action = false;
|
|
317
|
+
|
|
318
|
+
this .disconnect ();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const
|
|
325
|
+
button0 = gamepad .buttons [0] .pressed,
|
|
326
|
+
button1 = gamepad .buttons [1] .pressed;
|
|
327
|
+
|
|
328
|
+
if (gamepads .button0 !== button0 || gamepads .button1 !== button1)
|
|
329
|
+
{
|
|
330
|
+
gamepads .button0 = button0;
|
|
331
|
+
gamepads .button1 = button1;
|
|
332
|
+
|
|
333
|
+
this .disconnect ();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const f = 60 / this .getBrowser () .currentFrameRate;
|
|
337
|
+
|
|
338
|
+
gamepads .action = true;
|
|
339
|
+
|
|
340
|
+
if (button0)
|
|
341
|
+
{
|
|
342
|
+
this .zoom (gamepad .axes [3] * GAMEPAD_ZOOM_FACTOR * f, Math .sign (-gamepad .axes [3]));
|
|
343
|
+
}
|
|
344
|
+
else if (button1)
|
|
345
|
+
{
|
|
346
|
+
// Pan
|
|
347
|
+
this .startPan (0, 0);
|
|
348
|
+
this .pan (-gamepad .axes [2] * GAMEPAD_PAN_FACTOR * f, gamepad .axes [3] * GAMEPAD_PAN_FACTOR * f);
|
|
349
|
+
}
|
|
350
|
+
else // default
|
|
351
|
+
{
|
|
352
|
+
// Rotate
|
|
353
|
+
|
|
354
|
+
this .startRotate (0, 0);
|
|
355
|
+
this .rotate (-gamepad .axes [2] * GAMEPAD_SPIN_FACTOR * f, gamepad .axes [3] * GAMEPAD_SPIN_FACTOR * f);
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
;// external "__X_ITE_X3D__ .X3DFlyViewer"
|
|
361
|
+
const external_X_ITE_X3D_X3DFlyViewer_namespaceObject = __X_ITE_X3D__ .X3DFlyViewer;
|
|
362
|
+
var external_X_ITE_X3D_X3DFlyViewer_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_X3DFlyViewer_namespaceObject);
|
|
363
|
+
;// ./src/x_ite/Browser/WebXR/WebXRX3DFlyViewer.js
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
const GAMEPAD_SPEED_FACTOR = new (external_X_ITE_X3D_Vector3_default()) (300, 300, 400);
|
|
368
|
+
|
|
369
|
+
Object .assign ((external_X_ITE_X3D_X3DFlyViewer_default()).prototype,
|
|
370
|
+
{
|
|
371
|
+
gamepads: (function ()
|
|
372
|
+
{
|
|
373
|
+
const axis = new (external_X_ITE_X3D_Vector3_default()) ();
|
|
374
|
+
|
|
375
|
+
return function (gamepads)
|
|
376
|
+
{
|
|
377
|
+
const gamepad = gamepads .find (({ axes }) => axes [2] || axes [3]);
|
|
378
|
+
|
|
379
|
+
if (!gamepad)
|
|
380
|
+
{
|
|
381
|
+
this .startTime = Date .now ();
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const button1 = gamepad .buttons [1] .pressed;
|
|
386
|
+
|
|
387
|
+
if (button1)
|
|
388
|
+
{
|
|
389
|
+
axis
|
|
390
|
+
.set (gamepad .axes [2], -gamepad .axes [3], 0)
|
|
391
|
+
.multVec (GAMEPAD_SPEED_FACTOR);
|
|
392
|
+
|
|
393
|
+
// Moving average.
|
|
394
|
+
this .direction .add (axis) .divide (2);
|
|
395
|
+
|
|
396
|
+
this .pan ();
|
|
397
|
+
}
|
|
398
|
+
else // default
|
|
399
|
+
{
|
|
400
|
+
axis
|
|
401
|
+
.set (gamepad .axes [2], 0, gamepad .axes [3])
|
|
402
|
+
.multVec (GAMEPAD_SPEED_FACTOR);
|
|
403
|
+
|
|
404
|
+
// Moving average.
|
|
405
|
+
this .direction .add (axis) .divide (2);
|
|
406
|
+
|
|
407
|
+
this .fly ();
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
})(),
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
;// external "__X_ITE_X3D__ .X3DViewer"
|
|
414
|
+
const external_X_ITE_X3D_X3DViewer_namespaceObject = __X_ITE_X3D__ .X3DViewer;
|
|
415
|
+
var external_X_ITE_X3D_X3DViewer_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_X3DViewer_namespaceObject);
|
|
416
|
+
;// ./src/x_ite/Browser/WebXR/WebXRX3DViewer.js
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
Object .assign ((external_X_ITE_X3D_X3DViewer_default()).prototype,
|
|
420
|
+
{
|
|
421
|
+
gamepads ()
|
|
422
|
+
{ },
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
;// ./src/x_ite/Browser/WebXR/X3DWebXRContext.js
|
|
426
|
+
/*******************************************************************************
|
|
427
|
+
*
|
|
428
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
429
|
+
*
|
|
430
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
|
|
431
|
+
*
|
|
432
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
433
|
+
*
|
|
434
|
+
* The copyright notice above does not evidence any actual of intended
|
|
435
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
436
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
437
|
+
* create3000.
|
|
438
|
+
*
|
|
439
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
440
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
441
|
+
* permission of create3000.
|
|
442
|
+
*
|
|
443
|
+
* NON-MILITARY USE ONLY
|
|
444
|
+
*
|
|
445
|
+
* All create3000 software are effectively free software with a non-military use
|
|
446
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
447
|
+
* source in any way you please with the exception anything that uses it must be
|
|
448
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
449
|
+
*
|
|
450
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
451
|
+
*
|
|
452
|
+
* Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
|
|
453
|
+
*
|
|
454
|
+
* This file is part of the X_ITE Project.
|
|
455
|
+
*
|
|
456
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
457
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
458
|
+
* Free Software Foundation.
|
|
459
|
+
*
|
|
460
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
461
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
462
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
463
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
464
|
+
*
|
|
465
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
466
|
+
* along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
|
|
467
|
+
* copy of the GPLv3 License.
|
|
468
|
+
*
|
|
469
|
+
* For Silvio, Joy and Adi.
|
|
470
|
+
*
|
|
471
|
+
******************************************************************************/
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
const
|
|
487
|
+
_referenceSpace = Symbol (),
|
|
488
|
+
_baseLayer = Symbol (),
|
|
489
|
+
_pose = Symbol (),
|
|
490
|
+
_inputSources = Symbol (),
|
|
491
|
+
_inputRay = Symbol (),
|
|
492
|
+
_inputPoint = Symbol (),
|
|
493
|
+
_gamepads = Symbol (),
|
|
494
|
+
_frame = Symbol ();
|
|
495
|
+
|
|
496
|
+
function X3DWebXRContext ()
|
|
497
|
+
{
|
|
498
|
+
this [_gamepads] = [ ];
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
Object .assign (X3DWebXRContext .prototype,
|
|
502
|
+
{
|
|
503
|
+
async initXRSession ()
|
|
504
|
+
{
|
|
505
|
+
return external_X_ITE_X3D_Lock_default().acquire (`X3DWebXRContext.session-${this .getId ()}`, async () =>
|
|
506
|
+
{
|
|
507
|
+
if (this .getSession () !== window)
|
|
508
|
+
return;
|
|
509
|
+
|
|
510
|
+
const
|
|
511
|
+
gl = this .getContext (),
|
|
512
|
+
mode = this .getBrowserOption ("XRSessionMode") .toLowerCase () .replaceAll ("_", "-"),
|
|
513
|
+
compatible = await gl .makeXRCompatible (),
|
|
514
|
+
session = await navigator .xr .requestSession (mode),
|
|
515
|
+
referenceSpace = await session .requestReferenceSpace ("local");
|
|
516
|
+
|
|
517
|
+
// WebXR Emulator: must bind default framebuffer, to get xr emulator working.
|
|
518
|
+
gl .bindFramebuffer (gl .FRAMEBUFFER, null);
|
|
519
|
+
|
|
520
|
+
this .cameraEvents () .addInterest ("updatePose", this);
|
|
521
|
+
this .finishedEvents () .addInterest ("updatePointers", this);
|
|
522
|
+
this .endEvents () .addInterest ("endFrame", this);
|
|
523
|
+
|
|
524
|
+
session .addEventListener ("inputsourceschange", event => this .updateInputSources (event));
|
|
525
|
+
session .addEventListener ("end", () => this .stopXRSession ());
|
|
526
|
+
|
|
527
|
+
this [_referenceSpace] = referenceSpace;
|
|
528
|
+
|
|
529
|
+
this [_inputSources] = new Set ();
|
|
530
|
+
this [_inputRay] = new (external_X_ITE_X3D_ScreenLine_default()) (this, 4, 2, 0.9);
|
|
531
|
+
this [_inputPoint] = new Rendering_ScreenPoint (this);
|
|
532
|
+
|
|
533
|
+
Object .assign (this [_gamepads], { action: true });
|
|
534
|
+
|
|
535
|
+
this [_pose] = {
|
|
536
|
+
cameraSpaceMatrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
537
|
+
viewMatrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
538
|
+
views: [ ],
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
this .updateBaseLayer ({ }, session);
|
|
542
|
+
this .setSession (session);
|
|
543
|
+
this .removeHit (this .getHit ());
|
|
544
|
+
|
|
545
|
+
// session .addEventListener ("select", event =>
|
|
546
|
+
// {
|
|
547
|
+
// const { inputSource, frame } = event;
|
|
548
|
+
//
|
|
549
|
+
// console .log (event)
|
|
550
|
+
// console .log (inputSource)
|
|
551
|
+
// console .log (frame)
|
|
552
|
+
// });
|
|
553
|
+
});
|
|
554
|
+
},
|
|
555
|
+
stopXRSession ()
|
|
556
|
+
{
|
|
557
|
+
return external_X_ITE_X3D_Lock_default().acquire (`X3DWebXRContext.session-${this .getId ()}`, async () =>
|
|
558
|
+
{
|
|
559
|
+
if (this .getSession () === window)
|
|
560
|
+
return;
|
|
561
|
+
|
|
562
|
+
await this .getSession () .end () .catch (Function .prototype);
|
|
563
|
+
|
|
564
|
+
this .cameraEvents () .removeInterest ("updatePose", this);
|
|
565
|
+
this .finishedEvents () .removeInterest ("updatePointers", this);
|
|
566
|
+
this .endEvents () .removeInterest ("endFrame", this);
|
|
567
|
+
|
|
568
|
+
this .setSession (window);
|
|
569
|
+
this .setDefaultFramebuffer (null);
|
|
570
|
+
|
|
571
|
+
for (const { hit } of this [_inputSources])
|
|
572
|
+
this .removeHit (hit);
|
|
573
|
+
|
|
574
|
+
this [_referenceSpace] = null;
|
|
575
|
+
this [_baseLayer] = null;
|
|
576
|
+
this [_pose] = null;
|
|
577
|
+
this [_inputSources] = null;
|
|
578
|
+
this [_inputRay] = null;
|
|
579
|
+
this [_inputPoint] = null;
|
|
580
|
+
this [_frame] = null;
|
|
581
|
+
});
|
|
582
|
+
},
|
|
583
|
+
setFramebufferScaleFactor (framebufferScaleFactor)
|
|
584
|
+
{
|
|
585
|
+
this .updateBaseLayer ({ framebufferScaleFactor });
|
|
586
|
+
},
|
|
587
|
+
updateBaseLayer (options = { }, session = this .getSession ())
|
|
588
|
+
{
|
|
589
|
+
if (session === window)
|
|
590
|
+
return;
|
|
591
|
+
|
|
592
|
+
const baseLayer = new XRWebGLLayer (session, this .getContext (), Object .assign ({
|
|
593
|
+
antialias: false,
|
|
594
|
+
alpha: true,
|
|
595
|
+
depth: false,
|
|
596
|
+
ignoreDepthValues: true,
|
|
597
|
+
framebufferScaleFactor: this .getRenderingProperty ("ContentScale"),
|
|
598
|
+
},
|
|
599
|
+
options));
|
|
600
|
+
|
|
601
|
+
this [_baseLayer] = baseLayer;
|
|
602
|
+
|
|
603
|
+
session .updateRenderState ({ baseLayer });
|
|
604
|
+
|
|
605
|
+
this .setDefaultFramebuffer (baseLayer .framebuffer);
|
|
606
|
+
},
|
|
607
|
+
updateInputSources (event)
|
|
608
|
+
{
|
|
609
|
+
for (const inputSource of event .added)
|
|
610
|
+
{
|
|
611
|
+
this [_inputSources] .add (Object .assign (inputSource,
|
|
612
|
+
{
|
|
613
|
+
active: false,
|
|
614
|
+
matrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
615
|
+
inverse: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
616
|
+
hit: Object .assign (this .getHit () .copy (),
|
|
617
|
+
{
|
|
618
|
+
button: false,
|
|
619
|
+
pressed: false,
|
|
620
|
+
pulse: true,
|
|
621
|
+
poseViewMatrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
622
|
+
originalPoint: new (external_X_ITE_X3D_Vector3_default()) (),
|
|
623
|
+
originalNormal: new (external_X_ITE_X3D_Vector3_default()) (),
|
|
624
|
+
}),
|
|
625
|
+
}));
|
|
626
|
+
|
|
627
|
+
if (inputSource .gamepad)
|
|
628
|
+
inputSource .gamepad .hit = inputSource .hit;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
for (const inputSource of event .removed)
|
|
632
|
+
{
|
|
633
|
+
this .removeHit (inputSource .hit);
|
|
634
|
+
this [_inputSources] .delete (inputSource);
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
setFrame (frame)
|
|
638
|
+
{
|
|
639
|
+
if (!frame)
|
|
640
|
+
return;
|
|
641
|
+
|
|
642
|
+
this [_frame] = frame;
|
|
643
|
+
|
|
644
|
+
// Emulator
|
|
645
|
+
|
|
646
|
+
const emulator = !this .getCanvas () .parent () .is (this .getSurface ());
|
|
647
|
+
|
|
648
|
+
// WebXR Emulator or polyfill.
|
|
649
|
+
if (emulator)
|
|
650
|
+
this .getCanvas () .css (this .getXREmulatorCSS ());
|
|
651
|
+
|
|
652
|
+
// TODO: Clip planes
|
|
653
|
+
|
|
654
|
+
// const
|
|
655
|
+
// navigationInfoNode = this .getActiveNavigationInfo (),
|
|
656
|
+
// viewpointNode = this .getActiveViewpoint ();
|
|
657
|
+
|
|
658
|
+
// this .getSession () .updateRenderState ({
|
|
659
|
+
// depthNear: viewpointNode .getNearDistance (navigationInfoNode), // 0.1
|
|
660
|
+
// depthFar: viewpointNode .getFarDistance (navigationInfoNode), // 10_000
|
|
661
|
+
// });
|
|
662
|
+
|
|
663
|
+
// Navigation
|
|
664
|
+
|
|
665
|
+
this [_gamepads] .length = 0;
|
|
666
|
+
|
|
667
|
+
for (const { active, gamepad } of this [_inputSources])
|
|
668
|
+
{
|
|
669
|
+
if (!active)
|
|
670
|
+
continue;
|
|
671
|
+
|
|
672
|
+
if (gamepad .axes .length < 4)
|
|
673
|
+
continue;
|
|
674
|
+
|
|
675
|
+
this [_gamepads] .push (gamepad);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
this .getViewer () .gamepads (this [_gamepads]);
|
|
679
|
+
|
|
680
|
+
// Trigger new frame.
|
|
681
|
+
|
|
682
|
+
this .addBrowserEvent ();
|
|
683
|
+
},
|
|
684
|
+
getPose ()
|
|
685
|
+
{
|
|
686
|
+
return this [_pose];
|
|
687
|
+
},
|
|
688
|
+
updatePose ()
|
|
689
|
+
{
|
|
690
|
+
// Get matrices from views.
|
|
691
|
+
|
|
692
|
+
const
|
|
693
|
+
originalPose = this [_frame] .getViewerPose (this [_referenceSpace]),
|
|
694
|
+
pose = this [_pose],
|
|
695
|
+
viewpointNode = this .getActiveViewpoint ();
|
|
696
|
+
|
|
697
|
+
pose .cameraSpaceMatrix .assign (originalPose .transform .matrix);
|
|
698
|
+
pose .viewMatrix .assign (originalPose .transform .inverse .matrix);
|
|
699
|
+
|
|
700
|
+
if (viewpointNode)
|
|
701
|
+
{
|
|
702
|
+
pose .cameraSpaceMatrix .multRight (viewpointNode .getCameraSpaceMatrix ());
|
|
703
|
+
pose .viewMatrix .multLeft (viewpointNode .getViewMatrix ());
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
let v = 0;
|
|
707
|
+
|
|
708
|
+
for (const originalView of originalPose .views)
|
|
709
|
+
{
|
|
710
|
+
const { x, y, width, height } = this [_baseLayer] .getViewport (originalView);
|
|
711
|
+
|
|
712
|
+
// WebXR Emulator: second view has width zero if in non-stereo mode.
|
|
713
|
+
if (!width)
|
|
714
|
+
continue;
|
|
715
|
+
|
|
716
|
+
this .reshapeFramebuffer (v, x|0, y|0, width|0, height|0);
|
|
717
|
+
|
|
718
|
+
const view = pose .views [v] ??= {
|
|
719
|
+
projectionMatrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
720
|
+
cameraSpaceMatrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
721
|
+
viewMatrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
722
|
+
matrix: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
723
|
+
inverse: new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
view .projectionMatrix .assign (originalView .projectionMatrix);
|
|
727
|
+
view .cameraSpaceMatrix .assign (originalView .transform .matrix);
|
|
728
|
+
view .viewMatrix .assign (originalView .transform .inverse .matrix);
|
|
729
|
+
|
|
730
|
+
if (viewpointNode)
|
|
731
|
+
{
|
|
732
|
+
view .cameraSpaceMatrix .multRight (viewpointNode .getCameraSpaceMatrix ());
|
|
733
|
+
view .viewMatrix .multLeft (viewpointNode .getViewMatrix ());
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
view .matrix .assign (pose .cameraSpaceMatrix) .multRight (view .viewMatrix);
|
|
737
|
+
view .inverse .assign (view .cameraSpaceMatrix) .multRight (pose .viewMatrix);
|
|
738
|
+
|
|
739
|
+
++ v;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
pose .views .length = v;
|
|
743
|
+
this .getFramebuffers () .length = v;
|
|
744
|
+
},
|
|
745
|
+
updatePointers: (function ()
|
|
746
|
+
{
|
|
747
|
+
const
|
|
748
|
+
blue = new (external_X_ITE_X3D_Color3_default()) (0.5, 0.75, 1),
|
|
749
|
+
inputRayMatrix = new (external_X_ITE_X3D_Matrix4_default()) (),
|
|
750
|
+
toVector = new (external_X_ITE_X3D_Vector3_default()) (0, 0, -0.5),
|
|
751
|
+
fromPoint = new (external_X_ITE_X3D_Vector3_default()) (),
|
|
752
|
+
toPoint = new (external_X_ITE_X3D_Vector3_default()) (),
|
|
753
|
+
hitPoint = new (external_X_ITE_X3D_Vector3_default()) (),
|
|
754
|
+
hitRotation = new (external_X_ITE_X3D_Rotation4_default()) (),
|
|
755
|
+
hitSize = 0.007,
|
|
756
|
+
hitPressedSize = 0.005;
|
|
757
|
+
|
|
758
|
+
return function ()
|
|
759
|
+
{
|
|
760
|
+
const
|
|
761
|
+
viewport = this .getViewport () .getValue (),
|
|
762
|
+
pose = this [_pose],
|
|
763
|
+
viewpointNode = this .getActiveViewpoint ();
|
|
764
|
+
|
|
765
|
+
// Get target ray matrices from input sources.
|
|
766
|
+
|
|
767
|
+
for (const inputSource of this [_inputSources])
|
|
768
|
+
{
|
|
769
|
+
const { targetRaySpace, matrix, inverse } = inputSource;
|
|
770
|
+
|
|
771
|
+
const targetRayPose = this [_frame] .getPose (targetRaySpace, this [_referenceSpace]);
|
|
772
|
+
|
|
773
|
+
inputSource .active = !! targetRayPose;
|
|
774
|
+
|
|
775
|
+
if (!targetRayPose)
|
|
776
|
+
continue;
|
|
777
|
+
|
|
778
|
+
matrix .assign (targetRayPose .transform .matrix);
|
|
779
|
+
inverse .assign (targetRayPose .transform .inverse .matrix);
|
|
780
|
+
|
|
781
|
+
if (viewpointNode)
|
|
782
|
+
{
|
|
783
|
+
matrix .multRight (viewpointNode .getCameraSpaceMatrix ());
|
|
784
|
+
inverse .multLeft (viewpointNode .getViewMatrix ());
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Test for hits.
|
|
789
|
+
|
|
790
|
+
for (const inputSource of this [_inputSources])
|
|
791
|
+
{
|
|
792
|
+
const { active, gamepad, matrix, hit } = inputSource;
|
|
793
|
+
|
|
794
|
+
if (!active)
|
|
795
|
+
continue;
|
|
796
|
+
|
|
797
|
+
this .touch (viewport [2] / 2, viewport [3] / 2, hit, inputSource);
|
|
798
|
+
|
|
799
|
+
// Make a vibration puls if there is a sensor hit.
|
|
800
|
+
|
|
801
|
+
this .sensorHitPulse (hit, gamepad);
|
|
802
|
+
|
|
803
|
+
// Update matrices and determine pointer position.
|
|
804
|
+
|
|
805
|
+
if (!hit .id)
|
|
806
|
+
continue;
|
|
807
|
+
|
|
808
|
+
const projectionMatrix = pose .views [0] .projectionMatrix;
|
|
809
|
+
|
|
810
|
+
if (!hit .pressed)
|
|
811
|
+
hit .poseViewMatrix .assign (pose .viewMatrix);
|
|
812
|
+
|
|
813
|
+
inputRayMatrix .assign (matrix) .multRight (hit .poseViewMatrix);
|
|
814
|
+
|
|
815
|
+
for (const sensor of hit .sensors .values ())
|
|
816
|
+
{
|
|
817
|
+
sensor .projectionMatrix .assign (projectionMatrix);
|
|
818
|
+
sensor .modelViewMatrix .multRight (inputRayMatrix);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
external_X_ITE_X3D_ViewVolume_default().projectPoint (hit .point, inputRayMatrix, projectionMatrix, viewport, hit .pointer);
|
|
822
|
+
|
|
823
|
+
hit .originalPoint .assign (hit .point);
|
|
824
|
+
hit .originalNormal .assign (hit .normal);
|
|
825
|
+
|
|
826
|
+
hit .ray .multLineMatrix (inputRayMatrix);
|
|
827
|
+
inputRayMatrix .multVecMatrix (hit .point);
|
|
828
|
+
inputRayMatrix .submatrix .inverse () .multMatrixVec (hit .normal);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// Handle nodes of type X3DPointingDeviceSensorNodes.
|
|
832
|
+
|
|
833
|
+
for (const { active, gamepad, hit } of this [_inputSources])
|
|
834
|
+
{
|
|
835
|
+
if (!active)
|
|
836
|
+
continue;
|
|
837
|
+
|
|
838
|
+
// Press & Release
|
|
839
|
+
|
|
840
|
+
const button0 = gamepad ?.buttons [0];
|
|
841
|
+
|
|
842
|
+
if (button0 ?.pressed)
|
|
843
|
+
{
|
|
844
|
+
if (!hit .button)
|
|
845
|
+
{
|
|
846
|
+
hit .button = true;
|
|
847
|
+
hit .pressed ||= this .buttonPressEvent (0, 0, hit);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
else
|
|
851
|
+
{
|
|
852
|
+
hit .button = false;
|
|
853
|
+
|
|
854
|
+
if (hit .pressed)
|
|
855
|
+
{
|
|
856
|
+
hit .pressed = false;
|
|
857
|
+
|
|
858
|
+
this .buttonReleaseEvent (hit);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// Motion
|
|
863
|
+
|
|
864
|
+
this .motionNotifyEvent (0, 0, hit);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// Draw input source rays.
|
|
868
|
+
|
|
869
|
+
for (const [i, { viewMatrix, projectionMatrix }] of pose .views .entries ())
|
|
870
|
+
{
|
|
871
|
+
const frameBuffer = this .getFramebuffers () [i];
|
|
872
|
+
|
|
873
|
+
for (const { active, gamepad, matrix, hit } of this [_inputSources])
|
|
874
|
+
{
|
|
875
|
+
if (!active)
|
|
876
|
+
continue;
|
|
877
|
+
|
|
878
|
+
// Draw input ray.
|
|
879
|
+
|
|
880
|
+
const
|
|
881
|
+
pressed = gamepad ?.buttons .some (button => button .pressed),
|
|
882
|
+
color = pressed ? blue : (external_X_ITE_X3D_Color3_default()).White;
|
|
883
|
+
|
|
884
|
+
inputRayMatrix
|
|
885
|
+
.assign (matrix)
|
|
886
|
+
.multRight (viewMatrix);
|
|
887
|
+
|
|
888
|
+
inputRayMatrix .multVecMatrix (fromPoint .assign ((external_X_ITE_X3D_Vector3_default()).Zero));
|
|
889
|
+
inputRayMatrix .multVecMatrix (toPoint .assign (toVector));
|
|
890
|
+
inputRayMatrix .multVecMatrix (hitPoint .assign (hit .originalPoint));
|
|
891
|
+
|
|
892
|
+
// Make ray shorter if track point is very close.
|
|
893
|
+
if (hitPoint .distance (fromPoint) < toPoint .distance (fromPoint))
|
|
894
|
+
toPoint .assign (hitPoint);
|
|
895
|
+
|
|
896
|
+
if (fromPoint .z > 0 || toPoint .z > 0)
|
|
897
|
+
continue;
|
|
898
|
+
|
|
899
|
+
external_X_ITE_X3D_ViewVolume_default().projectPointMatrix (fromPoint, projectionMatrix, viewport, fromPoint);
|
|
900
|
+
external_X_ITE_X3D_ViewVolume_default().projectPointMatrix (toPoint, projectionMatrix, viewport, toPoint);
|
|
901
|
+
|
|
902
|
+
fromPoint .z = 0;
|
|
903
|
+
toPoint .z = 0;
|
|
904
|
+
|
|
905
|
+
this [_inputRay]
|
|
906
|
+
.setColor (color)
|
|
907
|
+
.display (fromPoint, toPoint, frameBuffer);
|
|
908
|
+
|
|
909
|
+
// Draw hit point.
|
|
910
|
+
|
|
911
|
+
if (!hit .id)
|
|
912
|
+
continue;
|
|
913
|
+
|
|
914
|
+
const radius = pressed ? hitPressedSize : hitSize;
|
|
915
|
+
|
|
916
|
+
inputRayMatrix
|
|
917
|
+
.assign (matrix)
|
|
918
|
+
.multRight (viewMatrix)
|
|
919
|
+
.translate (hit .originalPoint)
|
|
920
|
+
.rotate (hitRotation .setFromToVec ((external_X_ITE_X3D_Vector3_default()).zAxis, hit .originalNormal));
|
|
921
|
+
|
|
922
|
+
this [_inputPoint] .display (radius, color, 0.3, 0.8, inputRayMatrix, projectionMatrix, frameBuffer);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
})(),
|
|
927
|
+
endFrame ()
|
|
928
|
+
{
|
|
929
|
+
const gl = this .getContext ();
|
|
930
|
+
|
|
931
|
+
// WebXR Emulator and polyfill: bind to null, to prevent changes.
|
|
932
|
+
gl .bindVertexArray (null);
|
|
933
|
+
},
|
|
934
|
+
sensorHitPulse (hit, gamepad)
|
|
935
|
+
{
|
|
936
|
+
if (hit .sensors .size)
|
|
937
|
+
{
|
|
938
|
+
if (hit .pulse)
|
|
939
|
+
{
|
|
940
|
+
gamepad ?.hapticActuators ?.[0] ?.pulse (0.25, 10);
|
|
941
|
+
|
|
942
|
+
hit .pulse = false;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
else
|
|
946
|
+
{
|
|
947
|
+
hit .pulse = true;
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
});
|
|
951
|
+
|
|
952
|
+
const X3DWebXRContext_default_ = X3DWebXRContext;
|
|
953
|
+
;
|
|
954
|
+
|
|
955
|
+
/* harmony default export */ const WebXR_X3DWebXRContext = (external_X_ITE_X3D_Namespace_default().add ("X3DWebXRContext", X3DWebXRContext_default_));
|
|
956
|
+
;// ./src/assets/components/WebXRComponent.js
|
|
957
|
+
/*******************************************************************************
|
|
958
|
+
*
|
|
959
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
960
|
+
*
|
|
961
|
+
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
|
|
962
|
+
*
|
|
963
|
+
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
|
|
964
|
+
*
|
|
965
|
+
* The copyright notice above does not evidence any actual of intended
|
|
966
|
+
* publication of such source code, and is an unpublished work by create3000.
|
|
967
|
+
* This material contains CONFIDENTIAL INFORMATION that is the property of
|
|
968
|
+
* create3000.
|
|
969
|
+
*
|
|
970
|
+
* No permission is granted to copy, distribute, or create derivative works from
|
|
971
|
+
* the contents of this software, in whole or in part, without the prior written
|
|
972
|
+
* permission of create3000.
|
|
973
|
+
*
|
|
974
|
+
* NON-MILITARY USE ONLY
|
|
975
|
+
*
|
|
976
|
+
* All create3000 software are effectively free software with a non-military use
|
|
977
|
+
* restriction. It is free. Well commented source is provided. You may reuse the
|
|
978
|
+
* source in any way you please with the exception anything that uses it must be
|
|
979
|
+
* marked to indicate is contains 'non-military use only' components.
|
|
980
|
+
*
|
|
981
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
982
|
+
*
|
|
983
|
+
* Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
|
|
984
|
+
*
|
|
985
|
+
* This file is part of the X_ITE Project.
|
|
986
|
+
*
|
|
987
|
+
* X_ITE is free software: you can redistribute it and/or modify it under the
|
|
988
|
+
* terms of the GNU General Public License version 3 only, as published by the
|
|
989
|
+
* Free Software Foundation.
|
|
990
|
+
*
|
|
991
|
+
* X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
992
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
993
|
+
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
|
|
994
|
+
* details (a copy is included in the LICENSE file that accompanied this code).
|
|
995
|
+
*
|
|
996
|
+
* You should have received a copy of the GNU General Public License version 3
|
|
997
|
+
* along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
|
|
998
|
+
* copy of the GPLv3 License.
|
|
999
|
+
*
|
|
1000
|
+
* For Silvio, Joy and Adi.
|
|
1001
|
+
*
|
|
1002
|
+
******************************************************************************/
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
external_X_ITE_X3D_Components_default().add ({
|
|
1008
|
+
name: "WebXR",
|
|
1009
|
+
concreteNodes:
|
|
1010
|
+
[
|
|
1011
|
+
],
|
|
1012
|
+
abstractNodes:
|
|
1013
|
+
[
|
|
1014
|
+
],
|
|
1015
|
+
browserContext: WebXR_X3DWebXRContext,
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
const WebXRComponent_default_ = undefined;
|
|
1019
|
+
;
|
|
1020
|
+
|
|
1021
|
+
/* harmony default export */ const WebXRComponent = (external_X_ITE_X3D_Namespace_default().add ("WebXRComponent", WebXRComponent_default_));
|
|
1022
|
+
/******/ })()
|
|
1023
|
+
;
|