zimjs 18.2.0 → 18.2.1
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/package.json +1 -1
- package/src/zim.js +92 -24
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -57012,6 +57012,7 @@ props - the object literal holding properties and values to animate
|
|
|
57012
57012
|
then this will be the last of the series to run
|
|
57013
57013
|
Note: color cannot be animated in a series - rather animate in a call function to accomplish a series of color changes
|
|
57014
57014
|
Note: a sequence cannot be seriesed and a series cannot be sequenced
|
|
57015
|
+
Note: series with dot properties (like rotation.x for threejs) could have problems with from and set
|
|
57015
57016
|
time - |ZIM VEE| (default 1) the time for the tween in seconds (also see ZIM TIME constant)
|
|
57016
57017
|
see also the rate parameter and property to dynamically change the time the animation takes (its speed)
|
|
57017
57018
|
ease - |ZIM VEE| (default "quadInOut") the equation type for easing ("bounceOut", "elasticIn", "backInOut", "linear", etc)
|
|
@@ -57113,7 +57114,6 @@ protect - (default false) protects animation from being interrupted before finis
|
|
|
57113
57114
|
override - (default true) subesequent tweens of any type on object cancel all earlier tweens on object
|
|
57114
57115
|
set to false to allow multiple tweens of same object
|
|
57115
57116
|
from - |ZIM VEE| (default false) set to true to animate from obj properties to the current properties set on target
|
|
57116
|
-
note that from is not supported with dot properties such as "rotation.x" with threejs (a difficult bug)
|
|
57117
57117
|
set - |ZIM VEE| (default null) an object of properties to set on the target to start (but after the wait time)
|
|
57118
57118
|
id - (default null) set to String to use with pauseAnimate(state, id) and stopAnimate(id) - thanks Sean Berwick for typo catch
|
|
57119
57119
|
series animate gets only one overall id - so no id per animation object
|
|
@@ -57387,7 +57387,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
57387
57387
|
|
|
57388
57388
|
// handle setting value with dot property format
|
|
57389
57389
|
// (target, "rotation.x", 200) for instance
|
|
57390
|
-
function setValue(what, prop, val) {
|
|
57390
|
+
function setValue(what, prop, val) {
|
|
57391
57391
|
if (prop.substr(0,1) == ".") {
|
|
57392
57392
|
var dots = prop.split(".");
|
|
57393
57393
|
var lastdot = what;
|
|
@@ -57426,8 +57426,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
57426
57426
|
// PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
|
|
57427
57427
|
var extraTypes = ["extra", "zoom", "speed", "layer", "fade"];
|
|
57428
57428
|
var extraLookup = {zoom:target.type=="Pen"?"size":"scale", speed:"percentSpeed", layer:"layer", fade:"alpha"};
|
|
57429
|
-
|
|
57430
|
-
|
|
57429
|
+
|
|
57431
57430
|
if (target instanceof Array) {
|
|
57432
57431
|
if (sequenceReverse) target.reverse();
|
|
57433
57432
|
|
|
@@ -57728,7 +57727,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
57728
57727
|
}
|
|
57729
57728
|
|
|
57730
57729
|
if (o.from) {
|
|
57731
|
-
var firstFrom = froms.at(o.target);
|
|
57730
|
+
var firstFrom = froms.at(o.target);
|
|
57732
57731
|
if (firstFrom) {
|
|
57733
57732
|
if (o.set) {
|
|
57734
57733
|
// all properties from obj go to set
|
|
@@ -58184,11 +58183,12 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
58184
58183
|
target.zimLastObj[i] = rewind?target.zimTweenOriginals[i]:obj[i];
|
|
58185
58184
|
}
|
|
58186
58185
|
}
|
|
58187
|
-
|
|
58186
|
+
|
|
58188
58187
|
function relativeSetAdjust() {
|
|
58189
58188
|
var newStart;
|
|
58190
58189
|
for (i in set) {
|
|
58191
58190
|
if (typeof set[i] == "string" && i != "transform") {
|
|
58191
|
+
|
|
58192
58192
|
if (i.substring && i.substring(0,1)==".") {
|
|
58193
58193
|
if (set[i].substr(0,1)=="+"||set[i].substr(0,1)=="-") continue;
|
|
58194
58194
|
} else {
|
|
@@ -58376,14 +58376,13 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
58376
58376
|
delete obj.path;
|
|
58377
58377
|
obj.pathRatio = 1; // this is what we are animating to
|
|
58378
58378
|
}
|
|
58379
|
-
|
|
58380
|
-
// !!!!! fix for dot values
|
|
58381
|
-
|
|
58379
|
+
|
|
58382
58380
|
// PREPARE START VALUES - now that pathRatio is set
|
|
58383
58381
|
// moved to prepareRelative
|
|
58384
58382
|
// if (from) obj = getFroms(target, obj, set, true);
|
|
58385
58383
|
var startObj = {} // for later getStart()
|
|
58386
58384
|
function getFroms(target, obj, set, update) {
|
|
58385
|
+
|
|
58387
58386
|
fromCheck = true;
|
|
58388
58387
|
// animating based on pathRatio - but API is percentComplete
|
|
58389
58388
|
// with from set, this causes problems - so add pathRatio equal to percentComplete to set
|
|
@@ -58396,9 +58395,17 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
58396
58395
|
if (set && !zot(set[i])) {
|
|
58397
58396
|
newObj[i] = set[i];
|
|
58398
58397
|
} else {
|
|
58399
|
-
|
|
58398
|
+
if (i.match(/\./)) { // handle dot props like threejs - patched ZIM 018
|
|
58399
|
+
var bunch = i.split(/\./g);
|
|
58400
|
+
newObj[i] = target[bunch[1]][bunch[2]];
|
|
58401
|
+
} else {
|
|
58402
|
+
newObj[i] = target[i];
|
|
58403
|
+
}
|
|
58400
58404
|
}
|
|
58401
|
-
if (update)
|
|
58405
|
+
if (update) {
|
|
58406
|
+
if (i.match(/\./)) target[bunch[1]][bunch[2]] = obj[i];
|
|
58407
|
+
else target[i] = obj[i];
|
|
58408
|
+
}
|
|
58402
58409
|
}
|
|
58403
58410
|
return newObj;
|
|
58404
58411
|
}
|
|
@@ -59113,9 +59120,9 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
59113
59120
|
if (!startTest) {
|
|
59114
59121
|
obj2 = getStart();
|
|
59115
59122
|
startTest = true;
|
|
59116
|
-
}
|
|
59117
|
-
|
|
59118
|
-
if (target.set && !from) target.set(set);
|
|
59123
|
+
}
|
|
59124
|
+
checkSets();
|
|
59125
|
+
// if (target.set && !from) target.set(set);
|
|
59119
59126
|
tween = target.zimTweens[id] = target.zimTween = createjs.Tween.get(target, cjsProps)
|
|
59120
59127
|
.call(doStartCall)
|
|
59121
59128
|
.to(obj, t, finalEase)
|
|
@@ -59170,7 +59177,9 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
59170
59177
|
}
|
|
59171
59178
|
}
|
|
59172
59179
|
function tween2(lastTween) {
|
|
59173
|
-
|
|
59180
|
+
|
|
59181
|
+
checkSets();
|
|
59182
|
+
// if (target.set && !from) {target.set(set);}
|
|
59174
59183
|
tween = target.zimTweens[id] = target.zimTween = createjs.Tween.get(target, cjsProps)
|
|
59175
59184
|
.call(doStartCall)
|
|
59176
59185
|
.to(obj, t, finalEase)
|
|
@@ -59265,6 +59274,26 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
59265
59274
|
}
|
|
59266
59275
|
}
|
|
59267
59276
|
|
|
59277
|
+
function checkSets() {
|
|
59278
|
+
if (!from) {
|
|
59279
|
+
if (set) {
|
|
59280
|
+
if (target.set) {
|
|
59281
|
+
target.set(set);
|
|
59282
|
+
} else {
|
|
59283
|
+
if (target)
|
|
59284
|
+
for (i in set) {
|
|
59285
|
+
if (i.match(/\./)) { // handle dot props like threejs - patched ZIM 018
|
|
59286
|
+
var bunch = i.split(/\./g);
|
|
59287
|
+
target[bunch[0]][bunch[1]] = set[i];
|
|
59288
|
+
} else {
|
|
59289
|
+
target[i] = set[i];
|
|
59290
|
+
}
|
|
59291
|
+
}
|
|
59292
|
+
}
|
|
59293
|
+
}
|
|
59294
|
+
}
|
|
59295
|
+
}
|
|
59296
|
+
|
|
59268
59297
|
function transferIds(lastTween, tween) {
|
|
59269
59298
|
tween.zimIdSet = lastTween.zimIdSet; // know we need this one - not sure about the rest 10.4.0
|
|
59270
59299
|
tween.zimObj = lastTween.zimObj;
|
|
@@ -86873,7 +86902,7 @@ loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, cr
|
|
|
86873
86902
|
note: this means the Bitmap will be interactive everywhere - not just in opaque areas
|
|
86874
86903
|
note: loading images this way will not count as progress (bytes loaded ratio) in the progress event but do count for fileloaded and complete events
|
|
86875
86904
|
asset can be a ZIM multi-asset object {assets:[], path:"dir/", loadTimeout:1, maxNum:num, noCORSonImage:true}
|
|
86876
|
-
where the array can hold multiple files that will have the provided properties applied
|
|
86905
|
+
where the array can hold multiple files that will have the provided properties applied
|
|
86877
86906
|
this is handy for loading assets from multiple directories (added in ZIM Cat 02 - thanks Netanela for the prompting)
|
|
86878
86907
|
eg.
|
|
86879
86908
|
[
|
|
@@ -86918,6 +86947,8 @@ loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, cr
|
|
|
86918
86947
|
]
|
|
86919
86948
|
}}
|
|
86920
86949
|
See also previewAudioSprite() method in the META section of docs.
|
|
86950
|
+
DO NOT put an audioSprite in a multi-assets object if there is another path defined - we hope to fix for ZIM 019
|
|
86951
|
+
Instead, make the path for the audioSprite be the main path and put the other path in the multi-assets object
|
|
86921
86952
|
path - pass in an optional path String that gets prepended to the asset
|
|
86922
86953
|
when accessing the asset with the asset() method you do NOT include the path
|
|
86923
86954
|
assets with an absolute URL (http[s]://etc.) will ignore path
|
|
@@ -88028,6 +88059,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88028
88059
|
// 018 TRYING TO FIX CREATEJS ERROR IF SOUND LOADED AGAIN - BUT BREAKS LAZY LOAD
|
|
88029
88060
|
// var emptyAssets = false;
|
|
88030
88061
|
|
|
88062
|
+
|
|
88031
88063
|
for (i=0; i<assets.length; i++) {
|
|
88032
88064
|
a = assets[i];
|
|
88033
88065
|
// if (zim.assets[a]) {
|
|
@@ -88059,7 +88091,13 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88059
88091
|
fonts.push(aj);
|
|
88060
88092
|
} else if (zim.assetIDs[aj]) {
|
|
88061
88093
|
assetMulti.push({id:a.path+aj, src:a.path+aj, path:null, loadTimeout:a.loadTimeout, maxNum:a.maxNum, noCORSonImage:a.noCORSonImage});
|
|
88062
|
-
} else {
|
|
88094
|
+
} else if (aj.audioSprite) {
|
|
88095
|
+
// ZIM 018 attempted patch for audioSprite not working in multi-assets object
|
|
88096
|
+
// tried passing path but it substitutes it somewhere with the default path - boo
|
|
88097
|
+
// so tried what was used with assetIDs above and it still does it.
|
|
88098
|
+
// assetMulti.push({id:a.path+aj.src, src:a.path+aj.src, path:null, audioSprite:aj.audioSprite, data:aj.data, loadTimeout:a.loadTimeout, maxNum:a.maxNum, noCORSonImage:a.noCORSonImage});
|
|
88099
|
+
assetMulti.push({id:aj.src, src:aj.src, path:aj.path, audioSprite:aj.audioSprite, data:aj.data, loadTimeout:a.loadTimeout, maxNum:a.maxNum, noCORSonImage:a.noCORSonImage});
|
|
88100
|
+
} else {
|
|
88063
88101
|
assetMulti.push({id:aj, src:aj, path:a.path, loadTimeout:a.loadTimeout, maxNum:a.maxNum, noCORSonImage:a.noCORSonImage});
|
|
88064
88102
|
}
|
|
88065
88103
|
}
|
|
@@ -88093,7 +88131,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88093
88131
|
replacement.push({id:r[0], startTime:Math.round(r[1]*1000), duration:Math.round((r[2]-r[1])*1000)});
|
|
88094
88132
|
}
|
|
88095
88133
|
delete(obj.audioSprite); // the ZIM data
|
|
88096
|
-
obj.data = {audioSprite:replacement}; // the CreateJS data
|
|
88134
|
+
obj.data = {audioSprite:replacement}; // the CreateJS data
|
|
88097
88135
|
manifest.push(obj);
|
|
88098
88136
|
} else if (a.data && a.data.audioSprite) { // CreateJS AudioSprite
|
|
88099
88137
|
obj = zim.copy(a);
|
|
@@ -88117,13 +88155,13 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88117
88155
|
found = url.match(/(.*?)([^/])\/[^/]/);
|
|
88118
88156
|
url = found[1]+found[2];
|
|
88119
88157
|
a.src = url+a.path+a.src;
|
|
88120
|
-
} else {
|
|
88121
|
-
var pname = WW.location.pathname;
|
|
88158
|
+
} else {
|
|
88159
|
+
var pname = WW.location.pathname;
|
|
88122
88160
|
url = WW.location.href;
|
|
88123
88161
|
var fileOnly = url.split(pname)[0] + pname;
|
|
88124
88162
|
found = fileOnly.match(/(.*)\//);
|
|
88125
88163
|
a.path = a.path.replace(/^\.\//,"");
|
|
88126
|
-
var goBack = a.path.match(/\.\.\//g);
|
|
88164
|
+
var goBack = a.path.match(/\.\.\//g);s
|
|
88127
88165
|
var pref = found[1];
|
|
88128
88166
|
if (goBack) {
|
|
88129
88167
|
for (z_i=0; z_i<goBack.length; z_i++) {
|
|
@@ -88162,7 +88200,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88162
88200
|
queue.loadAssetsCount--;
|
|
88163
88201
|
if (queue.loadAssetsCount == 0) endAssetLoad();
|
|
88164
88202
|
}
|
|
88165
|
-
} else {
|
|
88203
|
+
} else {
|
|
88166
88204
|
zim.assetIDs[a.id] = a.src;
|
|
88167
88205
|
var mn = a.maxNum;
|
|
88168
88206
|
if (zot(mn)) mn = maxNum;
|
|
@@ -88197,7 +88235,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88197
88235
|
if (soundCheck && firstSoundCheck) {
|
|
88198
88236
|
// dynamically make audio tag with sound to overcome some Apple devices not playing sounds
|
|
88199
88237
|
var audioTag = document.createElement("audio");
|
|
88200
|
-
audioTag.setAttribute("src", ((!zot(path) && !a.match(/^http:\/\/|https:\/\//i))?path:"")+a);
|
|
88238
|
+
audioTag.setAttribute("src", ((!zot(path) && !a.match(/^http:\/\/|https:\/\/|file:\/\//i))?path:"")+a);
|
|
88201
88239
|
document.body.appendChild(audioTag);
|
|
88202
88240
|
firstSoundCheck = false;
|
|
88203
88241
|
}
|
|
@@ -95951,6 +95989,10 @@ https://zimjs.com/015/textureactive_raw.html
|
|
|
95951
95989
|
ZIM in VR
|
|
95952
95990
|
https://zimjs.com/015/vr.html - use triggers (drag), sticks (motion) and b and y buttons (teleport)
|
|
95953
95991
|
|
|
95992
|
+
ZIM Central
|
|
95993
|
+
Use ZIM in Frame scaling:FULL and ZIM Central() to match ZIM scaling with three.js fullscreen scaling
|
|
95994
|
+
https://zimjs.com/three/central.html
|
|
95995
|
+
|
|
95954
95996
|
Z-Dog is a quick alternative for three.js - here are a couple examples
|
|
95955
95997
|
https://codepen.io/zimjs/pen/joXxGJ
|
|
95956
95998
|
https://codepen.io/zimjs/pen/rgEEXy
|
|
@@ -95998,6 +96040,32 @@ const dial = new Dial({min:0, max:360, step:0, continuous:true}).pos(70,0,LEFT,C
|
|
|
95998
96040
|
});
|
|
95999
96041
|
END EXAMPLE
|
|
96000
96042
|
|
|
96043
|
+
EXAMPLE
|
|
96044
|
+
// use ZIM Central() to make a threejs-like full scale but centered experience
|
|
96045
|
+
new Frame({ready, color:yellow}); // use FULL mode (default)
|
|
96046
|
+
function ready() {
|
|
96047
|
+
const three = new Three({
|
|
96048
|
+
width:W,
|
|
96049
|
+
height:H,
|
|
96050
|
+
cameraPosition:new THREE.Vector3(-200,200,300),
|
|
96051
|
+
colorManagement:true,
|
|
96052
|
+
interactive:false,
|
|
96053
|
+
full:true, // add full screen three.js
|
|
96054
|
+
lay:OVER // or UNDER - see https://zimjs.com/three/central.html
|
|
96055
|
+
});
|
|
96056
|
+
const geometry = new THREE.BoxGeometry(100,100,100);
|
|
96057
|
+
const material = new THREE.MeshNormalMaterial();
|
|
96058
|
+
const mesh = new THREE.Mesh(geometry, material);
|
|
96059
|
+
three.scene.add(mesh);
|
|
96060
|
+
|
|
96061
|
+
const central = new Central().center();
|
|
96062
|
+
|
|
96063
|
+
new Slider({currentValue:5})
|
|
96064
|
+
.pos(0,200,CENTER,CENTER,central)
|
|
96065
|
+
.wire(mesh.rotation, "y");
|
|
96066
|
+
}
|
|
96067
|
+
END EXAMPLE
|
|
96068
|
+
|
|
96001
96069
|
PARAMETERS
|
|
96002
96070
|
** supports DUO - parameters or single object with properties below
|
|
96003
96071
|
width - (default ZIM Frame width) the width to make the three.js canvas
|
|
@@ -98494,4 +98562,4 @@ export let Ticker = zim.Ticker;
|
|
|
98494
98562
|
export let Style = zim.Style;
|
|
98495
98563
|
export let assets = zim.assets;
|
|
98496
98564
|
export let assetIDs = zim.assetIDs;
|
|
98497
|
-
export let ZIMON = zim.ZIMON;
|
|
98565
|
+
export let ZIMON = zim.ZIMON;
|