zimjs 18.2.0 → 18.2.2
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 +96 -27
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -56990,7 +56990,6 @@ props - the object literal holding properties and values to animate
|
|
|
56990
56990
|
DOT PROPERTIES: you can animate properties on properties using quotes:
|
|
56991
56991
|
Here is animate used as a function to animate a threejs mesh
|
|
56992
56992
|
animate(mesh, {"rotation.y":360*RAD}, 5000);
|
|
56993
|
-
note that the from parameter is not currently supported with dot properties (difficult bug)
|
|
56994
56993
|
CSS PROPERTIES: animate can animate CSS properties
|
|
56995
56994
|
ZIM's CreateJS 1.3.2 has the CreateJS CSS Pluging installed
|
|
56996
56995
|
Set the css parameter to true and see the CSS parameter for more details
|
|
@@ -57012,6 +57011,7 @@ props - the object literal holding properties and values to animate
|
|
|
57012
57011
|
then this will be the last of the series to run
|
|
57013
57012
|
Note: color cannot be animated in a series - rather animate in a call function to accomplish a series of color changes
|
|
57014
57013
|
Note: a sequence cannot be seriesed and a series cannot be sequenced
|
|
57014
|
+
Note: series with dot properties (like rotation.x for threejs) could have problems with from and set
|
|
57015
57015
|
time - |ZIM VEE| (default 1) the time for the tween in seconds (also see ZIM TIME constant)
|
|
57016
57016
|
see also the rate parameter and property to dynamically change the time the animation takes (its speed)
|
|
57017
57017
|
ease - |ZIM VEE| (default "quadInOut") the equation type for easing ("bounceOut", "elasticIn", "backInOut", "linear", etc)
|
|
@@ -57113,7 +57113,6 @@ protect - (default false) protects animation from being interrupted before finis
|
|
|
57113
57113
|
override - (default true) subesequent tweens of any type on object cancel all earlier tweens on object
|
|
57114
57114
|
set to false to allow multiple tweens of same object
|
|
57115
57115
|
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
57116
|
set - |ZIM VEE| (default null) an object of properties to set on the target to start (but after the wait time)
|
|
57118
57117
|
id - (default null) set to String to use with pauseAnimate(state, id) and stopAnimate(id) - thanks Sean Berwick for typo catch
|
|
57119
57118
|
series animate gets only one overall id - so no id per animation object
|
|
@@ -57253,10 +57252,11 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
57253
57252
|
if (target && (target.props || target.obj)) {
|
|
57254
57253
|
var duo; if (duo = zob(zim.animate, arguments, sig)) return duo;
|
|
57255
57254
|
}
|
|
57256
|
-
|
|
57255
|
+
|
|
57256
|
+
if (target && target.type && target.type=="AC" && WW.zdf) {WW.zdf.ac("animate", arguments); return target;}
|
|
57257
57257
|
if (!zim.animateCheck) {z_d("45"); zim.animateCheck=true;}
|
|
57258
57258
|
|
|
57259
|
-
if (!target)
|
|
57259
|
+
if (!target) target = {}; // ZIM 018 replacing: return; from 10.9.0
|
|
57260
57260
|
var AN = zim.ANIMATE;
|
|
57261
57261
|
if (WW.ANIMATE != null) AN = WW.ANIMATE;
|
|
57262
57262
|
if (!AN) {
|
|
@@ -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,18 @@ 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
|
+
if (bunch[0]=="") bunch.shift(); // sometimes has dot on front and sometimes not
|
|
58401
|
+
newObj[i] = target[bunch[0]][bunch[1]];
|
|
58402
|
+
} else {
|
|
58403
|
+
newObj[i] = target[i];
|
|
58404
|
+
}
|
|
58400
58405
|
}
|
|
58401
|
-
if (update)
|
|
58406
|
+
if (update) {
|
|
58407
|
+
if (i.match(/\./)) target[bunch[0]][bunch[1]] = obj[i];
|
|
58408
|
+
else target[i] = obj[i];
|
|
58409
|
+
}
|
|
58402
58410
|
}
|
|
58403
58411
|
return newObj;
|
|
58404
58412
|
}
|
|
@@ -59113,9 +59121,9 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
59113
59121
|
if (!startTest) {
|
|
59114
59122
|
obj2 = getStart();
|
|
59115
59123
|
startTest = true;
|
|
59116
|
-
}
|
|
59117
|
-
|
|
59118
|
-
if (target.set && !from) target.set(set);
|
|
59124
|
+
}
|
|
59125
|
+
checkSets();
|
|
59126
|
+
// if (target.set && !from) target.set(set);
|
|
59119
59127
|
tween = target.zimTweens[id] = target.zimTween = createjs.Tween.get(target, cjsProps)
|
|
59120
59128
|
.call(doStartCall)
|
|
59121
59129
|
.to(obj, t, finalEase)
|
|
@@ -59170,7 +59178,9 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
59170
59178
|
}
|
|
59171
59179
|
}
|
|
59172
59180
|
function tween2(lastTween) {
|
|
59173
|
-
|
|
59181
|
+
|
|
59182
|
+
checkSets();
|
|
59183
|
+
// if (target.set && !from) {target.set(set);}
|
|
59174
59184
|
tween = target.zimTweens[id] = target.zimTween = createjs.Tween.get(target, cjsProps)
|
|
59175
59185
|
.call(doStartCall)
|
|
59176
59186
|
.to(obj, t, finalEase)
|
|
@@ -59265,6 +59275,26 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
59265
59275
|
}
|
|
59266
59276
|
}
|
|
59267
59277
|
|
|
59278
|
+
function checkSets() {
|
|
59279
|
+
if (!from) {
|
|
59280
|
+
if (set) {
|
|
59281
|
+
if (target.set) {
|
|
59282
|
+
target.set(set);
|
|
59283
|
+
} else {
|
|
59284
|
+
if (target)
|
|
59285
|
+
for (i in set) {
|
|
59286
|
+
if (i.match(/\./)) { // handle dot props like threejs - patched ZIM 018
|
|
59287
|
+
var bunch = i.split(/\./g);
|
|
59288
|
+
target[bunch[0]][bunch[1]] = set[i];
|
|
59289
|
+
} else {
|
|
59290
|
+
target[i] = set[i];
|
|
59291
|
+
}
|
|
59292
|
+
}
|
|
59293
|
+
}
|
|
59294
|
+
}
|
|
59295
|
+
}
|
|
59296
|
+
}
|
|
59297
|
+
|
|
59268
59298
|
function transferIds(lastTween, tween) {
|
|
59269
59299
|
tween.zimIdSet = lastTween.zimIdSet; // know we need this one - not sure about the rest 10.4.0
|
|
59270
59300
|
tween.zimObj = lastTween.zimObj;
|
|
@@ -86873,7 +86903,7 @@ loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, cr
|
|
|
86873
86903
|
note: this means the Bitmap will be interactive everywhere - not just in opaque areas
|
|
86874
86904
|
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
86905
|
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
|
|
86906
|
+
where the array can hold multiple files that will have the provided properties applied
|
|
86877
86907
|
this is handy for loading assets from multiple directories (added in ZIM Cat 02 - thanks Netanela for the prompting)
|
|
86878
86908
|
eg.
|
|
86879
86909
|
[
|
|
@@ -86918,6 +86948,8 @@ loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, cr
|
|
|
86918
86948
|
]
|
|
86919
86949
|
}}
|
|
86920
86950
|
See also previewAudioSprite() method in the META section of docs.
|
|
86951
|
+
DO NOT put an audioSprite in a multi-assets object if there is another path defined - we hope to fix for ZIM 019
|
|
86952
|
+
Instead, make the path for the audioSprite be the main path and put the other path in the multi-assets object
|
|
86921
86953
|
path - pass in an optional path String that gets prepended to the asset
|
|
86922
86954
|
when accessing the asset with the asset() method you do NOT include the path
|
|
86923
86955
|
assets with an absolute URL (http[s]://etc.) will ignore path
|
|
@@ -88028,6 +88060,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88028
88060
|
// 018 TRYING TO FIX CREATEJS ERROR IF SOUND LOADED AGAIN - BUT BREAKS LAZY LOAD
|
|
88029
88061
|
// var emptyAssets = false;
|
|
88030
88062
|
|
|
88063
|
+
|
|
88031
88064
|
for (i=0; i<assets.length; i++) {
|
|
88032
88065
|
a = assets[i];
|
|
88033
88066
|
// if (zim.assets[a]) {
|
|
@@ -88059,7 +88092,13 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88059
88092
|
fonts.push(aj);
|
|
88060
88093
|
} else if (zim.assetIDs[aj]) {
|
|
88061
88094
|
assetMulti.push({id:a.path+aj, src:a.path+aj, path:null, loadTimeout:a.loadTimeout, maxNum:a.maxNum, noCORSonImage:a.noCORSonImage});
|
|
88062
|
-
} else {
|
|
88095
|
+
} else if (aj.audioSprite) {
|
|
88096
|
+
// ZIM 018 attempted patch for audioSprite not working in multi-assets object
|
|
88097
|
+
// tried passing path but it substitutes it somewhere with the default path - boo
|
|
88098
|
+
// so tried what was used with assetIDs above and it still does it.
|
|
88099
|
+
// 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});
|
|
88100
|
+
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});
|
|
88101
|
+
} else {
|
|
88063
88102
|
assetMulti.push({id:aj, src:aj, path:a.path, loadTimeout:a.loadTimeout, maxNum:a.maxNum, noCORSonImage:a.noCORSonImage});
|
|
88064
88103
|
}
|
|
88065
88104
|
}
|
|
@@ -88093,7 +88132,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88093
88132
|
replacement.push({id:r[0], startTime:Math.round(r[1]*1000), duration:Math.round((r[2]-r[1])*1000)});
|
|
88094
88133
|
}
|
|
88095
88134
|
delete(obj.audioSprite); // the ZIM data
|
|
88096
|
-
obj.data = {audioSprite:replacement}; // the CreateJS data
|
|
88135
|
+
obj.data = {audioSprite:replacement}; // the CreateJS data
|
|
88097
88136
|
manifest.push(obj);
|
|
88098
88137
|
} else if (a.data && a.data.audioSprite) { // CreateJS AudioSprite
|
|
88099
88138
|
obj = zim.copy(a);
|
|
@@ -88117,13 +88156,13 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88117
88156
|
found = url.match(/(.*?)([^/])\/[^/]/);
|
|
88118
88157
|
url = found[1]+found[2];
|
|
88119
88158
|
a.src = url+a.path+a.src;
|
|
88120
|
-
} else {
|
|
88121
|
-
var pname = WW.location.pathname;
|
|
88159
|
+
} else {
|
|
88160
|
+
var pname = WW.location.pathname;
|
|
88122
88161
|
url = WW.location.href;
|
|
88123
88162
|
var fileOnly = url.split(pname)[0] + pname;
|
|
88124
88163
|
found = fileOnly.match(/(.*)\//);
|
|
88125
88164
|
a.path = a.path.replace(/^\.\//,"");
|
|
88126
|
-
var goBack = a.path.match(/\.\.\//g);
|
|
88165
|
+
var goBack = a.path.match(/\.\.\//g);s
|
|
88127
88166
|
var pref = found[1];
|
|
88128
88167
|
if (goBack) {
|
|
88129
88168
|
for (z_i=0; z_i<goBack.length; z_i++) {
|
|
@@ -88162,7 +88201,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88162
88201
|
queue.loadAssetsCount--;
|
|
88163
88202
|
if (queue.loadAssetsCount == 0) endAssetLoad();
|
|
88164
88203
|
}
|
|
88165
|
-
} else {
|
|
88204
|
+
} else {
|
|
88166
88205
|
zim.assetIDs[a.id] = a.src;
|
|
88167
88206
|
var mn = a.maxNum;
|
|
88168
88207
|
if (zot(mn)) mn = maxNum;
|
|
@@ -88197,7 +88236,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88197
88236
|
if (soundCheck && firstSoundCheck) {
|
|
88198
88237
|
// dynamically make audio tag with sound to overcome some Apple devices not playing sounds
|
|
88199
88238
|
var audioTag = document.createElement("audio");
|
|
88200
|
-
audioTag.setAttribute("src", ((!zot(path) && !a.match(/^http:\/\/|https:\/\//i))?path:"")+a);
|
|
88239
|
+
audioTag.setAttribute("src", ((!zot(path) && !a.match(/^http:\/\/|https:\/\/|file:\/\//i))?path:"")+a);
|
|
88201
88240
|
document.body.appendChild(audioTag);
|
|
88202
88241
|
firstSoundCheck = false;
|
|
88203
88242
|
}
|
|
@@ -95951,6 +95990,10 @@ https://zimjs.com/015/textureactive_raw.html
|
|
|
95951
95990
|
ZIM in VR
|
|
95952
95991
|
https://zimjs.com/015/vr.html - use triggers (drag), sticks (motion) and b and y buttons (teleport)
|
|
95953
95992
|
|
|
95993
|
+
ZIM Central
|
|
95994
|
+
Use ZIM in Frame scaling:FULL and ZIM Central() to match ZIM scaling with three.js fullscreen scaling
|
|
95995
|
+
https://zimjs.com/three/central.html
|
|
95996
|
+
|
|
95954
95997
|
Z-Dog is a quick alternative for three.js - here are a couple examples
|
|
95955
95998
|
https://codepen.io/zimjs/pen/joXxGJ
|
|
95956
95999
|
https://codepen.io/zimjs/pen/rgEEXy
|
|
@@ -95998,6 +96041,32 @@ const dial = new Dial({min:0, max:360, step:0, continuous:true}).pos(70,0,LEFT,C
|
|
|
95998
96041
|
});
|
|
95999
96042
|
END EXAMPLE
|
|
96000
96043
|
|
|
96044
|
+
EXAMPLE
|
|
96045
|
+
// use ZIM Central() to make a threejs-like full scale but centered experience
|
|
96046
|
+
new Frame({ready, color:yellow}); // use FULL mode (default)
|
|
96047
|
+
function ready() {
|
|
96048
|
+
const three = new Three({
|
|
96049
|
+
width:W,
|
|
96050
|
+
height:H,
|
|
96051
|
+
cameraPosition:new THREE.Vector3(-200,200,300),
|
|
96052
|
+
colorManagement:true,
|
|
96053
|
+
interactive:false,
|
|
96054
|
+
full:true, // add full screen three.js
|
|
96055
|
+
lay:OVER // or UNDER - see https://zimjs.com/three/central.html
|
|
96056
|
+
});
|
|
96057
|
+
const geometry = new THREE.BoxGeometry(100,100,100);
|
|
96058
|
+
const material = new THREE.MeshNormalMaterial();
|
|
96059
|
+
const mesh = new THREE.Mesh(geometry, material);
|
|
96060
|
+
three.scene.add(mesh);
|
|
96061
|
+
|
|
96062
|
+
const central = new Central().center();
|
|
96063
|
+
|
|
96064
|
+
new Slider({currentValue:5})
|
|
96065
|
+
.pos(0,200,CENTER,CENTER,central)
|
|
96066
|
+
.wire(mesh.rotation, "y");
|
|
96067
|
+
}
|
|
96068
|
+
END EXAMPLE
|
|
96069
|
+
|
|
96001
96070
|
PARAMETERS
|
|
96002
96071
|
** supports DUO - parameters or single object with properties below
|
|
96003
96072
|
width - (default ZIM Frame width) the width to make the three.js canvas
|
|
@@ -98494,4 +98563,4 @@ export let Ticker = zim.Ticker;
|
|
|
98494
98563
|
export let Style = zim.Style;
|
|
98495
98564
|
export let assets = zim.assets;
|
|
98496
98565
|
export let assetIDs = zim.assetIDs;
|
|
98497
|
-
export let ZIMON = zim.ZIMON;
|
|
98566
|
+
export let ZIMON = zim.ZIMON;
|