x_ite 8.6.7 → 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.
- package/.vscode/tasks.json +1 -1
- 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 +26 -26
- 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 +25 -27
- 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 +33 -33
- 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/x_ite.css +1 -1
- package/dist/x_ite.js +907 -689
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +2 -2
- package/docs/laboratory/gltf-sample-viewer.html +4 -4
- package/package.json +1 -1
- package/src/assets/shaders/webgl1/Pointing.fs.js +1 -1
- package/src/assets/shaders/webgl1/include/Fragment.glsl.js +17 -1
- package/src/assets/shaders/webgl1/include/Point.glsl.js +10 -2
- package/src/assets/shaders/webgl1/include/Texture.glsl.js +31 -1
- package/src/assets/shaders/webgl1/include/Vertex.glsl.js +26 -3
- package/src/assets/shaders/webgl2/Pointing.fs.js +1 -1
- package/src/assets/shaders/webgl2/include/Fragment.glsl.js +18 -0
- package/src/assets/shaders/webgl2/include/Particle.glsl.js +9 -23
- package/src/assets/shaders/webgl2/include/Point.glsl.js +12 -4
- package/src/assets/shaders/webgl2/include/Texture.glsl.js +17 -20
- package/src/assets/shaders/webgl2/include/Vertex.glsl.js +24 -0
- package/src/bookmarks.js +1 -1
- package/src/standard/Math/Numbers/Color3.js +2 -2
- package/src/standard/Math/Numbers/Color4.js +1 -1
- package/src/tests.js +1 -0
- package/src/x_ite/Browser/Core/BrowserOptions.js +3 -0
- package/src/x_ite/Browser/Core/BrowserTimings.js +12 -11
- package/src/x_ite/Browser/Core/Context.js +64 -64
- package/src/x_ite/Browser/Core/ContextMenu.js +0 -9
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +1 -1
- package/src/x_ite/Browser/Shaders/Shaders.js +0 -2
- package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +8 -0
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/X3DBrowser.js +1 -1
- package/src/x_ite/Components/Core/X3DBindableNode.js +0 -2
- package/src/x_ite/Components/Core/X3DNode.js +3 -8
- package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +1 -1
- package/src/x_ite/Components/Layering/X3DLayerNode.js +6 -2
- package/src/x_ite/Components/Navigation/NavigationInfo.js +1 -0
- package/src/x_ite/Components/Navigation/X3DViewpointNode.js +34 -21
- package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +2 -4
- package/src/x_ite/Components/Rendering/X3DGeometryNode.js +5 -19
- package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +6 -12
- package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +4 -8
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +28 -27
- package/src/x_ite/Components/Shape/Material.js +28 -23
- package/src/x_ite/Components/Shape/PhysicalMaterial.js +5 -0
- package/src/x_ite/Components/Shape/TwoSidedMaterial.js +1 -0
- package/src/x_ite/Components/Shape/UnlitMaterial.js +1 -0
- package/src/x_ite/Components/Shape/X3DMaterialNode.js +21 -19
- package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +16 -10
- package/src/x_ite/Components/Texturing/ImageTexture.js +86 -44
- package/src/x_ite/Components/Texturing/MovieTexture.js +5 -4
- package/src/x_ite/Components/Texturing/MultiTexture.js +7 -4
- package/src/x_ite/Components/Texturing/MultiTextureCoordinate.js +19 -16
- package/src/x_ite/Components/Texturing/MultiTextureTransform.js +16 -32
- package/src/x_ite/Components/Texturing/TextureCoordinateGenerator.js +1 -1
- package/src/x_ite/Components/Texturing/X3DSingleTextureCoordinateNode.js +2 -8
- package/src/x_ite/Components/Texturing/X3DSingleTextureTransformNode.js +2 -8
- package/src/x_ite/Execution/NamedNodesHandling.js +84 -0
- package/src/x_ite/Execution/X3DExecutionContext.js +7 -37
- package/src/x_ite/Execution/X3DScene.js +5 -0
- package/src/x_ite/InputOutput/FileLoader.js +1 -1
- package/src/x_ite/InputOutput/Generator.js +32 -81
- package/src/x_ite/Parser/GLTF2Parser.js +112 -52
- package/src/x_ite/Parser/OBJParser.js +48 -39
- package/src/x_ite/Parser/STLAParser.js +3 -0
- package/src/x_ite/Parser/SVGParser.js +4 -0
- package/src/x_ite/Rendering/X3DRenderObject.js +2 -0
- package/src/x_ite.html +52 -46
- package/x_ite.min.html +52 -46
- package/src/assets/shaders/webgl1/include/Particle.glsl.js +0 -7
|
@@ -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
|
|
140
|
-
browser
|
|
141
|
-
gl
|
|
142
|
-
maxClipPlanes
|
|
143
|
-
maxLights
|
|
144
|
-
maxTextures
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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);
|
|
@@ -71,29 +71,30 @@ Material .prototype = Object .assign (Object .create (X3DOneSidedMaterialNode .p
|
|
|
71
71
|
{
|
|
72
72
|
constructor: Material,
|
|
73
73
|
[Symbol .for ("X_ITE.X3DBaseNode.fieldDefinitions")]: new FieldDefinitionArray ([
|
|
74
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata",
|
|
75
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "ambientIntensity",
|
|
76
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "ambientTextureMapping",
|
|
77
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "ambientTexture",
|
|
78
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "diffuseColor",
|
|
79
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "diffuseTextureMapping",
|
|
80
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "diffuseTexture",
|
|
81
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "specularColor",
|
|
82
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "specularTextureMapping",
|
|
83
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "specularTexture",
|
|
84
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveColor",
|
|
85
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
86
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
87
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
88
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
89
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
90
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
91
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
92
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
93
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
94
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
95
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
96
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "
|
|
74
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
75
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "ambientIntensity", new Fields .SFFloat (0.2)),
|
|
76
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "ambientTextureMapping", new Fields .SFString ()),
|
|
77
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "ambientTexture", new Fields .SFNode ()),
|
|
78
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "diffuseColor", new Fields .SFColor (0.8, 0.8, 0.8)),
|
|
79
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "diffuseTextureMapping", new Fields .SFString ()),
|
|
80
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "diffuseTexture", new Fields .SFNode ()),
|
|
81
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "specularColor", new Fields .SFColor ()),
|
|
82
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "specularTextureMapping", new Fields .SFString ()),
|
|
83
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "specularTexture", new Fields .SFNode ()),
|
|
84
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveColor", new Fields .SFColor ()),
|
|
85
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveStrength", new Fields .SFFloat (1)),
|
|
86
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveTextureMapping", new Fields .SFString ()),
|
|
87
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveTexture", new Fields .SFNode ()),
|
|
88
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "shininess", new Fields .SFFloat (0.2)),
|
|
89
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "shininessTextureMapping", new Fields .SFString ()),
|
|
90
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "shininessTexture", new Fields .SFNode ()),
|
|
91
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "occlusionStrength", new Fields .SFFloat (1)),
|
|
92
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "occlusionTextureMapping", new Fields .SFString ()),
|
|
93
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "occlusionTexture", new Fields .SFNode ()),
|
|
94
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "normalScale", new Fields .SFFloat (1)),
|
|
95
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "normalTextureMapping", new Fields .SFString ()),
|
|
96
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "normalTexture", new Fields .SFNode ()),
|
|
97
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "transparency", new Fields .SFFloat ()),
|
|
97
98
|
]),
|
|
98
99
|
getTypeName: function ()
|
|
99
100
|
{
|
|
@@ -213,6 +214,10 @@ Material .prototype = Object .assign (Object .create (X3DOneSidedMaterialNode .p
|
|
|
213
214
|
this .setTransparent (!!(this .getTransparency () ||
|
|
214
215
|
(this .diffuseTextureNode && this .diffuseTextureNode .isTransparent ())));
|
|
215
216
|
},
|
|
217
|
+
getBaseTexture: function ()
|
|
218
|
+
{
|
|
219
|
+
return this .diffuseTexture;
|
|
220
|
+
},
|
|
216
221
|
getTextureIndices: (function ()
|
|
217
222
|
{
|
|
218
223
|
let i = 0;
|
|
@@ -71,6 +71,7 @@ PhysicalMaterial .prototype = Object .assign (Object .create (X3DOneSidedMateria
|
|
|
71
71
|
new X3DFieldDefinition (X3DConstants .inputOutput, "baseTextureMapping", new Fields .SFString ()),
|
|
72
72
|
new X3DFieldDefinition (X3DConstants .inputOutput, "baseTexture", new Fields .SFNode ()),
|
|
73
73
|
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveColor", new Fields .SFColor (0, 0, 0)),
|
|
74
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveStrength", new Fields .SFFloat (1)),
|
|
74
75
|
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveTextureMapping", new Fields .SFString ()),
|
|
75
76
|
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveTexture", new Fields .SFNode ()),
|
|
76
77
|
new X3DFieldDefinition (X3DConstants .inputOutput, "metallic", new Fields .SFFloat (1)),
|
|
@@ -172,6 +173,10 @@ PhysicalMaterial .prototype = Object .assign (Object .create (X3DOneSidedMateria
|
|
|
172
173
|
this .setTransparent (!!(this .getTransparency () ||
|
|
173
174
|
(this .baseTextureNode && this .baseTextureNode .isTransparent ())));
|
|
174
175
|
},
|
|
176
|
+
getBaseTexture: function ()
|
|
177
|
+
{
|
|
178
|
+
return this .baseTextureNode;
|
|
179
|
+
},
|
|
175
180
|
getTextureIndices: (function ()
|
|
176
181
|
{
|
|
177
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)
|
|
@@ -64,6 +64,7 @@ UnlitMaterial .prototype = Object .assign (Object .create (X3DOneSidedMaterialNo
|
|
|
64
64
|
[Symbol .for ("X_ITE.X3DBaseNode.fieldDefinitions")]: new FieldDefinitionArray ([
|
|
65
65
|
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
|
|
66
66
|
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveColor", new Fields .SFColor (1, 1, 1)),
|
|
67
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveStrength", new Fields .SFFloat (1)),
|
|
67
68
|
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveTextureMapping", new Fields .SFString ()),
|
|
68
69
|
new X3DFieldDefinition (X3DConstants .inputOutput, "emissiveTexture", new Fields .SFNode ()),
|
|
69
70
|
new X3DFieldDefinition (X3DConstants .inputOutput, "normalScale", new Fields .SFFloat (1)),
|
|
@@ -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
|
-
|
|
218
|
-
|
|
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 (
|
|
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 "
|
|
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 ())
|
|
@@ -69,11 +69,12 @@ X3DOneSidedMaterialNode .prototype = Object .assign (Object .create (X3DMaterial
|
|
|
69
69
|
{
|
|
70
70
|
X3DMaterialNode .prototype .initialize .call (this);
|
|
71
71
|
|
|
72
|
-
this ._emissiveColor
|
|
73
|
-
this .
|
|
74
|
-
this .
|
|
75
|
-
this .
|
|
76
|
-
this ._transparency
|
|
72
|
+
this ._emissiveColor .addInterest ("set_emissiveColor__", this);
|
|
73
|
+
this ._emissiveStrength .addInterest ("set_emissiveColor__", this);
|
|
74
|
+
this ._emissiveTexture .addInterest ("set_emissiveTexture__", this);
|
|
75
|
+
this ._normalTexture .addInterest ("set_normalTexture__", this);
|
|
76
|
+
this ._transparency .addInterest ("set_transparency__", this);
|
|
77
|
+
this ._transparency .addInterest ("set_transparent__", this);
|
|
77
78
|
|
|
78
79
|
this .set_emissiveColor__ ();
|
|
79
80
|
this .set_emissiveTexture__ ();
|
|
@@ -86,12 +87,13 @@ X3DOneSidedMaterialNode .prototype = Object .assign (Object .create (X3DMaterial
|
|
|
86
87
|
//this .emissiveColor .set (this ._emissiveColor .getValue ());
|
|
87
88
|
|
|
88
89
|
const
|
|
89
|
-
emissiveColor
|
|
90
|
-
emissiveColor_
|
|
90
|
+
emissiveColor = this .emissiveColor,
|
|
91
|
+
emissiveColor_ = this ._emissiveColor .getValue (),
|
|
92
|
+
emissiveStrength = this ._emissiveStrength .getValue ();
|
|
91
93
|
|
|
92
|
-
emissiveColor [0] = emissiveColor_ .r;
|
|
93
|
-
emissiveColor [1] = emissiveColor_ .g;
|
|
94
|
-
emissiveColor [2] = emissiveColor_ .b;
|
|
94
|
+
emissiveColor [0] = emissiveColor_ .r * emissiveStrength;
|
|
95
|
+
emissiveColor [1] = emissiveColor_ .g * emissiveStrength;
|
|
96
|
+
emissiveColor [2] = emissiveColor_ .b * emissiveStrength;
|
|
95
97
|
},
|
|
96
98
|
set_emissiveTexture__: function ()
|
|
97
99
|
{
|
|
@@ -113,6 +115,10 @@ X3DOneSidedMaterialNode .prototype = Object .assign (Object .create (X3DMaterial
|
|
|
113
115
|
{
|
|
114
116
|
this .setTransparent (Boolean (this .transparency));
|
|
115
117
|
},
|
|
118
|
+
getBaseTexture: function ()
|
|
119
|
+
{
|
|
120
|
+
return this .getEmissiveTexture ();
|
|
121
|
+
},
|
|
116
122
|
getEmissiveTexture: function ()
|
|
117
123
|
{
|
|
118
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
|
|
|
@@ -77,6 +76,7 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
77
76
|
new X3DFieldDefinition (X3DConstants .inputOutput, "url", new Fields .MFString ()),
|
|
78
77
|
new X3DFieldDefinition (X3DConstants .inputOutput, "autoRefresh", new Fields .SFTime ()),
|
|
79
78
|
new X3DFieldDefinition (X3DConstants .inputOutput, "autoRefreshTimeLimit", new Fields .SFTime (3600)),
|
|
79
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "flipVertically", new Fields .SFBool ()),
|
|
80
80
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "repeatS", new Fields .SFBool (true)),
|
|
81
81
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "repeatT", new Fields .SFBool (true)),
|
|
82
82
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "textureProperties", new Fields .SFNode ()),
|
|
@@ -98,6 +98,8 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
98
98
|
X3DTexture2DNode .prototype .initialize .call (this);
|
|
99
99
|
X3DUrlObject .prototype .initialize .call (this);
|
|
100
100
|
|
|
101
|
+
this ._flipVertically .addInterest ("set_url__", this);
|
|
102
|
+
|
|
101
103
|
this .image .on ("load", this .setImage .bind (this));
|
|
102
104
|
this .image .on ("abort error", this .setError .bind (this));
|
|
103
105
|
this .image .prop ("crossOrigin", "Anonymous");
|
|
@@ -145,7 +147,7 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
145
147
|
|
|
146
148
|
this .loadNext ();
|
|
147
149
|
},
|
|
148
|
-
setImage: function ()
|
|
150
|
+
setImage: async function ()
|
|
149
151
|
{
|
|
150
152
|
if (DEBUG)
|
|
151
153
|
{
|
|
@@ -156,69 +158,61 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
156
158
|
try
|
|
157
159
|
{
|
|
158
160
|
const
|
|
159
|
-
gl
|
|
160
|
-
image
|
|
161
|
-
canvas = this .canvas [0],
|
|
162
|
-
cx = canvas .getContext ("2d", { willReadFrequently: true });
|
|
163
|
-
|
|
164
|
-
let
|
|
165
|
-
width = image .width,
|
|
166
|
-
height = image .height;
|
|
161
|
+
gl = this .getBrowser () .getContext (),
|
|
162
|
+
image = this .image [0];
|
|
167
163
|
|
|
168
164
|
// https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap
|
|
169
165
|
// createImageBitmap
|
|
170
166
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (gl .getVersion () >= 2 || (Algorithm .isPowerOfTwo (width) && Algorithm .isPowerOfTwo (height)))
|
|
167
|
+
if (gl .getVersion () === 1 && !(Algorithm .isPowerOfTwo (image .width) && Algorithm .isPowerOfTwo (image .height)))
|
|
174
168
|
{
|
|
175
|
-
|
|
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);
|
|
174
|
+
|
|
175
|
+
// Flip Y and scale image to next power of two if needed.
|
|
176
176
|
|
|
177
177
|
canvas .width = width;
|
|
178
178
|
canvas .height = height;
|
|
179
179
|
|
|
180
180
|
cx .clearRect (0, 0, width, height);
|
|
181
181
|
cx .save ();
|
|
182
|
-
cx .translate (0, height);
|
|
183
|
-
cx .scale (1, -1);
|
|
184
|
-
cx .drawImage (image, 0, 0);
|
|
185
|
-
cx .restore ();
|
|
186
|
-
}
|
|
187
|
-
else
|
|
188
|
-
{
|
|
189
|
-
// Flip Y and scale image to next power of two.
|
|
190
182
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
183
|
+
if (!this ._flipVertically .getValue ())
|
|
184
|
+
{
|
|
185
|
+
cx .translate (0, height);
|
|
186
|
+
cx .scale (1, -1);
|
|
187
|
+
}
|
|
196
188
|
|
|
197
|
-
cx .clearRect (0, 0, width, height);
|
|
198
|
-
cx .save ();
|
|
199
|
-
cx .translate (0, height);
|
|
200
|
-
cx .scale (1, -1);
|
|
201
189
|
cx .drawImage (image, 0, 0, image .width, image .height, 0, 0, width, height);
|
|
202
190
|
cx .restore ();
|
|
203
|
-
}
|
|
204
191
|
|
|
205
|
-
|
|
192
|
+
// Determine image alpha.
|
|
206
193
|
|
|
207
|
-
|
|
194
|
+
const
|
|
195
|
+
data = cx .getImageData (0, 0, width, height, { premultipliedAlpha: false }) .data,
|
|
196
|
+
transparent = this .isImageTransparent (data);
|
|
208
197
|
|
|
209
|
-
|
|
198
|
+
// Upload image to GPU.
|
|
210
199
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (data [i] !== 255)
|
|
214
|
-
{
|
|
215
|
-
transparent = true;
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
200
|
+
this .setTexture (width, height, transparent, data, false);
|
|
201
|
+
this .setLoadState (X3DConstants .COMPLETE_STATE);
|
|
218
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.
|
|
219
212
|
|
|
220
|
-
|
|
221
|
-
|
|
213
|
+
this .setTexture (width, height, transparent, data, !this ._flipVertically .getValue ());
|
|
214
|
+
this .setLoadState (X3DConstants .COMPLETE_STATE);
|
|
215
|
+
}
|
|
222
216
|
}
|
|
223
217
|
catch (error)
|
|
224
218
|
{
|
|
@@ -226,6 +220,54 @@ ImageTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
226
220
|
this .setError ({ type: error .message });
|
|
227
221
|
}
|
|
228
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
|
+
},
|
|
229
271
|
dispose: function ()
|
|
230
272
|
{
|
|
231
273
|
X3DUrlObject .prototype .dispose .call (this);
|
|
@@ -93,6 +93,7 @@ MovieTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
93
93
|
new X3DFieldDefinition (X3DConstants .outputOnly, "isActive", new Fields .SFBool ()),
|
|
94
94
|
new X3DFieldDefinition (X3DConstants .outputOnly, "elapsedTime", new Fields .SFTime ()),
|
|
95
95
|
new X3DFieldDefinition (X3DConstants .outputOnly, "duration_changed", new Fields .SFTime (-1)),
|
|
96
|
+
new X3DFieldDefinition (X3DConstants .initializeOnly, "flipVertically", new Fields .SFBool ()),
|
|
96
97
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "repeatS", new Fields .SFBool (true)),
|
|
97
98
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "repeatT", new Fields .SFBool (true)),
|
|
98
99
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "textureProperties", new Fields .SFNode ()),
|
|
@@ -219,7 +220,7 @@ MovieTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
219
220
|
throw new Error ("The movie texture is a non power-of-two texture.");
|
|
220
221
|
|
|
221
222
|
this .setMedia (this .video [0]);
|
|
222
|
-
this .setTexture (width, height, false, video,
|
|
223
|
+
this .setTexture (width, height, false, video, !this ._flipVertically .getValue ());
|
|
223
224
|
this .setLoadState (X3DConstants .COMPLETE_STATE);
|
|
224
225
|
}
|
|
225
226
|
catch (error)
|
|
@@ -239,7 +240,7 @@ MovieTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
239
240
|
gif .pause ();
|
|
240
241
|
|
|
241
242
|
this .setMedia (gif);
|
|
242
|
-
this .setTexture (gif .get_canvas () .width, gif .get_canvas () .height, false, gif .get_frames () [0] .data,
|
|
243
|
+
this .setTexture (gif .get_canvas () .width, gif .get_canvas () .height, false, gif .get_frames () [0] .data, !this ._flipVertically .getValue ());
|
|
243
244
|
this .setLoadState (X3DConstants .COMPLETE_STATE);
|
|
244
245
|
}
|
|
245
246
|
catch (error)
|
|
@@ -256,9 +257,9 @@ MovieTexture .prototype = Object .assign (Object .create (X3DTexture2DNode .prot
|
|
|
256
257
|
return;
|
|
257
258
|
|
|
258
259
|
if (this .gif)
|
|
259
|
-
this .updateTexture (this .gif .currentFrame .data,
|
|
260
|
+
this .updateTexture (this .gif .currentFrame .data, !this ._flipVertically .getValue ());
|
|
260
261
|
else
|
|
261
|
-
this .updateTexture (this .video [0],
|
|
262
|
+
this .updateTexture (this .video [0], !this ._flipVertically .getValue ());
|
|
262
263
|
},
|
|
263
264
|
traverse: X3DTexture2DNode .prototype .traverse,
|
|
264
265
|
dispose: function ()
|
|
@@ -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 .
|
|
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 .
|
|
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 .
|
|
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 .
|
|
314
|
+
channels = Math .min (this .maxTextures, textureNodes .length);
|
|
312
315
|
|
|
313
316
|
gl .uniform4fv (shaderObject .x3d_MultiTextureColor, this .color);
|
|
314
317
|
|