x_ite 8.6.8 → 8.6.9

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 (102) 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 +27 -27
  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 +25 -27
  25. package/dist/assets/components/ParticleSystems.min.js +1 -1
  26. package/dist/assets/components/Picking.js +19 -19
  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 +897 -660
  44. package/dist/x_ite.min.js +1 -1
  45. package/dist/x_ite.zip +0 -0
  46. package/docs/_config.yml +2 -2
  47. package/docs/laboratory/gltf-sample-viewer.html +4 -4
  48. package/package.json +1 -1
  49. package/src/assets/shaders/webgl1/Pointing.fs.js +1 -1
  50. package/src/assets/shaders/webgl1/include/Fragment.glsl.js +17 -1
  51. package/src/assets/shaders/webgl1/include/Point.glsl.js +10 -2
  52. package/src/assets/shaders/webgl1/include/Texture.glsl.js +31 -1
  53. package/src/assets/shaders/webgl1/include/Vertex.glsl.js +24 -0
  54. package/src/assets/shaders/webgl2/Pointing.fs.js +1 -1
  55. package/src/assets/shaders/webgl2/include/Fragment.glsl.js +18 -0
  56. package/src/assets/shaders/webgl2/include/Point.glsl.js +12 -4
  57. package/src/assets/shaders/webgl2/include/Texture.glsl.js +17 -20
  58. package/src/assets/shaders/webgl2/include/Vertex.glsl.js +24 -0
  59. package/src/bookmarks.js +1 -1
  60. package/src/tests.js +1 -0
  61. package/src/x_ite/Browser/Core/BrowserOptions.js +3 -0
  62. package/src/x_ite/Browser/Core/BrowserTimings.js +12 -11
  63. package/src/x_ite/Browser/Core/Context.js +64 -64
  64. package/src/x_ite/Browser/Core/ContextMenu.js +0 -9
  65. package/src/x_ite/Browser/Navigation/ExamineViewer.js +1 -1
  66. package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +8 -0
  67. package/src/x_ite/Browser/VERSION.js +1 -1
  68. package/src/x_ite/Browser/X3DBrowser.js +1 -1
  69. package/src/x_ite/Components/Core/X3DBindableNode.js +0 -2
  70. package/src/x_ite/Components/Core/X3DNode.js +3 -8
  71. package/src/x_ite/Components/Layering/X3DLayerNode.js +6 -2
  72. package/src/x_ite/Components/Navigation/NavigationInfo.js +1 -0
  73. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +34 -21
  74. package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +2 -4
  75. package/src/x_ite/Components/Rendering/X3DGeometryNode.js +5 -19
  76. package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +6 -12
  77. package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +4 -8
  78. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +28 -27
  79. package/src/x_ite/Components/Shape/Material.js +4 -0
  80. package/src/x_ite/Components/Shape/PhysicalMaterial.js +4 -0
  81. package/src/x_ite/Components/Shape/TwoSidedMaterial.js +1 -0
  82. package/src/x_ite/Components/Shape/X3DMaterialNode.js +21 -19
  83. package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +4 -0
  84. package/src/x_ite/Components/Texturing/ImageTexture.js +77 -48
  85. package/src/x_ite/Components/Texturing/MultiTexture.js +7 -4
  86. package/src/x_ite/Components/Texturing/MultiTextureCoordinate.js +19 -16
  87. package/src/x_ite/Components/Texturing/MultiTextureTransform.js +16 -32
  88. package/src/x_ite/Components/Texturing/TextureCoordinateGenerator.js +1 -1
  89. package/src/x_ite/Components/Texturing/X3DSingleTextureCoordinateNode.js +2 -8
  90. package/src/x_ite/Components/Texturing/X3DSingleTextureTransformNode.js +2 -8
  91. package/src/x_ite/Execution/NamedNodesHandling.js +84 -0
  92. package/src/x_ite/Execution/X3DExecutionContext.js +7 -37
  93. package/src/x_ite/Execution/X3DScene.js +5 -0
  94. package/src/x_ite/InputOutput/FileLoader.js +1 -1
  95. package/src/x_ite/InputOutput/Generator.js +32 -81
  96. package/src/x_ite/Parser/GLTF2Parser.js +109 -43
  97. package/src/x_ite/Parser/OBJParser.js +42 -30
  98. package/src/x_ite/Parser/STLAParser.js +3 -0
  99. package/src/x_ite/Parser/SVGParser.js +4 -0
  100. package/src/x_ite/Rendering/X3DRenderObject.js +2 -0
  101. package/src/x_ite.html +52 -46
  102. package/x_ite.min.html +52 -46
@@ -110,9 +110,6 @@ X3DProgrammableShaderObject .prototype =
110
110
 
111
111
  browser .getRenderingProperties () ._LogarithmicDepthBuffer .addInterest ("set_logarithmicDepthBuffer__", this);
112
112
 
113
- // Use by multi texture nodes.
114
- this .x3d_MaxTextures = browser .getMaxTextures ();
115
-
116
113
  this .set_logarithmicDepthBuffer__ ();
117
114
  },
118
115
  set_logarithmicDepthBuffer__: function ()
@@ -136,12 +133,14 @@ X3DProgrammableShaderObject .prototype =
136
133
  // Get uniforms and attributes.
137
134
 
138
135
  const
139
- program = this .getProgram (),
140
- browser = this .getBrowser (),
141
- gl = browser .getContext (),
142
- maxClipPlanes = browser .getMaxClipPlanes (),
143
- maxLights = browser .getMaxLights (),
144
- maxTextures = browser .getMaxTextures ();
136
+ program = this .getProgram (),
137
+ browser = this .getBrowser (),
138
+ gl = browser .getContext (),
139
+ maxClipPlanes = browser .getMaxClipPlanes (),
140
+ maxLights = browser .getMaxLights (),
141
+ maxTextures = browser .getMaxTextures (),
142
+ maxTextureTransforms = browser .getMaxTextureTransforms (),
143
+ maxTexCoords = browser .getMaxTexCoords ();
145
144
 
146
145
  gl .useProgram (program);
147
146
 
@@ -242,17 +241,6 @@ X3DProgrammableShaderObject .prototype =
242
241
 
243
242
  for (let i = 0; i < maxTextures; ++ i)
244
243
  {
245
- // Attributes
246
-
247
- const x3d_TexCoord = this .getAttribLocation (gl, program, "x3d_TexCoord" + i, i ? "" : "x3d_TexCoord");
248
-
249
- if (x3d_TexCoord !== -1)
250
- this .x3d_TexCoord .push ([i, x3d_TexCoord]);
251
-
252
- // Uniforms
253
-
254
- this .x3d_TextureMatrix [i] = gl .getUniformLocation (program, "x3d_TextureMatrix[" + i + "]");
255
-
256
244
  this .x3d_TextureCoordinateGeneratorMode [i] = gl .getUniformLocation (program, "x3d_TextureCoordinateGenerator[" + i + "].mode");
257
245
  this .x3d_TextureCoordinateGeneratorParameter [i] = gl .getUniformLocation (program, "x3d_TextureCoordinateGenerator[" + i + "].parameter");
258
246
 
@@ -272,6 +260,22 @@ X3DProgrammableShaderObject .prototype =
272
260
  this .x3d_ProjectiveTextureLocation [i] = gl .getUniformLocation (program, "x3d_ProjectiveTextureLocation[" + i + "]");
273
261
  }
274
262
 
263
+ for (let i = 0; i < maxTextureTransforms; ++ i)
264
+ {
265
+ const uniform = gl .getUniformLocation (program, "x3d_TextureMatrix[" + i + "]");
266
+
267
+ if (uniform !== null)
268
+ this .x3d_TextureMatrix [i] = uniform;
269
+ }
270
+
271
+ for (let i = 0; i < maxTexCoords; ++ i)
272
+ {
273
+ const x3d_TexCoord = this .getAttribLocation (gl, program, "x3d_TexCoord" + i, i ? "" : "x3d_TexCoord");
274
+
275
+ if (x3d_TexCoord !== -1)
276
+ this .x3d_TexCoord .push ([i, x3d_TexCoord]);
277
+ }
278
+
275
279
  this .x3d_TexCoordRamp = gl .getUniformLocation (program, "x3d_TexCoordRamp");
276
280
 
277
281
  this .x3d_Viewport = gl .getUniformLocation (program, "x3d_Viewport");
@@ -355,7 +359,7 @@ X3DProgrammableShaderObject .prototype =
355
359
  for (const uniform of this .x3d_ProjectiveTexture)
356
360
  gl .uniform1i (uniform, browser .getDefaultTexture2DUnit ());
357
361
 
358
- gl .uniform1i (this .x3d_TexCoordRamp, browser .getDefaultTexture2DUnit ());
362
+ gl .uniform1i (this .x3d_TexCoordRamp, browser .getDefaultTexture2DUnit ());
359
363
  },
360
364
  getUniformLocation: function (gl, program, name, depreciated)
361
365
  {
@@ -1041,8 +1045,7 @@ X3DProgrammableShaderObject .prototype =
1041
1045
 
1042
1046
  // Fog
1043
1047
 
1044
- if (fogNode)
1045
- fogNode .setShaderUniforms (gl, this);
1048
+ fogNode?.setShaderUniforms (gl, this);
1046
1049
 
1047
1050
  // Clip planes and local lights
1048
1051
 
@@ -1059,8 +1062,7 @@ X3DProgrammableShaderObject .prototype =
1059
1062
 
1060
1063
  // Style Properties
1061
1064
 
1062
- if (stylePropertiesNode)
1063
- stylePropertiesNode .setShaderUniforms (gl, this);
1065
+ stylePropertiesNode?.setShaderUniforms (gl, this);
1064
1066
 
1065
1067
  // Material
1066
1068
 
@@ -1068,8 +1070,7 @@ X3DProgrammableShaderObject .prototype =
1068
1070
 
1069
1071
  // Texture
1070
1072
 
1071
- if (textureNode)
1072
- textureNode .setShaderUniforms (gl, this, renderObject);
1073
+ textureNode?.setShaderUniforms (gl, this, renderObject);
1073
1074
 
1074
1075
  appearanceNode .getTextureTransform () .setShaderUniforms (gl, this);
1075
1076
  geometryContext .getTextureCoordinate () .setShaderUniforms (gl, this);
@@ -214,6 +214,10 @@ Material .prototype = Object .assign (Object .create (X3DOneSidedMaterialNode .p
214
214
  this .setTransparent (!!(this .getTransparency () ||
215
215
  (this .diffuseTextureNode && this .diffuseTextureNode .isTransparent ())));
216
216
  },
217
+ getBaseTexture: function ()
218
+ {
219
+ return this .diffuseTexture;
220
+ },
217
221
  getTextureIndices: (function ()
218
222
  {
219
223
  let i = 0;
@@ -173,6 +173,10 @@ PhysicalMaterial .prototype = Object .assign (Object .create (X3DOneSidedMateria
173
173
  this .setTransparent (!!(this .getTransparency () ||
174
174
  (this .baseTextureNode && this .baseTextureNode .isTransparent ())));
175
175
  },
176
+ getBaseTexture: function ()
177
+ {
178
+ return this .baseTextureNode;
179
+ },
176
180
  getTextureIndices: (function ()
177
181
  {
178
182
  let i = 0;
@@ -248,6 +248,7 @@ TwoSidedMaterial .prototype = Object .assign (Object .create (X3DMaterialNode .p
248
248
  {
249
249
  this .setTransparent (Boolean (this ._transparency .getValue () || (this ._separateBackColor .getValue () && this ._backTransparency .getValue ())));
250
250
  },
251
+ getBaseTexture: Material .prototype .getBaseTexture,
251
252
  getMaterialKey: Material .prototype .getMaterialKey,
252
253
  createShader: Material .prototype .createShader,
253
254
  setShaderUniforms: function (gl, shaderObject, renderObject, textureTransformMapping, textureCoordinateMapping, front)
@@ -88,6 +88,10 @@ X3DMaterialNode .prototype = Object .assign (Object .create (X3DAppearanceChildN
88
88
  {
89
89
  return this ._transparent .getValue ();
90
90
  },
91
+ getBaseTexture: function ()
92
+ {
93
+ return null;
94
+ },
91
95
  setTexture: function (index, textureNode)
92
96
  {
93
97
  const textureType = textureNode ? textureNode .getTextureType () - 1 : 0;
@@ -212,37 +216,35 @@ X3DMaterialNode .prototype = Object .assign (Object .create (X3DAppearanceChildN
212
216
  options .push ("X3D_STYLE_PROPERTIES");
213
217
 
214
218
  if (+this .textureBits)
215
- {
216
219
  options .push ("X3D_MATERIAL_TEXTURES");
217
- options .push ("X3D_NUM_TEXTURE_TRANSFORMS " + (appearanceNode .getTextureTransformMapping () .size || 1));
218
- options .push ("X3D_NUM_TEXTURE_COORDINATES " + (geometryContext .getTextureCoordinateMapping () .size || 1));
220
+
221
+ if (renderContext .textureNode)
222
+ {
223
+ // ScreenText
224
+
225
+ options .push ("X3D_TEXTURE",
226
+ "X3D_NUM_TEXTURES 1",
227
+ "X3D_NUM_TEXTURE_TRANSFORMS 1",
228
+ "X3D_NUM_TEXTURE_COORDINATES 1",
229
+ "X3D_TEXTURE0_2D");
219
230
  }
220
231
  else
221
232
  {
222
- if (renderContext .textureNode)
223
- {
224
- // ScreenText
225
-
226
- options .push ("X3D_TEXTURE",
227
- "X3D_NUM_TEXTURES 1",
228
- "X3D_NUM_TEXTURE_TRANSFORMS 1",
229
- "X3D_NUM_TEXTURE_COORDINATES 1",
230
- "X3D_TEXTURE0_2D");
231
- }
232
- else if (+appearanceNode .getTextureBits ())
233
+ if (+appearanceNode .getTextureBits () && !this .getBaseTexture ())
233
234
  {
234
235
  const textureNode = appearanceNode .getTexture ();
235
236
 
236
237
  options .push ("X3D_TEXTURE");
237
- options .push ("X3D_NUM_TEXTURES " + textureNode .getCount ());
238
- options .push ("X3D_NUM_TEXTURE_TRANSFORMS " + textureNode .getCount ());
239
- options .push ("X3D_NUM_TEXTURE_COORDINATES " + textureNode .getCount ());
240
-
241
- textureNode .getShaderOptions (options);
238
+ options .push ("X3D_NUM_TEXTURES " + textureNode .getCount ());
242
239
 
243
240
  if (textureNode .getType () .includes (X3DConstants .MultiTexture))
244
241
  options .push ("X3D_MULTI_TEXTURING");
242
+
243
+ textureNode .getShaderOptions (options);
245
244
  }
245
+
246
+ options .push ("X3D_NUM_TEXTURE_TRANSFORMS " + (appearanceNode .getTextureTransformMapping () .size || 1));
247
+ options .push ("X3D_NUM_TEXTURE_COORDINATES " + (geometryContext .textureCoordinateMapping .size || 1));
246
248
  }
247
249
 
248
250
  switch (shapeNode .getShapeKey ())
@@ -115,6 +115,10 @@ X3DOneSidedMaterialNode .prototype = Object .assign (Object .create (X3DMaterial
115
115
  {
116
116
  this .setTransparent (Boolean (this .transparency));
117
117
  },
118
+ getBaseTexture: function ()
119
+ {
120
+ return this .getEmissiveTexture ();
121
+ },
118
122
  getEmissiveTexture: function ()
119
123
  {
120
124
  return this .emissiveTextureNode;
@@ -62,7 +62,6 @@ function ImageTexture (executionContext)
62
62
  this .addType (X3DConstants .ImageTexture);
63
63
 
64
64
  this .image = $("<img></img>");
65
- this .canvas = $("<canvas></canvas>");
66
65
  this .urlStack = new Fields .MFString ();
67
66
  }
68
67
 
@@ -148,7 +147,7 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
148
147
 
149
148
  this .loadNext ();
150
149
  },
151
- setImage: function ()
150
+ setImage: async function ()
152
151
  {
153
152
  if (DEBUG)
154
153
  {
@@ -159,45 +158,21 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
159
158
  try
160
159
  {
161
160
  const
162
- gl = this .getBrowser () .getContext (),
163
- image = this .image [0],
164
- canvas = this .canvas [0],
165
- cx = canvas .getContext ("2d", { willReadFrequently: true });
166
-
167
- let
168
- width = image .width,
169
- height = image .height;
161
+ gl = this .getBrowser () .getContext (),
162
+ image = this .image [0];
170
163
 
171
164
  // https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap
172
165
  // createImageBitmap
173
166
 
174
- // Scale image if needed and flip vertically.
175
-
176
- if (gl .getVersion () >= 2 || (Algorithm .isPowerOfTwo (width) && Algorithm .isPowerOfTwo (height)))
167
+ if (gl .getVersion () === 1 && !(Algorithm .isPowerOfTwo (image .width) && Algorithm .isPowerOfTwo (image .height)))
177
168
  {
178
- // Flip Y
169
+ const
170
+ canvas = document .createElement ("canvas"),
171
+ cx = canvas .getContext ("2d", { willReadFrequently: true }),
172
+ width = Algorithm .nextPowerOfTwo (image .width),
173
+ height = Algorithm .nextPowerOfTwo (image .height);
179
174
 
180
- canvas .width = width;
181
- canvas .height = height;
182
-
183
- cx .clearRect (0, 0, width, height);
184
- cx .save ();
185
-
186
- if (!this ._flipVertically .getValue ())
187
- {
188
- cx .translate (0, height);
189
- cx .scale (1, -1);
190
- }
191
-
192
- cx .drawImage (image, 0, 0);
193
- cx .restore ();
194
- }
195
- else
196
- {
197
- // Flip Y and scale image to next power of two.
198
-
199
- width = Algorithm .nextPowerOfTwo (width);
200
- height = Algorithm .nextPowerOfTwo (height);
175
+ // Flip Y and scale image to next power of two if needed.
201
176
 
202
177
  canvas .width = width;
203
178
  canvas .height = height;
@@ -213,25 +188,31 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
213
188
 
214
189
  cx .drawImage (image, 0, 0, image .width, image .height, 0, 0, width, height);
215
190
  cx .restore ();
216
- }
217
191
 
218
- // Determine image alpha.
192
+ // Determine image alpha.
219
193
 
220
- const data = cx .getImageData (0, 0, width, height) .data;
194
+ const
195
+ data = cx .getImageData (0, 0, width, height, { premultipliedAlpha: false }) .data,
196
+ transparent = this .isImageTransparent (data);
221
197
 
222
- let transparent = false;
198
+ // Upload image to GPU.
223
199
 
224
- for (let i = 3, length = data .length; i < length; i += 4)
225
- {
226
- if (data [i] !== 255)
227
- {
228
- transparent = true;
229
- break;
230
- }
200
+ this .setTexture (width, height, transparent, data, false);
201
+ this .setLoadState (X3DConstants .COMPLETE_STATE);
231
202
  }
203
+ else
204
+ {
205
+ const
206
+ data = await this .getImageData (image),
207
+ transparent = this .isImageTransparent (data),
208
+ width = image .width,
209
+ height = image .height;
210
+
211
+ // Upload image to GPU.
232
212
 
233
- this .setTexture (width, height, transparent, data, false);
234
- this .setLoadState (X3DConstants .COMPLETE_STATE);
213
+ this .setTexture (width, height, transparent, data, !this ._flipVertically .getValue ());
214
+ this .setLoadState (X3DConstants .COMPLETE_STATE);
215
+ }
235
216
  }
236
217
  catch (error)
237
218
  {
@@ -239,6 +220,54 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
239
220
  this .setError ({ type: error .message });
240
221
  }
241
222
  },
223
+ getImageData: async function (image)
224
+ {
225
+ const
226
+ gl = this .getBrowser () .getContext (),
227
+ framebuffer = gl .createFramebuffer (),
228
+ texture = gl .createTexture (),
229
+ data = new Uint8Array (image .width * image .height * 4);
230
+
231
+ gl .bindFramebuffer (gl.FRAMEBUFFER, framebuffer);
232
+ gl .bindTexture (gl.TEXTURE_2D, texture);
233
+ gl .framebufferTexture2D (gl.FRAMEBUFFER, gl .COLOR_ATTACHMENT0, gl .TEXTURE_2D, texture, 0);
234
+ gl .texImage2D (gl .TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
235
+ await gl .readPixelsAsync (0, 0, image .width, image .height, gl.RGBA, gl.UNSIGNED_BYTE, data);
236
+ gl .deleteFramebuffer (framebuffer);
237
+ gl .deleteTexture (texture);
238
+
239
+ return data;
240
+ },
241
+ isImageTransparent: function (data)
242
+ {
243
+ for (let i = 3, length = data .length; i < length; i += 4)
244
+ {
245
+ if (data [i] !== 255)
246
+ return true;
247
+ }
248
+
249
+ return false;
250
+ },
251
+ flipImage (data, width, height, components)
252
+ {
253
+ const
254
+ height1_2 = height >> 1,
255
+ bytesPerRow = width * components,
256
+ tmp = new Uint8Array (bytesPerRow);
257
+
258
+ for (let y = 0; y < height1_2; ++ y)
259
+ {
260
+ const
261
+ top = y * bytesPerRow,
262
+ bottom = (height - y - 1) * bytesPerRow;
263
+
264
+ tmp .set (data .subarray (top, top + bytesPerRow));
265
+ data .copyWithin (top, bottom, bottom + bytesPerRow);
266
+ data .set (tmp, bottom);
267
+ }
268
+
269
+ return data;
270
+ },
242
271
  dispose: function ()
243
272
  {
244
273
  X3DUrlObject .prototype .dispose .call (this);
@@ -63,6 +63,9 @@ function MultiTexture (executionContext)
63
63
 
64
64
  this .addChildObjects ("loadState", new Fields .SFInt32 (X3DConstants .NOT_STARTED_STATE));
65
65
 
66
+ const browser = this .getBrowser ();
67
+
68
+ this .maxTextures = browser .getMaxTextures ()
66
69
  this .color = new Float32Array (4);
67
70
  this .modes = [ ];
68
71
  this .alphaModes = [ ];
@@ -118,7 +121,7 @@ MultiTexture .prototype = Object .assign (Object .create (X3DTextureNode .protot
118
121
  },
119
122
  getCount: function ()
120
123
  {
121
- return Math .min (this .getBrowser () .getMaxTextures (), this .textureNodes .length);
124
+ return Math .min (this .maxTextures, this .textureNodes .length);
122
125
  },
123
126
  getMode: function (index)
124
127
  {
@@ -281,7 +284,7 @@ MultiTexture .prototype = Object .assign (Object .create (X3DTextureNode .protot
281
284
  updateTextureBits: function (textureBits)
282
285
  {
283
286
  const
284
- maxTextures = this .getBrowser () .getMaxTextures (),
287
+ maxTextures = this .maxTextures,
285
288
  textureNodes = this .textureNodes,
286
289
  channels = Math .min (maxTextures, textureNodes .length);
287
290
 
@@ -294,7 +297,7 @@ MultiTexture .prototype = Object .assign (Object .create (X3DTextureNode .protot
294
297
  {
295
298
  const
296
299
  textureNodes = this .textureNodes,
297
- channels = Math .min (this .getBrowser () .getMaxTextures (), textureNodes .length);
300
+ channels = Math .min (this .maxTextures, textureNodes .length);
298
301
 
299
302
  for (let i = 0; i < channels; ++ i)
300
303
  textureNodes [i] .getShaderOptions (options, i);
@@ -308,7 +311,7 @@ MultiTexture .prototype = Object .assign (Object .create (X3DTextureNode .protot
308
311
  {
309
312
  const
310
313
  textureNodes = this .textureNodes,
311
- channels = Math .min (this .getBrowser () .getMaxTextures (), textureNodes .length);
314
+ channels = Math .min (this .maxTextures, textureNodes .length);
312
315
 
313
316
  gl .uniform4fv (shaderObject .x3d_MultiTextureColor, this .color);
314
317
 
@@ -58,6 +58,9 @@ function MultiTextureCoordinate (executionContext)
58
58
 
59
59
  this .addType (X3DConstants .MultiTextureCoordinate);
60
60
 
61
+ const browser = this .getBrowser ();
62
+
63
+ this .maxTexCoords = browser .getMaxTexCoords ();
61
64
  this .textureCoordinateNodes = [ ];
62
65
  }
63
66
 
@@ -110,7 +113,7 @@ MultiTextureCoordinate .prototype = Object .assign (Object .create (X3DTextureCo
110
113
  },
111
114
  getCount: function ()
112
115
  {
113
- return Math .min (this .getBrowser () .getMaxTextures (), this .textureCoordinateNodes .length);
116
+ return Math .min (this .maxTexCoords, this .textureCoordinateNodes .length);
114
117
  },
115
118
  isEmpty: function ()
116
119
  {
@@ -136,21 +139,27 @@ MultiTextureCoordinate .prototype = Object .assign (Object .create (X3DTextureCo
136
139
  },
137
140
  init: function (multiArray)
138
141
  {
139
- for (const textureCoordinateNode of this .textureCoordinateNodes)
140
- textureCoordinateNode .init (multiArray);
142
+ const
143
+ textureCoordinateNodes = this .textureCoordinateNodes,
144
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
145
+
146
+ for (let i = 0; i < length; ++ i)
147
+ textureCoordinateNodes [i] .init (multiArray);
141
148
  },
142
149
  addPoint: function (index, multiArray)
143
150
  {
144
- const textureCoordinateNodes = this .textureCoordinateNodes;
151
+ const
152
+ textureCoordinateNodes = this .textureCoordinateNodes,
153
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
145
154
 
146
- for (let i = 0, length = textureCoordinateNodes .length; i < length; ++ i)
155
+ for (let i = 0; i < length; ++ i)
147
156
  textureCoordinateNodes [i] .addPointToChannel (index, multiArray [i]);
148
157
  },
149
158
  getTextureCoordinateMapping: function (textureCoordinateMapping)
150
159
  {
151
160
  const
152
161
  textureCoordinateNodes = this .textureCoordinateNodes,
153
- length = Math .min (this .getBrowser () .getMaxTextures (), textureCoordinateNodes .length);
162
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
154
163
 
155
164
  for (let i = 0; i < length; ++ i)
156
165
  textureCoordinateNodes [i] .getTextureCoordinateMapping (textureCoordinateMapping, i);
@@ -159,22 +168,16 @@ MultiTextureCoordinate .prototype = Object .assign (Object .create (X3DTextureCo
159
168
  {
160
169
  const
161
170
  textureCoordinateNodes = this .textureCoordinateNodes,
162
- length = Math .min (shaderObject .x3d_MaxTextures, textureCoordinateNodes .length);
163
-
164
- for (let i = 0; i < length; ++ i)
165
- textureCoordinateNodes [i] .setShaderUniformsToChannel (gl, shaderObject, i);
171
+ length = Math .min (this .maxTexCoords, textureCoordinateNodes .length);
166
172
 
167
173
  if (length)
168
174
  {
169
- const last = textureCoordinateNodes .at (-1);
170
-
171
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
172
- last .setShaderUniformsToChannel (gl, shaderObject, i);
175
+ for (let i = 0; i < length; ++ i)
176
+ textureCoordinateNodes [i] .setShaderUniforms (gl, shaderObject, i);
173
177
  }
174
178
  else
175
179
  {
176
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
177
- gl .uniform1i (shaderObject .x3d_TextureCoordinateGeneratorMode [i], 0);
180
+ this .getBrowser () .getDefaultTextureCoordinate () .setShaderUniforms (gl, shaderObject, 0);
178
181
  }
179
182
  },
180
183
  });
@@ -51,7 +51,6 @@ import FieldDefinitionArray from "../../Base/FieldDefinitionArray.js";
51
51
  import X3DTextureTransformNode from "./X3DTextureTransformNode.js";
52
52
  import X3DConstants from "../../Base/X3DConstants.js";
53
53
  import X3DCast from "../../Base/X3DCast.js";
54
- import Matrix4 from "../../../standard/Math/Numbers/Matrix4.js";
55
54
 
56
55
  function MultiTextureTransform (executionContext)
57
56
  {
@@ -59,6 +58,9 @@ function MultiTextureTransform (executionContext)
59
58
 
60
59
  this .addType (X3DConstants .MultiTextureTransform);
61
60
 
61
+ const browser = this .getBrowser ();
62
+
63
+ this .maxTextureTransforms = browser .getMaxTextureTransforms ();
62
64
  this .textureTransformNodes = [ ];
63
65
  }
64
66
 
@@ -102,53 +104,35 @@ MultiTextureTransform .prototype = Object .assign (Object .create (X3DTextureTra
102
104
  if (textureTransformNode)
103
105
  textureTransformNodes .push (textureTransformNode);
104
106
  }
107
+
108
+ if (!textureTransformNodes .length)
109
+ textureTransformNodes .push (this .getBrowser () .getDefaultTextureTransform ());
105
110
  },
106
111
  getCount: function ()
107
112
  {
108
- return Math .min (this .getBrowser () .getMaxTextures (), this .textureTransformNodes .length);
113
+ return Math .min (this .maxTextureTransforms, this .textureTransformNodes .length);
109
114
  },
110
115
  getTextureTransformMapping: function (textureTransformMapping)
111
116
  {
112
117
  const
113
118
  textureTransformNodes = this .textureTransformNodes,
114
- length = Math .min (this .getBrowser () .getMaxTextures (), textureTransformNodes .length);
119
+ length = Math .min (this .maxTextureTransforms, textureTransformNodes .length);
115
120
 
116
121
  for (let i = 0; i < length; ++ i)
117
122
  textureTransformNodes [i] .getTextureTransformMapping (textureTransformMapping, i);
118
123
  },
119
- setShaderUniforms: (function ()
124
+ setShaderUniforms: function (gl, shaderObject)
120
125
  {
121
- const matrixArray = new Float32Array (Matrix4 .Identity);
122
-
123
- return function (gl, shaderObject)
124
- {
125
- const
126
- textureTransformNodes = this .textureTransformNodes,
127
- length = Math .min (shaderObject .x3d_MaxTextures, textureTransformNodes .length);
128
-
129
- for (let i = 0; i < length; ++ i)
130
- textureTransformNodes [i] .setShaderUniformsToChannel (gl, shaderObject, i);
131
-
132
- if (length)
133
- {
134
- const last = textureTransformNodes .at (-1);
126
+ const
127
+ textureTransformNodes = this .textureTransformNodes,
128
+ length = Math .min (this .maxTextureTransforms, textureTransformNodes .length);
135
129
 
136
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
137
- last .setShaderUniformsToChannel (gl, shaderObject, i);
138
- }
139
- else
140
- {
141
- for (let i = length, l = shaderObject .x3d_MaxTextures; i < l; ++ i)
142
- gl .uniformMatrix4fv (shaderObject .x3d_TextureMatrix [i], false, matrixArray);
143
- }
144
- };
145
- })(),
130
+ for (let i = 0; i < length; ++ i)
131
+ textureTransformNodes [i] .setShaderUniforms (gl, shaderObject, i);
132
+ },
146
133
  transformPoint: function (texCoord)
147
134
  {
148
- if (this .textureTransformNodes .length)
149
- return this .textureTransformNodes [0] .transformPoint (texCoord);
150
-
151
- return texCoord;
135
+ return this .textureTransformNodes [0] .transformPoint (texCoord);
152
136
  },
153
137
  });
154
138
 
@@ -138,7 +138,7 @@ TextureCoordinateGenerator .prototype = Object .assign (Object .create (X3DSingl
138
138
  {
139
139
  array .push (0, 0, 0, 1);
140
140
  },
141
- setShaderUniformsToChannel: function (gl, shaderObject, channel = 0)
141
+ setShaderUniforms: function (gl, shaderObject, channel = 0)
142
142
  {
143
143
  gl .uniform1i (shaderObject .x3d_TextureCoordinateGeneratorMode [channel], this .mode);
144
144
  gl .uniform1fv (shaderObject .x3d_TextureCoordinateGeneratorParameter [channel], this .parameter);
@@ -77,15 +77,9 @@ X3DSingleTextureCoordinateNode .prototype = Object .assign (Object .create (X3DT
77
77
  },
78
78
  getTextureCoordinateMapping: function (textureCoordinateMapping, channel = 0)
79
79
  {
80
- if (this ._mapping .getValue ())
81
- textureCoordinateMapping .set (this ._mapping .getValue (), channel);
80
+ textureCoordinateMapping .set (this ._mapping .getValue () || channel, channel);
82
81
  },
83
- setShaderUniforms: function (gl, shaderObject)
84
- {
85
- for (let i = 0, length = shaderObject .x3d_MaxTextures; i < length; ++ i)
86
- this .setShaderUniformsToChannel (gl, shaderObject, i);
87
- },
88
- setShaderUniformsToChannel: function (gl, shaderObject, channel = 0)
82
+ setShaderUniforms: function (gl, shaderObject, channel = 0)
89
83
  {
90
84
  gl .uniform1i (shaderObject .x3d_TextureCoordinateGeneratorMode [channel], 0);
91
85
  },
@@ -71,15 +71,9 @@ X3DSingleTextureTransformNode .prototype = Object .assign (Object .create (X3DTe
71
71
  },
72
72
  getTextureTransformMapping: function (textureTransformMapping, channel = 0)
73
73
  {
74
- if (this ._mapping .getValue ())
75
- textureTransformMapping .set (this ._mapping .getValue (), channel);
74
+ textureTransformMapping .set (this ._mapping .getValue () || channel, channel);
76
75
  },
77
- setShaderUniforms: function (gl, shaderObject)
78
- {
79
- for (let i = 0, length = shaderObject .x3d_MaxTextures; i < length; ++ i)
80
- this .setShaderUniformsToChannel (gl, shaderObject, i);
81
- },
82
- setShaderUniformsToChannel: function (gl, shaderObject, channel = 0)
76
+ setShaderUniforms: function (gl, shaderObject, channel = 0)
83
77
  {
84
78
  gl .uniformMatrix4fv (shaderObject .x3d_TextureMatrix [channel], false, this .matrixArray);
85
79
  },