x_ite 8.6.6 → 8.6.8
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 +1 -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 +25 -25
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +13 -13
- 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 +18 -18
- 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 +27 -27
- 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 +23 -23
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +19 -19
- 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 +28 -28
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +24 -24
- 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 +31 -31
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +19 -19
- 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/assets/lib/draco_decoder_gltf.js +29 -0
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +2768 -2611
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +1 -1
- package/docs/_posts/laboratory/x3d-file-converter.md +3 -0
- package/docs/_tabs/laboratory.md +2 -2
- package/docs/laboratory/gltf-sample-viewer.html +72 -3
- package/package.json +2 -2
- package/src/assets/lib/draco_decoder_gltf.js +29 -0
- package/src/assets/shaders/webgl2/include/Particle.glsl.js +8 -9
- package/src/standard/Math/Numbers/Color3.js +2 -2
- package/src/standard/Math/Numbers/Color4.js +1 -1
- package/src/standard/Utility/ObjectCache.js +9 -10
- package/src/x_ite/Browser/Networking/URLs.js +4 -0
- package/src/x_ite/Browser/Picking/X3DPickingContext.js +1 -1
- package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +1 -1
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/X3DBrowser.js +7 -0
- package/src/x_ite/Browser/X3DBrowserContext.js +3 -3
- package/src/x_ite/Components/Interpolation/SquadOrientationInterpolator.js +6 -7
- package/src/x_ite/Components/Layering/X3DLayerNode.js +1 -3
- package/src/x_ite/Components/Navigation/OrthoViewpoint.js +1 -1
- package/src/x_ite/Parser/GLTF2Parser.js +186 -34
- package/src/x_ite/Parser/OBJParser.js +6 -9
- package/src/x_ite/Parser/SVGParser.js +5 -2
- package/src/x_ite/Rendering/X3DRenderObject.js +3 -4
- package/webpack.config.js +2 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default /* glsl */ `
|
|
2
2
|
#if defined (X3D_PARTICLE_SYSTEM)
|
|
3
|
-
|
|
4
|
-
in vec4 x3d_Particle;
|
|
5
|
-
in mat4 x3d_ParticleMatrix;
|
|
3
|
+
#if defined (X3D_TEX_COORD_RAMP)
|
|
6
4
|
|
|
7
5
|
uniform sampler2D x3d_TexCoordRamp;
|
|
8
6
|
|
|
7
|
+
in vec4 x3d_Particle;
|
|
8
|
+
|
|
9
9
|
vec4
|
|
10
10
|
texelFetch (const in sampler2D sampler, const in int index, const in int lod)
|
|
11
11
|
{
|
|
@@ -16,7 +16,6 @@ texelFetch (const in sampler2D sampler, const in int index, const in int lod)
|
|
|
16
16
|
return t;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
#if defined (X3D_TEX_COORD_RAMP)
|
|
20
19
|
vec4
|
|
21
20
|
getTexCoord (const in vec4 texCoord)
|
|
22
21
|
{
|
|
@@ -27,9 +26,11 @@ getTexCoord (const in vec4 texCoord)
|
|
|
27
26
|
return texelFetch (x3d_TexCoordRamp, index0 + map [gl_VertexID % 6], 0);
|
|
28
27
|
}
|
|
29
28
|
#else
|
|
30
|
-
#define getTexCoord(texCoord) texCoord
|
|
29
|
+
#define getTexCoord(texCoord) (texCoord)
|
|
31
30
|
#endif
|
|
32
31
|
|
|
32
|
+
in mat4 x3d_ParticleMatrix;
|
|
33
|
+
|
|
33
34
|
vec4
|
|
34
35
|
getVertex (const in vec4 vertex)
|
|
35
36
|
{
|
|
@@ -37,9 +38,7 @@ getVertex (const in vec4 vertex)
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
#else
|
|
40
|
-
|
|
41
|
-
#define
|
|
42
|
-
#define getTexCoord(texCoord) (texCoord)
|
|
43
|
-
|
|
41
|
+
#define getVertex(vertex) (vertex)
|
|
42
|
+
#define getTexCoord(texCoord) (texCoord)
|
|
44
43
|
#endif
|
|
45
44
|
`;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
import Algorithm from "../Algorithm.js";
|
|
49
49
|
|
|
50
|
-
const clamp = Algorithm
|
|
50
|
+
const { clamp, interval, degrees } = Algorithm;
|
|
51
51
|
|
|
52
52
|
const
|
|
53
53
|
_r = Symbol .for ("X_ITE.Color3.r"),
|
|
@@ -157,7 +157,7 @@ Color3 .prototype =
|
|
|
157
157
|
}
|
|
158
158
|
else
|
|
159
159
|
{
|
|
160
|
-
const w =
|
|
160
|
+
const w = degrees (interval (h, 0, Math .PI * 2)) / 60; // sector 0 to 5
|
|
161
161
|
|
|
162
162
|
const i = Math .floor (w);
|
|
163
163
|
const f = w - i; // factorial part of h
|
|
@@ -47,27 +47,26 @@
|
|
|
47
47
|
|
|
48
48
|
function ObjectCache (Type)
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
size: 0,
|
|
50
|
+
return Object .assign ([ ],
|
|
51
|
+
{
|
|
52
|
+
top: 0,
|
|
54
53
|
pop: function ()
|
|
55
54
|
{
|
|
56
|
-
if (this .
|
|
57
|
-
return
|
|
55
|
+
if (this .top !== 0)
|
|
56
|
+
return this [-- this .top];
|
|
58
57
|
|
|
59
58
|
return new Type ();
|
|
60
59
|
},
|
|
61
60
|
push: function (object)
|
|
62
61
|
{
|
|
63
|
-
|
|
62
|
+
this [this .top ++] = object;
|
|
64
63
|
},
|
|
65
64
|
clear: function ()
|
|
66
65
|
{
|
|
67
|
-
|
|
68
|
-
this .
|
|
66
|
+
this .length = 0;
|
|
67
|
+
this .top = 0;
|
|
69
68
|
},
|
|
70
|
-
};
|
|
69
|
+
});
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
export default ObjectCache;
|
|
@@ -86,6 +86,10 @@ const URLs = {
|
|
|
86
86
|
{
|
|
87
87
|
return new URL ("assets/hatching/" + index + ".png", this .getScriptUrl ()) .href;
|
|
88
88
|
},
|
|
89
|
+
getLibUrl: function (file)
|
|
90
|
+
{
|
|
91
|
+
return new URL ("assets/lib/" + file, this .getScriptUrl ()) .href;
|
|
92
|
+
},
|
|
89
93
|
};
|
|
90
94
|
|
|
91
95
|
export default URLs;
|
|
@@ -111,7 +111,7 @@ X3DPickingContext .prototype =
|
|
|
111
111
|
{
|
|
112
112
|
this [_pickingTime] .start ();
|
|
113
113
|
|
|
114
|
-
this .getWorld () .traverse (TraverseType .PICKING
|
|
114
|
+
this .getWorld () .traverse (TraverseType .PICKING);
|
|
115
115
|
|
|
116
116
|
for (const transformSensorNode of this [_transformSensorNodes])
|
|
117
117
|
{
|
|
@@ -220,7 +220,7 @@ X3DPointingDeviceSensorContext .prototype =
|
|
|
220
220
|
this [_pointer] .set (x, y);
|
|
221
221
|
this [_pointingBuffer] .bind ();
|
|
222
222
|
|
|
223
|
-
this .getWorld () .traverse (TraverseType .POINTER
|
|
223
|
+
this .getWorld () .traverse (TraverseType .POINTER);
|
|
224
224
|
|
|
225
225
|
this [_pointingBuffer] .getHit (hit);
|
|
226
226
|
this [_pointingBuffer] .unbind ();
|
|
@@ -871,6 +871,13 @@ Object .defineProperty (X3DBrowser .prototype, "version",
|
|
|
871
871
|
configurable: false
|
|
872
872
|
});
|
|
873
873
|
|
|
874
|
+
Object .defineProperty (X3DBrowser .prototype, "providerUrl",
|
|
875
|
+
{
|
|
876
|
+
get: function () { return this .getProviderUrl (); },
|
|
877
|
+
enumerable: true,
|
|
878
|
+
configurable: false
|
|
879
|
+
});
|
|
880
|
+
|
|
874
881
|
Object .defineProperty (X3DBrowser .prototype, "currentFrameRate",
|
|
875
882
|
{
|
|
876
883
|
get: function () { return this .getCurrentFrameRate (); },
|
|
@@ -276,7 +276,7 @@ X3DBrowserContext .prototype = Object .assign (Object .create (X3DBaseNode .prot
|
|
|
276
276
|
// Camera
|
|
277
277
|
|
|
278
278
|
this [_cameraTime] .start ();
|
|
279
|
-
this [_world] .traverse (TraverseType .CAMERA
|
|
279
|
+
this [_world] .traverse (TraverseType .CAMERA);
|
|
280
280
|
this [_cameraTime] .stop ();
|
|
281
281
|
|
|
282
282
|
// Collision
|
|
@@ -284,7 +284,7 @@ X3DBrowserContext .prototype = Object .assign (Object .create (X3DBaseNode .prot
|
|
|
284
284
|
this [_collisionTime] .start ();
|
|
285
285
|
|
|
286
286
|
if (this .getCollisionCount ())
|
|
287
|
-
this [_world] .traverse (TraverseType .COLLISION
|
|
287
|
+
this [_world] .traverse (TraverseType .COLLISION);
|
|
288
288
|
|
|
289
289
|
this [_collisionTime] .stop ();
|
|
290
290
|
|
|
@@ -304,7 +304,7 @@ X3DBrowserContext .prototype = Object .assign (Object .create (X3DBaseNode .prot
|
|
|
304
304
|
gl .clearColor (0, 0, 0, 0);
|
|
305
305
|
gl .clear (gl .COLOR_BUFFER_BIT);
|
|
306
306
|
|
|
307
|
-
this [_world] .traverse (TraverseType .DISPLAY
|
|
307
|
+
this [_world] .traverse (TraverseType .DISPLAY);
|
|
308
308
|
|
|
309
309
|
this .getFrameBuffer () .blit ();
|
|
310
310
|
|
|
@@ -68,13 +68,12 @@ SquadOrientationInterpolator .prototype = Object .assign (Object .create (X3DInt
|
|
|
68
68
|
{
|
|
69
69
|
constructor: SquadOrientationInterpolator,
|
|
70
70
|
[Symbol .for ("X_ITE.X3DBaseNode.fieldDefinitions")]: new FieldDefinitionArray ([
|
|
71
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata",
|
|
72
|
-
new X3DFieldDefinition (X3DConstants .inputOnly, "set_fraction",
|
|
73
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "closed",
|
|
74
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "key",
|
|
75
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "keyValue",
|
|
76
|
-
new X3DFieldDefinition (X3DConstants .
|
|
77
|
-
new X3DFieldDefinition (X3DConstants .outputOnly, "value_changed", new Fields .SFRotation ()),
|
|
71
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
72
|
+
new X3DFieldDefinition (X3DConstants .inputOnly, "set_fraction", new Fields .SFFloat ()),
|
|
73
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "closed", new Fields .SFBool ()),
|
|
74
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "key", new Fields .MFFloat ()),
|
|
75
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "keyValue", new Fields .MFRotation ()),
|
|
76
|
+
new X3DFieldDefinition (X3DConstants .outputOnly, "value_changed", new Fields .SFRotation ()),
|
|
78
77
|
]),
|
|
79
78
|
getTypeName: function ()
|
|
80
79
|
{
|
|
@@ -258,10 +258,8 @@ X3DLayerNode .prototype = Object .assign (Object .create (X3DNode .prototype),
|
|
|
258
258
|
if (viewpointNode ._viewAll .getValue ())
|
|
259
259
|
viewpointNode .viewAll (this .getBBox (new Box3 ()));
|
|
260
260
|
},
|
|
261
|
-
traverse: function (type, renderObject)
|
|
261
|
+
traverse: function (type, renderObject = this)
|
|
262
262
|
{
|
|
263
|
-
renderObject = renderObject || this;
|
|
264
|
-
|
|
265
263
|
const viewpointNode = this .getViewpoint ();
|
|
266
264
|
|
|
267
265
|
this .getProjectionMatrix () .pushMatrix (viewpointNode .getProjectionMatrix (this));
|
|
@@ -47,15 +47,14 @@
|
|
|
47
47
|
|
|
48
48
|
import X3DParser from "./X3DParser.js";
|
|
49
49
|
import X3DOptimizer from "./X3DOptimizer.js";
|
|
50
|
+
import URLs from "../Browser/Networking/URLs.js";
|
|
50
51
|
import Vector2 from "../../standard/Math/Numbers/Vector2.js";
|
|
51
52
|
import Vector3 from "../../standard/Math/Numbers/Vector3.js";
|
|
52
53
|
import Quaternion from "../../standard/Math/Numbers/Quaternion.js";
|
|
53
54
|
import Rotation4 from "../../standard/Math/Numbers/Rotation4.js";
|
|
54
|
-
import Matrix3 from "../../standard/Math/Numbers/Matrix3.js";
|
|
55
55
|
import Matrix4 from "../../standard/Math/Numbers/Matrix4.js";
|
|
56
56
|
import Color3 from "../../standard/Math/Numbers/Color3.js";
|
|
57
57
|
import Color4 from "../../standard/Math/Numbers/Color4.js";
|
|
58
|
-
import Box3 from "../../standard/Math/Geometry/Box3.js";
|
|
59
58
|
import Algorithm from "../../standard/Math/Algorithm.js";
|
|
60
59
|
import DEBUG from "../DEBUG.js"
|
|
61
60
|
|
|
@@ -79,7 +78,7 @@ function GLTF2Parser (scene)
|
|
|
79
78
|
|
|
80
79
|
// Globals
|
|
81
80
|
|
|
82
|
-
this .
|
|
81
|
+
this .extensions = new Set ();
|
|
83
82
|
this .lights = [ ];
|
|
84
83
|
this .usedLights = 0;
|
|
85
84
|
this .buffers = [ ];
|
|
@@ -182,13 +181,17 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
182
181
|
|
|
183
182
|
// Parse root objects.
|
|
184
183
|
|
|
185
|
-
this .assetObject
|
|
186
|
-
this .
|
|
187
|
-
this .
|
|
184
|
+
this .assetObject (glTF .asset);
|
|
185
|
+
this .extensionsArray (glTF .extensionsUsed, this .extensions);
|
|
186
|
+
this .extensionsArray (glTF .extensionsRequired, this .extensions);
|
|
187
|
+
this .extensionsObject (glTF .extensions);
|
|
188
188
|
|
|
189
189
|
await this .loadComponents ();
|
|
190
190
|
await this .buffersArray (glTF .buffers);
|
|
191
191
|
|
|
192
|
+
if (this .extensions .has ("KHR_draco_mesh_compression"))
|
|
193
|
+
this .draco = await this .createDraco ();
|
|
194
|
+
|
|
192
195
|
this .bufferViewsArray (glTF .bufferViews);
|
|
193
196
|
this .accessorsArray (glTF .accessors);
|
|
194
197
|
this .samplersArray (glTF .samplers);
|
|
@@ -249,19 +252,19 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
249
252
|
|
|
250
253
|
scene .getRootNodes () .push (worldInfoNode);
|
|
251
254
|
},
|
|
252
|
-
|
|
255
|
+
extensionsArray: function (extensions, set)
|
|
253
256
|
{
|
|
254
|
-
if (!(
|
|
257
|
+
if (!(extensions instanceof Array))
|
|
255
258
|
return;
|
|
256
259
|
|
|
257
260
|
const
|
|
258
261
|
browser = this .getBrowser (),
|
|
259
262
|
scene = this .getExecutionContext ();
|
|
260
263
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
for (const extension of extensionsUsed)
|
|
264
|
+
for (const extension of extensions)
|
|
264
265
|
{
|
|
266
|
+
set .add (extension);
|
|
267
|
+
|
|
265
268
|
switch (extension)
|
|
266
269
|
{
|
|
267
270
|
case "KHR_texture_transform":
|
|
@@ -312,8 +315,10 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
312
315
|
scene = this .getExecutionContext (),
|
|
313
316
|
name = this .sanitizeName (light .name);
|
|
314
317
|
|
|
315
|
-
|
|
316
|
-
|
|
318
|
+
const color = new Color3 (1, 1, 1);
|
|
319
|
+
|
|
320
|
+
if (this .vectorValue (light .color, color))
|
|
321
|
+
lightNode ._color = color;
|
|
317
322
|
|
|
318
323
|
lightNode ._intensity = this .numberValue (light .intensity, 1);
|
|
319
324
|
|
|
@@ -375,20 +380,21 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
375
380
|
|
|
376
381
|
this .buffers = await Promise .all (buffers .map ((buffer, i) => this .bufferObject (buffer, i)));
|
|
377
382
|
},
|
|
378
|
-
bufferObject: function (buffer, i)
|
|
383
|
+
bufferObject: async function (buffer, i)
|
|
379
384
|
{
|
|
380
385
|
if (!(buffer instanceof Object))
|
|
381
386
|
return;
|
|
382
387
|
|
|
383
388
|
if (!buffer .uri)
|
|
384
|
-
return
|
|
389
|
+
return this .buffers [i];
|
|
385
390
|
|
|
386
|
-
const
|
|
391
|
+
const
|
|
392
|
+
url = new URL (buffer .uri, this .getExecutionContext () .getWorldURL ()),
|
|
393
|
+
response = await fetch (url),
|
|
394
|
+
blob = await response .blob (),
|
|
395
|
+
arrayBuffer = await blob .arrayBuffer ();
|
|
387
396
|
|
|
388
|
-
return
|
|
389
|
-
.then (response => response .blob ())
|
|
390
|
-
.then (blob => blob .arrayBuffer ())
|
|
391
|
-
.then (arrayBuffer => $.ungzip (arrayBuffer));
|
|
397
|
+
return $.ungzip (arrayBuffer);
|
|
392
398
|
},
|
|
393
399
|
bufferViewsArray: function (bufferViews)
|
|
394
400
|
{
|
|
@@ -459,7 +465,7 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
459
465
|
{
|
|
460
466
|
const
|
|
461
467
|
TypedArray = TypedArrays .get (accessor .componentType),
|
|
462
|
-
bufferView = this .bufferViews [accessor .bufferView],
|
|
468
|
+
bufferView = this .bufferViews [accessor .bufferView || 0],
|
|
463
469
|
byteOffset = accessor .byteOffset || 0,
|
|
464
470
|
byteStride = bufferView .byteStride || 0,
|
|
465
471
|
components = Components .get (accessor .type),
|
|
@@ -921,14 +927,14 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
921
927
|
if (!(KHR_materials_emissive_strength instanceof Object))
|
|
922
928
|
return;
|
|
923
929
|
|
|
924
|
-
materialNode ._emissiveStrength = this .numberValue(
|
|
930
|
+
materialNode ._emissiveStrength = this .numberValue (KHR_materials_emissive_strength .emissiveStrength, 1);
|
|
925
931
|
},
|
|
926
932
|
textureTransformObject: function (KHR_texture_transform, mapping)
|
|
927
933
|
{
|
|
928
934
|
if (!(KHR_texture_transform instanceof Object))
|
|
929
935
|
return;
|
|
930
936
|
|
|
931
|
-
if (!this .
|
|
937
|
+
if (!this .extensions .has ("KHR_texture_transform"))
|
|
932
938
|
return;
|
|
933
939
|
|
|
934
940
|
const
|
|
@@ -1009,6 +1015,8 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
1009
1015
|
primitive .indices = this .accessors [primitive .indices];
|
|
1010
1016
|
primitive .material = this .materials [primitive .material];
|
|
1011
1017
|
|
|
1018
|
+
this .primitiveExtensionsObject (primitive .extensions, primitive)
|
|
1019
|
+
|
|
1012
1020
|
shapeNodes .push (this .createShape (primitive));
|
|
1013
1021
|
},
|
|
1014
1022
|
attributesObject: function (attributes)
|
|
@@ -1016,32 +1024,176 @@ GLTF2Parser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
1016
1024
|
if (!(attributes instanceof Object))
|
|
1017
1025
|
return;
|
|
1018
1026
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
attributes .POSITION = this .accessors [attributes .POSITION];
|
|
1027
|
+
for (const key in attributes)
|
|
1028
|
+
attributes [key] = this .accessors [attributes [key]];
|
|
1022
1029
|
|
|
1023
1030
|
attributes .TEXCOORD = [ ];
|
|
1024
1031
|
attributes .COLOR = [ ];
|
|
1025
1032
|
attributes .JOINTS = [ ];
|
|
1026
1033
|
attributes .WEIGHTS = [ ];
|
|
1027
1034
|
|
|
1028
|
-
for (let i = 0;
|
|
1029
|
-
attributes .TEXCOORD .push (
|
|
1035
|
+
for (let i = 0; attributes ["TEXCOORD_" + i]; ++ i)
|
|
1036
|
+
attributes .TEXCOORD .push (attributes ["TEXCOORD_" + i]);
|
|
1030
1037
|
|
|
1031
|
-
for (let i = 0;
|
|
1032
|
-
attributes .COLOR .push (
|
|
1038
|
+
for (let i = 0; attributes ["COLOR_" + i]; ++ i)
|
|
1039
|
+
attributes .COLOR .push (attributes ["COLOR_" + i]);
|
|
1033
1040
|
|
|
1034
|
-
for (let i = 0;
|
|
1035
|
-
attributes .JOINTS .push (
|
|
1041
|
+
for (let i = 0; attributes ["JOINTS_" + i]; ++ i)
|
|
1042
|
+
attributes .JOINTS .push (attributes ["JOINTS_" + i]);
|
|
1036
1043
|
|
|
1037
|
-
for (let i = 0;
|
|
1038
|
-
attributes .WEIGHTS .push (
|
|
1044
|
+
for (let i = 0; attributes ["WEIGHTS_" + i]; ++ i)
|
|
1045
|
+
attributes .WEIGHTS .push (attributes ["WEIGHTS_" + i]);
|
|
1039
1046
|
},
|
|
1040
1047
|
targetsArray: function (targets)
|
|
1041
1048
|
{
|
|
1042
1049
|
if (!(targets instanceof Array))
|
|
1043
1050
|
return;
|
|
1044
1051
|
},
|
|
1052
|
+
primitiveExtensionsObject: function (extensions, primitive)
|
|
1053
|
+
{
|
|
1054
|
+
if (!(extensions instanceof Object))
|
|
1055
|
+
return;
|
|
1056
|
+
|
|
1057
|
+
for (const [key, value] of Object .entries (extensions))
|
|
1058
|
+
{
|
|
1059
|
+
switch (key)
|
|
1060
|
+
{
|
|
1061
|
+
case "KHR_draco_mesh_compression":
|
|
1062
|
+
return this .khrDracoMeshCompressionObject (value, primitive);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
khrDracoMeshCompressionObject: function (draco, primitive)
|
|
1067
|
+
{
|
|
1068
|
+
if (!(draco instanceof Object))
|
|
1069
|
+
return;
|
|
1070
|
+
|
|
1071
|
+
if (!this .draco)
|
|
1072
|
+
return;
|
|
1073
|
+
|
|
1074
|
+
function indicesCallback (array)
|
|
1075
|
+
{
|
|
1076
|
+
Object .defineProperty (primitive .indices, "array", { value: array });
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
function attributeCallback (key, array)
|
|
1080
|
+
{
|
|
1081
|
+
if (attributes [key])
|
|
1082
|
+
Object .defineProperty (attributes [key], "array", { value: array });
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
const
|
|
1086
|
+
attributes = primitive .attributes,
|
|
1087
|
+
dataView = new Uint8Array (this .bufferViews [draco .bufferView] .buffer);
|
|
1088
|
+
|
|
1089
|
+
this .dracoDecodeMesh (this .draco, dataView, draco .attributes, indicesCallback, attributeCallback);
|
|
1090
|
+
},
|
|
1091
|
+
dracoDecodeMesh: function (draco, dataView, attributes, indicesCallback, attributeCallback)
|
|
1092
|
+
{
|
|
1093
|
+
const
|
|
1094
|
+
buffer = new draco .DecoderBuffer (),
|
|
1095
|
+
decoder = new draco .Decoder ();
|
|
1096
|
+
|
|
1097
|
+
buffer .Init (dataView, dataView .byteLength);
|
|
1098
|
+
|
|
1099
|
+
let geometry, status;
|
|
1100
|
+
|
|
1101
|
+
try
|
|
1102
|
+
{
|
|
1103
|
+
const type = decoder .GetEncodedGeometryType (buffer);
|
|
1104
|
+
|
|
1105
|
+
switch (type)
|
|
1106
|
+
{
|
|
1107
|
+
case draco .TRIANGULAR_MESH:
|
|
1108
|
+
geometry = new draco .Mesh ();
|
|
1109
|
+
status = decoder .DecodeBufferToMesh (buffer, geometry);
|
|
1110
|
+
break;
|
|
1111
|
+
case draco .POINT_CLOUD:
|
|
1112
|
+
geometry = new draco .PointCloud ();
|
|
1113
|
+
status = decoder .DecodeBufferToPointCloud (buffer, geometry);
|
|
1114
|
+
break;
|
|
1115
|
+
default:
|
|
1116
|
+
throw new Error (`Invalid geometry type ${type}.`);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
if (!status .ok () || !geometry .ptr)
|
|
1120
|
+
throw new Error (status .error_msg ());
|
|
1121
|
+
|
|
1122
|
+
if (type === draco .TRIANGULAR_MESH)
|
|
1123
|
+
{
|
|
1124
|
+
const
|
|
1125
|
+
numFaces = geometry .num_faces (),
|
|
1126
|
+
numIndices = numFaces * 3,
|
|
1127
|
+
byteLength = numIndices * 4,
|
|
1128
|
+
ptr = draco ._malloc (byteLength);
|
|
1129
|
+
|
|
1130
|
+
try
|
|
1131
|
+
{
|
|
1132
|
+
const indices = new Uint32Array (numIndices);
|
|
1133
|
+
|
|
1134
|
+
decoder .GetTrianglesUInt32Array (geometry, byteLength, ptr);
|
|
1135
|
+
|
|
1136
|
+
indices .set (new Uint32Array (draco .HEAPF32 .buffer, ptr, numIndices));
|
|
1137
|
+
|
|
1138
|
+
indicesCallback (indices);
|
|
1139
|
+
}
|
|
1140
|
+
finally
|
|
1141
|
+
{
|
|
1142
|
+
draco ._free (ptr);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
for (const [key, id] of Object .entries (attributes))
|
|
1147
|
+
{
|
|
1148
|
+
const
|
|
1149
|
+
attribute = decoder .GetAttributeByUniqueId (geometry, id),
|
|
1150
|
+
numComponents = attribute .num_components (),
|
|
1151
|
+
numPoints = geometry .num_points (),
|
|
1152
|
+
numValues = numPoints * numComponents,
|
|
1153
|
+
byteLength = numValues * Float32Array .BYTES_PER_ELEMENT,
|
|
1154
|
+
ptr = draco ._malloc (byteLength);
|
|
1155
|
+
|
|
1156
|
+
try
|
|
1157
|
+
{
|
|
1158
|
+
const array = new Float32Array (numValues);
|
|
1159
|
+
|
|
1160
|
+
decoder .GetAttributeDataArrayForAllPoints (geometry, attribute, draco .DT_FLOAT32, byteLength, ptr);
|
|
1161
|
+
|
|
1162
|
+
array .set (new Float32Array (draco .HEAPF32 .buffer, ptr, numValues));
|
|
1163
|
+
|
|
1164
|
+
attributeCallback (key, array);
|
|
1165
|
+
}
|
|
1166
|
+
finally
|
|
1167
|
+
{
|
|
1168
|
+
draco ._free (ptr);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
finally
|
|
1173
|
+
{
|
|
1174
|
+
if (geometry)
|
|
1175
|
+
draco .destroy (geometry);
|
|
1176
|
+
|
|
1177
|
+
draco .destroy (decoder);
|
|
1178
|
+
draco .destroy (buffer);
|
|
1179
|
+
}
|
|
1180
|
+
},
|
|
1181
|
+
createDraco: async function ()
|
|
1182
|
+
{
|
|
1183
|
+
if (this .constructor .draco)
|
|
1184
|
+
{
|
|
1185
|
+
return this .constructor .draco;
|
|
1186
|
+
}
|
|
1187
|
+
else
|
|
1188
|
+
{
|
|
1189
|
+
const
|
|
1190
|
+
response = await fetch (URLs .getLibUrl ("draco_decoder_gltf.js")),
|
|
1191
|
+
text = await response .text (),
|
|
1192
|
+
draco = await new Function (text) () ();
|
|
1193
|
+
|
|
1194
|
+
return this .constructor .draco = draco;
|
|
1195
|
+
}
|
|
1196
|
+
},
|
|
1045
1197
|
camerasArray: function (cameras)
|
|
1046
1198
|
{
|
|
1047
1199
|
if (!(cameras instanceof Array))
|
|
@@ -275,15 +275,12 @@ OBJParser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
275
275
|
try
|
|
276
276
|
{
|
|
277
277
|
const
|
|
278
|
-
scene
|
|
279
|
-
url
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
.catch (Function .prototype);
|
|
285
|
-
|
|
286
|
-
const parser = new MaterialParser (scene, input);
|
|
278
|
+
scene = this .getExecutionContext (),
|
|
279
|
+
url = new URL (path, scene .getWorldURL ()),
|
|
280
|
+
response = await fetch (url),
|
|
281
|
+
arrayBuffer = await response .arrayBuffer (),
|
|
282
|
+
input = $.decodeText ($.ungzip (arrayBuffer)),
|
|
283
|
+
parser = new MaterialParser (scene, input);
|
|
287
284
|
|
|
288
285
|
parser .parse ();
|
|
289
286
|
|
|
@@ -950,7 +950,7 @@ SVGParser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
950
950
|
shapeNode .geometry = geometryNode;
|
|
951
951
|
geometryNode .solid = this .solid;
|
|
952
952
|
geometryNode .index = this .triangulatePolygon (contours, coordinateNode);
|
|
953
|
-
geometryNode .texCoord = this .createTextureCoordinate (coordinateNode, bbox);
|
|
953
|
+
geometryNode .texCoord = this .createTextureCoordinate (coordinateNode, bbox, shapeNode .appearance);
|
|
954
954
|
geometryNode .coord = coordinateNode;
|
|
955
955
|
}
|
|
956
956
|
}
|
|
@@ -2678,8 +2678,11 @@ SVGParser .prototype = Object .assign (Object .create (X3DParser .prototype),
|
|
|
2678
2678
|
|
|
2679
2679
|
return texturePropertiesNode;
|
|
2680
2680
|
},
|
|
2681
|
-
createTextureCoordinate: function (coordinateNode, bbox)
|
|
2681
|
+
createTextureCoordinate: function (coordinateNode, bbox, appearance)
|
|
2682
2682
|
{
|
|
2683
|
+
if (!appearance || !appearance .texture)
|
|
2684
|
+
return null;
|
|
2685
|
+
|
|
2683
2686
|
const
|
|
2684
2687
|
scene = this .getExecutionContext (),
|
|
2685
2688
|
texCoordNode = scene .createNode ("TextureCoordinate"),
|
|
@@ -61,8 +61,6 @@ import StopWatch from "../../standard/Time/StopWatch.js";
|
|
|
61
61
|
|
|
62
62
|
const DEPTH_BUFFER_SIZE = 16;
|
|
63
63
|
|
|
64
|
-
function compareDistance (lhs, rhs) { return lhs .distance < rhs .distance; }
|
|
65
|
-
|
|
66
64
|
function X3DRenderObject (executionContext)
|
|
67
65
|
{
|
|
68
66
|
this .viewVolumes = [ ];
|
|
@@ -98,7 +96,7 @@ function X3DRenderObject (executionContext)
|
|
|
98
96
|
this .shadowShapes = [ ];
|
|
99
97
|
this .opaqueShapes = [ ];
|
|
100
98
|
this .transparentShapes = [ ];
|
|
101
|
-
this .transparencySorter = new MergeSort (this .transparentShapes,
|
|
99
|
+
this .transparencySorter = new MergeSort (this .transparentShapes, (a, b) => a .distance < b .distance);
|
|
102
100
|
this .speed = 0;
|
|
103
101
|
|
|
104
102
|
try
|
|
@@ -636,6 +634,8 @@ X3DRenderObject .prototype =
|
|
|
636
634
|
this .transparentShapes .push (this .createRenderContext (true));
|
|
637
635
|
|
|
638
636
|
var renderContext = this .transparentShapes [num];
|
|
637
|
+
|
|
638
|
+
renderContext .distance = bboxCenter .z;
|
|
639
639
|
}
|
|
640
640
|
else
|
|
641
641
|
{
|
|
@@ -653,7 +653,6 @@ X3DRenderObject .prototype =
|
|
|
653
653
|
renderContext .fogNode = this .localFogs .at (-1);
|
|
654
654
|
renderContext .shapeNode = shapeNode;
|
|
655
655
|
renderContext .appearanceNode = shapeNode .getAppearance ();
|
|
656
|
-
renderContext .distance = bboxCenter .z;
|
|
657
656
|
|
|
658
657
|
// Clip planes and local lights
|
|
659
658
|
|