@playcanvas/supersplat-viewer 1.3.1 → 1.4.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 +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/public/index.js +29 -22
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -94931,6 +94931,10 @@ const migrateAnimTrack = (track) => {
|
|
|
94931
94931
|
times[i] *= defaultFrameRate;
|
|
94932
94932
|
}
|
|
94933
94933
|
}
|
|
94934
|
+
// smoothness property added in v1.4.0
|
|
94935
|
+
if (!track.hasOwnProperty('smoothness')) {
|
|
94936
|
+
track.smoothness = 0;
|
|
94937
|
+
}
|
|
94934
94938
|
};
|
|
94935
94939
|
const migrateSettings = (settings) => {
|
|
94936
94940
|
settings.animTracks?.forEach((track) => {
|
|
@@ -95014,7 +95018,7 @@ class CubicSpline {
|
|
|
95014
95018
|
while (time >= times[seg + 1]) {
|
|
95015
95019
|
seg++;
|
|
95016
95020
|
}
|
|
95017
|
-
|
|
95021
|
+
this.evaluateSegment(seg, (time - times[seg]) / (times[seg + 1] - times[seg]), result);
|
|
95018
95022
|
}
|
|
95019
95023
|
}
|
|
95020
95024
|
getKnot(index, result) {
|
|
@@ -95045,14 +95049,15 @@ class CubicSpline {
|
|
|
95045
95049
|
m1 * (t2 * (t - 1));
|
|
95046
95050
|
}
|
|
95047
95051
|
}
|
|
95048
|
-
//
|
|
95052
|
+
// calculate cubic spline knots from points
|
|
95049
95053
|
// times: time values for each control point
|
|
95050
95054
|
// points: control point values to be interpolated (n dimensional)
|
|
95051
|
-
//
|
|
95052
|
-
static
|
|
95053
|
-
const
|
|
95054
|
-
const
|
|
95055
|
-
|
|
95055
|
+
// smoothness: 0 = linear, 1 = smooth
|
|
95056
|
+
static calcKnots(times, points, smoothness) {
|
|
95057
|
+
const n = times.length;
|
|
95058
|
+
const dim = points.length / n;
|
|
95059
|
+
const knots = new Array(n * dim * 3);
|
|
95060
|
+
for (let i = 0; i < n; i++) {
|
|
95056
95061
|
const t = times[i];
|
|
95057
95062
|
for (let j = 0; j < dim; j++) {
|
|
95058
95063
|
const idx = i * dim + j;
|
|
@@ -95061,28 +95066,29 @@ class CubicSpline {
|
|
|
95061
95066
|
if (i === 0) {
|
|
95062
95067
|
tangent = (points[idx + dim] - p) / (times[i + 1] - t);
|
|
95063
95068
|
}
|
|
95064
|
-
else if (i ===
|
|
95069
|
+
else if (i === n - 1) {
|
|
95065
95070
|
tangent = (p - points[idx - dim]) / (t - times[i - 1]);
|
|
95066
95071
|
}
|
|
95067
95072
|
else {
|
|
95068
|
-
|
|
95069
|
-
tangent = 0.5 * ((points[idx + dim] - p) / (times[i + 1] - t) + (p - points[idx - dim]) / (t - times[i - 1]));
|
|
95070
|
-
// cardinal spline tangents
|
|
95071
|
-
// tangent = (points[idx + dim] - points[idx - dim]) / (times[i + 1] - times[i - 1]);
|
|
95073
|
+
tangent = (points[idx + dim] - points[idx - dim]) / (times[i + 1] - times[i - 1]);
|
|
95072
95074
|
}
|
|
95073
|
-
//
|
|
95074
|
-
|
|
95075
|
-
|
|
95075
|
+
// convert to derivatives w.r.t normalized segment parameter
|
|
95076
|
+
const inScale = i > 0 ? (times[i] - times[i - 1]) : (times[1] - times[0]);
|
|
95077
|
+
const outScale = i < n - 1 ? (times[i + 1] - times[i]) : (times[i] - times[i - 1]);
|
|
95078
|
+
knots[idx * 3] = tangent * inScale * smoothness;
|
|
95076
95079
|
knots[idx * 3 + 1] = p;
|
|
95077
|
-
knots[idx * 3 + 2] = tangent;
|
|
95080
|
+
knots[idx * 3 + 2] = tangent * outScale * smoothness;
|
|
95078
95081
|
}
|
|
95079
95082
|
}
|
|
95080
|
-
return
|
|
95083
|
+
return knots;
|
|
95084
|
+
}
|
|
95085
|
+
static fromPoints(times, points, smoothness = 1) {
|
|
95086
|
+
return new CubicSpline(times, CubicSpline.calcKnots(times, points, smoothness));
|
|
95081
95087
|
}
|
|
95082
95088
|
// create a looping spline by duplicating animation points at the end and beginning
|
|
95083
|
-
static fromPointsLooping(length, times, points,
|
|
95089
|
+
static fromPointsLooping(length, times, points, smoothness = 1) {
|
|
95084
95090
|
if (times.length < 2) {
|
|
95085
|
-
return CubicSpline.fromPoints(times, points
|
|
95091
|
+
return CubicSpline.fromPoints(times, points);
|
|
95086
95092
|
}
|
|
95087
95093
|
const dim = points.length / times.length;
|
|
95088
95094
|
const newTimes = times.slice();
|
|
@@ -95093,7 +95099,7 @@ class CubicSpline {
|
|
|
95093
95099
|
// prepend last two points
|
|
95094
95100
|
newTimes.splice(0, 0, times[times.length - 2] - length, times[times.length - 1] - length);
|
|
95095
95101
|
newPoints.splice(0, 0, ...points.slice(points.length - dim * 2));
|
|
95096
|
-
return CubicSpline.fromPoints(newTimes, newPoints,
|
|
95102
|
+
return CubicSpline.fromPoints(newTimes, newPoints, smoothness);
|
|
95097
95103
|
}
|
|
95098
95104
|
}
|
|
95099
95105
|
|
|
@@ -95174,7 +95180,7 @@ class AnimController extends InputController {
|
|
|
95174
95180
|
}
|
|
95175
95181
|
// construct an animation from a settings track
|
|
95176
95182
|
static fromTrack(track) {
|
|
95177
|
-
const { keyframes, duration, frameRate, loopMode } = track;
|
|
95183
|
+
const { keyframes, duration, frameRate, loopMode, smoothness } = track;
|
|
95178
95184
|
const { times, values } = keyframes;
|
|
95179
95185
|
const { position, target } = values;
|
|
95180
95186
|
// construct the points array containing position and target
|
|
@@ -95184,7 +95190,7 @@ class AnimController extends InputController {
|
|
|
95184
95190
|
points.push(target[i * 3], target[i * 3 + 1], target[i * 3 + 2]);
|
|
95185
95191
|
}
|
|
95186
95192
|
const extra = (duration === times[times.length - 1] / frameRate) ? 1 : 0;
|
|
95187
|
-
const spline = CubicSpline.fromPointsLooping((duration + extra) * frameRate, times, points,
|
|
95193
|
+
const spline = CubicSpline.fromPointsLooping((duration + extra) * frameRate, times, points, smoothness);
|
|
95188
95194
|
return new AnimController(spline, duration, loopMode, frameRate);
|
|
95189
95195
|
}
|
|
95190
95196
|
}
|
|
@@ -95433,6 +95439,7 @@ const createRotateTrack = (initial, keys = 12, duration = 20) => {
|
|
|
95433
95439
|
target: 'camera',
|
|
95434
95440
|
loopMode: 'repeat',
|
|
95435
95441
|
interpolation: 'spline',
|
|
95442
|
+
smoothness: 1,
|
|
95436
95443
|
keyframes: {
|
|
95437
95444
|
times,
|
|
95438
95445
|
values: {
|