animejs 4.4.0 → 4.5.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/README.md +4 -5
- package/dist/bundles/anime.esm.js +491 -272
- package/dist/bundles/anime.esm.min.js +2 -2
- package/dist/bundles/anime.umd.js +491 -272
- package/dist/bundles/anime.umd.min.js +2 -2
- package/dist/modules/adapters/index.cjs +14 -0
- package/dist/modules/adapters/index.d.ts +1 -0
- package/dist/modules/adapters/index.js +8 -0
- package/dist/modules/adapters/registry.cjs +149 -0
- package/dist/modules/adapters/registry.d.ts +65 -0
- package/dist/modules/adapters/registry.js +146 -0
- package/dist/modules/adapters/three/adapter.cjs +26 -0
- package/dist/modules/adapters/three/adapter.d.ts +15 -0
- package/dist/modules/adapters/three/adapter.js +24 -0
- package/dist/modules/adapters/three/helpers.cjs +297 -0
- package/dist/modules/adapters/three/helpers.d.ts +89 -0
- package/dist/modules/adapters/three/helpers.js +280 -0
- package/dist/modules/adapters/three/index.cjs +20 -0
- package/dist/modules/adapters/three/index.d.ts +2 -0
- package/dist/modules/adapters/three/index.js +12 -0
- package/dist/modules/adapters/three/instance.cjs +368 -0
- package/dist/modules/adapters/three/instance.d.ts +133 -0
- package/dist/modules/adapters/three/instance.js +365 -0
- package/dist/modules/adapters/three/object3d.cjs +214 -0
- package/dist/modules/adapters/three/object3d.d.ts +1 -0
- package/dist/modules/adapters/three/object3d.js +212 -0
- package/dist/modules/adapters/three/resolvers.cjs +105 -0
- package/dist/modules/adapters/three/resolvers.d.ts +1 -0
- package/dist/modules/adapters/three/resolvers.js +103 -0
- package/dist/modules/adapters/three/uniform.cjs +41 -0
- package/dist/modules/adapters/three/uniform.d.ts +1 -0
- package/dist/modules/adapters/three/uniform.js +39 -0
- package/dist/modules/animatable/animatable.cjs +2 -1
- package/dist/modules/animatable/animatable.d.ts +2 -1
- package/dist/modules/animatable/animatable.js +2 -1
- package/dist/modules/animatable/index.cjs +1 -1
- package/dist/modules/animatable/index.js +1 -1
- package/dist/modules/animation/additive.cjs +1 -1
- package/dist/modules/animation/additive.js +1 -1
- package/dist/modules/animation/animation.cjs +43 -16
- package/dist/modules/animation/animation.d.ts +5 -0
- package/dist/modules/animation/animation.js +45 -18
- package/dist/modules/animation/composition.cjs +38 -35
- package/dist/modules/animation/composition.js +38 -35
- package/dist/modules/animation/index.cjs +1 -1
- package/dist/modules/animation/index.js +1 -1
- package/dist/modules/core/clock.cjs +11 -15
- package/dist/modules/core/clock.d.ts +0 -2
- package/dist/modules/core/clock.js +11 -15
- package/dist/modules/core/colors.cjs +1 -1
- package/dist/modules/core/colors.js +1 -1
- package/dist/modules/core/consts.cjs +15 -1
- package/dist/modules/core/consts.d.ts +2 -0
- package/dist/modules/core/consts.js +14 -2
- package/dist/modules/core/globals.cjs +7 -4
- package/dist/modules/core/globals.d.ts +8 -2
- package/dist/modules/core/globals.js +8 -5
- package/dist/modules/core/helpers.cjs +2 -2
- package/dist/modules/core/helpers.js +3 -3
- package/dist/modules/core/render.cjs +93 -73
- package/dist/modules/core/render.js +96 -76
- package/dist/modules/core/styles.cjs +16 -2
- package/dist/modules/core/styles.js +16 -2
- package/dist/modules/core/targets.cjs +11 -13
- package/dist/modules/core/targets.js +11 -13
- package/dist/modules/core/transforms.cjs +1 -1
- package/dist/modules/core/transforms.js +1 -1
- package/dist/modules/core/units.cjs +1 -1
- package/dist/modules/core/units.js +1 -1
- package/dist/modules/core/values.cjs +73 -82
- package/dist/modules/core/values.d.ts +1 -2
- package/dist/modules/core/values.js +76 -84
- package/dist/modules/draggable/draggable.cjs +1 -1
- package/dist/modules/draggable/draggable.js +1 -1
- package/dist/modules/draggable/index.cjs +1 -1
- package/dist/modules/draggable/index.js +1 -1
- package/dist/modules/easings/cubic-bezier/index.cjs +1 -1
- package/dist/modules/easings/cubic-bezier/index.js +1 -1
- package/dist/modules/easings/eases/index.cjs +1 -1
- package/dist/modules/easings/eases/index.js +1 -1
- package/dist/modules/easings/eases/parser.cjs +3 -3
- package/dist/modules/easings/eases/parser.d.ts +4 -5
- package/dist/modules/easings/eases/parser.js +3 -3
- package/dist/modules/easings/index.cjs +1 -1
- package/dist/modules/easings/index.js +1 -1
- package/dist/modules/easings/irregular/index.cjs +1 -1
- package/dist/modules/easings/irregular/index.js +1 -1
- package/dist/modules/easings/linear/index.cjs +1 -1
- package/dist/modules/easings/linear/index.js +1 -1
- package/dist/modules/easings/none.cjs +1 -1
- package/dist/modules/easings/none.js +1 -1
- package/dist/modules/easings/spring/index.cjs +1 -1
- package/dist/modules/easings/spring/index.js +1 -1
- package/dist/modules/easings/steps/index.cjs +1 -1
- package/dist/modules/easings/steps/index.js +1 -1
- package/dist/modules/engine/engine.cjs +4 -2
- package/dist/modules/engine/engine.js +4 -2
- package/dist/modules/engine/index.cjs +1 -1
- package/dist/modules/engine/index.js +1 -1
- package/dist/modules/events/index.cjs +1 -1
- package/dist/modules/events/index.js +1 -1
- package/dist/modules/events/scroll.cjs +3 -1
- package/dist/modules/events/scroll.js +3 -1
- package/dist/modules/index.cjs +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/layout/index.cjs +1 -1
- package/dist/modules/layout/index.js +1 -1
- package/dist/modules/layout/layout.cjs +1 -1
- package/dist/modules/layout/layout.js +1 -1
- package/dist/modules/scope/index.cjs +1 -1
- package/dist/modules/scope/index.js +1 -1
- package/dist/modules/scope/scope.cjs +1 -1
- package/dist/modules/scope/scope.js +1 -1
- package/dist/modules/svg/drawable.cjs +1 -1
- package/dist/modules/svg/drawable.js +1 -1
- package/dist/modules/svg/helpers.cjs +1 -1
- package/dist/modules/svg/helpers.js +1 -1
- package/dist/modules/svg/index.cjs +1 -1
- package/dist/modules/svg/index.js +1 -1
- package/dist/modules/svg/morphto.cjs +1 -1
- package/dist/modules/svg/morphto.js +1 -1
- package/dist/modules/svg/motionpath.cjs +1 -1
- package/dist/modules/svg/motionpath.js +1 -1
- package/dist/modules/text/index.cjs +1 -1
- package/dist/modules/text/index.js +1 -1
- package/dist/modules/text/scramble.cjs +12 -2
- package/dist/modules/text/scramble.d.ts +9 -1
- package/dist/modules/text/scramble.js +12 -2
- package/dist/modules/text/split.cjs +2 -1
- package/dist/modules/text/split.js +2 -1
- package/dist/modules/timeline/index.cjs +1 -1
- package/dist/modules/timeline/index.js +1 -1
- package/dist/modules/timeline/position.cjs +1 -1
- package/dist/modules/timeline/position.js +1 -1
- package/dist/modules/timeline/timeline.cjs +14 -5
- package/dist/modules/timeline/timeline.d.ts +3 -3
- package/dist/modules/timeline/timeline.js +14 -5
- package/dist/modules/timer/index.cjs +1 -1
- package/dist/modules/timer/index.js +1 -1
- package/dist/modules/timer/timer.cjs +1 -1
- package/dist/modules/timer/timer.js +1 -1
- package/dist/modules/types/index.d.ts +36 -11
- package/dist/modules/utils/chainable.cjs +1 -1
- package/dist/modules/utils/chainable.js +1 -1
- package/dist/modules/utils/index.cjs +1 -1
- package/dist/modules/utils/index.js +1 -1
- package/dist/modules/utils/number.cjs +1 -1
- package/dist/modules/utils/number.js +1 -1
- package/dist/modules/utils/random.cjs +4 -3
- package/dist/modules/utils/random.d.ts +1 -1
- package/dist/modules/utils/random.js +4 -3
- package/dist/modules/utils/stagger.cjs +67 -13
- package/dist/modules/utils/stagger.js +69 -15
- package/dist/modules/utils/target.cjs +4 -1
- package/dist/modules/utils/target.js +4 -1
- package/dist/modules/utils/time.cjs +6 -5
- package/dist/modules/utils/time.d.ts +1 -1
- package/dist/modules/utils/time.js +6 -5
- package/dist/modules/waapi/composition.cjs +1 -1
- package/dist/modules/waapi/composition.js +1 -1
- package/dist/modules/waapi/index.cjs +1 -1
- package/dist/modules/waapi/index.js +1 -1
- package/dist/modules/waapi/waapi.cjs +1 -1
- package/dist/modules/waapi/waapi.js +1 -1
- package/package.json +38 -5
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - adapters - ESM
|
|
3
|
+
* @version v4.5.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Object3D, Color, SRGBColorSpace } from 'three';
|
|
9
|
+
import { radToDeg, degToRad } from '../../utils/number.js';
|
|
10
|
+
import { threeAdapter } from './adapter.js';
|
|
11
|
+
import { readScalar, PATH_DIRECT, writeScalar, readColorAt, writeColorAt, readColorHex, COLOR_NORM, applySkewOrigin } from './helpers.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `Object3D` adapter. Maps flat properties (position, rotation, scale, opacity, color, visible, light / audio / camera specifics) onto the matching three.js fields, and auto-detects material props (direct / uniform / TSL `UniformNode`) on the target's `material` at tween creation.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const colorTarget = (t) => t.isLight ? t : t.material;
|
|
19
|
+
|
|
20
|
+
// Per-mesh skew and transformOrigin state, stored under a private symbol so we add one hidden property instead of polluting the Object3D surface with seven underscored fields.
|
|
21
|
+
const skewSymbol = Symbol('animejs.skewOrigin');
|
|
22
|
+
|
|
23
|
+
// Fallback opacity storage for Object3D targets without a material such as Groups or CSS2DObjects.
|
|
24
|
+
// Without it reads always return the default 1, so reverse-direction tweens between two non-default values collapse to a no-op delta and the visibility flip never fires on the way back.
|
|
25
|
+
const opacitySymbol = Symbol('animejs.opacity');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Sets `o.visible` based on opacity and current scale. If `opacity` is omitted, reads it from `o.material` (defaults to `1` when no material is present).
|
|
29
|
+
*
|
|
30
|
+
* @param {Object3D & { material?: import('three').Material | import('three').Material[] }} o
|
|
31
|
+
* @param {number} [opacity]
|
|
32
|
+
*/
|
|
33
|
+
function setVisibility(o, opacity) {
|
|
34
|
+
if (opacity === undefined) {
|
|
35
|
+
if (o.material) {
|
|
36
|
+
opacity = readScalar(o.material, 'opacity', PATH_DIRECT, 1);
|
|
37
|
+
} else {
|
|
38
|
+
const v = o[opacitySymbol];
|
|
39
|
+
opacity = v === undefined ? 1 : v;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const s = o.scale;
|
|
43
|
+
o.visible = !!(opacity && s.x && s.y && s.z);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Installs a per-mesh `updateMatrix` override on first skew / transformOrigin write. The override calls the original three.js compose, then patches the result with `applySkewOrigin` whenever any axis is non-zero. Idempotent.
|
|
48
|
+
*
|
|
49
|
+
* @param {any} mesh
|
|
50
|
+
* @return {{ skewX: number, skewY: number, skewZ: number, originX: number, originY: number, originZ: number }}
|
|
51
|
+
*/
|
|
52
|
+
function installSkewMatrix(mesh) {
|
|
53
|
+
let s = mesh[skewSymbol];
|
|
54
|
+
if (s) return s;
|
|
55
|
+
s = mesh[skewSymbol] = { skewX: 0, skewY: 0, skewZ: 0, originX: 0, originY: 0, originZ: 0 };
|
|
56
|
+
const original = mesh.updateMatrix;
|
|
57
|
+
mesh.updateMatrix = function () {
|
|
58
|
+
original.call(this);
|
|
59
|
+
const st = this[skewSymbol];
|
|
60
|
+
if (st.skewX !== 0 || st.skewY !== 0 || st.skewZ !== 0 || st.originX !== 0 || st.originY !== 0 || st.originZ !== 0) {
|
|
61
|
+
applySkewOrigin(this.matrix.elements, st.skewX, st.skewY, st.skewZ, st.originX, st.originY, st.originZ);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return s;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const threeObject3D = threeAdapter.registerTargetAdapter((t) => t instanceof Object3D);
|
|
68
|
+
|
|
69
|
+
// Position
|
|
70
|
+
threeObject3D.registerProperty('x', (t) => t.position.x, (t, v) => { t.position.x = v; });
|
|
71
|
+
threeObject3D.registerProperty('y', (t) => t.position.y, (t, v) => { t.position.y = v; });
|
|
72
|
+
threeObject3D.registerProperty('z', (t) => t.position.z, (t, v) => { t.position.z = v; });
|
|
73
|
+
|
|
74
|
+
// Rotation in degrees
|
|
75
|
+
threeObject3D.registerProperty('rotateX', (t) => radToDeg(t.rotation.x), (t, v) => { t.rotation.x = degToRad(v); });
|
|
76
|
+
threeObject3D.registerProperty('rotateY', (t) => radToDeg(t.rotation.y), (t, v) => { t.rotation.y = degToRad(v); });
|
|
77
|
+
threeObject3D.registerProperty('rotateZ', (t) => radToDeg(t.rotation.z), (t, v) => { t.rotation.z = degToRad(v); });
|
|
78
|
+
|
|
79
|
+
// Scale per-axis and uniform
|
|
80
|
+
threeObject3D.registerProperty('scaleX', (t) => t.scale.x, (t, v) => { t.scale.x = v; setVisibility(t); });
|
|
81
|
+
threeObject3D.registerProperty('scaleY', (t) => t.scale.y, (t, v) => { t.scale.y = v; setVisibility(t); });
|
|
82
|
+
threeObject3D.registerProperty('scaleZ', (t) => t.scale.z, (t, v) => { t.scale.z = v; setVisibility(t); });
|
|
83
|
+
threeObject3D.registerProperty('scale',
|
|
84
|
+
(t) => t.scale.x,
|
|
85
|
+
(t, v) => {
|
|
86
|
+
t.scale.x = v; t.scale.y = v; t.scale.z = v;
|
|
87
|
+
setVisibility(t);
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// Material
|
|
92
|
+
threeObject3D.registerProperty('visible', (t) => t.visible, (t, v) => { t.visible = !!v; });
|
|
93
|
+
threeObject3D.registerProperty('opacity',
|
|
94
|
+
(t) => {
|
|
95
|
+
if (t.material) return readScalar(t.material, 'opacity', PATH_DIRECT, 1);
|
|
96
|
+
const v = t[opacitySymbol];
|
|
97
|
+
return v === undefined ? 1 : v;
|
|
98
|
+
},
|
|
99
|
+
(t, v) => {
|
|
100
|
+
if (t.material) writeScalar(t.material, 'opacity', v, PATH_DIRECT);
|
|
101
|
+
else t[opacitySymbol] = v;
|
|
102
|
+
setVisibility(t, v);
|
|
103
|
+
},
|
|
104
|
+
(t) => !t.isLight,
|
|
105
|
+
);
|
|
106
|
+
threeObject3D.registerProperty('color',
|
|
107
|
+
(t) => readColorAt(colorTarget(t), 'color', PATH_DIRECT),
|
|
108
|
+
(t, _, tw) => writeColorAt(colorTarget(t), 'color', tw._numbers, PATH_DIRECT),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// HemisphereLight
|
|
112
|
+
threeObject3D.registerProperty('groundColor',
|
|
113
|
+
(t) => readColorAt(t, 'groundColor', PATH_DIRECT),
|
|
114
|
+
(t, _, tw) => writeColorAt(t, 'groundColor', tw._numbers, PATH_DIRECT),
|
|
115
|
+
(t) => !!t.groundColor,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Scene background, lazily initializes scene background to a Color on first write so the user does not have to set one upfront.
|
|
119
|
+
threeObject3D.registerProperty('background',
|
|
120
|
+
(t) => {
|
|
121
|
+
const bg = /** @type {any} */(t).background;
|
|
122
|
+
return bg && bg.isColor ? readColorHex(bg) : '#000000';
|
|
123
|
+
},
|
|
124
|
+
(t, _, tw) => {
|
|
125
|
+
const scene = /** @type {any} */(t);
|
|
126
|
+
let bg = scene.background;
|
|
127
|
+
if (!bg || !bg.isColor) {
|
|
128
|
+
bg = new Color();
|
|
129
|
+
scene.background = bg;
|
|
130
|
+
}
|
|
131
|
+
const ns = tw._numbers;
|
|
132
|
+
bg.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
|
|
133
|
+
},
|
|
134
|
+
(t) => !!t.isScene,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Method-bridged props for Audio and PerspectiveCamera focalLength, read via getXxx and write via setXxx.
|
|
138
|
+
const registerMethodProp = (apiName, getter, setter, gate) => {
|
|
139
|
+
threeObject3D.registerProperty(apiName,
|
|
140
|
+
(t) => t[getter](),
|
|
141
|
+
(t, v) => { t[setter](v); },
|
|
142
|
+
(t) => !!t[gate],
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
registerMethodProp('volume', 'getVolume', 'setVolume', 'setVolume');
|
|
146
|
+
// PositionalAudio
|
|
147
|
+
registerMethodProp('refDistance', 'getRefDistance', 'setRefDistance', 'setRefDistance');
|
|
148
|
+
registerMethodProp('rolloffFactor', 'getRolloffFactor', 'setRolloffFactor', 'setRefDistance');
|
|
149
|
+
registerMethodProp('maxDistance', 'getMaxDistance', 'setMaxDistance', 'setRefDistance');
|
|
150
|
+
// PerspectiveCamera
|
|
151
|
+
registerMethodProp('focalLength', 'getFocalLength', 'setFocalLength', 'setFocalLength');
|
|
152
|
+
|
|
153
|
+
// Camera projection-update props, setter writes the value then calls updateProjectionMatrix.
|
|
154
|
+
const registerCameraProp = (apiName, gate) => {
|
|
155
|
+
threeObject3D.registerProperty(apiName,
|
|
156
|
+
(t) => t[apiName],
|
|
157
|
+
(t, v) => { t[apiName] = v; t.updateProjectionMatrix(); },
|
|
158
|
+
gate,
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
const isPersp = (t) => !!t.isPerspectiveCamera;
|
|
162
|
+
const isOrtho = (t) => !!t.isOrthographicCamera;
|
|
163
|
+
registerCameraProp('fov', isPersp);
|
|
164
|
+
registerCameraProp('aspect', isPersp);
|
|
165
|
+
registerCameraProp('left', isOrtho);
|
|
166
|
+
registerCameraProp('right', isOrtho);
|
|
167
|
+
registerCameraProp('top', isOrtho);
|
|
168
|
+
registerCameraProp('bottom', isOrtho);
|
|
169
|
+
|
|
170
|
+
// Skew in degrees and transform-origin in object-space.
|
|
171
|
+
// Patches mesh updateMatrix on first write so the standard PRS compose is followed by an in-place skew and origin shift.
|
|
172
|
+
// Reads default to 0 for meshes that have never been written.
|
|
173
|
+
/**
|
|
174
|
+
* @param {String} apiName
|
|
175
|
+
* @param {String} key
|
|
176
|
+
*/
|
|
177
|
+
const registerSkewProp = (apiName, key) => {
|
|
178
|
+
threeObject3D.registerProperty(apiName,
|
|
179
|
+
(t) => { const s = /** @type {any} */(t)[skewSymbol]; return s ? s[key] : 0; },
|
|
180
|
+
(t, v) => { installSkewMatrix(t)[key] = v; },
|
|
181
|
+
);
|
|
182
|
+
};
|
|
183
|
+
registerSkewProp('skewX', 'skewX');
|
|
184
|
+
registerSkewProp('skewY', 'skewY');
|
|
185
|
+
registerSkewProp('skewZ', 'skewZ');
|
|
186
|
+
registerSkewProp('transformOriginX', 'originX');
|
|
187
|
+
registerSkewProp('transformOriginY', 'originY');
|
|
188
|
+
registerSkewProp('transformOriginZ', 'originZ');
|
|
189
|
+
|
|
190
|
+
// Shorthand 3-token string x y z or 2-string from-to array routed via the engine COMPLEX path.
|
|
191
|
+
// The setter reads tween _numbers for the per-frame lerped triplet.
|
|
192
|
+
threeObject3D.registerProperty('transformOrigin',
|
|
193
|
+
(t) => {
|
|
194
|
+
const s = /** @type {any} */(t)[skewSymbol];
|
|
195
|
+
return s ? `${s.originX} ${s.originY} ${s.originZ}` : '0 0 0';
|
|
196
|
+
},
|
|
197
|
+
(t, _, tw) => {
|
|
198
|
+
const s = installSkewMatrix(t);
|
|
199
|
+
const ns = tw._numbers;
|
|
200
|
+
s.originX = ns[0];
|
|
201
|
+
s.originY = ns[1];
|
|
202
|
+
s.originZ = ns[2];
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// Shared by both camera types.
|
|
207
|
+
const isCamera = (t) => !!t.isPerspectiveCamera || !!t.isOrthographicCamera;
|
|
208
|
+
registerCameraProp('near', isCamera);
|
|
209
|
+
registerCameraProp('far', isCamera);
|
|
210
|
+
registerCameraProp('zoom', isCamera);
|
|
211
|
+
|
|
212
|
+
// Auto-detection for material props on meshes and direct Vector / Color fields on the target is provided by the shared resolvers in resolvers.js.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - adapters - CJS
|
|
3
|
+
* @version v4.5.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var adapter = require('./adapter.cjs');
|
|
11
|
+
var number = require('../../utils/number.cjs');
|
|
12
|
+
var helpers = require('./helpers.cjs');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Global property resolvers for three.js targets. Auto-detect `Color`-typed properties, `Vector2/3/4` axis components, shader uniforms, and TSL `UniformNode` slots on any three.js object. For mesh-like targets, a second resolver walks to `target.material` and runs the same detection there.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const identity = (t) => t;
|
|
20
|
+
const getMaterial = (t) => t.material;
|
|
21
|
+
|
|
22
|
+
const directColorCache = [{}, {}, {}];
|
|
23
|
+
const directScalarCache = [{}, {}, {}];
|
|
24
|
+
const directVectorCache = [{}, {}, {}];
|
|
25
|
+
|
|
26
|
+
const materialColorCache = [{}, {}, {}];
|
|
27
|
+
const materialScalarCache = [{}, {}, {}];
|
|
28
|
+
const materialVectorCache = [{}, {}, {}];
|
|
29
|
+
|
|
30
|
+
const buildEntry = (name, d, getHost, colorCaches, scalarCaches, vectorCaches) => {
|
|
31
|
+
const path = d.path;
|
|
32
|
+
if (d.kind === helpers.KIND_COLOR) {
|
|
33
|
+
const cache = colorCaches[path];
|
|
34
|
+
return cache[name] || (cache[name] = {
|
|
35
|
+
get: (t) => helpers.readColorAt(getHost(t), name, path),
|
|
36
|
+
set: (t, _, tw) => helpers.writeColorAt(getHost(t), name, tw._numbers, path),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (d.kind === helpers.KIND_SCALAR) {
|
|
40
|
+
const cache = scalarCaches[path];
|
|
41
|
+
return cache[name] || (cache[name] = {
|
|
42
|
+
get: (t) => helpers.readScalar(getHost(t), name, path),
|
|
43
|
+
set: (t, v) => helpers.writeScalar(getHost(t), name, v, path),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// KIND_VECTOR
|
|
47
|
+
const base = d.base;
|
|
48
|
+
const axis = d.axis;
|
|
49
|
+
const cache = vectorCaches[path];
|
|
50
|
+
return cache[name] || (cache[name] = {
|
|
51
|
+
get: (t) => helpers.readVectorAt(getHost(t), base, axis, path),
|
|
52
|
+
set: (t, v) => helpers.writeVectorAt(getHost(t), base, axis, v, path),
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Detect direct Color, Vector axis, uniforms, and UniformNode slots on the target.
|
|
57
|
+
// Numeric or boolean direct fields fall through to the engine OBJECT path.
|
|
58
|
+
adapter.threeAdapter.registerPropertyResolver((target, name) => {
|
|
59
|
+
const d = helpers.classifyTargetProp(target, name);
|
|
60
|
+
if (!d) return null;
|
|
61
|
+
if (d.kind === helpers.KIND_SCALAR && d.path === helpers.PATH_DIRECT) return null;
|
|
62
|
+
return buildEntry(name, d, identity, directColorCache, directScalarCache, directVectorCache);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Walk to target.material for meshes and other Object3D subclasses with a material field.
|
|
66
|
+
// Skip when the target already exposes the name directly so a mesh-level mapping wins.
|
|
67
|
+
adapter.threeAdapter.registerPropertyResolver((target, name) => {
|
|
68
|
+
if (target[name] !== undefined) return null;
|
|
69
|
+
const m = target.material;
|
|
70
|
+
if (!m) return null;
|
|
71
|
+
const first = Array.isArray(m) ? m[0] : m;
|
|
72
|
+
if (!first) return null;
|
|
73
|
+
const d = helpers.classifyTargetProp(first, name);
|
|
74
|
+
if (!d) return null;
|
|
75
|
+
return buildEntry(name, d, getMaterial, materialColorCache, materialScalarCache, materialVectorCache);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Convert angle-named scalar fields between degrees and radians so users animate in degrees on any three.js target.
|
|
79
|
+
// Object3D Euler rotation is excluded because Euler is not a number, the rotateX/Y/Z mappings handle it.
|
|
80
|
+
const ANGLE_NAMES = { rotation: 1, angle: 1 };
|
|
81
|
+
const angleEntries = {};
|
|
82
|
+
adapter.threeAdapter.registerPropertyResolver((target, name) => {
|
|
83
|
+
if (!ANGLE_NAMES[name]) return null;
|
|
84
|
+
if (typeof target[name] !== 'number') return null;
|
|
85
|
+
return angleEntries[name] || (angleEntries[name] = {
|
|
86
|
+
get: (t) => number.radToDeg(t[name]),
|
|
87
|
+
set: (t, v) => { t[name] = number.degToRad(v); },
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Decompose Euler-typed angle fields to axis components in degrees, like rotationX, rotationY, rotationZ when rotation is an Euler.
|
|
92
|
+
// Object3D mappings win because static adapter props beat resolvers, so this only catches non-Object3D targets with an Euler rotation field.
|
|
93
|
+
const eulerAxisEntries = {};
|
|
94
|
+
adapter.threeAdapter.registerPropertyResolver((target, name) => {
|
|
95
|
+
const axis = helpers.AXIS_MAP[name[name.length - 1]];
|
|
96
|
+
if (!axis) return null;
|
|
97
|
+
const base = name.slice(0, -1);
|
|
98
|
+
if (!ANGLE_NAMES[base]) return null;
|
|
99
|
+
const v = target[base];
|
|
100
|
+
if (!v || !v.isEuler) return null;
|
|
101
|
+
return eulerAxisEntries[name] || (eulerAxisEntries[name] = {
|
|
102
|
+
get: (t) => number.radToDeg(t[base][axis]),
|
|
103
|
+
set: (t, v) => { t[base][axis] = number.degToRad(v); },
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - adapters - ESM
|
|
3
|
+
* @version v4.5.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { threeAdapter } from './adapter.js';
|
|
9
|
+
import { radToDeg, degToRad } from '../../utils/number.js';
|
|
10
|
+
import { classifyTargetProp, KIND_SCALAR, PATH_DIRECT, AXIS_MAP, KIND_COLOR, writeColorAt, readColorAt, writeScalar, readScalar, writeVectorAt, readVectorAt } from './helpers.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Global property resolvers for three.js targets. Auto-detect `Color`-typed properties, `Vector2/3/4` axis components, shader uniforms, and TSL `UniformNode` slots on any three.js object. For mesh-like targets, a second resolver walks to `target.material` and runs the same detection there.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const identity = (t) => t;
|
|
18
|
+
const getMaterial = (t) => t.material;
|
|
19
|
+
|
|
20
|
+
const directColorCache = [{}, {}, {}];
|
|
21
|
+
const directScalarCache = [{}, {}, {}];
|
|
22
|
+
const directVectorCache = [{}, {}, {}];
|
|
23
|
+
|
|
24
|
+
const materialColorCache = [{}, {}, {}];
|
|
25
|
+
const materialScalarCache = [{}, {}, {}];
|
|
26
|
+
const materialVectorCache = [{}, {}, {}];
|
|
27
|
+
|
|
28
|
+
const buildEntry = (name, d, getHost, colorCaches, scalarCaches, vectorCaches) => {
|
|
29
|
+
const path = d.path;
|
|
30
|
+
if (d.kind === KIND_COLOR) {
|
|
31
|
+
const cache = colorCaches[path];
|
|
32
|
+
return cache[name] || (cache[name] = {
|
|
33
|
+
get: (t) => readColorAt(getHost(t), name, path),
|
|
34
|
+
set: (t, _, tw) => writeColorAt(getHost(t), name, tw._numbers, path),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (d.kind === KIND_SCALAR) {
|
|
38
|
+
const cache = scalarCaches[path];
|
|
39
|
+
return cache[name] || (cache[name] = {
|
|
40
|
+
get: (t) => readScalar(getHost(t), name, path),
|
|
41
|
+
set: (t, v) => writeScalar(getHost(t), name, v, path),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// KIND_VECTOR
|
|
45
|
+
const base = d.base;
|
|
46
|
+
const axis = d.axis;
|
|
47
|
+
const cache = vectorCaches[path];
|
|
48
|
+
return cache[name] || (cache[name] = {
|
|
49
|
+
get: (t) => readVectorAt(getHost(t), base, axis, path),
|
|
50
|
+
set: (t, v) => writeVectorAt(getHost(t), base, axis, v, path),
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Detect direct Color, Vector axis, uniforms, and UniformNode slots on the target.
|
|
55
|
+
// Numeric or boolean direct fields fall through to the engine OBJECT path.
|
|
56
|
+
threeAdapter.registerPropertyResolver((target, name) => {
|
|
57
|
+
const d = classifyTargetProp(target, name);
|
|
58
|
+
if (!d) return null;
|
|
59
|
+
if (d.kind === KIND_SCALAR && d.path === PATH_DIRECT) return null;
|
|
60
|
+
return buildEntry(name, d, identity, directColorCache, directScalarCache, directVectorCache);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Walk to target.material for meshes and other Object3D subclasses with a material field.
|
|
64
|
+
// Skip when the target already exposes the name directly so a mesh-level mapping wins.
|
|
65
|
+
threeAdapter.registerPropertyResolver((target, name) => {
|
|
66
|
+
if (target[name] !== undefined) return null;
|
|
67
|
+
const m = target.material;
|
|
68
|
+
if (!m) return null;
|
|
69
|
+
const first = Array.isArray(m) ? m[0] : m;
|
|
70
|
+
if (!first) return null;
|
|
71
|
+
const d = classifyTargetProp(first, name);
|
|
72
|
+
if (!d) return null;
|
|
73
|
+
return buildEntry(name, d, getMaterial, materialColorCache, materialScalarCache, materialVectorCache);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Convert angle-named scalar fields between degrees and radians so users animate in degrees on any three.js target.
|
|
77
|
+
// Object3D Euler rotation is excluded because Euler is not a number, the rotateX/Y/Z mappings handle it.
|
|
78
|
+
const ANGLE_NAMES = { rotation: 1, angle: 1 };
|
|
79
|
+
const angleEntries = {};
|
|
80
|
+
threeAdapter.registerPropertyResolver((target, name) => {
|
|
81
|
+
if (!ANGLE_NAMES[name]) return null;
|
|
82
|
+
if (typeof target[name] !== 'number') return null;
|
|
83
|
+
return angleEntries[name] || (angleEntries[name] = {
|
|
84
|
+
get: (t) => radToDeg(t[name]),
|
|
85
|
+
set: (t, v) => { t[name] = degToRad(v); },
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Decompose Euler-typed angle fields to axis components in degrees, like rotationX, rotationY, rotationZ when rotation is an Euler.
|
|
90
|
+
// Object3D mappings win because static adapter props beat resolvers, so this only catches non-Object3D targets with an Euler rotation field.
|
|
91
|
+
const eulerAxisEntries = {};
|
|
92
|
+
threeAdapter.registerPropertyResolver((target, name) => {
|
|
93
|
+
const axis = AXIS_MAP[name[name.length - 1]];
|
|
94
|
+
if (!axis) return null;
|
|
95
|
+
const base = name.slice(0, -1);
|
|
96
|
+
if (!ANGLE_NAMES[base]) return null;
|
|
97
|
+
const v = target[base];
|
|
98
|
+
if (!v || !v.isEuler) return null;
|
|
99
|
+
return eulerAxisEntries[name] || (eulerAxisEntries[name] = {
|
|
100
|
+
get: (t) => radToDeg(t[base][axis]),
|
|
101
|
+
set: (t, v) => { t[base][axis] = degToRad(v); },
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - adapters - CJS
|
|
3
|
+
* @version v4.5.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var three = require('three');
|
|
11
|
+
var adapter = require('./adapter.cjs');
|
|
12
|
+
var helpers = require('./helpers.cjs');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Bare `UniformNode` adapter. Auto-detects `UniformNode` instances and exposes their `.value` for animation. Scalars and booleans animate via `value`, `Color` uniforms via `color`, and `Vector2/3/4` uniforms via `x` / `y` / `z` / `w` axes.
|
|
16
|
+
*
|
|
17
|
+
* import 'animejs/bindings/three';
|
|
18
|
+
* import { uniform } from 'three/tsl';
|
|
19
|
+
* animate(uniform(0), { value: 1 });
|
|
20
|
+
* animate(uniform(new Color()), { color: '#0f0' });
|
|
21
|
+
* animate(uniform(new Vector3()), { x: 1, y: 0.5 });
|
|
22
|
+
*
|
|
23
|
+
* `UniformNode` slots assigned to `NodeMaterial` (`material.colorNode`, `material.offsetNode`, ...) are auto-detected by the shared resolvers in `resolvers.js`. Non-uniform nodes (`mix`, `add`, computed expressions), `Matrix3/4` and `Texture` valued uniforms, and `UniformArrayNode` / `BufferNode` are out of scope and fall through to the engine's direct property path.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const uniformNode = adapter.threeAdapter.registerTargetAdapter((t) => !!(t && t.isUniformNode));
|
|
28
|
+
|
|
29
|
+
// Scalar and bool uniforms animate via the engine OBJECT fallthrough on value, no adapter prop needed since the engine writes uniform value natively.
|
|
30
|
+
uniformNode.registerProperty('color',
|
|
31
|
+
(t) => helpers.readColorHex(t.value),
|
|
32
|
+
(t, _, tw) => {
|
|
33
|
+
const ns = tw._numbers;
|
|
34
|
+
t.value.setRGB(ns[0] * helpers.COLOR_NORM, ns[1] * helpers.COLOR_NORM, ns[2] * helpers.COLOR_NORM, three.SRGBColorSpace);
|
|
35
|
+
},
|
|
36
|
+
(t) => !!(t.value && t.value.isColor),
|
|
37
|
+
);
|
|
38
|
+
uniformNode.registerProperty('x', (t) => t.value.x, (t, v) => { t.value.x = v; }, (t) => helpers.isVectorWith(t.value, 'x'));
|
|
39
|
+
uniformNode.registerProperty('y', (t) => t.value.y, (t, v) => { t.value.y = v; }, (t) => helpers.isVectorWith(t.value, 'y'));
|
|
40
|
+
uniformNode.registerProperty('z', (t) => t.value.z, (t, v) => { t.value.z = v; }, (t) => helpers.isVectorWith(t.value, 'z'));
|
|
41
|
+
uniformNode.registerProperty('w', (t) => t.value.w, (t, v) => { t.value.w = v; }, (t) => helpers.isVectorWith(t.value, 'w'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anime.js - adapters - ESM
|
|
3
|
+
* @version v4.5.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2026 - Julian Garnier
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { SRGBColorSpace } from 'three';
|
|
9
|
+
import { threeAdapter } from './adapter.js';
|
|
10
|
+
import { readColorHex, COLOR_NORM, isVectorWith } from './helpers.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Bare `UniformNode` adapter. Auto-detects `UniformNode` instances and exposes their `.value` for animation. Scalars and booleans animate via `value`, `Color` uniforms via `color`, and `Vector2/3/4` uniforms via `x` / `y` / `z` / `w` axes.
|
|
14
|
+
*
|
|
15
|
+
* import 'animejs/bindings/three';
|
|
16
|
+
* import { uniform } from 'three/tsl';
|
|
17
|
+
* animate(uniform(0), { value: 1 });
|
|
18
|
+
* animate(uniform(new Color()), { color: '#0f0' });
|
|
19
|
+
* animate(uniform(new Vector3()), { x: 1, y: 0.5 });
|
|
20
|
+
*
|
|
21
|
+
* `UniformNode` slots assigned to `NodeMaterial` (`material.colorNode`, `material.offsetNode`, ...) are auto-detected by the shared resolvers in `resolvers.js`. Non-uniform nodes (`mix`, `add`, computed expressions), `Matrix3/4` and `Texture` valued uniforms, and `UniformArrayNode` / `BufferNode` are out of scope and fall through to the engine's direct property path.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const uniformNode = threeAdapter.registerTargetAdapter((t) => !!(t && t.isUniformNode));
|
|
26
|
+
|
|
27
|
+
// Scalar and bool uniforms animate via the engine OBJECT fallthrough on value, no adapter prop needed since the engine writes uniform value natively.
|
|
28
|
+
uniformNode.registerProperty('color',
|
|
29
|
+
(t) => readColorHex(t.value),
|
|
30
|
+
(t, _, tw) => {
|
|
31
|
+
const ns = tw._numbers;
|
|
32
|
+
t.value.setRGB(ns[0] * COLOR_NORM, ns[1] * COLOR_NORM, ns[2] * COLOR_NORM, SRGBColorSpace);
|
|
33
|
+
},
|
|
34
|
+
(t) => !!(t.value && t.value.isColor),
|
|
35
|
+
);
|
|
36
|
+
uniformNode.registerProperty('x', (t) => t.value.x, (t, v) => { t.value.x = v; }, (t) => isVectorWith(t.value, 'x'));
|
|
37
|
+
uniformNode.registerProperty('y', (t) => t.value.y, (t, v) => { t.value.y = v; }, (t) => isVectorWith(t.value, 'y'));
|
|
38
|
+
uniformNode.registerProperty('z', (t) => t.value.z, (t, v) => { t.value.z = v; }, (t) => isVectorWith(t.value, 'z'));
|
|
39
|
+
uniformNode.registerProperty('w', (t) => t.value.w, (t, v) => { t.value.w = v; }, (t) => isVectorWith(t.value, 'w'));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - animatable - CJS
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.5.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -60,6 +60,7 @@ class Animatable {
|
|
|
60
60
|
const callbacksAnimationParams = { v: 1, autoplay: false };
|
|
61
61
|
const properties = {};
|
|
62
62
|
this.targets = [];
|
|
63
|
+
/** @type {Record<String, JSAnimation>} */
|
|
63
64
|
this.animations = {};
|
|
64
65
|
/** @type {JSAnimation|null} */
|
|
65
66
|
this.callbacks = null;
|
|
@@ -16,7 +16,8 @@ export class Animatable {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(targets: TargetsParam, parameters: AnimatableParams);
|
|
18
18
|
targets: (HTMLElement | SVGElement | import("../types/index.js").JSTarget)[];
|
|
19
|
-
|
|
19
|
+
/** @type {Record<String, JSAnimation>} */
|
|
20
|
+
animations: Record<string, JSAnimation>;
|
|
20
21
|
/** @type {JSAnimation|null} */
|
|
21
22
|
callbacks: JSAnimation | null;
|
|
22
23
|
revert(): this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anime.js - animatable - ESM
|
|
3
|
-
* @version v4.
|
|
3
|
+
* @version v4.5.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 - Julian Garnier
|
|
6
6
|
*/
|
|
@@ -58,6 +58,7 @@ class Animatable {
|
|
|
58
58
|
const callbacksAnimationParams = { v: 1, autoplay: false };
|
|
59
59
|
const properties = {};
|
|
60
60
|
this.targets = [];
|
|
61
|
+
/** @type {Record<String, JSAnimation>} */
|
|
61
62
|
this.animations = {};
|
|
62
63
|
/** @type {JSAnimation|null} */
|
|
63
64
|
this.callbacks = null;
|