superfly-timeline
Advanced tools
Comparing version 8.2.3 to 8.2.4-nightly-20220126-125225-9165fac.0
@@ -270,4 +270,2 @@ "use strict"; | ||
activeObjIds[newObjInstance.id] = newObjInstance; | ||
// Update the tracking state as well: | ||
setStateAtTime(resolvedStates.state, layer, time, newObjInstance); | ||
// Add to nextEvents: | ||
@@ -285,4 +283,2 @@ resolvedStates.nextEvents.push({ | ||
delete currentState[layer]; | ||
// Update the tracking state as well: | ||
setStateAtTime(resolvedStates.state, layer, time, null); | ||
changed = true; | ||
@@ -398,4 +394,74 @@ } | ||
} | ||
// At this point, all instances of the objects should be properly calculated. | ||
// Go through all instances of all objects to create temporary states of all layers and times: | ||
{ | ||
const states = {}; | ||
for (const id of Object.keys(resolvedStates.objects)) { | ||
const obj = resolvedStates.objects[id]; | ||
const layer = `${obj.layer}`; | ||
if (!states[layer]) | ||
states[layer] = {}; | ||
const stateLayer = states[layer]; | ||
if (!obj.resolved.isKeyframe) { | ||
for (const instance of obj.resolved.instances) { | ||
const startTime = instance.start + ''; | ||
if (!stateLayer[startTime]) { | ||
stateLayer[startTime] = { | ||
startCount: 0, | ||
endCount: 0, | ||
objectInstance: null, | ||
}; | ||
} | ||
const newObjInstance = { | ||
...obj, | ||
instance: instance, | ||
}; | ||
stateLayer[startTime].startCount++; | ||
stateLayer[startTime].objectInstance = newObjInstance; | ||
if (instance.end) { | ||
const endTime = instance.end + ''; | ||
if (!stateLayer[endTime]) { | ||
stateLayer[endTime] = { | ||
startCount: 0, | ||
endCount: 0, | ||
objectInstance: null, | ||
}; | ||
} | ||
stateLayer[endTime].endCount++; | ||
} | ||
} | ||
} | ||
} | ||
// Go through the temporary states and apply the changes to the resolvedStates.state: | ||
for (const layer of Object.keys(states)) { | ||
let sum = 0; | ||
for (const time of Object.keys(states[layer])) { | ||
const s = states[layer][time]; | ||
sum += s.startCount; | ||
sum -= s.endCount; | ||
// Check for fatal bugs: | ||
// If the sum is larger than one, more than one start was found at the same time, which should not be possible. | ||
if (sum > 1) | ||
throw new Error(`Too many start events at ${layer} ${time}: ${sum}`); | ||
// If the sum is less than zero, there have been more ends than starts, which should not be possible. | ||
if (sum < 0) | ||
throw new Error(`Too many end events at ${layer} ${time}: ${sum}`); | ||
// Apply the state: | ||
if (!resolvedStates.state[layer]) | ||
resolvedStates.state[layer] = {}; | ||
if (sum) { | ||
// This means that the object has started | ||
if (!s.objectInstance) | ||
throw new Error(`objectInstance not set, event though sum=${sum} at ${layer} ${time}`); | ||
resolvedStates.state[layer][time] = [s.objectInstance]; | ||
} | ||
else { | ||
// This means that the object has ended | ||
resolvedStates.state[layer][time] = null; | ||
} | ||
} | ||
} | ||
} | ||
// Cap keyframes inside their parents: | ||
for (const id of Object.keys(resolvedStates.objects)) { | ||
// Cap keyframes inside their parents: | ||
{ | ||
@@ -495,7 +561,2 @@ const keyframe = resolvedStates.objects[id]; | ||
} | ||
function setStateAtTime(states, layer, time, objInstance) { | ||
if (!states[layer]) | ||
states[layer] = {}; | ||
states[layer][time + ''] = objInstance ? [objInstance] : objInstance; | ||
} | ||
function addKeyframeAtTime(states, layer, time, objInstanceKf) { | ||
@@ -502,0 +563,0 @@ if (!states[layer]) |
{ | ||
"name": "superfly-timeline", | ||
"version": "8.2.3", | ||
"version": "8.2.4-nightly-20220126-125225-9165fac.0", | ||
"description": "A collection of rules as well as a resolver for placing objects on a virtual timeline.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
300835
2886
1