x_ite 8.10.1 → 8.11.1
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/Makefile +3 -0
- package/build/bin/version.pl +28 -20
- package/build/docs/glTF-samples.pl +151 -0
- package/build/docs/nodes.pl +1 -1
- package/build/src/nodes.pl +41 -0
- package/dist/assets/components/Annotation.js +13 -13
- package/dist/assets/components/Annotation.min.js +1 -1
- package/dist/assets/components/CADGeometry.js +13 -13
- package/dist/assets/components/CADGeometry.min.js +1 -1
- package/dist/assets/components/CubeMapTexturing.js +30 -26
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +14 -14
- package/dist/assets/components/DIS.min.js +1 -1
- package/dist/assets/components/EventUtilities.js +9 -9
- package/dist/assets/components/EventUtilities.min.js +1 -1
- package/dist/assets/components/Geometry2D.js +19 -19
- package/dist/assets/components/Geometry2D.min.js +1 -1
- package/dist/assets/components/Geospatial.js +33 -33
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +394 -30
- package/dist/assets/components/HAnim.min.js +1 -1
- package/dist/assets/components/KeyDeviceSensor.js +8 -8
- package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
- package/dist/assets/components/Layout.js +26 -26
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +24 -24
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +73 -74
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +18 -18
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +18 -18
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +37 -37
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +55 -63
- package/dist/assets/components/Text.min.js +1 -1
- package/dist/assets/components/TextureProjector.js +14 -14
- package/dist/assets/components/TextureProjector.min.js +1 -1
- package/dist/assets/components/Texturing3D.js +35 -31
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +20 -20
- package/dist/assets/components/VolumeRendering.min.js +1 -1
- package/dist/assets/components/X_ITE.js +9 -9
- package/dist/assets/components/X_ITE.min.js +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +1456 -844
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +2 -2
- package/docs/_posts/components/Core/MetadataBoolean.md +6 -4
- package/docs/_posts/components/Core/MetadataDouble.md +6 -4
- package/docs/_posts/components/Core/MetadataFloat.md +6 -4
- package/docs/_posts/components/Core/MetadataInteger.md +6 -4
- package/docs/_posts/components/Core/MetadataSet.md +6 -4
- package/docs/_posts/components/Core/MetadataString.md +6 -4
- package/docs/_posts/components/DIS/DISEntityTypeMapping.md +1 -1
- package/docs/_posts/components/HAnim/HAnimMotion.md +48 -48
- package/docs/_posts/components/RigidBodyPhysics/Contact.md +1 -1
- package/docs/_posts/getting-started.md +45 -35
- package/docs/_posts/reference/browser-services.md +6 -0
- package/docs/_tabs/playground.html +215 -15
- package/docs/assets/css/style.scss +35 -2
- package/docs/assets/js/example.js +95 -3
- package/docs/laboratory/gltf-sample-viewer.html +603 -235
- package/package.json +2 -2
- package/src/assets/shaders/Types.glsl.js +4 -0
- package/src/assets/shaders/webgl1/include/Hatch.glsl.js +2 -3
- package/src/assets/shaders/webgl2/Compose.fs.js +29 -0
- package/src/assets/shaders/webgl2/Compose.vs.js +14 -0
- package/src/assets/shaders/webgl2/include/Fragment.glsl.js +24 -2
- package/src/assets/shaders/webgl2/include/Hatch.glsl.js +2 -3
- package/src/assets/shaders/webgl2/include/Stipple.glsl.js +5 -3
- package/src/bookmarks.js +92 -5
- package/src/examples.js +1 -0
- package/src/standard/Math/Numbers/Quaternion.js +191 -13
- package/src/standard/Math/Numbers/Rotation4.js +23 -0
- package/src/standard/Time/{MicroTime.js → Time.js} +21 -28
- package/src/x_ite/Base/X3DChildObject.js +5 -4
- package/src/x_ite/Browser/Core/BrowserOptions.js +71 -60
- package/src/x_ite/Browser/Core/Context.js +2 -2
- package/src/x_ite/Browser/Core/X3DCoreContext.js +6 -0
- package/src/x_ite/Browser/DOMIntegration.js +0 -17
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +5 -4
- package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +7 -4
- package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +20 -15
- package/src/x_ite/Browser/Shaders/Shaders.js +19 -15
- package/src/x_ite/Browser/Text/X3DTextContext.js +16 -16
- package/src/x_ite/Browser/Time/X3DTimeContext.js +3 -2
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/VolumeRendering/VolumeMaterial.js +2 -2
- package/src/x_ite/Browser/X3DBrowser.js +1 -2
- package/src/x_ite/Browser/X3DBrowserContext.js +0 -5
- package/src/x_ite/Components/Core/MetadataBoolean.js +8 -1
- package/src/x_ite/Components/Core/MetadataDouble.js +8 -1
- package/src/x_ite/Components/Core/MetadataFloat.js +8 -1
- package/src/x_ite/Components/Core/MetadataInteger.js +8 -1
- package/src/x_ite/Components/Core/MetadataSet.js +8 -1
- package/src/x_ite/Components/Core/MetadataString.js +8 -1
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +9 -6
- package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +2 -1
- package/src/x_ite/Components/DIS/DISEntityTypeMapping.js +1 -1
- package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +5 -1
- package/src/x_ite/Components/Grouping/X3DGroupingNode.js +2 -0
- package/src/x_ite/Components/HAnim/HAnimHumanoid.js +34 -2
- package/src/x_ite/Components/HAnim/HAnimMotion.js +331 -15
- package/src/x_ite/Components/Lighting/DirectionalLight.js +1 -3
- package/src/x_ite/Components/Lighting/PointLight.js +1 -3
- package/src/x_ite/Components/Lighting/SpotLight.js +1 -3
- package/src/x_ite/Components/Networking/X3DUrlObject.js +5 -4
- package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +47 -51
- package/src/x_ite/Components/Rendering/X3DGeometryNode.js +4 -2
- package/src/x_ite/Components/RigidBodyPhysics/Contact.js +1 -1
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +1 -1
- package/src/x_ite/Components/Shape/FillProperties.js +4 -0
- package/src/x_ite/Components/Shape/LineProperties.js +4 -0
- package/src/x_ite/Components/Shape/PointProperties.js +4 -0
- package/src/x_ite/Components/Shape/X3DMaterialNode.js +44 -20
- package/src/x_ite/Components/Sound/AudioClip.js +2 -1
- package/src/x_ite/Components/Text/X3DFontStyleNode.js +13 -23
- package/src/x_ite/Components/Texturing/ImageTexture.js +2 -1
- package/src/x_ite/Components/Texturing/MovieTexture.js +2 -1
- package/src/x_ite/Components/Texturing3D/ImageTextureAtlas.js +2 -1
- package/src/x_ite/Components/Time/TimeSensor.js +25 -24
- package/src/x_ite/Components/Time/X3DTimeDependentNode.js +5 -4
- package/src/x_ite/Execution/BindableList.js +3 -3
- package/src/x_ite/Execution/X3DScene.js +2 -0
- package/src/x_ite/Parser/XMLParser.js +12 -2
- package/src/x_ite/Rendering/MultiSampleFrameBuffer.js +264 -26
- package/src/x_ite/Rendering/PointingBuffer.js +5 -7
- package/src/x_ite/Rendering/TextureBuffer.js +6 -14
- package/src/x_ite/Rendering/X3DRenderObject.js +28 -28
- package/src/x_ite/X3D.js +0 -1
- package/src/x_ite/X3DCanvasElement.js +2 -0
- package/src/x_ite.html +23 -24
- package/x_ite.min.html +23 -24
- /package/build/{bin → docs}/tags.pl +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x_ite",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.11.1",
|
|
4
4
|
"description": "X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.",
|
|
5
5
|
"homepage": "https://create3000.github.io/x_ite/",
|
|
6
6
|
"author": "Holger Seelig <holger.seelig@gmail.com>",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"opentype.js": "^1.3.4",
|
|
73
73
|
"pako": "^2.1.0",
|
|
74
74
|
"string-replace-webpack-plugin": "^0.1.3",
|
|
75
|
-
"webpack": "^5.88.
|
|
75
|
+
"webpack": "^5.88.2",
|
|
76
76
|
"webpack-cli": "^5.1.4",
|
|
77
77
|
"webpack-shell-plugin-next": "^2.3.1"
|
|
78
78
|
},
|
|
@@ -52,7 +52,9 @@ struct x3d_LinePropertiesParameters
|
|
|
52
52
|
{
|
|
53
53
|
mediump int linetype;
|
|
54
54
|
mediump float lineStippleScale;
|
|
55
|
+
#if defined (X3D_STYLE_PROPERTIES_TEXTURE)
|
|
55
56
|
sampler2D texture;
|
|
57
|
+
#endif
|
|
56
58
|
};
|
|
57
59
|
#endif
|
|
58
60
|
|
|
@@ -64,7 +66,9 @@ struct x3d_FillPropertiesParameters
|
|
|
64
66
|
bool filled;
|
|
65
67
|
bool hatched;
|
|
66
68
|
mediump vec3 hatchColor;
|
|
69
|
+
#if defined (X3D_STYLE_PROPERTIES_TEXTURE)
|
|
67
70
|
sampler2D texture;
|
|
71
|
+
#endif
|
|
68
72
|
mediump float scale;
|
|
69
73
|
};
|
|
70
74
|
#endif
|
|
@@ -8,13 +8,12 @@ getHatchColor (vec4 color)
|
|
|
8
8
|
{
|
|
9
9
|
vec4 finalColor = x3d_FillProperties .filled ? color : vec4 (0.0);
|
|
10
10
|
|
|
11
|
-
if (
|
|
12
|
-
{
|
|
11
|
+
#if defined (X3D_STYLE_PROPERTIES_TEXTURE)
|
|
13
12
|
vec4 hatch = texture2D (x3d_FillProperties .texture, gl_FragCoord .xy / (32.0 * x3d_FillProperties .scale));
|
|
14
13
|
|
|
15
14
|
hatch .rgb *= x3d_FillProperties .hatchColor;
|
|
16
15
|
finalColor = mix (finalColor, hatch, hatch .a);
|
|
17
|
-
|
|
16
|
+
#endif
|
|
18
17
|
|
|
19
18
|
return finalColor;
|
|
20
19
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default /* glsl */ `#version 300 es
|
|
2
|
+
|
|
3
|
+
precision highp float;
|
|
4
|
+
precision highp int;
|
|
5
|
+
precision highp sampler2D;
|
|
6
|
+
|
|
7
|
+
/* sum(rgb * a), prod(1 - a) */
|
|
8
|
+
uniform sampler2D x3d_AccumRevealageTexture;
|
|
9
|
+
|
|
10
|
+
/* sum(a) */
|
|
11
|
+
uniform sampler2D x3d_AlphaTexture;
|
|
12
|
+
|
|
13
|
+
out vec4 x3d_FragColor;
|
|
14
|
+
|
|
15
|
+
void
|
|
16
|
+
main ()
|
|
17
|
+
{
|
|
18
|
+
ivec2 fragCoord = ivec2 (gl_FragCoord .xy);
|
|
19
|
+
vec4 accum = texelFetch (x3d_AccumRevealageTexture, fragCoord, 0);
|
|
20
|
+
|
|
21
|
+
if (accum .a >= 1.0)
|
|
22
|
+
discard;
|
|
23
|
+
|
|
24
|
+
float alpha = texelFetch (x3d_AlphaTexture, fragCoord, 0) .r;
|
|
25
|
+
float revealage = 1.0 - accum .a;
|
|
26
|
+
|
|
27
|
+
x3d_FragColor = vec4 (revealage * accum .rgb / clamp (alpha, 0.001, 50000.0), revealage);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -74,7 +74,12 @@ in vec3 vertex;
|
|
|
74
74
|
in float depth;
|
|
75
75
|
#endif
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
#if defined (X3D_ORDER_INDEPENDENT_TRANSPARENCY)
|
|
78
|
+
layout(location = 0) out vec4 x3d_FragData0;
|
|
79
|
+
layout(location = 1) out vec4 x3d_FragData1;
|
|
80
|
+
#else
|
|
81
|
+
out vec4 x3d_FragColor;
|
|
82
|
+
#endif
|
|
78
83
|
|
|
79
84
|
#pragma X3D include "Texture.glsl"
|
|
80
85
|
#pragma X3D include "ClipPlanes.glsl"
|
|
@@ -86,6 +91,14 @@ out vec4 x3d_FragColor;
|
|
|
86
91
|
vec4
|
|
87
92
|
getMaterialColor ();
|
|
88
93
|
|
|
94
|
+
#if defined (X3D_ORDER_INDEPENDENT_TRANSPARENCY)
|
|
95
|
+
float
|
|
96
|
+
weight (const in float z, const in float a)
|
|
97
|
+
{
|
|
98
|
+
return clamp (pow (min (1.0, a * 10.0) + 0.01, 3.0) * 1e8 * pow (1.0 - z * 0.9, 3.0), 1e-2, 3e3);
|
|
99
|
+
}
|
|
100
|
+
#endif
|
|
101
|
+
|
|
89
102
|
void
|
|
90
103
|
fragment_main ()
|
|
91
104
|
{
|
|
@@ -128,7 +141,16 @@ fragment_main ()
|
|
|
128
141
|
finalColor .a = 1.0;
|
|
129
142
|
#endif
|
|
130
143
|
|
|
131
|
-
|
|
144
|
+
#if defined (X3D_ORDER_INDEPENDENT_TRANSPARENCY)
|
|
145
|
+
float w = weight (gl_FragCoord .z, finalColor .a);
|
|
146
|
+
|
|
147
|
+
finalColor.rgb *= finalColor .a;
|
|
148
|
+
|
|
149
|
+
x3d_FragData0 = vec4 (finalColor .rgb * w, finalColor .a);
|
|
150
|
+
x3d_FragData1 = vec4 (finalColor .a * w);
|
|
151
|
+
#else
|
|
152
|
+
x3d_FragColor = finalColor;
|
|
153
|
+
#endif
|
|
132
154
|
|
|
133
155
|
#if defined (X3D_LOGARITHMIC_DEPTH_BUFFER)
|
|
134
156
|
//https://outerra.blogspot.com/2013/07/logarithmic-depth-buffer-optimizations.html
|
|
@@ -8,13 +8,12 @@ getHatchColor (vec4 color)
|
|
|
8
8
|
{
|
|
9
9
|
vec4 finalColor = x3d_FillProperties .filled ? color : vec4 (0.0);
|
|
10
10
|
|
|
11
|
-
if (
|
|
12
|
-
{
|
|
11
|
+
#if defined (X3D_STYLE_PROPERTIES_TEXTURE)
|
|
13
12
|
vec4 hatch = texture (x3d_FillProperties .texture, gl_FragCoord .xy / (32.0 * x3d_FillProperties .scale));
|
|
14
13
|
|
|
15
14
|
hatch .rgb *= x3d_FillProperties .hatchColor;
|
|
16
15
|
finalColor = mix (finalColor, hatch, hatch .a);
|
|
17
|
-
|
|
16
|
+
#endif
|
|
18
17
|
|
|
19
18
|
return finalColor;
|
|
20
19
|
}
|
|
@@ -25,8 +25,10 @@ stipple ()
|
|
|
25
25
|
#endif
|
|
26
26
|
#endif
|
|
27
27
|
|
|
28
|
-
if (
|
|
29
|
-
|
|
28
|
+
#if defined (X3D_STYLE_PROPERTIES_TEXTURE)
|
|
29
|
+
if (x3d_LineProperties .linetype == 16)
|
|
30
|
+
return;
|
|
31
|
+
|
|
30
32
|
int linetype = x3d_LineProperties .linetype;
|
|
31
33
|
int height = textureSize (x3d_LineProperties .texture, 0) .y;
|
|
32
34
|
float t = 1.0 - float (linetype * 2 + 1) / float (height * 2);
|
|
@@ -34,7 +36,7 @@ stipple ()
|
|
|
34
36
|
|
|
35
37
|
if (alpha != 1.0)
|
|
36
38
|
discard;
|
|
37
|
-
|
|
39
|
+
#endif
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
#endif
|
package/src/bookmarks.js
CHANGED
|
@@ -148,6 +148,8 @@ const Bookmarks = (() =>
|
|
|
148
148
|
|
|
149
149
|
const t0 = performance .now ();
|
|
150
150
|
|
|
151
|
+
this .browser .getBrowserOptions () .reset ();
|
|
152
|
+
|
|
151
153
|
await this .browser .loadURL (new X3D .MFString (url)) .catch (Function .prototype);
|
|
152
154
|
|
|
153
155
|
const loadTime = (performance .now () - t0) / 1000;
|
|
@@ -158,15 +160,15 @@ const Bookmarks = (() =>
|
|
|
158
160
|
{
|
|
159
161
|
try
|
|
160
162
|
{
|
|
161
|
-
$("#
|
|
163
|
+
$("#toolbar") .empty ();
|
|
162
164
|
|
|
163
165
|
$("<span></span>")
|
|
164
166
|
.text ("▣")
|
|
165
167
|
.attr ("title", "View All")
|
|
166
168
|
.on ("click", () => this .browser .viewAll (0))
|
|
167
|
-
.appendTo ($("#
|
|
169
|
+
.appendTo ($("#toolbar"));
|
|
168
170
|
|
|
169
|
-
$("<span></span>") .addClass ("separator") .appendTo ($("#
|
|
171
|
+
$("<span></span>") .addClass ("separator") .appendTo ($("#toolbar"));
|
|
170
172
|
|
|
171
173
|
const animations = this .browser .currentScene .getExportedNode ("Animations");
|
|
172
174
|
|
|
@@ -190,19 +192,104 @@ const Bookmarks = (() =>
|
|
|
190
192
|
timeSensor .loop = true;
|
|
191
193
|
timeSensor .startTime = Date .now () / 1000;
|
|
192
194
|
})
|
|
193
|
-
.appendTo ($("#
|
|
195
|
+
.appendTo ($("#toolbar"));
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
$("<span></span>")
|
|
197
199
|
.text ("◼")
|
|
198
200
|
.attr ("title", "Stop")
|
|
199
201
|
.on ("click", stop)
|
|
200
|
-
.appendTo ($("#
|
|
202
|
+
.appendTo ($("#toolbar"));
|
|
201
203
|
}
|
|
202
204
|
catch (error)
|
|
203
205
|
{
|
|
204
206
|
// console .log (error)
|
|
205
207
|
}
|
|
208
|
+
|
|
209
|
+
$("<span></span>") .addClass ("separator") .appendTo ($("#toolbar"));
|
|
210
|
+
|
|
211
|
+
const antialiased = $("<span></span>")
|
|
212
|
+
.text ("antialiased")
|
|
213
|
+
.attr ("title", "Toggle antialiasing.")
|
|
214
|
+
.addClass (this .browser .getBrowserOption ("Antialiased") ? "selected" : "")
|
|
215
|
+
.on ("click", () =>
|
|
216
|
+
{
|
|
217
|
+
const value = !this .browser .getBrowserOption ("Antialiased");
|
|
218
|
+
|
|
219
|
+
this .browser .setBrowserOption ("Antialiased", value);
|
|
220
|
+
|
|
221
|
+
antialiased .toggleClass ("selected");
|
|
222
|
+
})
|
|
223
|
+
.appendTo ($("#toolbar"));
|
|
224
|
+
|
|
225
|
+
$("<span></span>") .addClass ("dot") .appendTo ($("#toolbar"));
|
|
226
|
+
|
|
227
|
+
const contentScale = $("<span></span>")
|
|
228
|
+
.text ("contentScale 1.0")
|
|
229
|
+
.attr ("title", "Toggle contentScale between 0.1, 1.0 and 2.0.")
|
|
230
|
+
.on ("click", () =>
|
|
231
|
+
{
|
|
232
|
+
const
|
|
233
|
+
index = ((contentScale .attr ("index") ?? 1) + 1) % 3,
|
|
234
|
+
value = [0.1, 1, 2][index];
|
|
235
|
+
|
|
236
|
+
this .browser .setBrowserOption ("ContentScale", value);
|
|
237
|
+
|
|
238
|
+
contentScale
|
|
239
|
+
.attr ("index", index)
|
|
240
|
+
.text ("contentScale " + value .toFixed (1))
|
|
241
|
+
})
|
|
242
|
+
.appendTo ($("#toolbar"));
|
|
243
|
+
|
|
244
|
+
$("<span></span>") .addClass ("dot") .appendTo ($("#toolbar"));
|
|
245
|
+
|
|
246
|
+
const pixelated = $("<span></span>")
|
|
247
|
+
.text ("pixelated")
|
|
248
|
+
.attr ("title", "Set CSS property image-rendering to pixelated.")
|
|
249
|
+
.addClass ($("#browser") .css ("image-rendering") === "pixelated" ? "selected" : "")
|
|
250
|
+
.on ("click", () =>
|
|
251
|
+
{
|
|
252
|
+
$("#browser") .css ("image-rendering", pixelated .hasClass ("selected") ? "unset" : "pixelated");
|
|
253
|
+
|
|
254
|
+
pixelated .toggleClass ("selected");
|
|
255
|
+
})
|
|
256
|
+
.appendTo ($("#toolbar"));
|
|
257
|
+
|
|
258
|
+
$("<span></span>") .addClass ("separator") .appendTo ($("#toolbar"));
|
|
259
|
+
|
|
260
|
+
const oit = $("<span></span>")
|
|
261
|
+
.text ("oit")
|
|
262
|
+
.attr ("title", "Toggle order independent transparency.")
|
|
263
|
+
.addClass (this .browser .getBrowserOption ("OrderIndependentTransparency") ? "selected" : "")
|
|
264
|
+
.on ("click", () =>
|
|
265
|
+
{
|
|
266
|
+
const value = !this .browser .getBrowserOption ("OrderIndependentTransparency");
|
|
267
|
+
|
|
268
|
+
this .browser .setBrowserOption ("OrderIndependentTransparency", value);
|
|
269
|
+
|
|
270
|
+
oit .toggleClass ("selected");
|
|
271
|
+
})
|
|
272
|
+
.appendTo ($("#toolbar"));
|
|
273
|
+
|
|
274
|
+
$("<span></span>") .addClass ("dot") .appendTo ($("#toolbar"));
|
|
275
|
+
|
|
276
|
+
const log = $("<span></span>")
|
|
277
|
+
.text ("log")
|
|
278
|
+
.attr ("title", "Toggle logarithmic depth buffer.")
|
|
279
|
+
.addClass (this .browser .getBrowserOption ("LogarithmicDepthBuffer") ? "selected" : "")
|
|
280
|
+
.on ("click", () =>
|
|
281
|
+
{
|
|
282
|
+
const value = !this .browser .getBrowserOption ("LogarithmicDepthBuffer");
|
|
283
|
+
|
|
284
|
+
this .browser .setBrowserOption ("LogarithmicDepthBuffer", value);
|
|
285
|
+
|
|
286
|
+
log .toggleClass ("selected");
|
|
287
|
+
})
|
|
288
|
+
.appendTo ($("#toolbar"));
|
|
289
|
+
|
|
290
|
+
// this .browser .setBrowserOption ("Antialiased", false)
|
|
291
|
+
// this .browser .setBrowserOption ("OrderIndependentTransparency", true)
|
|
292
|
+
// this .browser .setBrowserOption ("ContentScale", -1)
|
|
206
293
|
}
|
|
207
294
|
});
|
|
208
295
|
|
package/src/examples.js
CHANGED
|
@@ -163,6 +163,179 @@ Object .assign (Quaternion .prototype,
|
|
|
163
163
|
|
|
164
164
|
return matrix;
|
|
165
165
|
},
|
|
166
|
+
setEuler (x, y, z, order = "XYZ")
|
|
167
|
+
{
|
|
168
|
+
// http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
|
|
169
|
+
|
|
170
|
+
const
|
|
171
|
+
c1 = Math .cos (x / 2),
|
|
172
|
+
c2 = Math .cos (y / 2),
|
|
173
|
+
c3 = Math .cos (z / 2),
|
|
174
|
+
s1 = Math .sin (x / 2),
|
|
175
|
+
s2 = Math .sin (y / 2),
|
|
176
|
+
s3 = Math .sin (z / 2);
|
|
177
|
+
|
|
178
|
+
switch (order)
|
|
179
|
+
{
|
|
180
|
+
case "XYZ":
|
|
181
|
+
this .x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
182
|
+
this .y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
183
|
+
this .z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
184
|
+
this .w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case "ZYX":
|
|
188
|
+
this .x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
189
|
+
this .y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
190
|
+
this .z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
191
|
+
this .w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
192
|
+
break;
|
|
193
|
+
|
|
194
|
+
case "YXZ":
|
|
195
|
+
this .x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
196
|
+
this .y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
197
|
+
this .z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
198
|
+
this .w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
199
|
+
break;
|
|
200
|
+
|
|
201
|
+
case "ZXY":
|
|
202
|
+
this .x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
203
|
+
this .y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
204
|
+
this .z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
205
|
+
this .w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
206
|
+
break;
|
|
207
|
+
|
|
208
|
+
case "YZX":
|
|
209
|
+
this .x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
210
|
+
this .y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
211
|
+
this .z = c1 * c2 * s3 - s1 * s2 * c3;
|
|
212
|
+
this .w = c1 * c2 * c3 - s1 * s2 * s3;
|
|
213
|
+
break;
|
|
214
|
+
|
|
215
|
+
case "XZY":
|
|
216
|
+
this .x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
217
|
+
this .y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
218
|
+
this .z = c1 * c2 * s3 + s1 * s2 * c3;
|
|
219
|
+
this .w = c1 * c2 * c3 + s1 * s2 * s3;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return this;
|
|
224
|
+
},
|
|
225
|
+
getEuler (euler = [ ], order = "XYZ")
|
|
226
|
+
{
|
|
227
|
+
const { 0: m0, 1: m1, 2: m2, 3: m3, 4: m4, 5: m5, 6: m6, 7: m7, 8: m8 } = this .getMatrix (m);
|
|
228
|
+
|
|
229
|
+
switch (order)
|
|
230
|
+
{
|
|
231
|
+
case "XYZ":
|
|
232
|
+
{
|
|
233
|
+
euler [1] = Math .asin (Algorithm .clamp (m6, -1, 1));
|
|
234
|
+
|
|
235
|
+
if (Math .abs (m6) < 0.9999999)
|
|
236
|
+
{
|
|
237
|
+
euler [0] = Math .atan2 (-m7, m8);
|
|
238
|
+
euler [2] = Math .atan2 (-m3, m0);
|
|
239
|
+
}
|
|
240
|
+
else
|
|
241
|
+
{
|
|
242
|
+
euler [0] = Math .atan2 (m5, m4);
|
|
243
|
+
euler [2] = 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case "ZYX":
|
|
249
|
+
{
|
|
250
|
+
euler [1] = Math .asin (- Algorithm .clamp (m2, -1, 1));
|
|
251
|
+
|
|
252
|
+
if (Math .abs (m2) < 0.9999999)
|
|
253
|
+
{
|
|
254
|
+
euler [0] = Math .atan2 (m5, m8);
|
|
255
|
+
euler [2] = Math .atan2 (m1, m0);
|
|
256
|
+
}
|
|
257
|
+
else
|
|
258
|
+
{
|
|
259
|
+
euler [0] = 0;
|
|
260
|
+
euler [2] = Math .atan2 (-m3, m4);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case "YXZ":
|
|
266
|
+
{
|
|
267
|
+
euler [0] = Math .asin (- Algorithm .clamp (m7, -1, 1));
|
|
268
|
+
|
|
269
|
+
if (Math .abs (m7) < 0.9999999)
|
|
270
|
+
{
|
|
271
|
+
euler [1] = Math .atan2 (m6, m8);
|
|
272
|
+
euler [2] = Math .atan2 (m1, m4);
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
else
|
|
276
|
+
{
|
|
277
|
+
euler [1] = Math .atan2 (-m2, m0);
|
|
278
|
+
euler [2] = 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
case "ZXY":
|
|
284
|
+
{
|
|
285
|
+
euler [0] = Math .asin (Algorithm .clamp (m5, -1, 1));
|
|
286
|
+
|
|
287
|
+
if (Math .abs (m5) < 0.9999999)
|
|
288
|
+
{
|
|
289
|
+
euler [1] = Math .atan2 (-m2, m8);
|
|
290
|
+
euler [2] = Math .atan2 (-m3, m4);
|
|
291
|
+
}
|
|
292
|
+
else
|
|
293
|
+
{
|
|
294
|
+
euler [1] = 0;
|
|
295
|
+
euler [2] = Math .atan2 (m1, m0);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case "YZX":
|
|
301
|
+
{
|
|
302
|
+
euler [2] = Math .asin (Algorithm .clamp (m1, -1, 1));
|
|
303
|
+
|
|
304
|
+
if (Math .abs (m1) < 0.9999999)
|
|
305
|
+
{
|
|
306
|
+
euler [0] = Math .atan2 (-m7, m4);
|
|
307
|
+
euler [1] = Math .atan2 (-m2, m0);
|
|
308
|
+
}
|
|
309
|
+
else
|
|
310
|
+
{
|
|
311
|
+
euler [0] = 0;
|
|
312
|
+
euler [1] = Math .atan2 (m6, m8);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
case "XZY":
|
|
318
|
+
{
|
|
319
|
+
euler [2] = Math .asin (- Algorithm .clamp (m3, -1, 1));
|
|
320
|
+
|
|
321
|
+
if (Math .abs (m3) < 0.9999999)
|
|
322
|
+
{
|
|
323
|
+
euler [0] = Math .atan2 (m5, m4);
|
|
324
|
+
euler [1] = Math .atan2 (m6, m0);
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
else
|
|
328
|
+
{
|
|
329
|
+
euler [0] = Math .atan2 (-m7, m8);
|
|
330
|
+
euler [1] = 0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return euler;
|
|
338
|
+
},
|
|
166
339
|
isReal ()
|
|
167
340
|
{
|
|
168
341
|
return !(this .x || this .y || this .z);
|
|
@@ -253,31 +426,35 @@ Object .assign (Quaternion .prototype,
|
|
|
253
426
|
},
|
|
254
427
|
multVecQuat (vector)
|
|
255
428
|
{
|
|
429
|
+
// https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Vector_rotation
|
|
430
|
+
|
|
256
431
|
const
|
|
257
432
|
{ x: qx, y: qy, z: qz, w: qw } = this,
|
|
258
433
|
{ x: vx, y: vy, z: vz } = vector,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
434
|
+
tx = 2 * (qy * vz - qz * vy),
|
|
435
|
+
ty = 2 * (qz * vx - qx * vz),
|
|
436
|
+
tz = 2 * (qx * vy - qy * vx);
|
|
262
437
|
|
|
263
|
-
vector .x
|
|
264
|
-
vector .y
|
|
265
|
-
vector .z
|
|
438
|
+
vector .x += qw * tx + qy * tz - qz * ty;
|
|
439
|
+
vector .y += qw * ty + qz * tx - qx * tz;
|
|
440
|
+
vector .z += qw * tz + qx * ty - qy * tx;
|
|
266
441
|
|
|
267
442
|
return vector;
|
|
268
443
|
},
|
|
269
444
|
multQuatVec (vector)
|
|
270
445
|
{
|
|
446
|
+
// https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Vector_rotation
|
|
447
|
+
|
|
271
448
|
const
|
|
272
449
|
{ x: qx, y: qy, z: qz, w: qw } = this,
|
|
273
450
|
{ x: vx, y: vy, z: vz } = vector,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
451
|
+
tx = 2 * (qz * vy - qy * vz),
|
|
452
|
+
ty = 2 * (qx * vz - qz * vx),
|
|
453
|
+
tz = 2 * (qy * vx - qx * vy);
|
|
277
454
|
|
|
278
|
-
vector .x
|
|
279
|
-
vector .y
|
|
280
|
-
vector .z
|
|
455
|
+
vector .x += qw * tx - qy * tz + qz * ty;
|
|
456
|
+
vector .y += qw * ty - qz * tx + qx * tz;
|
|
457
|
+
vector .z += qw * tz - qx * ty + qy * tx;
|
|
281
458
|
|
|
282
459
|
return vector;
|
|
283
460
|
},
|
|
@@ -482,6 +659,7 @@ Object .assign (Quaternion,
|
|
|
482
659
|
const
|
|
483
660
|
t1 = new Quaternion (0, 0, 0, 1),
|
|
484
661
|
t2 = new Quaternion (0, 0, 0, 1),
|
|
485
|
-
t3 = new Quaternion (0, 0, 0, 1)
|
|
662
|
+
t3 = new Quaternion (0, 0, 0, 1),
|
|
663
|
+
m = new Matrix3 ();
|
|
486
664
|
|
|
487
665
|
export default Quaternion;
|
|
@@ -303,6 +303,17 @@ Object .assign (Rotation4 .prototype,
|
|
|
303
303
|
{
|
|
304
304
|
return this [_quaternion] .getMatrix (matrix);
|
|
305
305
|
},
|
|
306
|
+
setEuler (x, y, z, order = "XYZ")
|
|
307
|
+
{
|
|
308
|
+
// Quaternion is then already normalized.
|
|
309
|
+
this [_quaternion] .setEuler (x, y, z, order);
|
|
310
|
+
this .update ();
|
|
311
|
+
return this;
|
|
312
|
+
},
|
|
313
|
+
getEuler (euler = [ ], order = "XYZ")
|
|
314
|
+
{
|
|
315
|
+
return this [_quaternion] .getEuler (euler, order);
|
|
316
|
+
},
|
|
306
317
|
equals (rotation)
|
|
307
318
|
{
|
|
308
319
|
return this [_quaternion] .equals (rotation [_quaternion]);
|
|
@@ -443,6 +454,18 @@ Object .defineProperties (Rotation4 .prototype,
|
|
|
443
454
|
Object .assign (Rotation4,
|
|
444
455
|
{
|
|
445
456
|
Identity: new Rotation4 (),
|
|
457
|
+
fromQuaternion (quaternion)
|
|
458
|
+
{
|
|
459
|
+
return new Rotation4 () .setQuaternion (quaternion);
|
|
460
|
+
},
|
|
461
|
+
fromMatrix (matrix)
|
|
462
|
+
{
|
|
463
|
+
return new Rotation4 () .setMatrix (matrix);
|
|
464
|
+
},
|
|
465
|
+
fromEuler (x, y, z, order = "XYZ")
|
|
466
|
+
{
|
|
467
|
+
return new Rotation4 () .setEuler (x, y, z, order);
|
|
468
|
+
},
|
|
446
469
|
spline (r0, r1, r2)
|
|
447
470
|
{
|
|
448
471
|
const copy = Object .create (this .prototype);
|
|
@@ -47,38 +47,31 @@
|
|
|
47
47
|
|
|
48
48
|
// Return a pseudo accurate timestamp.
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const Time =
|
|
51
51
|
{
|
|
52
|
-
|
|
53
|
-
offset = 0,
|
|
54
|
-
last = 0;
|
|
55
|
-
|
|
56
|
-
return function ()
|
|
52
|
+
now: (function ()
|
|
57
53
|
{
|
|
58
|
-
|
|
54
|
+
let
|
|
55
|
+
offset = 0,
|
|
56
|
+
last = 0;
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
return function ()
|
|
61
59
|
{
|
|
62
|
-
|
|
63
|
-
last = current;
|
|
60
|
+
const current = Date .now ();
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return last = current + (++ offset / 1000);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
62
|
+
if (current > last)
|
|
63
|
+
{
|
|
64
|
+
offset = 0;
|
|
65
|
+
last = current;
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})
|
|
82
|
-
}
|
|
67
|
+
return current;
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
{
|
|
71
|
+
return last = current + (offset < 1000 ? ++ offset : offset) / 1000;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
})(),
|
|
75
|
+
};
|
|
83
76
|
|
|
84
|
-
export default
|
|
77
|
+
export default Time;
|