@needle-tools/engine 4.9.3-next.0facab6 → 4.10.0-beta
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/CHANGELOG.md +9 -0
- package/dist/{needle-engine.bundle-DAo7BPxQ.umd.cjs → needle-engine.bundle-42AmEGfk.umd.cjs} +127 -126
- package/dist/{needle-engine.bundle-DP2gYtOQ.min.js → needle-engine.bundle-C6zhyLF5.min.js} +128 -127
- package/dist/{needle-engine.bundle-TvT7wv7z.js → needle-engine.bundle-Dj6faVbC.js} +4967 -4864
- package/dist/needle-engine.js +414 -413
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/codegen/register_types.js +2 -0
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +2 -2
- package/lib/engine-components/Renderer.js +6 -4
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +28 -6
- package/lib/engine-components/timeline/PlayableDirector.js +60 -26
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/TimelineModels.d.ts +3 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +7 -0
- package/lib/engine-components/timeline/TimelineTracks.js +19 -0
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +14 -4
- package/lib/engine-components/web/ScrollFollow.js +139 -25
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/package.json +2 -2
- package/src/engine/codegen/register_types.ts +2 -0
- package/src/engine-components/Renderer.ts +6 -4
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/timeline/PlayableDirector.ts +79 -34
- package/src/engine-components/timeline/TimelineModels.ts +3 -0
- package/src/engine-components/timeline/TimelineTracks.ts +22 -0
- package/src/engine-components/web/ScrollFollow.ts +177 -24
|
@@ -8,6 +8,7 @@ import { Object3D } from "three";
|
|
|
8
8
|
import { Mathf } from "../../engine/engine_math.js";
|
|
9
9
|
import { serializable } from "../../engine/engine_serialization.js";
|
|
10
10
|
import { getBoundingBox } from "../../engine/engine_three_utils.js";
|
|
11
|
+
import { getParam } from "../../engine/engine_utils.js";
|
|
11
12
|
import { Animation } from "../Animation.js";
|
|
12
13
|
import { Animator } from "../Animator.js";
|
|
13
14
|
import { AudioSource } from "../AudioSource.js";
|
|
@@ -16,6 +17,7 @@ import { EventList } from "../EventList.js";
|
|
|
16
17
|
import { Light } from "../Light.js";
|
|
17
18
|
import { SplineWalker } from "../splines/SplineWalker.js";
|
|
18
19
|
import { PlayableDirector } from "../timeline/PlayableDirector.js";
|
|
20
|
+
const debug = getParam("debugscroll");
|
|
19
21
|
/**
|
|
20
22
|
* The ScrollFollow component allows you to link the scroll position of the page (or a specific element) to one or more target objects.
|
|
21
23
|
* This can be used to create scroll-based animations, audio playback, or other effects. For example you can link the scroll position to a timeline (PlayableDirector) to create scroll-based storytelling effects or to an Animator component to change the animation state based on scroll.
|
|
@@ -67,6 +69,7 @@ export class ScrollFollow extends Behaviour {
|
|
|
67
69
|
*/
|
|
68
70
|
invert = false;
|
|
69
71
|
/**
|
|
72
|
+
* **Experimental - might change in future updates**
|
|
70
73
|
* If set, the scroll position will be read from the specified element instead of the window.
|
|
71
74
|
* Use a CSS selector to specify the element, e.g. `#my-scrollable-div` or `.scroll-container`.
|
|
72
75
|
* @default null
|
|
@@ -81,15 +84,19 @@ export class ScrollFollow extends Behaviour {
|
|
|
81
84
|
* Current scroll value in "pages" (0 = top of page, 1 = bottom of page)
|
|
82
85
|
*/
|
|
83
86
|
get currentValue() {
|
|
84
|
-
return this.
|
|
87
|
+
return this._current_value;
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
_current_value = 0;
|
|
90
|
+
_target_value = 0;
|
|
91
|
+
_appliedValue = -1;
|
|
92
|
+
_scrollStart = 0;
|
|
93
|
+
_scrollEnd = 0;
|
|
94
|
+
_scrollValue = 0;
|
|
95
|
+
_scrollContainerHeight = 0;
|
|
89
96
|
/** @internal */
|
|
90
97
|
onEnable() {
|
|
91
98
|
window.addEventListener("wheel", this.updateCurrentScrollValue, { passive: true });
|
|
92
|
-
this.
|
|
99
|
+
this._appliedValue = -1;
|
|
93
100
|
}
|
|
94
101
|
/** @internal */
|
|
95
102
|
onDisable() {
|
|
@@ -98,21 +105,25 @@ export class ScrollFollow extends Behaviour {
|
|
|
98
105
|
/** @internal */
|
|
99
106
|
lateUpdate() {
|
|
100
107
|
this.updateCurrentScrollValue();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
if (this._target_value >= 0) {
|
|
109
|
+
if (this.damping > 0) { // apply damping
|
|
110
|
+
this._current_value = Mathf.lerp(this._current_value, this._target_value, this.context.time.deltaTime / this.damping);
|
|
111
|
+
if (Math.abs(this._current_value - this._target_value) < 0.001) {
|
|
112
|
+
this._current_value = this._target_value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this._current_value = this._target_value;
|
|
117
|
+
}
|
|
107
118
|
}
|
|
108
|
-
if (this.
|
|
109
|
-
this.
|
|
119
|
+
if (this._current_value !== this._appliedValue) {
|
|
120
|
+
this._appliedValue = this._current_value;
|
|
110
121
|
let defaultPrevented = false;
|
|
111
122
|
if (this.changed.listenerCount > 0) {
|
|
112
123
|
// fire change event
|
|
113
124
|
const event = {
|
|
114
125
|
type: "change",
|
|
115
|
-
value: this.
|
|
126
|
+
value: this._current_value,
|
|
116
127
|
component: this,
|
|
117
128
|
preventDefault: () => { event.defaultPrevented = true; },
|
|
118
129
|
defaultPrevented: false,
|
|
@@ -122,19 +133,28 @@ export class ScrollFollow extends Behaviour {
|
|
|
122
133
|
}
|
|
123
134
|
// if not prevented apply scroll
|
|
124
135
|
if (!defaultPrevented) {
|
|
125
|
-
const value = this.invert ? 1 - this.
|
|
136
|
+
const value = this.invert ? 1 - this._current_value : this._current_value;
|
|
137
|
+
const height = this._rangeEndValue - this._rangeStartValue;
|
|
138
|
+
const pixelValue = this._rangeStartValue + value * height;
|
|
126
139
|
// apply scroll to target(s)
|
|
127
140
|
if (Array.isArray(this.target)) {
|
|
128
|
-
this.target.forEach(t => t &&
|
|
141
|
+
this.target.forEach(t => t && this.applyScroll(t, value));
|
|
129
142
|
}
|
|
130
143
|
else if (this.target) {
|
|
131
|
-
|
|
144
|
+
this.applyScroll(this.target, value);
|
|
145
|
+
}
|
|
146
|
+
if (debug && this.context.time.frame % 30 === 0) {
|
|
147
|
+
console.debug(`[ScrollFollow] ${this._current_value.toFixed(5)} — ${(this._target_value * 100).toFixed(0)}%`);
|
|
132
148
|
}
|
|
133
149
|
}
|
|
134
150
|
}
|
|
135
151
|
}
|
|
136
152
|
_lastSelectorValue = null;
|
|
137
153
|
_lastSelectorElement = null;
|
|
154
|
+
/** Top y */
|
|
155
|
+
_rangeStartValue = 0;
|
|
156
|
+
/** Bottom y */
|
|
157
|
+
_rangeEndValue = 0;
|
|
138
158
|
updateCurrentScrollValue = () => {
|
|
139
159
|
switch (this.mode) {
|
|
140
160
|
case "window":
|
|
@@ -145,25 +165,35 @@ export class ScrollFollow extends Behaviour {
|
|
|
145
165
|
}
|
|
146
166
|
if (this._lastSelectorElement) {
|
|
147
167
|
const rect = this._lastSelectorElement.getBoundingClientRect();
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
168
|
+
this._scrollStart = rect.top + window.scrollY;
|
|
169
|
+
this._scrollEnd = rect.height - window.innerHeight;
|
|
170
|
+
this._scrollValue = -rect.top;
|
|
171
|
+
this._target_value = -rect.top / (rect.height - window.innerHeight);
|
|
172
|
+
this._rangeStartValue = rect.top + window.scrollY;
|
|
173
|
+
this._rangeEndValue = this._rangeStartValue + rect.height - window.innerHeight;
|
|
174
|
+
this._scrollContainerHeight = rect.height;
|
|
151
175
|
break;
|
|
152
176
|
}
|
|
153
177
|
}
|
|
154
178
|
else {
|
|
155
|
-
this.
|
|
179
|
+
this._scrollStart = 0;
|
|
180
|
+
this._scrollEnd = window.document.body.scrollHeight - window.innerHeight;
|
|
181
|
+
this._scrollValue = window.scrollY;
|
|
182
|
+
this._target_value = this._scrollValue / (this._scrollEnd || 1);
|
|
183
|
+
this._rangeStartValue = 0;
|
|
184
|
+
this._rangeEndValue = document.body.scrollHeight;
|
|
185
|
+
this._scrollContainerHeight = window.innerHeight;
|
|
156
186
|
}
|
|
157
|
-
if (isNaN(this.target_value) || !isFinite(this.target_value))
|
|
158
|
-
this.target_value = 0;
|
|
159
187
|
break;
|
|
160
188
|
}
|
|
189
|
+
if (isNaN(this._target_value) || !isFinite(this._target_value))
|
|
190
|
+
this._target_value = -1;
|
|
161
191
|
};
|
|
162
|
-
|
|
192
|
+
applyScroll(target, value) {
|
|
163
193
|
if (!target)
|
|
164
194
|
return;
|
|
165
195
|
if (target instanceof PlayableDirector) {
|
|
166
|
-
target
|
|
196
|
+
this.handleTimelineTarget(target, value);
|
|
167
197
|
if (!target.isPlaying)
|
|
168
198
|
target.evaluate();
|
|
169
199
|
}
|
|
@@ -204,6 +234,88 @@ export class ScrollFollow extends Behaviour {
|
|
|
204
234
|
}
|
|
205
235
|
}
|
|
206
236
|
}
|
|
237
|
+
handleTimelineTarget(director, value) {
|
|
238
|
+
const duration = director.duration;
|
|
239
|
+
let scrollRegionStart = Infinity;
|
|
240
|
+
let scrollRegionEnd = 0;
|
|
241
|
+
markersArray.length = 0;
|
|
242
|
+
for (const marker of director.foreachMarker("ScrollMarker")) {
|
|
243
|
+
// Get marker elements from DOM
|
|
244
|
+
if (marker.selector?.length && (marker.element === undefined || marker.needsUpdate === true || /** element is not in DOM anymore? */ (!marker.element?.parentNode))) {
|
|
245
|
+
marker.needsUpdate = false;
|
|
246
|
+
try {
|
|
247
|
+
marker.element = document.querySelector(marker.selector) || null;
|
|
248
|
+
if (debug)
|
|
249
|
+
console.debug("ScrollMarker found on page", marker.element, marker.selector);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
marker.element = null;
|
|
253
|
+
console.error("ScrollMarker selector is not valid: " + marker.selector + "\n", error);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// skip markers without element (e.g. if the selector didn't return any element)
|
|
257
|
+
if (!marker.element)
|
|
258
|
+
continue;
|
|
259
|
+
markersArray.push(marker);
|
|
260
|
+
const top = marker.element.offsetTop;
|
|
261
|
+
const height = marker.element.offsetHeight;
|
|
262
|
+
const bottom = top + height;
|
|
263
|
+
if (top < scrollRegionStart) {
|
|
264
|
+
scrollRegionStart = top;
|
|
265
|
+
}
|
|
266
|
+
if (bottom > scrollRegionEnd) {
|
|
267
|
+
scrollRegionEnd = bottom;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const currentTop = this._scrollValue;
|
|
271
|
+
const currentBottom = currentTop + this._scrollContainerHeight;
|
|
272
|
+
weightsArray.length = 0;
|
|
273
|
+
let sum = 0;
|
|
274
|
+
let markerCount = 0;
|
|
275
|
+
for (const marker of markersArray) {
|
|
276
|
+
if (!marker.element)
|
|
277
|
+
continue;
|
|
278
|
+
const top = marker.element.offsetTop;
|
|
279
|
+
const height = marker.element.offsetHeight;
|
|
280
|
+
const bottom = top + height;
|
|
281
|
+
let overlap = 0;
|
|
282
|
+
// TODO: if we have two marker sections where no HTML overlaps (vor example because some large section is between them) we probably want to still virtually interpolate between them slowly in that region
|
|
283
|
+
if (bottom < currentTop) {
|
|
284
|
+
// marker is above scroll region
|
|
285
|
+
overlap = 0;
|
|
286
|
+
}
|
|
287
|
+
else if (top > currentBottom) {
|
|
288
|
+
// marker is below scroll region
|
|
289
|
+
overlap = 0;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
// calculate overlap in pixels
|
|
293
|
+
const overlapTop = Math.max(top, currentTop);
|
|
294
|
+
const overlapBottom = Math.min(bottom, currentBottom);
|
|
295
|
+
overlap = Math.max(0, overlapBottom - overlapTop);
|
|
296
|
+
// console.log(marker.element.className, overlap)
|
|
297
|
+
}
|
|
298
|
+
markerCount += 1;
|
|
299
|
+
if (overlap > 0) {
|
|
300
|
+
weightsArray.push({ time: marker.time, weight: overlap });
|
|
301
|
+
sum += overlap;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (weightsArray.length <= 0 && markerCount <= 0) {
|
|
305
|
+
director.time = value * duration;
|
|
306
|
+
}
|
|
307
|
+
else if (weightsArray.length > 0) {
|
|
308
|
+
// normalize and calculate weighted time
|
|
309
|
+
let time = weightsArray[0].time;
|
|
310
|
+
for (const o of weightsArray) {
|
|
311
|
+
const weight = o.weight / Math.max(0.00001, sum);
|
|
312
|
+
// lerp time based on weight
|
|
313
|
+
const diff = Math.abs(o.time - time);
|
|
314
|
+
time += diff * weight;
|
|
315
|
+
}
|
|
316
|
+
director.time = time;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
207
319
|
}
|
|
208
320
|
__decorate([
|
|
209
321
|
serializable([Behaviour, Object3D])
|
|
@@ -223,4 +335,6 @@ __decorate([
|
|
|
223
335
|
__decorate([
|
|
224
336
|
serializable(EventList)
|
|
225
337
|
], ScrollFollow.prototype, "changed", void 0);
|
|
338
|
+
const weightsArray = [];
|
|
339
|
+
const markersArray = [];
|
|
226
340
|
//# sourceMappingURL=ScrollFollow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollFollow.js","sourceRoot":"","sources":["../../../src/engine-components/web/ScrollFollow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ScrollFollow.js","sourceRoot":"","sources":["../../../src/engine-components/web/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
-
"version": "4.
|
|
3
|
+
"version": "4.10.0-beta",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.",
|
|
5
5
|
"main": "dist/needle-engine.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -168,4 +168,4 @@
|
|
|
168
168
|
"module": "lib/needle-engine.js",
|
|
169
169
|
"typings": "lib/needle-engine.d.ts",
|
|
170
170
|
"types": "lib/needle-engine.d.ts"
|
|
171
|
-
}
|
|
171
|
+
}
|
|
@@ -108,6 +108,7 @@ import { PlayableDirector } from "../../engine-components/timeline/PlayableDirec
|
|
|
108
108
|
import { SignalReceiver } from "../../engine-components/timeline/SignalAsset.js";
|
|
109
109
|
import { AnimationTrackHandler } from "../../engine-components/timeline/TimelineTracks.js";
|
|
110
110
|
import { AudioTrackHandler } from "../../engine-components/timeline/TimelineTracks.js";
|
|
111
|
+
import { MarkerTrackHandler } from "../../engine-components/timeline/TimelineTracks.js";
|
|
111
112
|
import { SignalTrackHandler } from "../../engine-components/timeline/TimelineTracks.js";
|
|
112
113
|
import { ControlTrackHandler } from "../../engine-components/timeline/TimelineTracks.js";
|
|
113
114
|
import { TransformGizmo } from "../../engine-components/TransformGizmo.js";
|
|
@@ -265,6 +266,7 @@ TypeStore.add("PlayableDirector", PlayableDirector);
|
|
|
265
266
|
TypeStore.add("SignalReceiver", SignalReceiver);
|
|
266
267
|
TypeStore.add("AnimationTrackHandler", AnimationTrackHandler);
|
|
267
268
|
TypeStore.add("AudioTrackHandler", AudioTrackHandler);
|
|
269
|
+
TypeStore.add("MarkerTrackHandler", MarkerTrackHandler);
|
|
268
270
|
TypeStore.add("SignalTrackHandler", SignalTrackHandler);
|
|
269
271
|
TypeStore.add("ControlTrackHandler", ControlTrackHandler);
|
|
270
272
|
TypeStore.add("TransformGizmo", TransformGizmo);
|
|
@@ -304,10 +304,12 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
304
304
|
return this._sharedMeshes;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
// @ts-ignore
|
|
307
308
|
get sharedMaterial(): SharedMaterial {
|
|
308
|
-
return this.sharedMaterials[0] as SharedMaterial;
|
|
309
|
+
return (this.sharedMaterials?.[0]) as SharedMaterial;
|
|
309
310
|
}
|
|
310
311
|
|
|
312
|
+
// @ts-ignore
|
|
311
313
|
set sharedMaterial(mat: SharedMaterial) {
|
|
312
314
|
const cur = this.sharedMaterials[0];
|
|
313
315
|
if (cur === mat) return;
|
|
@@ -315,12 +317,12 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
315
317
|
this.applyLightmapping();
|
|
316
318
|
}
|
|
317
319
|
|
|
318
|
-
/**@deprecated
|
|
320
|
+
/**@deprecated Use sharedMaterial */
|
|
319
321
|
get material(): SharedMaterial {
|
|
320
|
-
return this.sharedMaterials[0] as SharedMaterial;
|
|
322
|
+
return this.sharedMaterials?.[0] as SharedMaterial;
|
|
321
323
|
}
|
|
322
324
|
|
|
323
|
-
/**@deprecated
|
|
325
|
+
/**@deprecated Use sharedMaterial */
|
|
324
326
|
set material(mat: SharedMaterial) {
|
|
325
327
|
this.sharedMaterial = mat;
|
|
326
328
|
}
|
|
@@ -169,6 +169,7 @@ export { SignalReceiverEvent } from "../timeline/SignalAsset.js";
|
|
|
169
169
|
export { SignalReceiver } from "../timeline/SignalAsset.js";
|
|
170
170
|
export { AnimationTrackHandler } from "../timeline/TimelineTracks.js";
|
|
171
171
|
export { AudioTrackHandler } from "../timeline/TimelineTracks.js";
|
|
172
|
+
export { MarkerTrackHandler } from "../timeline/TimelineTracks.js";
|
|
172
173
|
export { SignalTrackHandler } from "../timeline/TimelineTracks.js";
|
|
173
174
|
export { ControlTrackHandler } from "../timeline/TimelineTracks.js";
|
|
174
175
|
export { TransformGizmo } from "../TransformGizmo.js";
|
|
@@ -293,6 +293,41 @@ export class PlayableDirector extends Behaviour {
|
|
|
293
293
|
return this._audioTracks;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
/**
|
|
297
|
+
* @returns all signal tracks of the timeline
|
|
298
|
+
*/
|
|
299
|
+
get signalTracks(): Tracks.SignalTrackHandler[] {
|
|
300
|
+
return this._signalTracks;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @returns all marker tracks of the timeline
|
|
305
|
+
*/
|
|
306
|
+
get markerTracks(): Tracks.MarkerTrackHandler[] {
|
|
307
|
+
return this._markerTracks;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Iterates over all markers of the timeline, optionally filtering by type
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* // Iterate over all ScrollMarkers in the timeline
|
|
316
|
+
* for (const marker of director.foreachMarker<{selector:string}>("ScrollMarker")) {
|
|
317
|
+
* console.log(marker.time, marker.selector);
|
|
318
|
+
* }
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
*/
|
|
322
|
+
*foreachMarker<T extends Record<string, any>>(type: string | null = null): Generator<(T & Models.MarkerModel)> {
|
|
323
|
+
for (const track of this._markerTracks) {
|
|
324
|
+
for (const marker of track.foreachMarker<T>(type)) {
|
|
325
|
+
yield marker as T & Models.MarkerModel;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
296
331
|
private _guidsMap?: GuidsMap;
|
|
297
332
|
/** @internal */
|
|
298
333
|
resolveGuids(map: GuidsMap) {
|
|
@@ -309,16 +344,18 @@ export class PlayableDirector extends Behaviour {
|
|
|
309
344
|
private _time: number = 0;
|
|
310
345
|
private _duration: number = 0;
|
|
311
346
|
private _weight: number = 1;
|
|
312
|
-
private _animationTracks: Array<Tracks.AnimationTrackHandler> = [];
|
|
313
|
-
private _audioTracks: Array<Tracks.AudioTrackHandler> = [];
|
|
314
|
-
private _signalTracks: Array<Tracks.SignalTrackHandler> = [];
|
|
315
|
-
private
|
|
316
|
-
private
|
|
317
|
-
|
|
318
|
-
|
|
347
|
+
private readonly _animationTracks: Array<Tracks.AnimationTrackHandler> = [];
|
|
348
|
+
private readonly _audioTracks: Array<Tracks.AudioTrackHandler> = [];
|
|
349
|
+
private readonly _signalTracks: Array<Tracks.SignalTrackHandler> = [];
|
|
350
|
+
private readonly _markerTracks: Array<Tracks.MarkerTrackHandler> = [];
|
|
351
|
+
private readonly _controlTracks: Array<Tracks.ControlTrackHandler> = [];
|
|
352
|
+
private readonly _customTracks: Array<Tracks.TrackHandler> = [];
|
|
353
|
+
|
|
354
|
+
private readonly _allTracks: Array<Array<Tracks.TrackHandler>> = [
|
|
319
355
|
this._animationTracks,
|
|
320
356
|
this._audioTracks,
|
|
321
357
|
this._signalTracks,
|
|
358
|
+
this._markerTracks,
|
|
322
359
|
this._controlTracks,
|
|
323
360
|
this._customTracks
|
|
324
361
|
];
|
|
@@ -335,7 +372,7 @@ export class PlayableDirector extends Behaviour {
|
|
|
335
372
|
}
|
|
336
373
|
}
|
|
337
374
|
|
|
338
|
-
private *internalUpdate() {
|
|
375
|
+
private * internalUpdate() {
|
|
339
376
|
while (this._isPlaying && this.activeAndEnabled) {
|
|
340
377
|
if (!this._isPaused && this._isPlaying) {
|
|
341
378
|
this._time += this.context.time.deltaTime * this.speed;
|
|
@@ -415,26 +452,18 @@ export class PlayableDirector extends Behaviour {
|
|
|
415
452
|
}
|
|
416
453
|
}
|
|
417
454
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
455
|
+
for (const track of this._allTracks) {
|
|
456
|
+
for (const handler of track) {
|
|
457
|
+
// When timeline reaches the end "stop()" is called which is evaluating with time 0
|
|
458
|
+
// We don't want to re-evaluate the animation then in case the timeline is blended with the Animator
|
|
459
|
+
// e.g then the timeline animation at time 0 is 100% applied on top of the animator animation
|
|
460
|
+
|
|
461
|
+
if (this._isStopping && handler instanceof Tracks.AnimationTrackHandler) {
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
423
464
|
handler.evaluate(time);
|
|
424
465
|
}
|
|
425
466
|
}
|
|
426
|
-
for (const handler of this._audioTracks) {
|
|
427
|
-
handler.evaluate(time);
|
|
428
|
-
}
|
|
429
|
-
for (const sig of this._signalTracks) {
|
|
430
|
-
sig.evaluate(time);
|
|
431
|
-
}
|
|
432
|
-
for (const ctrl of this._controlTracks) {
|
|
433
|
-
ctrl.evaluate(time);
|
|
434
|
-
}
|
|
435
|
-
for (const cust of this._customTracks) {
|
|
436
|
-
cust.evaluate(time);
|
|
437
|
-
}
|
|
438
467
|
}
|
|
439
468
|
|
|
440
469
|
private resolveBindings() {
|
|
@@ -630,26 +659,42 @@ export class PlayableDirector extends Behaviour {
|
|
|
630
659
|
}
|
|
631
660
|
}
|
|
632
661
|
else if (track.type === Models.TrackType.Marker) {
|
|
633
|
-
|
|
634
|
-
signalHandler.director = this;
|
|
635
|
-
signalHandler.track = track;
|
|
662
|
+
|
|
636
663
|
if (track.markers) {
|
|
664
|
+
// For the marker track we create both a signal track handler AND a markertrack handler because a marker track can have signals and markers
|
|
665
|
+
const signalHandler: Tracks.SignalTrackHandler = new Tracks.SignalTrackHandler();
|
|
666
|
+
signalHandler.director = this;
|
|
667
|
+
signalHandler.track = track;
|
|
668
|
+
|
|
669
|
+
const markerHandler: Tracks.MarkerTrackHandler = new Tracks.MarkerTrackHandler();
|
|
670
|
+
markerHandler.director = this;
|
|
671
|
+
markerHandler.track = track;
|
|
672
|
+
|
|
637
673
|
for (const marker of track.markers) {
|
|
638
674
|
switch (marker.type) {
|
|
639
675
|
case Models.MarkerType.Signal:
|
|
640
676
|
signalHandler.models.push(marker as Models.SignalMarkerModel);
|
|
641
677
|
signalHandler.didTrigger.push(false);
|
|
642
678
|
break;
|
|
679
|
+
default:
|
|
680
|
+
markerHandler.models.push(marker);
|
|
681
|
+
break;
|
|
643
682
|
}
|
|
644
683
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
684
|
+
|
|
685
|
+
if (signalHandler !== null && signalHandler.models.length > 0) {
|
|
686
|
+
const rec = GameObject.getComponent(this.gameObject, SignalReceiver);
|
|
687
|
+
if (rec) {
|
|
688
|
+
signalHandler.receivers.push(rec);
|
|
689
|
+
this._signalTracks.push(signalHandler);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
if (markerHandler !== null && markerHandler.models.length > 0) {
|
|
694
|
+
this._markerTracks.push(markerHandler);
|
|
651
695
|
}
|
|
652
696
|
}
|
|
697
|
+
|
|
653
698
|
}
|
|
654
699
|
else if (track.type === Models.TrackType.Signal) {
|
|
655
700
|
const handler = new Tracks.SignalTrackHandler();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnimationClip, Object3D, Quaternion, Vector3 } from "three";
|
|
2
|
+
import { Behavior } from "three-mesh-ui";
|
|
2
3
|
|
|
3
4
|
export declare type TimelineAssetModel = {
|
|
4
5
|
name: string;
|
|
@@ -90,3 +91,5 @@ export declare class SignalMarkerModel extends MarkerModel {
|
|
|
90
91
|
emitOnce: boolean;
|
|
91
92
|
asset: string;
|
|
92
93
|
}
|
|
94
|
+
|
|
95
|
+
export type ScrollMarkerModel = MarkerModel & { selector: string };
|
|
@@ -830,6 +830,28 @@ export class AudioTrackHandler extends TrackHandler {
|
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
+
export class MarkerTrackHandler extends TrackHandler {
|
|
834
|
+
models: Array<Models.MarkerModel & Record<string, any>> = [];
|
|
835
|
+
isDirty = true;
|
|
836
|
+
|
|
837
|
+
*foreachMarker<T>(type: string | null = null) {
|
|
838
|
+
for (const model of this.models) {
|
|
839
|
+
if (model && model.type === type) yield model as T;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
onEnable() {
|
|
844
|
+
this.isDirty = true;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
evaluate(_time: number) {
|
|
848
|
+
if (this.isDirty) {
|
|
849
|
+
this.isDirty = false;
|
|
850
|
+
this.models.sort((a, b) => a.time - b.time);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
833
855
|
export class SignalTrackHandler extends TrackHandler {
|
|
834
856
|
models: Models.SignalMarkerModel[] = [];
|
|
835
857
|
didTrigger: boolean[] = [];
|