x_ite 8.6.17 → 8.6.19
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/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 +28 -28
- package/dist/assets/components/CubeMapTexturing.min.js +1 -1
- package/dist/assets/components/DIS.js +13 -21
- 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 -39
- package/dist/assets/components/Geospatial.min.js +1 -1
- package/dist/assets/components/HAnim.js +18 -18
- package/dist/assets/components/HAnim.min.js +1 -1
- package/dist/assets/components/KeyDeviceSensor.js +8 -8
- package/dist/assets/components/KeyDeviceSensor.min.js +1 -1
- package/dist/assets/components/Layout.js +27 -27
- package/dist/assets/components/Layout.min.js +1 -1
- package/dist/assets/components/NURBS.js +24 -24
- package/dist/assets/components/NURBS.min.js +1 -1
- package/dist/assets/components/ParticleSystems.js +23 -25
- package/dist/assets/components/ParticleSystems.min.js +1 -1
- package/dist/assets/components/Picking.js +25 -26
- package/dist/assets/components/Picking.min.js +1 -1
- package/dist/assets/components/RigidBodyPhysics.js +20 -20
- package/dist/assets/components/RigidBodyPhysics.min.js +1 -1
- package/dist/assets/components/Scripting.js +121 -195
- package/dist/assets/components/Scripting.min.js +1 -1
- package/dist/assets/components/Text.js +30 -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 +174 -174
- package/dist/assets/components/Texturing3D.min.js +1 -1
- package/dist/assets/components/VolumeRendering.js +35 -33
- 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/example.html +1 -1
- package/dist/x_ite.css +1 -1
- package/dist/x_ite.js +512 -519
- package/dist/x_ite.min.js +1 -1
- package/dist/x_ite.zip +0 -0
- package/docs/_config.yml +1 -1
- package/docs/_posts/getting-started.md +1 -1
- package/docs/_posts/reference/prototype-services.md +2 -2
- package/docs/_posts/setup-a-localhost-server.md +2 -2
- package/package.json +4 -4
- package/src/example.html +1 -1
- package/src/standard/Math/Algorithm.js +1 -1
- package/src/standard/Math/Algorithms/MergeSort.js +7 -5
- package/src/standard/Math/Algorithms/PartialSort.js +3 -1
- package/src/standard/Math/Algorithms/QuickSort.js +1 -3
- package/src/standard/Math/Geometry/Box2.js +1 -1
- package/src/standard/Math/Geometry/Box3.js +1 -1
- package/src/standard/Math/Numbers/Quaternion.js +4 -3
- package/src/standard/Math/Numbers/Rotation4.js +4 -3
- package/src/x_ite/Base/X3DBaseNode.js +9 -24
- package/src/x_ite/Base/X3DEventObject.js +4 -3
- package/src/x_ite/Base/X3DField.js +19 -20
- package/src/x_ite/Base/X3DObject.js +5 -1
- package/src/x_ite/Base/X3DObjectArrayField.js +12 -11
- package/src/x_ite/Base/X3DTypedArrayField.js +3 -3
- package/src/x_ite/Browser/Core/Context.js +1 -1
- package/src/x_ite/Browser/Navigation/ExamineViewer.js +1 -1
- package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +14 -9
- package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +2 -2
- package/src/x_ite/Browser/VERSION.js +1 -1
- package/src/x_ite/Browser/VolumeRendering/X3DVolumeRenderingContext.js +2 -2
- package/src/x_ite/Browser/X3DBrowser.js +44 -77
- package/src/x_ite/Browser/X3DBrowserContext.js +3 -3
- package/src/x_ite/Components/Core/X3DNode.js +2 -2
- package/src/x_ite/Components/Core/X3DPrototypeInstance.js +3 -8
- package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +3 -3
- package/src/x_ite/Components/DIS/DISEntityTypeMapping.js +0 -8
- package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +14 -12
- package/src/x_ite/Components/EnvironmentalSensor/TransformSensor.js +3 -3
- package/src/x_ite/Components/EnvironmentalSensor/VisibilitySensor.js +1 -1
- package/src/x_ite/Components/EnvironmentalSensor/X3DEnvironmentalSensorNode.js +1 -1
- package/src/x_ite/Components/Geospatial/GeoMetadata.js +0 -6
- package/src/x_ite/Components/Networking/Anchor.js +36 -33
- package/src/x_ite/Components/Networking/Inline.js +3 -3
- package/src/x_ite/Components/Networking/X3DUrlObject.js +74 -23
- package/src/x_ite/Components/Picking/X3DPickSensorNode.js +6 -5
- package/src/x_ite/Components/RigidBodyPhysics/CollisionSensor.js +2 -2
- package/src/x_ite/Components/Scripting/Script.js +93 -167
- package/src/x_ite/Components/Shaders/ComposedShader.js +3 -18
- package/src/x_ite/Components/Shaders/PackagedShader.js +0 -2
- package/src/x_ite/Components/Shaders/ShaderPart.js +4 -4
- package/src/x_ite/Components/Shaders/ShaderProgram.js +0 -2
- package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +4 -5
- package/src/x_ite/Components/Sound/AudioClip.js +6 -6
- package/src/x_ite/Components/Sound/DynamicsCompressor.js +4 -4
- package/src/x_ite/Components/Text/Text.js +2 -3
- package/src/x_ite/Components/Text/X3DFontStyleNode.js +4 -4
- package/src/x_ite/Components/Texturing/ImageTexture.js +3 -3
- package/src/x_ite/Components/Texturing/MovieTexture.js +6 -6
- package/src/x_ite/Components/Texturing3D/ImageTexture3D.js +3 -3
- package/src/x_ite/Components/Texturing3D/ImageTextureAtlas.js +3 -3
- package/src/x_ite/Components/Time/X3DTimeDependentNode.js +31 -25
- package/src/x_ite/Components/VolumeRendering/IsoSurfaceVolumeData.js +1 -1
- package/src/x_ite/Components/VolumeRendering/SegmentedVolumeData.js +1 -1
- package/src/x_ite/Components/VolumeRendering/VolumeData.js +1 -1
- package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +11 -9
- package/src/x_ite/Execution/Scene.js +1 -1
- package/src/x_ite/Execution/X3DExecutionContext.js +30 -32
- package/src/x_ite/Execution/X3DScene.js +6 -6
- package/src/x_ite/Fields/ArrayFields.js +2 -1
- package/src/x_ite/Fields/SFImage.js +0 -1
- package/src/x_ite/Fields/SFNode.js +9 -8
- package/src/x_ite/Fields/SFRotation.js +2 -4
- package/src/x_ite/Fields/SFVecPrototypeTemplate.js +3 -3
- package/src/x_ite/InputOutput/FileLoader.js +3 -4
- package/src/x_ite/InputOutput/Generator.js +1 -1
- package/src/x_ite/Parser/GLTF2Parser.js +45 -45
- package/src/x_ite/Parser/VRMLParser.js +2 -2
- package/src/x_ite/Parser/X3DParser.js +4 -4
- package/src/x_ite/Parser/XMLParser.js +16 -22
- package/src/x_ite/Prototype/X3DExternProtoDeclaration.js +2 -2
- package/src/x_ite/Prototype/X3DProtoDeclarationNode.js +1 -1
- package/docs/_tabs/imprint.md +0 -52
|
@@ -45,8 +45,9 @@
|
|
|
45
45
|
*
|
|
46
46
|
******************************************************************************/
|
|
47
47
|
|
|
48
|
-
import Fields
|
|
49
|
-
import X3DConstants
|
|
48
|
+
import Fields from "../../Fields.js";
|
|
49
|
+
import X3DConstants from "../../Base/X3DConstants.js";
|
|
50
|
+
import X3DProtoDeclaration from "../../Prototype/X3DProtoDeclaration.js";
|
|
50
51
|
|
|
51
52
|
const
|
|
52
53
|
_cache = Symbol (),
|
|
@@ -59,7 +60,7 @@ function X3DUrlObject (executionContext)
|
|
|
59
60
|
this .addType (X3DConstants .X3DUrlObject);
|
|
60
61
|
|
|
61
62
|
this .addChildObjects ("loadState", new Fields .SFInt32 (X3DConstants .NOT_STARTED_STATE),
|
|
62
|
-
"
|
|
63
|
+
"loadData", new Fields .SFTime ());
|
|
63
64
|
|
|
64
65
|
this [_cache] = true;
|
|
65
66
|
this [_autoRefreshStartTime] = Date .now ();
|
|
@@ -74,7 +75,7 @@ X3DUrlObject .prototype =
|
|
|
74
75
|
|
|
75
76
|
this ._load .addInterest ("set_load__", this);
|
|
76
77
|
this ._url .addInterest ("set_url__", this);
|
|
77
|
-
this .
|
|
78
|
+
this ._loadData .addInterest ("loadData", this);
|
|
78
79
|
this ._autoRefresh .addInterest ("set_autoRefresh__", this);
|
|
79
80
|
this ._autoRefreshTimeLimit .addInterest ("set_autoRefresh__", this);
|
|
80
81
|
},
|
|
@@ -126,27 +127,73 @@ X3DUrlObject .prototype =
|
|
|
126
127
|
},
|
|
127
128
|
requestImmediateLoad: function (cache = true)
|
|
128
129
|
{
|
|
129
|
-
|
|
130
|
+
return new Promise ((resolve, reject) =>
|
|
131
|
+
{
|
|
132
|
+
const loading = () =>
|
|
133
|
+
{
|
|
134
|
+
const _loading = Symbol ();
|
|
130
135
|
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
this ._loadState .addFieldCallback (_loading, () =>
|
|
137
|
+
{
|
|
138
|
+
switch (this .checkLoadState ())
|
|
139
|
+
{
|
|
140
|
+
case X3DConstants .COMPLETE_STATE:
|
|
141
|
+
this ._loadState .removeFieldCallback (_loading);
|
|
142
|
+
resolve ();
|
|
143
|
+
break;
|
|
144
|
+
case X3DConstants .FAILED_STATE:
|
|
145
|
+
this ._loadState .removeFieldCallback (_loading);
|
|
146
|
+
reject ();
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
};
|
|
133
151
|
|
|
134
|
-
|
|
135
|
-
return;
|
|
152
|
+
const loadState = this .checkLoadState ();
|
|
136
153
|
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
if (loadState === X3DConstants .COMPLETE_STATE)
|
|
155
|
+
{
|
|
156
|
+
resolve ();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
139
159
|
|
|
140
|
-
|
|
141
|
-
|
|
160
|
+
if (loadState === X3DConstants .IN_PROGRESS_STATE)
|
|
161
|
+
{
|
|
162
|
+
loading ();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
142
165
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
166
|
+
if (!this ._load .getValue ())
|
|
167
|
+
{
|
|
168
|
+
reject ();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (this ._url .length === 0)
|
|
173
|
+
{
|
|
174
|
+
resolve ();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this .setCache (cache);
|
|
179
|
+
this .setLoadState (X3DConstants .IN_PROGRESS_STATE);
|
|
180
|
+
|
|
181
|
+
if (this .isInitialized ())
|
|
182
|
+
// Buffer prevents double load of the scene if load and url field are set at the same time.
|
|
183
|
+
this ._loadData = this .getBrowser () .getCurrentTime ();
|
|
184
|
+
else
|
|
185
|
+
this .loadData ();
|
|
186
|
+
|
|
187
|
+
loading ();
|
|
188
|
+
});
|
|
148
189
|
},
|
|
149
190
|
loadNow: function ()
|
|
191
|
+
{
|
|
192
|
+
this .setLoadState (X3DConstants .NOT_STARTED_STATE);
|
|
193
|
+
|
|
194
|
+
return this .requestImmediateLoad ();
|
|
195
|
+
},
|
|
196
|
+
loadData: function ()
|
|
150
197
|
{ },
|
|
151
198
|
requestUnload: function ()
|
|
152
199
|
{
|
|
@@ -156,9 +203,13 @@ X3DUrlObject .prototype =
|
|
|
156
203
|
return;
|
|
157
204
|
|
|
158
205
|
this .setLoadState (X3DConstants .NOT_STARTED_STATE);
|
|
159
|
-
this .
|
|
206
|
+
this .unloadData ();
|
|
207
|
+
},
|
|
208
|
+
unloadNow: function ()
|
|
209
|
+
{
|
|
210
|
+
this .requestUnload ();
|
|
160
211
|
},
|
|
161
|
-
|
|
212
|
+
unloadData: function ()
|
|
162
213
|
{ },
|
|
163
214
|
setAutoRefreshTimer: function (autoRefreshInterval)
|
|
164
215
|
{
|
|
@@ -180,7 +231,7 @@ X3DUrlObject .prototype =
|
|
|
180
231
|
performAutoRefresh: function ()
|
|
181
232
|
{
|
|
182
233
|
this .setLoadState (X3DConstants .NOT_STARTED_STATE);
|
|
183
|
-
this .requestImmediateLoad (false);
|
|
234
|
+
this .requestImmediateLoad (false) .catch (Function .prototype);
|
|
184
235
|
},
|
|
185
236
|
set_live__: function ()
|
|
186
237
|
{
|
|
@@ -192,7 +243,7 @@ X3DUrlObject .prototype =
|
|
|
192
243
|
set_load__: function ()
|
|
193
244
|
{
|
|
194
245
|
if (this ._load .getValue ())
|
|
195
|
-
this .requestImmediateLoad ();
|
|
246
|
+
this .requestImmediateLoad () .catch (Function .prototype);
|
|
196
247
|
else
|
|
197
248
|
this .requestUnload ();
|
|
198
249
|
},
|
|
@@ -202,7 +253,7 @@ X3DUrlObject .prototype =
|
|
|
202
253
|
return;
|
|
203
254
|
|
|
204
255
|
this .setLoadState (X3DConstants .NOT_STARTED_STATE);
|
|
205
|
-
this .requestImmediateLoad ();
|
|
256
|
+
this .requestImmediateLoad () .catch (Function .prototype);
|
|
206
257
|
},
|
|
207
258
|
set_autoRefresh__: function ()
|
|
208
259
|
{
|
|
@@ -124,18 +124,19 @@ X3DPickSensorNode .prototype = Object .assign (Object .create (X3DSensorNode .pr
|
|
|
124
124
|
},
|
|
125
125
|
getPickShape: (function ()
|
|
126
126
|
{
|
|
127
|
-
|
|
127
|
+
const pickShapes = new WeakMap ();
|
|
128
128
|
|
|
129
129
|
return function (geometryNode)
|
|
130
130
|
{
|
|
131
|
-
|
|
131
|
+
const pickShape = pickShapes .get (geometryNode);
|
|
132
132
|
|
|
133
133
|
if (pickShape !== undefined)
|
|
134
134
|
return pickShape;
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
const
|
|
137
|
+
browser = this .getBrowser (),
|
|
138
|
+
shapeNode = browser .getPrivateScene () .createNode ("Shape", false),
|
|
139
|
+
collidableShapeNode = browser .getPrivateScene () .createNode ("CollidableShape", false);
|
|
139
140
|
|
|
140
141
|
shapeNode .setPrivate (true);
|
|
141
142
|
collidableShapeNode .setPrivate (true);
|
|
@@ -259,12 +259,12 @@ CollisionSensor .prototype = Object .assign (Object .create (X3DSensorNode .prot
|
|
|
259
259
|
})(),
|
|
260
260
|
getContact: function (index)
|
|
261
261
|
{
|
|
262
|
-
|
|
262
|
+
const contactNode = this .contactCache [index];
|
|
263
263
|
|
|
264
264
|
if (contactNode)
|
|
265
265
|
return contactNode;
|
|
266
266
|
|
|
267
|
-
contactNode = this .contactCache [index] = this .getExecutionContext () .createNode ("Contact",
|
|
267
|
+
contactNode = this .contactCache [index] = this .getExecutionContext () .createNode ("Contact", false);
|
|
268
268
|
|
|
269
269
|
contactNode .setup ();
|
|
270
270
|
|
|
@@ -75,8 +75,6 @@ function Script (executionContext)
|
|
|
75
75
|
X3DScriptNode .call (this, executionContext);
|
|
76
76
|
|
|
77
77
|
this .addType (X3DConstants .Script);
|
|
78
|
-
|
|
79
|
-
this .pauseTime = 0;
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
@@ -112,10 +110,7 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
112
110
|
{
|
|
113
111
|
X3DScriptNode .prototype .initialize .call (this);
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
field .setModificationTime (0);
|
|
117
|
-
|
|
118
|
-
this .requestImmediateLoad ();
|
|
113
|
+
this .requestImmediateLoad () .catch (Function .prototype);
|
|
119
114
|
},
|
|
120
115
|
getExtendedEventHandling: function ()
|
|
121
116
|
{
|
|
@@ -129,36 +124,35 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
129
124
|
{
|
|
130
125
|
X3DScriptNode .prototype .addUserDefinedField .call (this, accessType, name, field);
|
|
131
126
|
|
|
132
|
-
if (!
|
|
127
|
+
if (!this .isInitialized ())
|
|
133
128
|
return;
|
|
134
129
|
|
|
135
130
|
this .setLoadState (X3DConstants .NOT_STARTED_STATE);
|
|
136
|
-
this .requestImmediateLoad ();
|
|
131
|
+
this .requestImmediateLoad () .catch (Function .prototype);
|
|
137
132
|
},
|
|
138
133
|
removeUserDefinedField: function (name)
|
|
139
134
|
{
|
|
135
|
+
this .getUserDefinedFields () .get (name) ?.removeInterest ("set_field__", this);
|
|
136
|
+
|
|
140
137
|
X3DScriptNode .prototype .removeUserDefinedField .call (this, name);
|
|
141
138
|
|
|
142
|
-
if (!
|
|
139
|
+
if (!this .isInitialized ())
|
|
143
140
|
return;
|
|
144
141
|
|
|
145
142
|
this .setLoadState (X3DConstants .NOT_STARTED_STATE);
|
|
146
|
-
this .requestImmediateLoad ();
|
|
143
|
+
this .requestImmediateLoad () .catch (Function .prototype);
|
|
147
144
|
},
|
|
148
145
|
getSourceText: function ()
|
|
149
146
|
{
|
|
150
147
|
return this ._url;
|
|
151
148
|
},
|
|
152
|
-
|
|
149
|
+
unloadData: function ()
|
|
153
150
|
{
|
|
154
151
|
this .initialize__ ("");
|
|
155
152
|
},
|
|
156
|
-
|
|
153
|
+
loadData: function ()
|
|
157
154
|
{
|
|
158
|
-
this .
|
|
159
|
-
|
|
160
|
-
new FileLoader (this) .loadDocument (this ._url,
|
|
161
|
-
function (data)
|
|
155
|
+
new FileLoader (this) .loadDocument (this ._url, (data) =>
|
|
162
156
|
{
|
|
163
157
|
if (data === null)
|
|
164
158
|
{
|
|
@@ -167,13 +161,12 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
167
161
|
}
|
|
168
162
|
else
|
|
169
163
|
{
|
|
170
|
-
this .setLoadState (X3DConstants .COMPLETE_STATE);
|
|
171
164
|
this .initialize__ ($.decodeText (data));
|
|
165
|
+
this .setLoadState (X3DConstants .COMPLETE_STATE);
|
|
172
166
|
}
|
|
173
|
-
}
|
|
174
|
-
.bind (this));
|
|
167
|
+
});
|
|
175
168
|
},
|
|
176
|
-
getContext: function (
|
|
169
|
+
getContext: function (sourceText)
|
|
177
170
|
{
|
|
178
171
|
try
|
|
179
172
|
{
|
|
@@ -192,20 +185,20 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
192
185
|
}
|
|
193
186
|
}
|
|
194
187
|
|
|
195
|
-
|
|
188
|
+
sourceText += "\nreturn [" + callbacks .map (function (c)
|
|
196
189
|
{
|
|
197
190
|
return `typeof ${c} !== "undefined" ? ${c} : undefined`;
|
|
198
191
|
})
|
|
199
192
|
.join (",") + "];";
|
|
200
193
|
|
|
201
|
-
this .
|
|
194
|
+
this .globalObject = this .getGlobalObject ();
|
|
202
195
|
|
|
203
196
|
const
|
|
204
|
-
result = evaluate (this .
|
|
205
|
-
context =
|
|
197
|
+
result = evaluate (this .globalObject, sourceText),
|
|
198
|
+
context = new Map ();
|
|
206
199
|
|
|
207
200
|
for (let i = 0; i < callbacks .length; ++ i)
|
|
208
|
-
context
|
|
201
|
+
context .set (callbacks [i], result [i]);
|
|
209
202
|
|
|
210
203
|
return context;
|
|
211
204
|
}
|
|
@@ -213,14 +206,14 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
213
206
|
{
|
|
214
207
|
this .setError ("while evaluating script source", error);
|
|
215
208
|
|
|
216
|
-
return
|
|
209
|
+
return new Map ();
|
|
217
210
|
}
|
|
218
211
|
},
|
|
219
|
-
evaluate: function (
|
|
212
|
+
evaluate: function (sourceText)
|
|
220
213
|
{
|
|
221
|
-
return evaluate (this .
|
|
214
|
+
return evaluate (this .globalObject, `return (${sourceText})`);
|
|
222
215
|
},
|
|
223
|
-
|
|
216
|
+
getGlobalObject: function ()
|
|
224
217
|
{
|
|
225
218
|
const
|
|
226
219
|
browser = this .getBrowser (),
|
|
@@ -249,7 +242,7 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
249
242
|
|
|
250
243
|
SFNode .prototype = Fields .SFNode .prototype;
|
|
251
244
|
|
|
252
|
-
const
|
|
245
|
+
const globalObject =
|
|
253
246
|
{
|
|
254
247
|
NULL: { value: null },
|
|
255
248
|
FALSE: { value: false },
|
|
@@ -329,9 +322,9 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
329
322
|
if (field .getAccessType () === X3DConstants .inputOnly)
|
|
330
323
|
continue;
|
|
331
324
|
|
|
332
|
-
if (!
|
|
325
|
+
if (!(name in globalObject))
|
|
333
326
|
{
|
|
334
|
-
|
|
327
|
+
globalObject [name] =
|
|
335
328
|
{
|
|
336
329
|
get: field .valueOf .bind (field),
|
|
337
330
|
set: field .setValue .bind (field),
|
|
@@ -340,7 +333,7 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
340
333
|
|
|
341
334
|
if (field .getAccessType () === X3DConstants .inputOutput)
|
|
342
335
|
{
|
|
343
|
-
|
|
336
|
+
globalObject [name + "_changed"] =
|
|
344
337
|
{
|
|
345
338
|
get: field .valueOf .bind (field),
|
|
346
339
|
set: field .setValue .bind (field),
|
|
@@ -348,138 +341,74 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
348
341
|
}
|
|
349
342
|
}
|
|
350
343
|
|
|
351
|
-
return Object .create (Object .prototype,
|
|
344
|
+
return Object .create (Object .prototype, globalObject);
|
|
352
345
|
},
|
|
353
|
-
|
|
346
|
+
initialize__: function (sourceText)
|
|
354
347
|
{
|
|
355
|
-
|
|
356
|
-
{
|
|
357
|
-
if (field .getModificationTime () <= this .pauseTime)
|
|
358
|
-
continue;
|
|
348
|
+
this .disconnect ();
|
|
359
349
|
|
|
360
|
-
|
|
361
|
-
{
|
|
362
|
-
case X3DConstants .inputOnly:
|
|
363
|
-
{
|
|
364
|
-
const callback = this .context [field .getName ()];
|
|
350
|
+
const browser = this .getBrowser ();
|
|
365
351
|
|
|
366
|
-
|
|
367
|
-
this .set_field__ (callback, field);
|
|
352
|
+
// Create context.
|
|
368
353
|
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
case X3DConstants .inputOutput:
|
|
372
|
-
{
|
|
373
|
-
const callback = this .context ["set_" + field .getName ()];
|
|
354
|
+
this .context = this .getContext (sourceText);
|
|
374
355
|
|
|
375
|
-
|
|
376
|
-
this .set_field__ (callback, field);
|
|
356
|
+
// Call initialize function.
|
|
377
357
|
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
initialize__: function (text)
|
|
384
|
-
{
|
|
385
|
-
this .context = this .getContext (text);
|
|
358
|
+
const initialize = this .context .get ("initialize");
|
|
386
359
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
set_live__: function ()
|
|
390
|
-
{
|
|
391
|
-
X3DScriptNode .prototype .set_live__ .call (this);
|
|
360
|
+
if (typeof initialize === "function")
|
|
361
|
+
this .call__ (initialize, "initialize");
|
|
392
362
|
|
|
393
|
-
|
|
394
|
-
return;
|
|
363
|
+
// Connect shutdown.
|
|
395
364
|
|
|
396
|
-
|
|
397
|
-
{
|
|
398
|
-
if (!this .initialized)
|
|
399
|
-
{
|
|
400
|
-
this .initialized = true;
|
|
365
|
+
const shutdown = this .context .get ("shutdown");
|
|
401
366
|
|
|
402
|
-
|
|
367
|
+
if (typeof shutdown === "function")
|
|
368
|
+
$(window) .on ("unload.Script" + this .getId (), this .call__ .bind (this, shutdown, "shutdown"));
|
|
403
369
|
|
|
404
|
-
|
|
405
|
-
{
|
|
406
|
-
const browser = this .getBrowser ();
|
|
370
|
+
// Connect prepareEvents.
|
|
407
371
|
|
|
408
|
-
|
|
372
|
+
const prepareEvents = this .context .get ("prepareEvents");
|
|
409
373
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this .context .initialize ();
|
|
413
|
-
}
|
|
414
|
-
catch (error)
|
|
415
|
-
{
|
|
416
|
-
this .setError ("in function 'initialize'", error);
|
|
417
|
-
}
|
|
374
|
+
if (typeof prepareEvents === "function")
|
|
375
|
+
browser .prepareEvents () .addInterest ("call__", this, prepareEvents, "prepareEvents");
|
|
418
376
|
|
|
419
|
-
|
|
420
|
-
}
|
|
377
|
+
// Connect eventsProcessed.
|
|
421
378
|
|
|
422
|
-
|
|
423
|
-
$(window) .on ("unload", this .shutdown__ .bind (this));
|
|
424
|
-
}
|
|
379
|
+
const eventsProcessed = this .context .get ("eventsProcessed");
|
|
425
380
|
|
|
426
|
-
|
|
427
|
-
|
|
381
|
+
if (typeof eventsProcessed === "function")
|
|
382
|
+
this .addInterest ("call__", this, eventsProcessed, "eventsProcessed");
|
|
428
383
|
|
|
429
|
-
|
|
430
|
-
this .addInterest ("eventsProcessed__", this);
|
|
384
|
+
// Connect fields.
|
|
431
385
|
|
|
432
|
-
|
|
386
|
+
for (const field of this .getUserDefinedFields ())
|
|
387
|
+
{
|
|
388
|
+
switch (field .getAccessType ())
|
|
433
389
|
{
|
|
434
|
-
|
|
390
|
+
case X3DConstants .inputOnly:
|
|
435
391
|
{
|
|
436
|
-
|
|
437
|
-
{
|
|
438
|
-
const callback = this .context [field .getName ()];
|
|
439
|
-
|
|
440
|
-
if (typeof callback === "function")
|
|
441
|
-
field .addInterest ("set_field__", this, callback);
|
|
392
|
+
const callback = this .context .get (field .getName ());
|
|
442
393
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
case X3DConstants .inputOutput:
|
|
446
|
-
{
|
|
447
|
-
const callback = this .context ["set_" + field .getName ()];
|
|
448
|
-
|
|
449
|
-
if (typeof callback === "function")
|
|
450
|
-
field .addInterest ("set_field__", this, callback);
|
|
394
|
+
if (typeof callback === "function")
|
|
395
|
+
field .addInterest ("set_field__", this, callback);
|
|
451
396
|
|
|
452
|
-
|
|
453
|
-
}
|
|
397
|
+
break;
|
|
454
398
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
else
|
|
460
|
-
{
|
|
461
|
-
if (this .context .prepareEvents)
|
|
462
|
-
this .getBrowser () .prepareEvents () .removeInterest ("prepareEvents__", this);
|
|
399
|
+
case X3DConstants .inputOutput:
|
|
400
|
+
{
|
|
401
|
+
const callback = this .context .get ("set_" + field .getName ());
|
|
463
402
|
|
|
464
|
-
|
|
465
|
-
|
|
403
|
+
if (typeof callback === "function")
|
|
404
|
+
field .addInterest ("set_field__", this, callback);
|
|
466
405
|
|
|
467
|
-
|
|
468
|
-
{
|
|
469
|
-
switch (field .getAccessType ())
|
|
470
|
-
{
|
|
471
|
-
case X3DConstants .inputOnly:
|
|
472
|
-
case X3DConstants .inputOutput:
|
|
473
|
-
field .removeInterest ("set_field__", this);
|
|
474
|
-
break;
|
|
406
|
+
break;
|
|
475
407
|
}
|
|
476
408
|
}
|
|
477
|
-
|
|
478
|
-
if (this .initialized)
|
|
479
|
-
this .pauseTime = Date .now ();
|
|
480
409
|
}
|
|
481
410
|
},
|
|
482
|
-
|
|
411
|
+
call__: function (callback, name)
|
|
483
412
|
{
|
|
484
413
|
const browser = this .getBrowser ();
|
|
485
414
|
|
|
@@ -487,12 +416,11 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
487
416
|
|
|
488
417
|
try
|
|
489
418
|
{
|
|
490
|
-
|
|
491
|
-
browser .addBrowserEvent ();
|
|
419
|
+
callback (browser .getCurrentTime ());
|
|
492
420
|
}
|
|
493
421
|
catch (error)
|
|
494
422
|
{
|
|
495
|
-
this .setError (
|
|
423
|
+
this .setError (`in function '${name}'`, error);
|
|
496
424
|
}
|
|
497
425
|
|
|
498
426
|
browser .getScriptStack () .pop ();
|
|
@@ -516,44 +444,42 @@ Script .prototype = Object .assign (Object .create (X3DScriptNode .prototype),
|
|
|
516
444
|
browser .getScriptStack () .pop ();
|
|
517
445
|
field .setTainted (false);
|
|
518
446
|
},
|
|
519
|
-
|
|
447
|
+
setError: function (reason, error)
|
|
520
448
|
{
|
|
521
|
-
|
|
449
|
+
console .error ("JavaScript Error in Script '" + this .getName () + "', " + reason + "\nworld url is '" + this .getExecutionContext () .getWorldURL () + "':");
|
|
450
|
+
console .error (error);
|
|
451
|
+
},
|
|
452
|
+
disconnect: function ()
|
|
453
|
+
{
|
|
454
|
+
// Call shutdown.
|
|
522
455
|
|
|
523
|
-
|
|
456
|
+
const shutdown = this .context ?.get ("shutdown");
|
|
524
457
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
this .context .eventsProcessed ();
|
|
528
|
-
}
|
|
529
|
-
catch (error)
|
|
530
|
-
{
|
|
531
|
-
this .setError ("in function 'eventsProcessed'", error);
|
|
532
|
-
}
|
|
458
|
+
if (typeof shutdown === "function")
|
|
459
|
+
this .call__ (shutdown, "shutdown");
|
|
533
460
|
|
|
534
|
-
|
|
535
|
-
},
|
|
536
|
-
shutdown__: function ()
|
|
537
|
-
{
|
|
538
|
-
const browser = this .getBrowser ();
|
|
461
|
+
// Disconnect shutdown.
|
|
539
462
|
|
|
540
|
-
|
|
463
|
+
$(window) .off (".Script" + this .getId ());
|
|
541
464
|
|
|
542
|
-
|
|
543
|
-
{
|
|
544
|
-
this .context .shutdown ();
|
|
545
|
-
}
|
|
546
|
-
catch (error)
|
|
547
|
-
{
|
|
548
|
-
this .setError ("in function 'shutdown'", error);
|
|
549
|
-
}
|
|
465
|
+
// Disconnect prepareEvents.
|
|
550
466
|
|
|
551
|
-
|
|
467
|
+
this .getBrowser () .prepareEvents () .removeInterest ("call__", this);
|
|
468
|
+
|
|
469
|
+
// Disconnect eventsProcessed.
|
|
470
|
+
|
|
471
|
+
this .removeInterest ("call__", this);
|
|
472
|
+
|
|
473
|
+
// Disconnect fields.
|
|
474
|
+
|
|
475
|
+
for (const field of this .getUserDefinedFields ())
|
|
476
|
+
field .removeInterest ("set_field__", this);
|
|
552
477
|
},
|
|
553
|
-
|
|
478
|
+
dispose: function ()
|
|
554
479
|
{
|
|
555
|
-
|
|
556
|
-
|
|
480
|
+
this .disconnect ();
|
|
481
|
+
|
|
482
|
+
X3DScriptNode .prototype .dispose .call (this);
|
|
557
483
|
},
|
|
558
484
|
});
|
|
559
485
|
|
|
@@ -99,8 +99,6 @@ ComposedShader .prototype = Object .assign (Object .create (X3DShaderNode .proto
|
|
|
99
99
|
X3DShaderNode .prototype .initialize .call (this);
|
|
100
100
|
X3DProgrammableShaderObject .prototype .initialize .call (this);
|
|
101
101
|
|
|
102
|
-
this .getLive () .addInterest ("set_live__", this);
|
|
103
|
-
|
|
104
102
|
// https://www.web3d.org/documents/specifications/19775-1/V4.0/Part01/shaders_glsl.html#relinkingprograms
|
|
105
103
|
this ._activate .addInterest ("set_activate__", this);
|
|
106
104
|
|
|
@@ -123,7 +121,7 @@ ComposedShader .prototype = Object .assign (Object .create (X3DShaderNode .proto
|
|
|
123
121
|
},
|
|
124
122
|
addUserDefinedField: function (accessType, name, field)
|
|
125
123
|
{
|
|
126
|
-
const shaderFields = this .isInitialized () && this .
|
|
124
|
+
const shaderFields = this .isInitialized () && this .isValid ();
|
|
127
125
|
|
|
128
126
|
if (shaderFields)
|
|
129
127
|
this .removeShaderFields ();
|
|
@@ -135,7 +133,7 @@ ComposedShader .prototype = Object .assign (Object .create (X3DShaderNode .proto
|
|
|
135
133
|
},
|
|
136
134
|
removeUserDefinedField: function (name)
|
|
137
135
|
{
|
|
138
|
-
const shaderFields = this .isInitialized () && this .
|
|
136
|
+
const shaderFields = this .isInitialized () && this .isValid ();
|
|
139
137
|
|
|
140
138
|
if (shaderFields)
|
|
141
139
|
this .removeShaderFields ();
|
|
@@ -153,22 +151,9 @@ ComposedShader .prototype = Object .assign (Object .create (X3DShaderNode .proto
|
|
|
153
151
|
{
|
|
154
152
|
return this .program;
|
|
155
153
|
},
|
|
156
|
-
set_live__: function ()
|
|
157
|
-
{
|
|
158
|
-
if (this .getLive () .getValue ())
|
|
159
|
-
{
|
|
160
|
-
if (this .isValid ())
|
|
161
|
-
this .addShaderFields ();
|
|
162
|
-
}
|
|
163
|
-
else
|
|
164
|
-
{
|
|
165
|
-
if (this .isValid ())
|
|
166
|
-
this .removeShaderFields ();
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
154
|
set_activate__: function ()
|
|
170
155
|
{
|
|
171
|
-
if (!
|
|
156
|
+
if (!this ._activate .getValue ())
|
|
172
157
|
return;
|
|
173
158
|
|
|
174
159
|
this .set_loaded__ ();
|
|
@@ -101,8 +101,6 @@ PackagedShader .prototype = Object .assign (Object .create (X3DShaderNode .proto
|
|
|
101
101
|
},
|
|
102
102
|
requestImmediateLoad: function (cache = true)
|
|
103
103
|
{ },
|
|
104
|
-
requestUnload: function ()
|
|
105
|
-
{ },
|
|
106
104
|
initialize: function ()
|
|
107
105
|
{
|
|
108
106
|
X3DShaderNode .prototype .initialize .call (this);
|