x_ite 8.7.4 → 8.7.5

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.
Files changed (92) hide show
  1. package/.vscode/tasks.json +1 -1
  2. package/dist/assets/components/Annotation.js +13 -13
  3. package/dist/assets/components/Annotation.min.js +1 -1
  4. package/dist/assets/components/CADGeometry.js +13 -13
  5. package/dist/assets/components/CADGeometry.min.js +1 -1
  6. package/dist/assets/components/CubeMapTexturing.js +25 -25
  7. package/dist/assets/components/CubeMapTexturing.min.js +1 -1
  8. package/dist/assets/components/DIS.js +13 -13
  9. package/dist/assets/components/DIS.min.js +1 -1
  10. package/dist/assets/components/EventUtilities.js +9 -9
  11. package/dist/assets/components/EventUtilities.min.js +1 -1
  12. package/dist/assets/components/Geometry2D.js +19 -19
  13. package/dist/assets/components/Geometry2D.min.js +1 -1
  14. package/dist/assets/components/Geospatial.js +33 -33
  15. package/dist/assets/components/Geospatial.min.js +1 -1
  16. package/dist/assets/components/HAnim.js +18 -18
  17. package/dist/assets/components/HAnim.min.js +1 -1
  18. package/dist/assets/components/KeyDeviceSensor.js +8 -8
  19. package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
  20. package/dist/assets/components/Layout.js +36 -31
  21. package/dist/assets/components/Layout.min.js +1 -1
  22. package/dist/assets/components/NURBS.js +24 -24
  23. package/dist/assets/components/NURBS.min.js +1 -1
  24. package/dist/assets/components/ParticleSystems.js +22 -22
  25. package/dist/assets/components/ParticleSystems.min.js +1 -1
  26. package/dist/assets/components/Picking.js +18 -18
  27. package/dist/assets/components/Picking.min.js +1 -1
  28. package/dist/assets/components/RigidBodyPhysics.js +18 -18
  29. package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
  30. package/dist/assets/components/Scripting.js +28 -28
  31. package/dist/assets/components/Scripting.min.js +1 -1
  32. package/dist/assets/components/Text.js +24 -24
  33. package/dist/assets/components/Text.min.js +1 -1
  34. package/dist/assets/components/TextureProjector.js +14 -14
  35. package/dist/assets/components/TextureProjector.min.js +1 -1
  36. package/dist/assets/components/Texturing3D.js +30 -30
  37. package/dist/assets/components/Texturing3D.min.js +1 -1
  38. package/dist/assets/components/VolumeRendering.js +19 -19
  39. package/dist/assets/components/VolumeRendering.min.js +1 -1
  40. package/dist/assets/components/X_ITE.js +9 -9
  41. package/dist/assets/components/X_ITE.min.js +1 -1
  42. package/dist/x_ite.css +1 -1
  43. package/dist/x_ite.js +903 -1163
  44. package/dist/x_ite.min.js +1 -1
  45. package/dist/x_ite.zip +0 -0
  46. package/docs/_config.yml +1 -1
  47. package/docs/_posts/reference/field-services-and-objects.md +26 -6
  48. package/package.json +1 -1
  49. package/src/standard/Math/Algorithms/eigen_decomposition.js +9 -9
  50. package/src/standard/Math/Geometry/Box2.js +20 -20
  51. package/src/standard/Math/Geometry/Box3.js +20 -20
  52. package/src/standard/Math/Numbers/Color3.js +10 -18
  53. package/src/standard/Math/Numbers/Color4.js +12 -23
  54. package/src/standard/Math/Numbers/Complex.js +59 -54
  55. package/src/standard/Math/Numbers/Matrix2.js +31 -45
  56. package/src/standard/Math/Numbers/Matrix3.js +59 -94
  57. package/src/standard/Math/Numbers/Matrix4.js +73 -114
  58. package/src/standard/Math/Numbers/Quaternion.js +49 -65
  59. package/src/standard/Math/Numbers/Rotation4.js +15 -13
  60. package/src/standard/Math/Numbers/Vector2.js +12 -14
  61. package/src/standard/Math/Numbers/Vector3.js +17 -22
  62. package/src/standard/Math/Numbers/Vector4.js +22 -30
  63. package/src/x_ite/Base/X3DInfoArray.js +9 -7
  64. package/src/x_ite/Browser/Core/X3DCoreContext.js +3 -3
  65. package/src/x_ite/Browser/Layout/ScreenText.js +9 -4
  66. package/src/x_ite/Browser/VERSION.js +1 -1
  67. package/src/x_ite/Browser/X3DBrowser.js +57 -64
  68. package/src/x_ite/Browser/X3DBrowserContext.js +8 -8
  69. package/src/x_ite/Components/Layering/X3DLayerNode.js +1 -1
  70. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +2 -3
  71. package/src/x_ite/Execution/X3DExecutionContext.js +52 -58
  72. package/src/x_ite/Execution/X3DExportedNode.js +13 -11
  73. package/src/x_ite/Execution/X3DImportedNode.js +25 -25
  74. package/src/x_ite/Execution/X3DScene.js +129 -53
  75. package/src/x_ite/Fields/SFColor.js +10 -15
  76. package/src/x_ite/Fields/SFColorRGBA.js +11 -18
  77. package/src/x_ite/Fields/SFImage.js +38 -33
  78. package/src/x_ite/Fields/SFMatrix3.js +1 -3
  79. package/src/x_ite/Fields/SFMatrix4.js +1 -5
  80. package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +6 -5
  81. package/src/x_ite/Fields/SFRotation.js +14 -21
  82. package/src/x_ite/Fields/SFString.js +0 -1
  83. package/src/x_ite/Fields/SFVec2.js +8 -15
  84. package/src/x_ite/Fields/SFVec3.js +10 -17
  85. package/src/x_ite/Fields/SFVec4.js +12 -23
  86. package/src/x_ite/Fields/SFVecPrototypeTemplate.js +15 -14
  87. package/src/x_ite/Parser/SVGParser.js +2 -2
  88. package/src/x_ite/Parser/X3DOptimizer.js +1 -1
  89. package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +26 -27
  90. package/src/x_ite/Prototype/X3DProtoDeclaration.js +16 -15
  91. package/src/x_ite/Routing/X3DRoute.js +26 -25
  92. package/src/x_ite/Execution/Scene.js +0 -145
@@ -61,6 +61,7 @@ import SFNodeCache from "../Fields/SFNodeCache.js";
61
61
  SupportedNodes .addAbstractType ("X3DScene", X3DScene);
62
62
 
63
63
  const
64
+ _browser = Symbol .for ("X_ITE.X3DEventObject.browser"),
64
65
  _specificationVersion = Symbol (),
65
66
  _encoding = Symbol (),
66
67
  _profile = Symbol (),
@@ -68,13 +69,16 @@ const
68
69
  _worldURL = Symbol (),
69
70
  _units = Symbol (),
70
71
  _metadata = Symbol (),
71
- _exportedNodes = Symbol ();
72
+ _exportedNodes = Symbol (),
73
+ _loadingObjects = Symbol ();
72
74
 
73
- const LATEST_VERSION = "4.0";
75
+ const X3D_LATEST_VERSION = "4.0";
74
76
 
75
- function X3DScene (executionContext)
77
+ function X3DScene (browser)
76
78
  {
77
- X3DExecutionContext .call (this, executionContext);
79
+ this [_browser] = browser;
80
+
81
+ X3DExecutionContext .call (this, this);
78
82
 
79
83
  this .addType (X3DConstants .X3DScene)
80
84
 
@@ -82,9 +86,11 @@ function X3DScene (executionContext)
82
86
  "components_changed", new Fields .SFTime (),
83
87
  "units_changed", new Fields .SFTime (),
84
88
  "metadata_changed", new Fields .SFTime (),
85
- "exportedNodes_changed", new Fields .SFTime ())
89
+ "exportedNodes_changed", new Fields .SFTime (),
90
+ "initLoadCount", new Fields .SFInt32 (),
91
+ "loadCount", new Fields .SFInt32 ())
86
92
 
87
- this [_specificationVersion] = LATEST_VERSION;
93
+ this [_specificationVersion] = X3D_LATEST_VERSION;
88
94
  this [_encoding] = "SCRIPTED";
89
95
  this [_profile] = null;
90
96
  this [_components] = new ComponentInfoArray ([ ]);
@@ -96,8 +102,9 @@ function X3DScene (executionContext)
96
102
  this [_units] .add ("length", new UnitInfo ("length", "metre", 1));
97
103
  this [_units] .add ("mass", new UnitInfo ("mass", "kilogram", 1));
98
104
 
99
- this [_metadata] = new Map ();
100
- this [_exportedNodes] = new ExportedNodesArray ();
105
+ this [_metadata] = new Map ();
106
+ this [_exportedNodes] = new ExportedNodesArray ();
107
+ this [_loadingObjects] = new Set ();
101
108
 
102
109
  this .getRootNodes () .setAccessType (X3DConstants .inputOutput);
103
110
 
@@ -255,7 +262,7 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
255
262
  if (!name .length)
256
263
  throw new Error ("Couldn't add metadata: name is empty.");
257
264
 
258
- if (! Array .isArray (values))
265
+ if (!Array .isArray (values))
259
266
  values = [String (values)];
260
267
 
261
268
  if (!values .length)
@@ -398,7 +405,7 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
398
405
  {
399
406
  generator .string += generator .Indent ();
400
407
  generator .string += "#X3D V";
401
- generator .string += LATEST_VERSION;
408
+ generator .string += X3D_LATEST_VERSION;
402
409
  generator .string += generator .Space ();
403
410
  generator .string += "utf8";
404
411
  generator .string += generator .Space ();
@@ -490,9 +497,9 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
490
497
  generator .string += generator .TidyBreak ();
491
498
  generator .string += generator .Indent ();
492
499
  generator .string += "<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D ";
493
- generator .string += LATEST_VERSION;
500
+ generator .string += X3D_LATEST_VERSION;
494
501
  generator .string += "//EN\" \"http://www.web3d.org/specifications/x3d-";
495
- generator .string += LATEST_VERSION;
502
+ generator .string += X3D_LATEST_VERSION;
496
503
  generator .string += ".dtd\">";
497
504
  generator .string += generator .TidyBreak ();
498
505
  }
@@ -505,13 +512,13 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
505
512
  generator .string += "'";
506
513
  generator .string += generator .Space ();
507
514
  generator .string += "version='";
508
- generator .string += LATEST_VERSION;
515
+ generator .string += X3D_LATEST_VERSION;
509
516
  generator .string += "'";
510
517
  generator .string += generator .Space ();
511
518
  generator .string += "xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'";
512
519
  generator .string += generator .Space ();
513
520
  generator .string += "xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-";
514
- generator .string += LATEST_VERSION;
521
+ generator .string += X3D_LATEST_VERSION;
515
522
  generator .string += ".xsd'>";
516
523
  generator .string += generator .TidyBreak ();
517
524
 
@@ -671,7 +678,7 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
671
678
  generator .string += ':';
672
679
  generator .string += generator .TidySpace ();
673
680
  generator .string += '"';
674
- generator .string += LATEST_VERSION;
681
+ generator .string += X3D_LATEST_VERSION;
675
682
  generator .string += '"';
676
683
  generator .string += ',';
677
684
  generator .string += generator .TidyBreak ();
@@ -687,7 +694,7 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
687
694
  generator .string += generator .TidySpace ();
688
695
  generator .string += '"';
689
696
  generator .string += "http://www.web3d.org/specifications/x3d-";
690
- generator .string += LATEST_VERSION;
697
+ generator .string += X3D_LATEST_VERSION;
691
698
  generator .string += ".xsd";
692
699
  generator .string += '"';
693
700
  generator .string += ',';
@@ -704,7 +711,7 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
704
711
  generator .string += generator .TidySpace ();
705
712
  generator .string += '"';
706
713
  generator .string += "http://www.web3d.org/specifications/x3d-";
707
- generator .string += LATEST_VERSION;
714
+ generator .string += X3D_LATEST_VERSION;
708
715
  generator .string += "-JSONSchema.json";
709
716
  generator .string += '"';
710
717
  generator .string += ',';
@@ -958,52 +965,121 @@ X3DScene .prototype = Object .assign (Object .create (X3DExecutionContext .proto
958
965
  generator .string += generator .Indent ();
959
966
  generator .string += '}';
960
967
  },
961
- });
968
+ },
969
+ {
970
+ setExecutionContext: function (value)
971
+ {
972
+ if (!this .isMainScene ())
973
+ {
974
+ const scene = this .getScene ();
962
975
 
963
- for (const key of Reflect .ownKeys (X3DScene .prototype))
964
- Object .defineProperty (X3DScene .prototype, key, { enumerable: false });
976
+ for (const object of this [_loadingObjects])
977
+ scene .removeLoadingObject (object);
978
+ }
965
979
 
966
- Object .defineProperty (X3DScene .prototype, "specificationVersion",
967
- {
968
- get: X3DScene .prototype .getSpecificationVersion,
969
- enumerable: true,
970
- });
980
+ X3DExecutionContext .prototype .setExecutionContext .call (this, value);
971
981
 
972
- Object .defineProperty (X3DScene .prototype, "encoding",
973
- {
974
- get: X3DScene .prototype .getEncoding,
975
- enumerable: true,
976
- });
982
+ if (!this .isMainScene ())
983
+ {
984
+ const scene = this .getScene ();
977
985
 
978
- Object .defineProperty (X3DScene .prototype, "profile",
979
- {
980
- get: X3DScene .prototype .getProfile,
981
- enumerable: true,
982
- });
986
+ for (const object of this [_loadingObjects])
987
+ scene .addLoadingObject (object);
988
+ }
989
+ },
990
+ addInitLoadCount: function (node)
991
+ {
992
+ this ._initLoadCount = this ._initLoadCount .getValue () + 1;
993
+ },
994
+ removeInitLoadCount: function (node)
995
+ {
996
+ this ._initLoadCount = this ._initLoadCount .getValue () - 1;
997
+ },
998
+ getLoadingObjects: function ()
999
+ {
1000
+ return this [_loadingObjects];
1001
+ },
1002
+ addLoadingObject: function (node)
1003
+ {
1004
+ if (this [_loadingObjects] .has (node))
1005
+ return;
983
1006
 
984
- Object .defineProperty (X3DScene .prototype, "components",
985
- {
986
- get: X3DScene .prototype .getComponents,
987
- enumerable: true,
988
- });
1007
+ this [_loadingObjects] .add (node);
989
1008
 
990
- Object .defineProperty (X3DScene .prototype, "worldURL",
991
- {
992
- get: X3DScene .prototype .getWorldURL,
993
- enumerable: true,
994
- });
1009
+ this ._loadCount = this [_loadingObjects] .size;
995
1010
 
996
- Object .defineProperty (X3DScene .prototype, "units",
997
- {
998
- get: X3DScene .prototype .getUnits,
999
- enumerable: true,
1011
+ const
1012
+ browser = this .getBrowser (),
1013
+ scene = this .getScene ();
1014
+
1015
+ if (this === browser .getExecutionContext () || this .loader === browser .loader)
1016
+ browser .addLoadingObject (node);
1017
+
1018
+ if (!this .isMainScene ())
1019
+ scene .addLoadingObject (node);
1020
+ },
1021
+ removeLoadingObject: function (node)
1022
+ {
1023
+ if (!this [_loadingObjects] .has (node))
1024
+ return;
1025
+
1026
+ this [_loadingObjects] .delete (node);
1027
+
1028
+ this ._loadCount = this [_loadingObjects] .size;
1029
+
1030
+ const
1031
+ browser = this .getBrowser (),
1032
+ scene = this .getScene ();
1033
+
1034
+ if (this === browser .getExecutionContext () || this .loader === browser .loader)
1035
+ browser .removeLoadingObject (node);
1036
+
1037
+ if (!this .isMainScene ())
1038
+ scene .removeLoadingObject (node);
1039
+ },
1000
1040
  });
1001
1041
 
1002
- Object .defineProperty (X3DScene .prototype, "rootNodes",
1042
+ for (const key of Reflect .ownKeys (X3DScene .prototype))
1043
+ Object .defineProperty (X3DScene .prototype, key, { enumerable: false });
1044
+
1045
+ Object .defineProperties (X3DScene .prototype,
1003
1046
  {
1004
- get: X3DScene .prototype .getRootNodes,
1005
- set: X3DScene .prototype .setRootNodes,
1006
- enumerable: true,
1047
+ specificationVersion:
1048
+ {
1049
+ get: X3DScene .prototype .getSpecificationVersion,
1050
+ enumerable: true,
1051
+ },
1052
+ encoding:
1053
+ {
1054
+ get: X3DScene .prototype .getEncoding,
1055
+ enumerable: true,
1056
+ },
1057
+ profile:
1058
+ {
1059
+ get: X3DScene .prototype .getProfile,
1060
+ enumerable: true,
1061
+ },
1062
+ components:
1063
+ {
1064
+ get: X3DScene .prototype .getComponents,
1065
+ enumerable: true,
1066
+ },
1067
+ worldURL:
1068
+ {
1069
+ get: X3DScene .prototype .getWorldURL,
1070
+ enumerable: true,
1071
+ },
1072
+ units:
1073
+ {
1074
+ get: X3DScene .prototype .getUnits,
1075
+ enumerable: true,
1076
+ },
1077
+ rootNodes:
1078
+ {
1079
+ get: X3DScene .prototype .getRootNodes,
1080
+ set: X3DScene .prototype .setRootNodes,
1081
+ enumerable: true,
1082
+ },
1007
1083
  });
1008
1084
 
1009
1085
  export default X3DScene;
@@ -121,7 +121,7 @@ SFColor .prototype = Object .assign (Object .create (X3DField .prototype),
121
121
  destination .getValue () .getHSV (d),
122
122
  Color3 .lerp (s, d, t, r),
123
123
 
124
- result .setHSV (r [0], r [1], r [2], r [3]);
124
+ result .setHSV (r [0], r [1], r [2]);
125
125
 
126
126
  return result;
127
127
  };
@@ -188,7 +188,6 @@ const r = {
188
188
  this .getValue () .r = +value;
189
189
  this .addEvent ();
190
190
  },
191
- enumerable: true,
192
191
  };
193
192
 
194
193
  const g = {
@@ -201,7 +200,6 @@ const g = {
201
200
  this .getValue () .g = +value;
202
201
  this .addEvent ();
203
202
  },
204
- enumerable: true,
205
203
  };
206
204
 
207
205
  const b = {
@@ -214,19 +212,16 @@ const b = {
214
212
  this .getValue () .b = +value;
215
213
  this .addEvent ();
216
214
  },
217
- enumerable: true,
218
215
  };
219
216
 
220
- Object .defineProperty (SFColor .prototype, "r", r);
221
- Object .defineProperty (SFColor .prototype, "g", g);
222
- Object .defineProperty (SFColor .prototype, "b", b);
223
-
224
- r .enumerable = false;
225
- g .enumerable = false;
226
- b .enumerable = false;
227
-
228
- Object .defineProperty (SFColor .prototype, "0", r);
229
- Object .defineProperty (SFColor .prototype, "1", g);
230
- Object .defineProperty (SFColor .prototype, "2", b);
217
+ Object .defineProperties (SFColor .prototype,
218
+ {
219
+ 0: r,
220
+ 1: g,
221
+ 2: b,
222
+ r: Object .assign ({ enumerable: true }, r),
223
+ g: Object .assign ({ enumerable: true }, g),
224
+ b: Object .assign ({ enumerable: true }, b),
225
+ });
231
226
 
232
227
  export default SFColor;
@@ -141,7 +141,6 @@ const r = {
141
141
  this .getValue () .r = +value;
142
142
  this .addEvent ();
143
143
  },
144
- enumerable: true,
145
144
  };
146
145
 
147
146
  const g = {
@@ -154,7 +153,6 @@ const g = {
154
153
  this .getValue () .g = +value;
155
154
  this .addEvent ();
156
155
  },
157
- enumerable: true,
158
156
  };
159
157
 
160
158
  const b = {
@@ -167,7 +165,6 @@ const b = {
167
165
  this .getValue () .b = +value;
168
166
  this .addEvent ();
169
167
  },
170
- enumerable: true,
171
168
  };
172
169
 
173
170
  const a = {
@@ -180,22 +177,18 @@ const a = {
180
177
  this .getValue () .a = +value;
181
178
  this .addEvent ();
182
179
  },
183
- enumerable: true,
184
180
  };
185
181
 
186
- Object .defineProperty (SFColorRGBA .prototype, "r", r);
187
- Object .defineProperty (SFColorRGBA .prototype, "g", g);
188
- Object .defineProperty (SFColorRGBA .prototype, "b", b);
189
- Object .defineProperty (SFColorRGBA .prototype, "a", a);
190
-
191
- r .enumerable = false;
192
- g .enumerable = false;
193
- b .enumerable = false;
194
- a .enumerable = false;
195
-
196
- Object .defineProperty (SFColorRGBA .prototype, "0", r);
197
- Object .defineProperty (SFColorRGBA .prototype, "1", g);
198
- Object .defineProperty (SFColorRGBA .prototype, "2", b);
199
- Object .defineProperty (SFColorRGBA .prototype, "3", a);
182
+ Object .defineProperties (SFColorRGBA .prototype,
183
+ {
184
+ 0: r,
185
+ 1: g,
186
+ 2: b,
187
+ 3: a,
188
+ r: Object .assign ({ enumerable: true }, r),
189
+ g: Object .assign ({ enumerable: true }, g),
190
+ b: Object .assign ({ enumerable: true }, b),
191
+ a: Object .assign ({ enumerable: true }, a),
192
+ });
200
193
 
201
194
  export default SFColorRGBA;
@@ -48,6 +48,9 @@
48
48
  import X3DField from "../Base/X3DField.js";
49
49
  import ArrayFields from "./ArrayFields.js";
50
50
  import X3DConstants from "../Base/X3DConstants.js";
51
+ import Algorithm from "../../standard/Math/Algorithm.js";
52
+
53
+ const MFInt32 = ArrayFields .MFInt32;
51
54
 
52
55
  /*
53
56
  * Image
@@ -55,11 +58,9 @@ import X3DConstants from "../Base/X3DConstants.js";
55
58
 
56
59
  function Image (width, height, comp, array)
57
60
  {
58
- const MFInt32 = ArrayFields .MFInt32;
59
-
60
- this .width = width|0;
61
- this .height = height|0;
62
- this .comp = comp|0;
61
+ this .width = Math .max (width|0, 0);
62
+ this .height = Math .max (height|0, 0);
63
+ this .comp = Algorithm .clamp (comp|0, 0, 4);
63
64
  this .array = new MFInt32 ();
64
65
  this .array .setValue (array);
65
66
  this .array .length = this .width * this .height;
@@ -95,8 +96,8 @@ Image .prototype =
95
96
  },
96
97
  setWidth: function (value)
97
98
  {
98
- this .width = value|0;
99
- this .array .length = this .width * this .height;
99
+ this .width = Math .max (value|0, 0);
100
+ this .array .length = this .width * this .height;
100
101
  },
101
102
  getWidth: function ()
102
103
  {
@@ -104,8 +105,8 @@ Image .prototype =
104
105
  },
105
106
  setHeight: function (value)
106
107
  {
107
- this .height = value|0;
108
- this .array .length = this .width * this .height;
108
+ this .height = Math .max (value|0, 0);
109
+ this .array .length = this .width * this .height;
109
110
  },
110
111
  getHeight: function ()
111
112
  {
@@ -113,7 +114,7 @@ Image .prototype =
113
114
  },
114
115
  setComp: function (value)
115
116
  {
116
- this .comp = value|0;
117
+ this .comp = Algorithm .clamp (value|0, 0, 4);
117
118
  },
118
119
  getComp: function ()
119
120
  {
@@ -122,7 +123,7 @@ Image .prototype =
122
123
  setArray: function (value)
123
124
  {
124
125
  this .array .setValue (value);
125
- this .array .length = this .width * this .height;
126
+ this .array .length = this .width * this .height;
126
127
  },
127
128
  getArray: function ()
128
129
  {
@@ -138,14 +139,23 @@ const _set_size = Symbol ();
138
139
 
139
140
  function SFImage (width, height, comp, array)
140
141
  {
141
- const MFInt32 = ArrayFields .MFInt32;
142
-
143
- if (arguments [0] instanceof Image)
144
- X3DField .call (this, arguments [0]);
145
- else if (arguments .length === 4)
146
- X3DField .call (this, new Image (width, height, comp, array));
147
- else
148
- X3DField .call (this, new Image (0, 0, 0, new MFInt32 ()));
142
+ switch (arguments .length)
143
+ {
144
+ case 0:
145
+ X3DField .call (this, new Image (0, 0, 0, new MFInt32 ()));
146
+ break;
147
+ case 1:
148
+ X3DField .call (this, arguments [0]);
149
+ break;
150
+ case 3:
151
+ X3DField .call (this, new Image (width, height, comp, new MFInt32 ()));
152
+ break;
153
+ case 4:
154
+ X3DField .call (this, new Image (width, height, comp, array));
155
+ break;
156
+ default:
157
+ throw new Error ("Invalid arguments.");
158
+ }
149
159
 
150
160
  this .getValue () .getArray () .addParent (this);
151
161
  this .addInterest (_set_size, this);
@@ -307,7 +317,6 @@ const width = {
307
317
  this .getValue () .setWidth (value);
308
318
  this .addEvent ();
309
319
  },
310
- enumerable: true,
311
320
  };
312
321
 
313
322
  const height = {
@@ -320,7 +329,6 @@ const height = {
320
329
  this .getValue () .setHeight (value);
321
330
  this .addEvent ();
322
331
  },
323
- enumerable: true,
324
332
  };
325
333
 
326
334
  const comp = {
@@ -333,7 +341,6 @@ const comp = {
333
341
  this .getValue () .setComp (value);
334
342
  this .addEvent ();
335
343
  },
336
- enumerable: true,
337
344
  };
338
345
 
339
346
  const array = {
@@ -346,18 +353,16 @@ const array = {
346
353
  this .getValue () .setArray (value);
347
354
  this .addEvent ();
348
355
  },
349
- enumerable: true,
350
356
  };
351
357
 
352
- Object .defineProperty (SFImage .prototype, "width", width);
353
- Object .defineProperty (SFImage .prototype, "height", height);
354
- Object .defineProperty (SFImage .prototype, "comp", comp);
355
- Object .defineProperty (SFImage .prototype, "array", array);
356
-
357
- width .enumerable = false;
358
- height .enumerable = false;
359
-
360
- Object .defineProperty (SFImage .prototype, "x", width);
361
- Object .defineProperty (SFImage .prototype, "y", height);
358
+ Object .defineProperties (SFImage .prototype,
359
+ {
360
+ x: width,
361
+ y: height,
362
+ width: Object .assign ({ enumerable: true }, width),
363
+ height: Object .assign ({ enumerable: true }, height),
364
+ comp: Object .assign ({ enumerable: true }, comp),
365
+ array: Object .assign ({ enumerable: true }, array),
366
+ });
362
367
 
363
368
  export default SFImage;
@@ -85,10 +85,8 @@ function SFMatrix3Template (TypeName, Type, SFVec2, double)
85
85
  throw new Error ("Invalid arguments.");
86
86
  }
87
87
 
88
- SFMatrix3 .prototype = Object .assign (Object .create (X3DField .prototype),
89
- SFMatrixPrototypeTemplate (TypeName, Type, Matrix3, SFVec2, double),
88
+ SFMatrix3 .prototype = Object .assign (SFMatrixPrototypeTemplate (SFMatrix3, TypeName, Type, Matrix3, SFVec2, double),
90
89
  {
91
- constructor: SFMatrix3,
92
90
  setTransform: function (translation, rotation, scale, scaleOrientation, center)
93
91
  {
94
92
  translation = translation ? translation .getValue () : null;
@@ -89,11 +89,7 @@ function SFMatrix4Template (TypeName, Type, SFVec3, double)
89
89
  throw new Error ("Invalid arguments.");
90
90
  }
91
91
 
92
- SFMatrix4 .prototype = Object .assign (Object .create (X3DField .prototype),
93
- SFMatrixPrototypeTemplate (TypeName, Type, Matrix4, SFVec3, double),
94
- {
95
- constructor: SFMatrix4,
96
- });
92
+ SFMatrix4 .prototype = SFMatrixPrototypeTemplate (SFMatrix4, TypeName, Type, Matrix4, SFVec3, double);
97
93
 
98
94
  for (const key of Reflect .ownKeys (SFMatrix4 .prototype))
99
95
  Object .defineProperty (SFMatrix4 .prototype, key, { enumerable: false });
@@ -47,12 +47,13 @@
47
47
 
48
48
  import X3DField from "../Base/X3DField.js";
49
49
 
50
- function SFMatrixPrototypeTemplate (TypeName, Type, Matrix, SFVec, double)
50
+ function SFMatrixPrototypeTemplate (Constructor, TypeName, Type, Matrix, SFVec, double)
51
51
  {
52
52
  const _formatter = double ? "DoubleFormat" : "FloatFormat";
53
53
 
54
54
  return Object .assign (Object .create (X3DField .prototype),
55
55
  {
56
+ constructor: Constructor,
56
57
  [Symbol .iterator]: function* ()
57
58
  {
58
59
  yield* this .getValue ();
@@ -107,19 +108,19 @@ function SFMatrixPrototypeTemplate (TypeName, Type, Matrix, SFVec, double)
107
108
  },
108
109
  transpose: function ()
109
110
  {
110
- return new (this .constructor) (Matrix .transpose (this .getValue ()));
111
+ return new (this .constructor) (this .getValue () .copy () .transpose ());
111
112
  },
112
113
  inverse: function ()
113
114
  {
114
- return new (this .constructor) (Matrix .inverse (this .getValue ()));
115
+ return new (this .constructor) (this .getValue () .copy () .inverse ());
115
116
  },
116
117
  multLeft: function (matrix)
117
118
  {
118
- return new (this .constructor) (Matrix .multLeft (this .getValue (), matrix .getValue ()));
119
+ return new (this .constructor) (this .getValue () .copy () .multLeft (matrix .getValue ()));
119
120
  },
120
121
  multRight: function (matrix)
121
122
  {
122
- return new (this .constructor) (Matrix .multRight (this .getValue (), matrix .getValue ()));
123
+ return new (this .constructor) (this .getValue () .copy () .multRight (matrix .getValue ()));
123
124
  },
124
125
  multVecMatrix: function (vector)
125
126
  {