Created
August 14, 2019 23:22
-
-
Save bzztbomb/9d15064895812de791193a77747a2615 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cam = Camera.worldTransform.position; | |
var subscription = | |
Reactive | |
.monitorMany( | |
{ | |
// Monitor camera position, this needs to be done per component since they are individual signals | |
cx: cam.x, | |
cy: cam.y, | |
cz: cam.z, | |
ox: sparkObject.transform.position.x, | |
oy: sparkObject.transform.position.y, | |
oz: sparkObject.transform.position.z, | |
// Monitor world tranform for parent changes. | |
wx: sparkObject.worldTransform.position.x, | |
wy: sparkObject.worldTransform.position.y, | |
wz: sparkObject.worldTransform.position.z, | |
}, | |
{fireOnInitialValue: true}) | |
.subscribe((changes) => { | |
var cameraPos = { | |
x: changes.newValues.cx, | |
y: changes.newValues.cy, | |
z: changes.newValues.cz | |
}; | |
var objPos = { | |
x: changes.newValues.ox, | |
y: changes.newValues.oy, | |
z: changes.newValues.oz | |
}; | |
var driver = | |
Animation.timeDriver({durationMilliseconds: 1, loopCount: 1}); | |
sparkObject.transform.x = Animation.animate( | |
driver, | |
Animation.samplers.linear(objPos.x, changes.newValues.cx)) | |
driver.start(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment