x_ite 8.9.5 → 8.10.0
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/build/bin/tests.pl +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 +35 -34
- package/dist/assets/components/Geometry2D.min.js +1 -1
- package/dist/assets/components/Geospatial.js +37 -37
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +370 -208
- 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 -30
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +26 -26
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +23 -23
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +18 -18
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +23 -23
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +37 -37
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +31 -31
- 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 +18 -18
- 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 +8088 -7729
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +5 -5
- package/docs/_posts/components/Core/MetadataBoolean.md +1 -1
- package/docs/_posts/components/Core/MetadataDouble.md +1 -1
- package/docs/_posts/components/Core/MetadataFloat.md +1 -1
- package/docs/_posts/components/Core/MetadataInteger.md +1 -1
- package/docs/_posts/components/Core/MetadataSet.md +1 -1
- package/docs/_posts/components/Core/MetadataString.md +1 -1
- package/docs/_posts/components/Core/WorldInfo.md +1 -1
- package/docs/_posts/components/EventUtilities/BooleanFilter.md +2 -2
- package/docs/_posts/components/EventUtilities/BooleanSequencer.md +2 -2
- package/docs/_posts/components/EventUtilities/BooleanToggle.md +2 -2
- package/docs/_posts/components/EventUtilities/BooleanTrigger.md +2 -2
- package/docs/_posts/components/EventUtilities/IntegerSequencer.md +2 -2
- package/docs/_posts/components/EventUtilities/IntegerTrigger.md +2 -2
- package/docs/_posts/components/EventUtilities/TimeTrigger.md +2 -2
- package/docs/_posts/components/Geometry2D/Arc2D.md +1 -1
- package/docs/_posts/components/Geometry2D/ArcClose2D.md +1 -1
- package/docs/_posts/components/Geometry2D/Circle2D.md +1 -1
- package/docs/_posts/components/Geometry2D/Disk2D.md +1 -1
- package/docs/_posts/components/Geometry2D/Polyline2D.md +1 -1
- package/docs/_posts/components/Geometry2D/Polypoint2D.md +1 -1
- package/docs/_posts/components/Geometry2D/Rectangle2D.md +1 -1
- package/docs/_posts/components/HAnim/HAnimHumanoid.md +17 -17
- package/docs/_posts/components/Interpolation/ColorInterpolator.md +1 -1
- package/docs/_posts/components/Interpolation/CoordinateInterpolator.md +1 -1
- package/docs/_posts/components/Interpolation/CoordinateInterpolator2D.md +1 -1
- package/docs/_posts/components/Interpolation/NormalInterpolator.md +1 -1
- package/docs/_posts/components/Interpolation/OrientationInterpolator.md +1 -1
- package/docs/_posts/components/Interpolation/PositionInterpolator.md +1 -1
- package/docs/_posts/components/Interpolation/PositionInterpolator2D.md +1 -1
- package/docs/_posts/components/Interpolation/ScalarInterpolator.md +1 -1
- package/docs/_posts/components/KeyDeviceSensor/KeySensor.md +1 -1
- package/docs/_posts/components/KeyDeviceSensor/StringSensor.md +1 -1
- package/docs/_posts/components/Networking/LoadSensor.md +1 -1
- package/docs/_posts/components/PointingDeviceSensor/CylinderSensor.md +1 -1
- package/docs/_posts/components/PointingDeviceSensor/PlaneSensor.md +1 -1
- package/docs/_posts/components/PointingDeviceSensor/TouchSensor.md +1 -1
- package/docs/_posts/components/Text/Text.md +1 -1
- package/docs/_posts/components/Time/TimeSensor.md +1 -1
- package/docs/_posts/reference/browser-services.md +6 -6
- package/docs/laboratory/gltf-sample-viewer.html +1 -1
- package/package.json +1 -1
- package/src/assets/shaders/webgl1/Depth.vs.js +4 -4
- package/src/assets/shaders/webgl1/Pointing.fs.js +1 -1
- package/src/assets/shaders/webgl2/Depth.vs.js +7 -4
- package/src/assets/shaders/webgl2/LineTransform.vs.js +24 -12
- package/src/assets/shaders/webgl2/Pointing.fs.js +1 -1
- package/src/assets/shaders/webgl2/Pointing.vs.js +12 -9
- package/src/assets/shaders/webgl2/include/Particle.glsl.js +5 -15
- package/src/assets/shaders/webgl2/include/Skin.glsl.js +88 -0
- package/src/assets/shaders/webgl2/include/Utils.glsl.js +13 -0
- package/src/assets/shaders/webgl2/include/Vertex.glsl.js +17 -8
- package/src/bookmarks.js +54 -2
- package/src/tests.js +0 -360
- package/src/x_ite/Base/X3DArrayField.js +18 -3
- package/src/x_ite/Base/X3DBaseNode.js +73 -56
- package/src/x_ite/Base/X3DChildObject.js +5 -3
- package/src/x_ite/Base/X3DObjectArrayField.js +6 -4
- package/src/x_ite/Browser/Core/Context.js +14 -4
- package/src/x_ite/Browser/Core/Notification.js +4 -3
- package/src/x_ite/Browser/Core/X3DCoreContext.js +8 -8
- package/src/x_ite/Browser/Geometry2D/Arc2DOptions.js +4 -3
- package/src/x_ite/Browser/Geometry2D/ArcClose2DOptions.js +4 -3
- package/src/x_ite/Browser/Geometry2D/Circle2DOptions.js +6 -6
- package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +9 -10
- package/src/x_ite/Browser/Geometry3D/ConeOptions.js +5 -4
- package/src/x_ite/Browser/Geometry3D/CylinderOptions.js +5 -4
- package/src/x_ite/Browser/Geometry3D/IcoSphereOptions.js +3 -2
- package/src/x_ite/Browser/Geometry3D/QuadSphereOptions.js +3 -2
- package/src/x_ite/Browser/Layout/ScreenText.js +2 -2
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +4 -4
- package/src/x_ite/Browser/Navigation/LookAtViewer.js +4 -4
- package/src/x_ite/Browser/Navigation/PlaneViewer.js +3 -3
- package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +3 -3
- package/src/x_ite/Browser/Navigation/X3DNavigationContext.js +6 -5
- package/src/x_ite/Browser/Navigation/X3DViewer.js +2 -13
- package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +5 -4
- package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +8 -18
- package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +17 -5
- package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +6 -5
- package/src/x_ite/Browser/Shaders/Shaders.js +4 -0
- package/src/x_ite/Browser/Shape/X3DShapeContext.js +3 -3
- package/src/x_ite/Browser/Sound/X3DSoundContext.js +4 -3
- package/src/x_ite/Browser/Text/PolygonText.js +2 -2
- package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +1 -1
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/X3DBrowser.js +49 -17
- package/src/x_ite/Browser/X3DBrowserContext.js +8 -7
- package/src/x_ite/Components/Core/X3DChildNode.js +2 -5
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +14 -16
- package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +1 -1
- package/src/x_ite/Components/EnvironmentalSensor/X3DEnvironmentalSensorNode.js +1 -1
- package/src/x_ite/Components/Geometry3D/ElevationGrid.js +5 -2
- package/src/x_ite/Components/Geometry3D/Extrusion.js +24 -13
- package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +5 -2
- package/src/x_ite/Components/Geospatial/GeoElevationGrid.js +2 -2
- package/src/x_ite/Components/Geospatial/GeoViewpoint.js +2 -2
- package/src/x_ite/Components/Grouping/X3DBoundedObject.js +1 -2
- package/src/x_ite/Components/HAnim/HAnimHumanoid.js +314 -161
- package/src/x_ite/Components/HAnim/HAnimJoint.js +37 -25
- package/src/x_ite/Components/Layering/X3DLayerNode.js +2 -2
- package/src/x_ite/Components/NURBS/NurbsOrientationInterpolator.js +1 -1
- package/src/x_ite/Components/NURBS/NurbsPositionInterpolator.js +1 -1
- package/src/x_ite/Components/Navigation/NavigationInfo.js +4 -4
- package/src/x_ite/Components/Navigation/OrthoViewpoint.js +1 -1
- package/src/x_ite/Components/Navigation/X3DViewpointNode.js +12 -12
- package/src/x_ite/Components/Networking/X3DUrlObject.js +18 -11
- package/src/x_ite/Components/Rendering/IndexedLineSet.js +17 -14
- package/src/x_ite/Components/Rendering/LineSet.js +16 -13
- package/src/x_ite/Components/Rendering/PointSet.js +16 -12
- package/src/x_ite/Components/Rendering/X3DColorNode.js +1 -3
- package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +3 -0
- package/src/x_ite/Components/Rendering/X3DGeometryNode.js +48 -77
- package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +31 -12
- package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +3 -0
- package/src/x_ite/Components/RigidBodyPhysics/RigidBody.js +3 -3
- package/src/x_ite/Components/RigidBodyPhysics/X3DNBodyCollidableNode.js +2 -2
- package/src/x_ite/Components/RigidBodyPhysics/X3DRigidJointNode.js +1 -1
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +24 -7
- package/src/x_ite/Components/Shaders/X3DVertexAttributeNode.js +1 -1
- package/src/x_ite/Components/Shape/FillProperties.js +1 -3
- package/src/x_ite/Components/Shape/X3DAppearanceNode.js +1 -3
- package/src/x_ite/Components/Shape/X3DMaterialNode.js +8 -6
- package/src/x_ite/Components/Shape/X3DOneSidedMaterialNode.js +0 -2
- package/src/x_ite/Components/Sound/AudioClip.js +1 -1
- package/src/x_ite/Components/Sound/BufferAudioSource.js +1 -1
- package/src/x_ite/Components/Sound/ListenerPointSource.js +2 -2
- package/src/x_ite/Components/Sound/MicrophoneSource.js +2 -2
- package/src/x_ite/Components/Sound/OscillatorSource.js +2 -2
- package/src/x_ite/Components/Sound/Sound.js +1 -1
- package/src/x_ite/Components/Sound/StreamAudioSource.js +2 -2
- package/src/x_ite/Components/Sound/X3DSoundProcessingNode.js +1 -1
- package/src/x_ite/Components/Text/X3DFontStyleNode.js +4 -4
- package/src/x_ite/Components/Texturing/MultiTexture.js +1 -1
- package/src/x_ite/Components/Texturing/PixelTexture.js +1 -1
- package/src/x_ite/Components/Texturing/X3DSingleTextureCoordinateNode.js +2 -2
- package/src/x_ite/Components/Texturing/X3DTextureNode.js +1 -3
- package/src/x_ite/Components/Texturing3D/ComposedTexture3D.js +2 -2
- package/src/x_ite/Components/Texturing3D/PixelTexture3D.js +1 -1
- package/src/x_ite/Components/Time/TimeSensor.js +1 -1
- package/src/x_ite/Components/Time/X3DTimeDependentNode.js +2 -2
- package/src/x_ite/Execution/X3DExecutionContext.js +3 -4
- package/src/x_ite/Execution/X3DScene.js +4 -4
- package/src/x_ite/Execution/X3DWorld.js +1 -1
- package/src/x_ite/Parser/GLTF2Parser.js +196 -116
- package/src/x_ite/Parser/X3DOptimizer.js +47 -18
- package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +4 -4
- package/src/x_ite/Prototype/X3DProtoDeclarationNode.js +1 -1
- package/src/x_ite/Rendering/X3DRenderObject.js +20 -12
- package/src/x_ite.html +36 -10
- package/x_ite.min.html +36 -10
|
@@ -55,8 +55,6 @@ import X3DBoundedObject from "../Grouping/X3DBoundedObject.js";
|
|
|
55
55
|
import TraverseType from "../../Rendering/TraverseType.js";
|
|
56
56
|
import X3DConstants from "../../Base/X3DConstants.js";
|
|
57
57
|
import X3DCast from "../../Base/X3DCast.js";
|
|
58
|
-
import Vector3 from "../../../standard/Math/Numbers/Vector3.js";
|
|
59
|
-
import Rotation4 from "../../../standard/Math/Numbers/Rotation4.js";
|
|
60
58
|
import Matrix4 from "../../../standard/Math/Numbers/Matrix4.js";
|
|
61
59
|
|
|
62
60
|
function HAnimHumanoid (executionContext)
|
|
@@ -66,6 +64,10 @@ function HAnimHumanoid (executionContext)
|
|
|
66
64
|
|
|
67
65
|
this .addType (X3DConstants .HAnimHumanoid);
|
|
68
66
|
|
|
67
|
+
this .addChildObjects (X3DConstants .inputOutput, "jointTextures", new Fields .SFTime (),
|
|
68
|
+
X3DConstants .inputOutput, "displacementsTexture", new Fields .SFTime (),
|
|
69
|
+
X3DConstants .inputOutput, "displacementWeightsTexture", new Fields .SFTime ());
|
|
70
|
+
|
|
69
71
|
this ._translation .setUnit ("length");
|
|
70
72
|
this ._center .setUnit ("length");
|
|
71
73
|
this ._bboxSize .setUnit ("length");
|
|
@@ -77,11 +79,10 @@ function HAnimHumanoid (executionContext)
|
|
|
77
79
|
this .transformNode = new Transform (executionContext);
|
|
78
80
|
this .jointNodes = [ ];
|
|
79
81
|
this .jointBindingMatrices = [ ];
|
|
80
|
-
this .
|
|
81
|
-
this .skinBindingCoord = null;
|
|
82
|
-
this .skinNormalNode = null;
|
|
82
|
+
this .displacementWeights = [ ];
|
|
83
83
|
this .skinCoordNode = null;
|
|
84
|
-
this .
|
|
84
|
+
this .change = new Lock ();
|
|
85
|
+
this .skinning = Function .prototype;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
Object .assign (Object .setPrototypeOf (HAnimHumanoid .prototype, X3DChildNode .prototype),
|
|
@@ -145,25 +146,64 @@ Object .assign (Object .setPrototypeOf (HAnimHumanoid .prototype, X3DChildNode .
|
|
|
145
146
|
this .setCameraObject (this .transformNode .isCameraObject ());
|
|
146
147
|
this .setPickableObject (this .transformNode .isPickableObject ());
|
|
147
148
|
|
|
148
|
-
//
|
|
149
|
+
// Check WebGL version.
|
|
150
|
+
|
|
151
|
+
const
|
|
152
|
+
browser = this .getBrowser (),
|
|
153
|
+
gl = browser .getContext ();
|
|
154
|
+
|
|
155
|
+
if (gl .getVersion () === 1)
|
|
156
|
+
return;
|
|
157
|
+
|
|
158
|
+
// Prepare skinNode.
|
|
159
|
+
|
|
160
|
+
this .skinNode .traverse = function (humanoidNode, type, renderObject)
|
|
161
|
+
{
|
|
162
|
+
renderObject .getHumanoids () .push (humanoidNode);
|
|
163
|
+
|
|
164
|
+
Group .prototype .traverse .call (this, type, renderObject);
|
|
165
|
+
|
|
166
|
+
renderObject .getHumanoids () .pop ();
|
|
167
|
+
}
|
|
168
|
+
.bind (this .skinNode, this);
|
|
149
169
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this .
|
|
153
|
-
this .
|
|
154
|
-
this .
|
|
155
|
-
|
|
156
|
-
this .
|
|
157
|
-
|
|
170
|
+
// Textures
|
|
171
|
+
|
|
172
|
+
this .jointsTexture = gl .createTexture ();
|
|
173
|
+
this .displacementsTexture = gl .createTexture ();
|
|
174
|
+
this .jointMatricesTexture = gl .createTexture ();
|
|
175
|
+
|
|
176
|
+
for (const texture of [this .jointsTexture, this .displacementsTexture, this .jointMatricesTexture])
|
|
177
|
+
{
|
|
178
|
+
gl .bindTexture (gl .TEXTURE_2D, texture);
|
|
179
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_WRAP_S, gl .CLAMP_TO_EDGE);
|
|
180
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_WRAP_T, gl .CLAMP_TO_EDGE);
|
|
181
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_MIN_FILTER, gl .LINEAR);
|
|
182
|
+
gl .texParameteri (gl .TEXTURE_2D, gl .TEXTURE_MAG_FILTER, gl .LINEAR);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Events
|
|
186
|
+
|
|
187
|
+
this ._joints .addInterest ("set_joints__", this);
|
|
188
|
+
this ._jointBindingPositions .addInterest ("set_joints__", this);
|
|
189
|
+
this ._jointBindingRotations .addInterest ("set_joints__", this);
|
|
190
|
+
this ._jointBindingScales .addInterest ("set_joints__", this);
|
|
191
|
+
this ._jointTextures .addInterest ("set_jointTextures__", this);
|
|
192
|
+
this ._displacementsTexture .addInterest ("set_displacementsTexture__", this);
|
|
193
|
+
this ._displacementWeightsTexture .addInterest ("set_displacementWeightsTexture__", this);
|
|
194
|
+
this ._skinCoord .addInterest ("set_skinCoord__", this);
|
|
158
195
|
|
|
159
196
|
this .set_joints__ ();
|
|
160
|
-
this .
|
|
161
|
-
this .set_skinBindingCoord__ ();
|
|
197
|
+
this .set_skinCoord__ ();
|
|
162
198
|
},
|
|
163
199
|
getBBox (bbox, shadows)
|
|
164
200
|
{
|
|
165
201
|
return this .transformNode .getBBox (bbox, shadows);
|
|
166
202
|
},
|
|
203
|
+
getMatrix ()
|
|
204
|
+
{
|
|
205
|
+
return this .transformNode .getMatrix ();
|
|
206
|
+
},
|
|
167
207
|
set_joints__ ()
|
|
168
208
|
{
|
|
169
209
|
const
|
|
@@ -174,7 +214,13 @@ Object .assign (Object .setPrototypeOf (HAnimHumanoid .prototype, X3DChildNode .
|
|
|
174
214
|
jointBindingScales = this ._jointBindingScales;
|
|
175
215
|
|
|
176
216
|
for (const jointNode of jointNodes)
|
|
177
|
-
|
|
217
|
+
{
|
|
218
|
+
jointNode .removeInterest ("enable", this .change);
|
|
219
|
+
jointNode ._skinCoordIndex .removeInterest ("addEvent", this ._jointTextures);
|
|
220
|
+
jointNode ._skinCoordWeight .removeInterest ("addEvent", this ._jointTextures);
|
|
221
|
+
jointNode ._displacements .removeInterest ("addEvent", this ._displacementsTexture);
|
|
222
|
+
jointNode ._displacementWeights .removeInterest ("addEvent", this ._displacementWeightsTexture);
|
|
223
|
+
}
|
|
178
224
|
|
|
179
225
|
jointNodes .length = 0;
|
|
180
226
|
jointBindingMatrices .length = 0;
|
|
@@ -183,67 +229,219 @@ Object .assign (Object .setPrototypeOf (HAnimHumanoid .prototype, X3DChildNode .
|
|
|
183
229
|
{
|
|
184
230
|
const jointNode = X3DCast (X3DConstants .HAnimJoint, node);
|
|
185
231
|
|
|
186
|
-
if (jointNode)
|
|
187
|
-
|
|
188
|
-
const jointBindingMatrix = new Matrix4 ();
|
|
232
|
+
if (!jointNode)
|
|
233
|
+
continue;
|
|
189
234
|
|
|
190
|
-
|
|
191
|
-
jointBindingMatrix .translate (jointBindingPositions [Math .min (i, jointBindingPositions .length - 1)] .getValue ());
|
|
235
|
+
const jointBindingMatrix = new Matrix4 ();
|
|
192
236
|
|
|
193
|
-
|
|
194
|
-
|
|
237
|
+
if (jointBindingPositions .length)
|
|
238
|
+
jointBindingMatrix .translate (jointBindingPositions [Math .min (i, jointBindingPositions .length - 1)] .getValue ());
|
|
195
239
|
|
|
196
|
-
|
|
197
|
-
|
|
240
|
+
if (jointBindingRotations .length)
|
|
241
|
+
jointBindingMatrix .rotate (jointBindingRotations [Math .min (i, jointBindingRotations .length - 1)] .getValue ());
|
|
198
242
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
243
|
+
if (jointBindingScales .length)
|
|
244
|
+
jointBindingMatrix .scale (jointBindingScales [Math .min (i, jointBindingScales .length - 1)] .getValue ());
|
|
245
|
+
|
|
246
|
+
jointNodes .push (jointNode);
|
|
247
|
+
jointBindingMatrices .push (jointBindingMatrix);
|
|
202
248
|
}
|
|
203
249
|
|
|
204
250
|
for (const jointNode of jointNodes)
|
|
205
|
-
|
|
251
|
+
{
|
|
252
|
+
jointNode .addInterest ("enable", this .change);
|
|
253
|
+
jointNode ._skinCoordIndex .addInterest ("addEvent", this ._jointTextures);
|
|
254
|
+
jointNode ._skinCoordWeight .addInterest ("addEvent", this ._jointTextures);
|
|
255
|
+
jointNode ._displacements .addInterest ("addEvent", this ._displacementsTexture);
|
|
256
|
+
jointNode ._displacementWeights .addInterest ("addEvent", this ._displacementWeightsTexture);
|
|
257
|
+
}
|
|
206
258
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
this .
|
|
259
|
+
const size = Math .ceil (Math .sqrt (jointNodes .length * 8));
|
|
260
|
+
|
|
261
|
+
this .jointMatricesArray = new Float32Array (size * size * 4),
|
|
262
|
+
|
|
263
|
+
this ._jointTextures .addEvent ();
|
|
264
|
+
this ._displacementsTexture .addEvent ();
|
|
265
|
+
this ._displacementWeightsTexture .addEvent ();
|
|
212
266
|
},
|
|
213
|
-
|
|
267
|
+
set_jointTextures__ ()
|
|
214
268
|
{
|
|
215
|
-
|
|
269
|
+
// Create arrays.
|
|
270
|
+
|
|
271
|
+
const
|
|
272
|
+
length = this .skinCoordNode ?._point .length || 1,
|
|
273
|
+
joints = Array .from ({ length }, () => [ ]),
|
|
274
|
+
weights = Array .from ({ length }, () => [ ]);
|
|
275
|
+
|
|
276
|
+
for (const [j, jointNode] of this .jointNodes .entries ())
|
|
277
|
+
{
|
|
278
|
+
const skinCoordWeight = jointNode ._skinCoordWeight .getValue ();
|
|
279
|
+
|
|
280
|
+
for (const [i, index] of jointNode ._skinCoordIndex .entries ())
|
|
281
|
+
{
|
|
282
|
+
joints [index] ?.push (j);
|
|
283
|
+
weights [index] ?.push (skinCoordWeight [i])
|
|
284
|
+
}
|
|
285
|
+
}
|
|
216
286
|
|
|
217
|
-
|
|
287
|
+
const
|
|
288
|
+
size = Math .ceil (Math .sqrt (length * 2)) || 1,
|
|
289
|
+
jointsArray = new Float32Array (size * size * 4);
|
|
290
|
+
|
|
291
|
+
for (let i = 0; i < length; ++ i)
|
|
292
|
+
{
|
|
293
|
+
const j = joints [i], w = weights [i];
|
|
294
|
+
|
|
295
|
+
j .length = w .length = Math .min (j .length, 4);
|
|
296
|
+
|
|
297
|
+
jointsArray .set (j, i * 8 + 0);
|
|
298
|
+
jointsArray .set (w, i * 8 + 4);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Upload textures.
|
|
302
|
+
|
|
303
|
+
const
|
|
304
|
+
browser = this .getBrowser (),
|
|
305
|
+
gl = browser .getContext ();
|
|
306
|
+
|
|
307
|
+
gl .bindTexture (gl .TEXTURE_2D, this .jointsTexture);
|
|
308
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, size, size, 0, gl .RGBA, gl .FLOAT, jointsArray);
|
|
309
|
+
|
|
310
|
+
// Trigger update.
|
|
311
|
+
|
|
312
|
+
this .change .enable ();
|
|
218
313
|
},
|
|
219
|
-
|
|
314
|
+
set_displacementsTexture__ ()
|
|
220
315
|
{
|
|
221
|
-
|
|
316
|
+
// Create array.
|
|
222
317
|
|
|
223
|
-
|
|
318
|
+
const
|
|
319
|
+
length = this .skinCoordNode ?._point .length || 1,
|
|
320
|
+
displacements = Array .from ({ length }, () => [ ]);
|
|
321
|
+
|
|
322
|
+
for (const [j, jointNode] of this .jointNodes .entries ())
|
|
323
|
+
{
|
|
324
|
+
for (const displacerNode of jointNode .getDisplacers ())
|
|
325
|
+
{
|
|
326
|
+
const d = displacerNode ._displacements;
|
|
327
|
+
|
|
328
|
+
for (const [i, index] of displacerNode ._coordIndex .entries ())
|
|
329
|
+
displacements [index] ?.push (... d [i]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const
|
|
334
|
+
size = even (Math .ceil (Math .sqrt (length * 2)) || 1),
|
|
335
|
+
displacementsArray = new Float32Array (size * size * 8);
|
|
336
|
+
|
|
337
|
+
for (let i = 0; i < length; ++ i)
|
|
338
|
+
{
|
|
339
|
+
const d = displacements [i];
|
|
340
|
+
|
|
341
|
+
d .length = Math .min (d .length, 8);
|
|
342
|
+
|
|
343
|
+
displacementsArray .set (d, i * 8);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Upload texture.
|
|
347
|
+
|
|
348
|
+
const
|
|
349
|
+
browser = this .getBrowser (),
|
|
350
|
+
gl = browser .getContext ();
|
|
351
|
+
|
|
352
|
+
gl .bindTexture (gl .TEXTURE_2D, this .displacementsTexture);
|
|
353
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, size, size, 0, gl .RGBA, gl .FLOAT, displacementsArray);
|
|
354
|
+
|
|
355
|
+
// Weights
|
|
356
|
+
|
|
357
|
+
const displacementWeights = this .displacementWeights;
|
|
358
|
+
|
|
359
|
+
for (let i = displacementWeights .length; i < length; ++ i)
|
|
360
|
+
displacementWeights [i] = [ ];
|
|
361
|
+
|
|
362
|
+
displacementWeights .length = length;
|
|
363
|
+
|
|
364
|
+
this .displacementWeightsArray = new Float32Array (size * size * 4);
|
|
365
|
+
|
|
366
|
+
// Trigger update.
|
|
367
|
+
|
|
368
|
+
this .change .enable ();
|
|
224
369
|
},
|
|
225
|
-
|
|
370
|
+
set_displacementWeightsTexture__ ()
|
|
226
371
|
{
|
|
227
|
-
|
|
372
|
+
// Create array.
|
|
228
373
|
|
|
229
|
-
|
|
230
|
-
|
|
374
|
+
const
|
|
375
|
+
length = this .skinCoordNode ?._point .length || 1,
|
|
376
|
+
displacementWeights = this .displacementWeights;
|
|
377
|
+
|
|
378
|
+
for (const d of displacementWeights)
|
|
379
|
+
d .length = 0;
|
|
380
|
+
|
|
381
|
+
for (const jointNode of this .jointNodes)
|
|
382
|
+
{
|
|
383
|
+
for (const displacerNode of jointNode .getDisplacers ())
|
|
384
|
+
{
|
|
385
|
+
const weight = displacerNode ._weight;
|
|
386
|
+
|
|
387
|
+
for (const index of displacerNode ._coordIndex)
|
|
388
|
+
displacementWeights [index] ?.push (weight);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const
|
|
393
|
+
size = even (Math .ceil (Math .sqrt (length * 2)) || 1),
|
|
394
|
+
displacementWeightsArray = this .displacementWeightsArray;
|
|
395
|
+
|
|
396
|
+
for (let i = 0; i < length; ++ i)
|
|
397
|
+
{
|
|
398
|
+
const d = displacementWeights [i];
|
|
399
|
+
|
|
400
|
+
d .length = Math .min (d .length, 8);
|
|
401
|
+
|
|
402
|
+
displacementWeightsArray .set (d, i * 8);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Upload texture.
|
|
406
|
+
|
|
407
|
+
const
|
|
408
|
+
browser = this .getBrowser (),
|
|
409
|
+
gl = browser .getContext ();
|
|
410
|
+
|
|
411
|
+
gl .bindTexture (gl .TEXTURE_2D, this .displacementsTexture);
|
|
412
|
+
gl .texSubImage2D (gl .TEXTURE_2D, 0, 0, size / 2, size, size / 2, gl .RGBA, gl .FLOAT, displacementWeightsArray)
|
|
231
413
|
|
|
232
|
-
|
|
414
|
+
// Trigger update.
|
|
415
|
+
|
|
416
|
+
this .change .enable ();
|
|
233
417
|
},
|
|
234
418
|
set_skinCoord__ ()
|
|
235
419
|
{
|
|
236
|
-
|
|
420
|
+
if (this .skinCoordNode)
|
|
421
|
+
{
|
|
422
|
+
this .skinCoordNode .removeInterest ("addEvent", this ._jointTextures);
|
|
423
|
+
this .skinCoordNode .removeInterest ("addEvent", this ._displacementsTexture);
|
|
424
|
+
this .skinCoordNode .removeInterest ("addEvent", this ._displacementWeightsTexture);
|
|
425
|
+
}
|
|
237
426
|
|
|
238
|
-
|
|
239
|
-
this .skinBindingCoord = this .skinCoordNode .copy ();
|
|
427
|
+
this .skinCoordNode = X3DCast (X3DConstants .X3DCoordinateNode, this ._skinCoord);
|
|
240
428
|
|
|
241
429
|
if (this .skinCoordNode)
|
|
430
|
+
{
|
|
242
431
|
delete this .skinning;
|
|
432
|
+
|
|
433
|
+
this .skinCoordNode .addInterest ("addEvent", this ._jointTextures);
|
|
434
|
+
this .skinCoordNode .addInterest ("addEvent", this ._displacementsTexture);
|
|
435
|
+
this .skinCoordNode .addInterest ("addEvent", this ._displacementWeightsTexture);
|
|
436
|
+
}
|
|
243
437
|
else
|
|
244
|
-
|
|
438
|
+
{
|
|
439
|
+
this .skinning = Function .prototype;
|
|
440
|
+
}
|
|
245
441
|
|
|
246
|
-
this .
|
|
442
|
+
this ._jointTextures .addEvent ();
|
|
443
|
+
this ._displacementsTexture .addEvent ();
|
|
444
|
+
this ._displacementWeightsTexture .addEvent ();
|
|
247
445
|
},
|
|
248
446
|
traverse (type, renderObject)
|
|
249
447
|
{
|
|
@@ -253,136 +451,67 @@ Object .assign (Object .setPrototypeOf (HAnimHumanoid .prototype, X3DChildNode .
|
|
|
253
451
|
},
|
|
254
452
|
skinning: (() =>
|
|
255
453
|
{
|
|
256
|
-
const
|
|
257
|
-
invModelMatrix = new Matrix4 (),
|
|
258
|
-
rest = new Vector3 (0, 0, 0),
|
|
259
|
-
skin = new Vector3 (0, 0, 0),
|
|
260
|
-
vector = new Vector3 (0, 0, 0),
|
|
261
|
-
point = new Vector3 (0, 0, 0);
|
|
454
|
+
const invModelViewMatrix = new Matrix4 ();
|
|
262
455
|
|
|
263
456
|
return function (type, renderObject)
|
|
264
457
|
{
|
|
265
|
-
if (type !== TraverseType .
|
|
458
|
+
if (type !== TraverseType .DISPLAY || this .change .lock ())
|
|
266
459
|
return;
|
|
267
460
|
|
|
268
|
-
|
|
269
|
-
return;
|
|
461
|
+
// Determine inverse model matrix of humanoid.
|
|
270
462
|
|
|
271
|
-
this .
|
|
463
|
+
invModelViewMatrix .assign (this .transformNode .getMatrix ())
|
|
464
|
+
.multRight (renderObject .getModelViewMatrix () .get ()) .inverse ();
|
|
465
|
+
|
|
466
|
+
// Create joint matrices.
|
|
272
467
|
|
|
273
468
|
const
|
|
274
469
|
jointNodes = this .jointNodes,
|
|
275
470
|
jointNodesLength = jointNodes .length,
|
|
276
471
|
jointBindingMatrices = this .jointBindingMatrices,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
skinNormalNode = this .skinNormalNode,
|
|
280
|
-
skinCoordNode = this .skinCoordNode;
|
|
281
|
-
|
|
282
|
-
// Reset skin normals and coords.
|
|
283
|
-
|
|
284
|
-
if (skinNormalNode)
|
|
285
|
-
skinNormalNode ._vector .assign (skinBindingNormal ._vector);
|
|
286
|
-
|
|
287
|
-
skinCoordNode ._point .assign (skinBindingCoord ._point);
|
|
288
|
-
|
|
289
|
-
// Determine inverse model matrix of humanoid.
|
|
290
|
-
|
|
291
|
-
invModelMatrix .assign (this .transformNode .getMatrix ())
|
|
292
|
-
.multRight (renderObject .getModelViewMatrix () .get ()) .inverse ();
|
|
293
|
-
|
|
294
|
-
// Apply joint transformations.
|
|
472
|
+
jointMatricesArray = this .jointMatricesArray,
|
|
473
|
+
size = Math .ceil (Math .sqrt (jointNodesLength * 8));
|
|
295
474
|
|
|
296
475
|
for (let i = 0; i < jointNodesLength; ++ i)
|
|
297
476
|
{
|
|
298
477
|
const
|
|
299
|
-
jointNode
|
|
300
|
-
jointBindingMatrix
|
|
301
|
-
jointMatrix
|
|
302
|
-
|
|
303
|
-
skinCoordIndexLength = jointNode ._skinCoordIndex .length;
|
|
304
|
-
|
|
305
|
-
for (const displacerNode of displacerNodes)
|
|
306
|
-
{
|
|
307
|
-
const
|
|
308
|
-
coordIndex = displacerNode ._coordIndex .getValue (),
|
|
309
|
-
coordIndexLength = displacerNode ._coordIndex .length,
|
|
310
|
-
weight = displacerNode ._weight .getValue (),
|
|
311
|
-
displacements = displacerNode ._displacements .getValue (),
|
|
312
|
-
displacementsLength = displacerNode ._displacements .length;
|
|
313
|
-
|
|
314
|
-
for (let i = 0; i < coordIndexLength; ++ i)
|
|
315
|
-
{
|
|
316
|
-
const
|
|
317
|
-
i3 = i * 3,
|
|
318
|
-
index = coordIndex [i],
|
|
319
|
-
displacement = i < displacementsLength ? point .set (displacements [i3], displacements [i3 + 1], displacements [i3 + 2]) : point .assign (Vector3 .Zero);
|
|
320
|
-
|
|
321
|
-
skinCoordNode .get1Point (index, skin);
|
|
322
|
-
jointMatrix .multDirMatrix (displacement) .multiply (weight) .add (skin);
|
|
323
|
-
skinCoordNode .set1Point (index, displacement);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
478
|
+
jointNode = jointNodes [i],
|
|
479
|
+
jointBindingMatrix = jointBindingMatrices [i],
|
|
480
|
+
jointMatrix = jointNode .getModelViewMatrix () .multRight (invModelViewMatrix) .multLeft (jointBindingMatrix),
|
|
481
|
+
jointNormalMatrix = jointMatrix .submatrix .transpose () .inverse ();
|
|
326
482
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
skinCoordIndex = jointNode ._skinCoordIndex .getValue (),
|
|
330
|
-
skinCoordWeight = jointNode ._skinCoordWeight .getValue (),
|
|
331
|
-
skinCoordWeightLength = jointNode ._skinCoordWeight .length;
|
|
332
|
-
|
|
333
|
-
for (let i = 0; i < skinCoordIndexLength; ++ i)
|
|
334
|
-
{
|
|
335
|
-
const
|
|
336
|
-
index = skinCoordIndex [i],
|
|
337
|
-
weight = i < skinCoordWeightLength ? skinCoordWeight [i] : 1;
|
|
338
|
-
|
|
339
|
-
if (skinNormalNode)
|
|
340
|
-
{
|
|
341
|
-
rest .assign (skinBindingNormal .get1Vector (index, vector));
|
|
342
|
-
skinNormalNode .get1Vector (index, skin);
|
|
343
|
-
normalMatrix .multVecMatrix (vector) .subtract (rest) .multiply (weight) .add (skin);
|
|
344
|
-
skinNormalNode .set1Vector (index, vector);
|
|
345
|
-
// Let the shader normalize the normals.
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
//skin += (rest * J - rest) * weight
|
|
349
|
-
rest .assign (skinBindingCoord .get1Point (index, point));
|
|
350
|
-
skinCoordNode .get1Point (index, skin);
|
|
351
|
-
jointMatrix .multVecMatrix (point) .subtract (rest) .multiply (weight) .add (skin);
|
|
352
|
-
skinCoordNode .set1Point (index, point);
|
|
353
|
-
}
|
|
483
|
+
jointMatricesArray .set (jointMatrix, i * 32 + 0);
|
|
484
|
+
jointMatricesArray .set (jointNormalMatrix, i * 32 + 16);
|
|
354
485
|
}
|
|
355
|
-
};
|
|
356
|
-
})(),
|
|
357
|
-
toVRMLStream (generator)
|
|
358
|
-
{
|
|
359
|
-
if (this .skinNormalNode)
|
|
360
|
-
this .skinNormalNode ._vector = this .skinBindingNormal ._vector;
|
|
361
486
|
|
|
362
|
-
|
|
363
|
-
this .skinCoordNode ._point = this .skinBindingCoord ._point;
|
|
487
|
+
// Upload textures.
|
|
364
488
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
{
|
|
369
|
-
if (this .skinNormalNode)
|
|
370
|
-
this .skinNormalNode ._vector = this .skinBindingNormal ._vector;
|
|
371
|
-
|
|
372
|
-
if (this .skinCoordNode)
|
|
373
|
-
this .skinCoordNode ._point = this .skinBindingCoord ._point;
|
|
489
|
+
const
|
|
490
|
+
browser = this .getBrowser (),
|
|
491
|
+
gl = browser .getContext ();
|
|
374
492
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
493
|
+
gl .bindTexture (gl .TEXTURE_2D, this .jointMatricesTexture);
|
|
494
|
+
gl .texImage2D (gl .TEXTURE_2D, 0, gl .RGBA32F, size, size, 0, gl .RGBA, gl .FLOAT, jointMatricesArray);
|
|
495
|
+
};
|
|
496
|
+
})(),
|
|
497
|
+
setShaderUniforms (gl, shaderObject)
|
|
378
498
|
{
|
|
379
|
-
|
|
380
|
-
this .
|
|
499
|
+
const
|
|
500
|
+
jointsTextureTextureUnit = this .getBrowser () .getTexture2DUnit (),
|
|
501
|
+
displacementsTextureTextureUnit = this .getBrowser () .getTexture2DUnit (),
|
|
502
|
+
jointMatricesTextureUnit = this .getBrowser () .getTexture2DUnit ();
|
|
381
503
|
|
|
382
|
-
|
|
383
|
-
|
|
504
|
+
gl .activeTexture (gl .TEXTURE0 + jointsTextureTextureUnit);
|
|
505
|
+
gl .bindTexture (gl .TEXTURE_2D, this .jointsTexture);
|
|
506
|
+
gl .uniform1i (shaderObject .x3d_JointsTexture, jointsTextureTextureUnit);
|
|
507
|
+
|
|
508
|
+
gl .activeTexture (gl .TEXTURE0 + displacementsTextureTextureUnit);
|
|
509
|
+
gl .bindTexture (gl .TEXTURE_2D, this .displacementsTexture);
|
|
510
|
+
gl .uniform1i (shaderObject .x3d_DisplacementsTexture, displacementsTextureTextureUnit);
|
|
384
511
|
|
|
385
|
-
|
|
512
|
+
gl .activeTexture (gl .TEXTURE0 + jointMatricesTextureUnit);
|
|
513
|
+
gl .bindTexture (gl .TEXTURE_2D, this .jointMatricesTexture);
|
|
514
|
+
gl .uniform1i (shaderObject .x3d_JointMatricesTexture, jointMatricesTextureUnit);
|
|
386
515
|
},
|
|
387
516
|
dispose ()
|
|
388
517
|
{
|
|
@@ -421,6 +550,8 @@ Object .defineProperties (HAnimHumanoid,
|
|
|
421
550
|
new X3DFieldDefinition (X3DConstants .inputOutput, "description", new Fields .SFString ()),
|
|
422
551
|
new X3DFieldDefinition (X3DConstants .inputOutput, "name", new Fields .SFString ()),
|
|
423
552
|
new X3DFieldDefinition (X3DConstants .inputOutput, "info", new Fields .MFString ()),
|
|
553
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "skeletalConfiguration", new Fields .SFString ("BASIC")),
|
|
554
|
+
new X3DFieldDefinition (X3DConstants .inputOutput, "loa", new Fields .SFInt32 (-1)),
|
|
424
555
|
new X3DFieldDefinition (X3DConstants .inputOutput, "translation", new Fields .SFVec3f ()),
|
|
425
556
|
new X3DFieldDefinition (X3DConstants .inputOutput, "rotation", new Fields .SFRotation ()),
|
|
426
557
|
new X3DFieldDefinition (X3DConstants .inputOutput, "scale", new Fields .SFVec3f (1, 1, 1)),
|
|
@@ -430,8 +561,6 @@ Object .defineProperties (HAnimHumanoid,
|
|
|
430
561
|
new X3DFieldDefinition (X3DConstants .inputOutput, "bboxDisplay", new Fields .SFBool ()),
|
|
431
562
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxSize", new Fields .SFVec3f (-1, -1, -1)),
|
|
432
563
|
new X3DFieldDefinition (X3DConstants .initializeOnly, "bboxCenter", new Fields .SFVec3f ()),
|
|
433
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "loa", new Fields .SFInt32 (-1)),
|
|
434
|
-
new X3DFieldDefinition (X3DConstants .inputOutput, "skeletalConfiguration", new Fields .SFString ("BASIC")),
|
|
435
564
|
new X3DFieldDefinition (X3DConstants .inputOutput, "skeleton", new Fields .MFNode ()),
|
|
436
565
|
new X3DFieldDefinition (X3DConstants .inputOutput, "viewpoints", new Fields .MFNode ()),
|
|
437
566
|
new X3DFieldDefinition (X3DConstants .inputOutput, "sites", new Fields .MFNode ()),
|
|
@@ -452,4 +581,28 @@ Object .defineProperties (HAnimHumanoid,
|
|
|
452
581
|
},
|
|
453
582
|
});
|
|
454
583
|
|
|
584
|
+
class Lock
|
|
585
|
+
{
|
|
586
|
+
#locked = true;
|
|
587
|
+
|
|
588
|
+
enable ()
|
|
589
|
+
{
|
|
590
|
+
this .#locked = false;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
lock ()
|
|
594
|
+
{
|
|
595
|
+
const locked = this .#locked;
|
|
596
|
+
|
|
597
|
+
this .#locked = true;
|
|
598
|
+
|
|
599
|
+
return locked;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function even (value)
|
|
604
|
+
{
|
|
605
|
+
return value + value % 2;
|
|
606
|
+
}
|
|
607
|
+
|
|
455
608
|
export default HAnimHumanoid;
|