aotrautils 0.0.1839 → 0.0.1841
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.
- aotrautils/aotrautils.build.js +286 -264
- aotrautils/package.json +1 -1
aotrautils/aotrautils.build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (09/04/2026-01:44:04)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -4117,13 +4117,30 @@ window.instanciate=function(className=null){
|
|
|
4117
4117
|
if(className==="Array") return [];
|
|
4118
4118
|
|
|
4119
4119
|
|
|
4120
|
-
|
|
4121
|
-
if(
|
|
4120
|
+
let classInWindow=globalThis[className];
|
|
4121
|
+
if(typeof(classInWindow)=="undefined"){
|
|
4122
4122
|
// TRACE
|
|
4123
|
-
lognow(`WARN : CAUTION : «${className}» class does not seem to be registered in the
|
|
4123
|
+
lognow(`WARN : CAUTION : «${className}» class does not seem to be registered in the globalThis object. This can lead to problems instanciating it in a pure nodejs context.`);
|
|
4124
|
+
classInWindow=window[className];
|
|
4125
|
+
if(typeof(classInWindow)=="undefined"){
|
|
4126
|
+
// TRACE
|
|
4127
|
+
lognow(`WARN : CAUTION : «${className}» class does not seem to be registered in the window object. This can lead to problems instanciating it in a pure nodejs context.`);
|
|
4128
|
+
if(typeof(global)!="undefined"){
|
|
4129
|
+
lognow(`WARN : Trying with global object...`);
|
|
4130
|
+
classInWindow=global[className];
|
|
4131
|
+
if(!classInWindow){
|
|
4132
|
+
// TRACE
|
|
4133
|
+
lognow(`ERROR : CAUTION : «${className}» class does not seem to be registered in the global object. Cannot instanciate it.`);
|
|
4134
|
+
return newObj;
|
|
4135
|
+
}
|
|
4136
|
+
}else{
|
|
4137
|
+
// TRACE
|
|
4138
|
+
lognow(`ERROR : CAUTION : «${className}» class does not seem to be accessible in the globalThis nor window object, and global object does not exist. Cannot instanciate it.`);
|
|
4139
|
+
return newObj;
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4124
4142
|
}
|
|
4125
4143
|
|
|
4126
|
-
|
|
4127
4144
|
// OLD :
|
|
4128
4145
|
// try{
|
|
4129
4146
|
// try{
|
|
@@ -4162,6 +4179,7 @@ window.instanciate=function(className=null){
|
|
|
4162
4179
|
// }
|
|
4163
4180
|
// }
|
|
4164
4181
|
|
|
4182
|
+
// NEW :
|
|
4165
4183
|
newObj=new classInWindow();
|
|
4166
4184
|
return newObj;
|
|
4167
4185
|
};
|
|
@@ -5117,6 +5135,264 @@ window.getPathFileName=(path, fileSeparator="/", removeExtension=false)=>{
|
|
|
5117
5135
|
}
|
|
5118
5136
|
|
|
5119
5137
|
|
|
5138
|
+
// -------------------------------------------------------------------------
|
|
5139
|
+
// ====================================================== ROUTINES ======================================================
|
|
5140
|
+
|
|
5141
|
+
|
|
5142
|
+
// ======================== Timeout ========================
|
|
5143
|
+
|
|
5144
|
+
// CAUTION : This is not a routine, but a single-use timeout !
|
|
5145
|
+
window.MonoThreadedTimeout=class {
|
|
5146
|
+
constructor(actuator, delayMillis){
|
|
5147
|
+
this.actuator=actuator;
|
|
5148
|
+
}
|
|
5149
|
+
start(delayMillis=null){
|
|
5150
|
+
this.started=true;
|
|
5151
|
+
this.time=getNow();
|
|
5152
|
+
this.delayMillis=delayMillis;
|
|
5153
|
+
}
|
|
5154
|
+
doStep(args=null){
|
|
5155
|
+
if(!this.started) return;
|
|
5156
|
+
if(!hasDelayPassed(this.time, this.delayMillis)) return;
|
|
5157
|
+
return this.stop(args);
|
|
5158
|
+
}
|
|
5159
|
+
stop(args=null){
|
|
5160
|
+
if(!this.started) return;
|
|
5161
|
+
this.started=false;
|
|
5162
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5163
|
+
return this;
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
|
|
5167
|
+
window.getMonoThreadedTimeout=function(actuator=null){
|
|
5168
|
+
return new MonoThreadedTimeout(actuator);
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5171
|
+
|
|
5172
|
+
// ======================== Routine ========================
|
|
5173
|
+
|
|
5174
|
+
window.MonoThreadedRoutine=class {
|
|
5175
|
+
constructor(actuator,refreshMillis=null,startDependsOnParentOnly=false){
|
|
5176
|
+
|
|
5177
|
+
this.actuator=actuator;
|
|
5178
|
+
this.startDependsOnParentOnly=startDependsOnParentOnly;
|
|
5179
|
+
this.started=false;
|
|
5180
|
+
this.paused=false;
|
|
5181
|
+
this.time=getNow();
|
|
5182
|
+
this.refreshMillis=refreshMillis;
|
|
5183
|
+
|
|
5184
|
+
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
5185
|
+
// Three-states : started, paused, stopped.
|
|
5186
|
+
|
|
5187
|
+
}
|
|
5188
|
+
|
|
5189
|
+
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
5190
|
+
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
5191
|
+
return this;
|
|
5192
|
+
}
|
|
5193
|
+
isStarted(){
|
|
5194
|
+
return this.started || this.startDependsOnParentOnly;
|
|
5195
|
+
}
|
|
5196
|
+
start(args=null){
|
|
5197
|
+
// if(this.isStarted()) return;
|
|
5198
|
+
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
5199
|
+
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
5200
|
+
// (ie. its stop conditions are fullfilled even before it has started)
|
|
5201
|
+
// we all the same have to trigger its stop treatments :
|
|
5202
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5203
|
+
return;
|
|
5204
|
+
}
|
|
5205
|
+
this.started=true;
|
|
5206
|
+
this.paused=false;
|
|
5207
|
+
return this;
|
|
5208
|
+
}
|
|
5209
|
+
stop(args=null){
|
|
5210
|
+
if(!this.isStarted()) return;
|
|
5211
|
+
this.started=false;
|
|
5212
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5213
|
+
}
|
|
5214
|
+
pause(args=null){
|
|
5215
|
+
this.paused=true;
|
|
5216
|
+
if(this.actuator.doOnSuspend) this.actuator.doOnSuspend(args);
|
|
5217
|
+
}
|
|
5218
|
+
resume(args=null){
|
|
5219
|
+
this.paused=false;
|
|
5220
|
+
if(this.actuator.doOnResume) this.actuator.doOnResume(args);
|
|
5221
|
+
}
|
|
5222
|
+
isPaused(){
|
|
5223
|
+
return this.paused;
|
|
5224
|
+
}
|
|
5225
|
+
doStep(args=null){
|
|
5226
|
+
if(!this.isStarted() || this.paused) return;
|
|
5227
|
+
// Looping index with a delay :
|
|
5228
|
+
|
|
5229
|
+
const delayHasPassed=hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor());
|
|
5230
|
+
if(!this.refreshMillis || delayHasPassed){
|
|
5231
|
+
if(this.refreshMillis && delayHasPassed){
|
|
5232
|
+
this.time=getNow();
|
|
5233
|
+
}
|
|
5234
|
+
// We perform the step :
|
|
5235
|
+
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
5236
|
+
this.stop(args);
|
|
5237
|
+
return;
|
|
5238
|
+
}
|
|
5239
|
+
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
5240
|
+
}
|
|
5241
|
+
|
|
5242
|
+
}
|
|
5243
|
+
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5246
|
+
|
|
5247
|
+
window.getMonoThreadedRoutine=function(actuator, refreshMillis=null, startDependsOnParentOnly=false){
|
|
5248
|
+
return new MonoThreadedRoutine(actuator, refreshMillis, startDependsOnParentOnly);
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5251
|
+
|
|
5252
|
+
window.MonoThreadedGoToGoal=class {
|
|
5253
|
+
constructor(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
5254
|
+
|
|
5255
|
+
this.actuator=actuator;
|
|
5256
|
+
|
|
5257
|
+
this.actualValue=actualValue;
|
|
5258
|
+
this.mode=mode;
|
|
5259
|
+
this.totalTimeMillis=totalTimeMillis;
|
|
5260
|
+
this.stepValue=((refreshMillis*(goalValue-actualValue))/totalTimeMillis);
|
|
5261
|
+
this.value=actualValue;
|
|
5262
|
+
this.goalValue=goalValue;
|
|
5263
|
+
this.started=false;
|
|
5264
|
+
this.paused=false;
|
|
5265
|
+
this.time=getNow();
|
|
5266
|
+
this.refreshMillis=refreshMillis;
|
|
5267
|
+
|
|
5268
|
+
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
5269
|
+
|
|
5270
|
+
// Three-states : started, paused, stopped.
|
|
5271
|
+
}
|
|
5272
|
+
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
5273
|
+
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
5274
|
+
|
|
5275
|
+
// We recalculate total time-dependent values :
|
|
5276
|
+
this.totalTimeMillis=this.totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
5277
|
+
this.stepValue=((this.refreshMillis*(this.goalValue-this.actualValue))/this.totalTimeMillis);
|
|
5278
|
+
|
|
5279
|
+
return this;
|
|
5280
|
+
}
|
|
5281
|
+
isStarted(){
|
|
5282
|
+
return this.started || this.startDependsOnParentOnly;
|
|
5283
|
+
}
|
|
5284
|
+
resetValueAndGoalTo(resetValue){
|
|
5285
|
+
this.value=resetValue;
|
|
5286
|
+
this.goalValue=resetValue;
|
|
5287
|
+
return this;
|
|
5288
|
+
}
|
|
5289
|
+
setNewGoal(goalValue, refreshMillisParam=null, totalTimeMillis=null){
|
|
5290
|
+
if(Math.round(this.value)===Math.round(goalValue)) return;
|
|
5291
|
+
if(refreshMillisParam) this.refreshMillis=refreshMillisParam;
|
|
5292
|
+
if(totalTimeMillis) this.totalTimeMillis=totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
5293
|
+
|
|
5294
|
+
this.goalValue=goalValue;
|
|
5295
|
+
this.stepValue=((this.refreshMillis*(this.goalValue-this.value))/this.totalTimeMillis);
|
|
5296
|
+
|
|
5297
|
+
if(!this.isStarted()) this.start();
|
|
5298
|
+
|
|
5299
|
+
return this;
|
|
5300
|
+
}
|
|
5301
|
+
start(args=null){
|
|
5302
|
+
|
|
5303
|
+
if( this.value===this.goalValue
|
|
5304
|
+
// || this.isStarted();
|
|
5305
|
+
|| (this.actuator.terminateFunction && this.actuator.terminateFunction())
|
|
5306
|
+
|| this.hasReachedGoal()){
|
|
5307
|
+
|
|
5308
|
+
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
5309
|
+
// (ie. its stop conditions are fullfilled even before it has started)
|
|
5310
|
+
// we all the same have to trigger its stop treatments :
|
|
5311
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5312
|
+
|
|
5313
|
+
return;
|
|
5314
|
+
}
|
|
5315
|
+
this.started=true;
|
|
5316
|
+
this.paused=false;
|
|
5317
|
+
|
|
5318
|
+
return this;
|
|
5319
|
+
}
|
|
5320
|
+
stop(args=null){
|
|
5321
|
+
if(!this.isStarted()) return;
|
|
5322
|
+
this.started=false;
|
|
5323
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5324
|
+
}
|
|
5325
|
+
pause(){
|
|
5326
|
+
this.paused=true;
|
|
5327
|
+
}
|
|
5328
|
+
resume(){
|
|
5329
|
+
this.paused=false;
|
|
5330
|
+
}
|
|
5331
|
+
hasReachedGoal(){
|
|
5332
|
+
if(this.stepValue<0){
|
|
5333
|
+
if(this.value<=this.goalValue) return true;
|
|
5334
|
+
}else{
|
|
5335
|
+
if(this.goalValue<=this.value) return true;
|
|
5336
|
+
}
|
|
5337
|
+
return false;
|
|
5338
|
+
}
|
|
5339
|
+
|
|
5340
|
+
doStep(args=null){
|
|
5341
|
+
if(!this.isStarted() || this.paused) return this.value;
|
|
5342
|
+
|
|
5343
|
+
// Looping index with a delay :
|
|
5344
|
+
|
|
5345
|
+
if(!this.refreshMillis || this.hasDelayPassed()){
|
|
5346
|
+
if(this.refreshMillis && this.hasDelayPassed()){
|
|
5347
|
+
this.time=getNow();
|
|
5348
|
+
}
|
|
5349
|
+
|
|
5350
|
+
// We check if we must stop :
|
|
5351
|
+
if(this.actuator.terminateFunction){
|
|
5352
|
+
if(this.actuator.terminateFunction()){
|
|
5353
|
+
this.stop();
|
|
5354
|
+
this.value=this.goalValue;
|
|
5355
|
+
return this.value;
|
|
5356
|
+
}
|
|
5357
|
+
}else{
|
|
5358
|
+
if(this.hasReachedGoal()){
|
|
5359
|
+
this.stop();
|
|
5360
|
+
this.value=this.goalValue;
|
|
5361
|
+
return this.value;
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
5364
|
+
|
|
5365
|
+
// We perform the step :
|
|
5366
|
+
if(this.mode==="exponential"){
|
|
5367
|
+
this.value+=Math.pow(this.stepValue,2);
|
|
5368
|
+
}else{ // default is "linear"
|
|
5369
|
+
this.value+=this.stepValue;
|
|
5370
|
+
}
|
|
5371
|
+
|
|
5372
|
+
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
5373
|
+
}
|
|
5374
|
+
|
|
5375
|
+
return this.value;
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
hasDelayPassed(){
|
|
5379
|
+
return (!this.time || hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor()));
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5382
|
+
|
|
5383
|
+
}
|
|
5384
|
+
|
|
5385
|
+
|
|
5386
|
+
window.getMonoThreadedGoToGoal=function(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
5387
|
+
return new MonoThreadedGoToGoal(actuator,actualValue,goalValue,refreshMillis,totalTimeMillis,mode);
|
|
5388
|
+
}
|
|
5389
|
+
|
|
5390
|
+
|
|
5391
|
+
// =====================================================================================================================
|
|
5392
|
+
|
|
5393
|
+
// -------------------------------------------------------------------------
|
|
5394
|
+
|
|
5395
|
+
|
|
5120
5396
|
|
|
5121
5397
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
5122
5398
|
|
|
@@ -5126,7 +5402,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5126
5402
|
|
|
5127
5403
|
|
|
5128
5404
|
|
|
5129
|
-
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (
|
|
5405
|
+
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (09/04/2026-01:44:04)»*/
|
|
5130
5406
|
/*-----------------------------------------------------------------------------*/
|
|
5131
5407
|
/* ## Utility global methods in a browser (htmljs) client environment.
|
|
5132
5408
|
*
|
|
@@ -9320,260 +9596,6 @@ function getSpriteMonoThreaded(imagesPool,/*OPTIONAL*/refreshMillis=null,
|
|
|
9320
9596
|
zoomsParam);
|
|
9321
9597
|
}
|
|
9322
9598
|
|
|
9323
|
-
// ====================================================== ROUTINES ======================================================
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
// ======================== Timeout ========================
|
|
9327
|
-
|
|
9328
|
-
// CAUTION : This is not a routine, but a single-use timeout !
|
|
9329
|
-
class MonoThreadedTimeout{
|
|
9330
|
-
constructor(actuator, delayMillis){
|
|
9331
|
-
this.actuator=actuator;
|
|
9332
|
-
}
|
|
9333
|
-
start(delayMillis=null){
|
|
9334
|
-
this.started=true;
|
|
9335
|
-
this.time=getNow();
|
|
9336
|
-
this.delayMillis=delayMillis;
|
|
9337
|
-
}
|
|
9338
|
-
doStep(args=null){
|
|
9339
|
-
if(!this.started) return;
|
|
9340
|
-
if(!hasDelayPassed(this.time, this.delayMillis)) return;
|
|
9341
|
-
return this.stop(args);
|
|
9342
|
-
}
|
|
9343
|
-
stop(args=null){
|
|
9344
|
-
if(!this.started) return;
|
|
9345
|
-
this.started=false;
|
|
9346
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9347
|
-
return this;
|
|
9348
|
-
}
|
|
9349
|
-
}
|
|
9350
|
-
|
|
9351
|
-
function getMonoThreadedTimeout(actuator=null){
|
|
9352
|
-
return new MonoThreadedTimeout(actuator);
|
|
9353
|
-
}
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
// ======================== Routine ========================
|
|
9357
|
-
|
|
9358
|
-
class MonoThreadedRoutine{
|
|
9359
|
-
constructor(actuator,refreshMillis=null,startDependsOnParentOnly=false){
|
|
9360
|
-
|
|
9361
|
-
this.actuator=actuator;
|
|
9362
|
-
this.startDependsOnParentOnly=startDependsOnParentOnly;
|
|
9363
|
-
this.started=false;
|
|
9364
|
-
this.paused=false;
|
|
9365
|
-
this.time=getNow();
|
|
9366
|
-
this.refreshMillis=refreshMillis;
|
|
9367
|
-
|
|
9368
|
-
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
9369
|
-
// Three-states : started, paused, stopped.
|
|
9370
|
-
|
|
9371
|
-
}
|
|
9372
|
-
|
|
9373
|
-
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
9374
|
-
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
9375
|
-
return this;
|
|
9376
|
-
}
|
|
9377
|
-
isStarted(){
|
|
9378
|
-
return this.started || this.startDependsOnParentOnly;
|
|
9379
|
-
}
|
|
9380
|
-
start(args=null){
|
|
9381
|
-
// if(this.isStarted()) return;
|
|
9382
|
-
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
9383
|
-
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
9384
|
-
// (ie. its stop conditions are fullfilled even before it has started)
|
|
9385
|
-
// we all the same have to trigger its stop treatments :
|
|
9386
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9387
|
-
return;
|
|
9388
|
-
}
|
|
9389
|
-
this.started=true;
|
|
9390
|
-
this.paused=false;
|
|
9391
|
-
return this;
|
|
9392
|
-
}
|
|
9393
|
-
stop(args=null){
|
|
9394
|
-
if(!this.isStarted()) return;
|
|
9395
|
-
this.started=false;
|
|
9396
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9397
|
-
}
|
|
9398
|
-
pause(args=null){
|
|
9399
|
-
this.paused=true;
|
|
9400
|
-
if(this.actuator.doOnSuspend) this.actuator.doOnSuspend(args);
|
|
9401
|
-
}
|
|
9402
|
-
resume(args=null){
|
|
9403
|
-
this.paused=false;
|
|
9404
|
-
if(this.actuator.doOnResume) this.actuator.doOnResume(args);
|
|
9405
|
-
}
|
|
9406
|
-
isPaused(){
|
|
9407
|
-
return this.paused;
|
|
9408
|
-
}
|
|
9409
|
-
doStep(args=null){
|
|
9410
|
-
if(!this.isStarted() || this.paused) return;
|
|
9411
|
-
// Looping index with a delay :
|
|
9412
|
-
|
|
9413
|
-
const delayHasPassed=hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor());
|
|
9414
|
-
if(!this.refreshMillis || delayHasPassed){
|
|
9415
|
-
if(this.refreshMillis && delayHasPassed){
|
|
9416
|
-
this.time=getNow();
|
|
9417
|
-
}
|
|
9418
|
-
// We perform the step :
|
|
9419
|
-
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
9420
|
-
this.stop(args);
|
|
9421
|
-
return;
|
|
9422
|
-
}
|
|
9423
|
-
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
9424
|
-
}
|
|
9425
|
-
|
|
9426
|
-
}
|
|
9427
|
-
|
|
9428
|
-
}
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
function getMonoThreadedRoutine(actuator, refreshMillis=null, startDependsOnParentOnly=false){
|
|
9432
|
-
return new MonoThreadedRoutine(actuator, refreshMillis, startDependsOnParentOnly);
|
|
9433
|
-
}
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
class MonoThreadedGoToGoal{
|
|
9437
|
-
constructor(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
9438
|
-
|
|
9439
|
-
this.actuator=actuator;
|
|
9440
|
-
|
|
9441
|
-
this.actualValue=actualValue;
|
|
9442
|
-
this.mode=mode;
|
|
9443
|
-
this.totalTimeMillis=totalTimeMillis;
|
|
9444
|
-
this.stepValue=((refreshMillis*(goalValue-actualValue))/totalTimeMillis);
|
|
9445
|
-
this.value=actualValue;
|
|
9446
|
-
this.goalValue=goalValue;
|
|
9447
|
-
this.started=false;
|
|
9448
|
-
this.paused=false;
|
|
9449
|
-
this.time=getNow();
|
|
9450
|
-
this.refreshMillis=refreshMillis;
|
|
9451
|
-
|
|
9452
|
-
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
9453
|
-
|
|
9454
|
-
// Three-states : started, paused, stopped.
|
|
9455
|
-
}
|
|
9456
|
-
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
9457
|
-
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
9458
|
-
|
|
9459
|
-
// We recalculate total time-dependent values :
|
|
9460
|
-
this.totalTimeMillis=this.totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
9461
|
-
this.stepValue=((this.refreshMillis*(this.goalValue-this.actualValue))/this.totalTimeMillis);
|
|
9462
|
-
|
|
9463
|
-
return this;
|
|
9464
|
-
}
|
|
9465
|
-
isStarted(){
|
|
9466
|
-
return this.started || this.startDependsOnParentOnly;
|
|
9467
|
-
}
|
|
9468
|
-
resetValueAndGoalTo(resetValue){
|
|
9469
|
-
this.value=resetValue;
|
|
9470
|
-
this.goalValue=resetValue;
|
|
9471
|
-
return this;
|
|
9472
|
-
}
|
|
9473
|
-
setNewGoal(goalValue, refreshMillisParam=null, totalTimeMillis=null){
|
|
9474
|
-
if(Math.round(this.value)===Math.round(goalValue)) return;
|
|
9475
|
-
if(refreshMillisParam) this.refreshMillis=refreshMillisParam;
|
|
9476
|
-
if(totalTimeMillis) this.totalTimeMillis=totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
9477
|
-
|
|
9478
|
-
this.goalValue=goalValue;
|
|
9479
|
-
this.stepValue=((this.refreshMillis*(this.goalValue-this.value))/this.totalTimeMillis);
|
|
9480
|
-
|
|
9481
|
-
if(!this.isStarted()) this.start();
|
|
9482
|
-
|
|
9483
|
-
return this;
|
|
9484
|
-
}
|
|
9485
|
-
start(args=null){
|
|
9486
|
-
|
|
9487
|
-
if( this.value===this.goalValue
|
|
9488
|
-
// || this.isStarted();
|
|
9489
|
-
|| (this.actuator.terminateFunction && this.actuator.terminateFunction())
|
|
9490
|
-
|| this.hasReachedGoal()){
|
|
9491
|
-
|
|
9492
|
-
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
9493
|
-
// (ie. its stop conditions are fullfilled even before it has started)
|
|
9494
|
-
// we all the same have to trigger its stop treatments :
|
|
9495
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9496
|
-
|
|
9497
|
-
return;
|
|
9498
|
-
}
|
|
9499
|
-
this.started=true;
|
|
9500
|
-
this.paused=false;
|
|
9501
|
-
|
|
9502
|
-
return this;
|
|
9503
|
-
}
|
|
9504
|
-
stop(args=null){
|
|
9505
|
-
if(!this.isStarted()) return;
|
|
9506
|
-
this.started=false;
|
|
9507
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9508
|
-
}
|
|
9509
|
-
pause(){
|
|
9510
|
-
this.paused=true;
|
|
9511
|
-
}
|
|
9512
|
-
resume(){
|
|
9513
|
-
this.paused=false;
|
|
9514
|
-
}
|
|
9515
|
-
hasReachedGoal(){
|
|
9516
|
-
if(this.stepValue<0){
|
|
9517
|
-
if(this.value<=this.goalValue) return true;
|
|
9518
|
-
}else{
|
|
9519
|
-
if(this.goalValue<=this.value) return true;
|
|
9520
|
-
}
|
|
9521
|
-
return false;
|
|
9522
|
-
}
|
|
9523
|
-
|
|
9524
|
-
doStep(args=null){
|
|
9525
|
-
if(!this.isStarted() || this.paused) return this.value;
|
|
9526
|
-
|
|
9527
|
-
// Looping index with a delay :
|
|
9528
|
-
|
|
9529
|
-
if(!this.refreshMillis || this.hasDelayPassed()){
|
|
9530
|
-
if(this.refreshMillis && this.hasDelayPassed()){
|
|
9531
|
-
this.time=getNow();
|
|
9532
|
-
}
|
|
9533
|
-
|
|
9534
|
-
// We check if we must stop :
|
|
9535
|
-
if(this.actuator.terminateFunction){
|
|
9536
|
-
if(this.actuator.terminateFunction()){
|
|
9537
|
-
this.stop();
|
|
9538
|
-
this.value=this.goalValue;
|
|
9539
|
-
return this.value;
|
|
9540
|
-
}
|
|
9541
|
-
}else{
|
|
9542
|
-
if(this.hasReachedGoal()){
|
|
9543
|
-
this.stop();
|
|
9544
|
-
this.value=this.goalValue;
|
|
9545
|
-
return this.value;
|
|
9546
|
-
}
|
|
9547
|
-
}
|
|
9548
|
-
|
|
9549
|
-
// We perform the step :
|
|
9550
|
-
if(this.mode==="exponential"){
|
|
9551
|
-
this.value+=Math.pow(this.stepValue,2);
|
|
9552
|
-
}else{ // default is "linear"
|
|
9553
|
-
this.value+=this.stepValue;
|
|
9554
|
-
}
|
|
9555
|
-
|
|
9556
|
-
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
9557
|
-
}
|
|
9558
|
-
|
|
9559
|
-
return this.value;
|
|
9560
|
-
}
|
|
9561
|
-
|
|
9562
|
-
hasDelayPassed(){
|
|
9563
|
-
return (!this.time || hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor()));
|
|
9564
|
-
}
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
}
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
function getMonoThreadedGoToGoal(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
9571
|
-
return new MonoThreadedGoToGoal(actuator,actualValue,goalValue,refreshMillis,totalTimeMillis,mode);
|
|
9572
|
-
}
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
// =====================================================================================================================
|
|
9576
|
-
|
|
9577
9599
|
|
|
9578
9600
|
//if signed :
|
|
9579
9601
|
//when precision==1/10000, range is -3.2766 to 3.2766
|
|
@@ -13206,7 +13228,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
|
|
|
13206
13228
|
|
|
13207
13229
|
|
|
13208
13230
|
|
|
13209
|
-
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (
|
|
13231
|
+
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (09/04/2026-01:44:04)»*/
|
|
13210
13232
|
/*-----------------------------------------------------------------------------*/
|
|
13211
13233
|
|
|
13212
13234
|
|
|
@@ -14535,10 +14557,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
|
|
|
14535
14557
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
14536
14558
|
|
|
14537
14559
|
AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
|
|
14538
|
-
/*utils 3D library associated with aotra version : «1_29072022-2359 (
|
|
14560
|
+
/*utils 3D library associated with aotra version : «1_29072022-2359 (09/04/2026-01:44:04)»*/
|
|
14539
14561
|
/*-----------------------------------------------------------------------------*/
|
|
14540
14562
|
|
|
14541
|
-
/*utils AI library associated with aotra version : «1_29072022-2359 (
|
|
14563
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (09/04/2026-01:44:04)»*/
|
|
14542
14564
|
/*-----------------------------------------------------------------------------*/
|
|
14543
14565
|
|
|
14544
14566
|
|
|
@@ -14684,7 +14706,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
|
|
|
14684
14706
|
|
|
14685
14707
|
|
|
14686
14708
|
|
|
14687
|
-
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (
|
|
14709
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (09/04/2026-01:44:04)»*/
|
|
14688
14710
|
/*-----------------------------------------------------------------------------*/
|
|
14689
14711
|
|
|
14690
14712
|
|
aotrautils/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1841",
|
|
4
4
|
"main": "aotrautils.build.js",
|
|
5
5
|
"description": "A library for vanilla javascript utils (client-side) used in aotra javascript CMS",
|
|
6
6
|
"author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
|