Skip to content

Commit

Permalink
Animate node rotation / movement / opacity #82
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Oct 22, 2019
1 parent debaf0b commit 985087c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions demo-solarsystem/app/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ import {ARDebugLevel} from "nativescript-ar";
saturnMoonColors.forEach(s => saturnMoonNColors.push(new Color(s)));
const saturnMoons = [];
for (let i = 0; i < NR_OF_SATURN_MOONS; i++) {
console.log(100 * Math.random());
saturnMoons.push({
name: "Saturn moon",
distance: 0.4 + (Math.random() / 300),
orbitSpeed: 100 * Math.random(),
scale: (Math.random() / 80) * SCALE_FACTOR,
tilt: i * 13,
position: {
x: 0.04 + (Math.random() / 50),
y: 0,
z: 0
},
distance: 0.35 + (Math.random() / 5),
orbitSpeed: -1000 * Math.random(),
scale: (Math.random() / 40) * SCALE_FACTOR,
tilt: i * 17,
materials: isIOS ? [{
diffuse: materialPrefix + "Luna_Mat_baseColor.png",
normal: materialPrefix + "Luna_Mat_normal.png",
Expand Down Expand Up @@ -387,12 +383,14 @@ import {ARDebugLevel} from "nativescript-ar";
// a bit of visual feedback
this.enableNativeAnimationsWithDurationOfSeconds(.3);
objectNode.scaleBy(.5);
setTimeout(() => {
objectNode.scaleBy(-.5);
setTimeout(() => this.disableNativeAnimations(), .35);
}, 300);
if (solarSystemObject.name !== "Sun" || this.hasControlPanel) {
this.enableNativeAnimationsWithDurationOfSeconds(.3);
objectNode.scaleBy(.5);
setTimeout(() => {
objectNode.scaleBy(-.5);
setTimeout(() => this.disableNativeAnimations(), .35);
}, 300);
}
if (solarSystemObject.name === "Sun") {
if (!this.hasControlPanel) {
Expand Down Expand Up @@ -504,6 +502,9 @@ import {ARDebugLevel} from "nativescript-ar";
let lastSunSize = this.sunSize;
setInterval(() => {
if (lastSunSize !== this.sunSize) {
// let's animate this scaleTo this way, until we're able to pass in an animate object
this.enableNativeAnimationsWithDurationOfSeconds(.3);
setTimeout(() => this.disableNativeAnimations(), 350);
lastSunSize = this.sunSize;
parentNode.scaleTo(0.016 * this.sunSize);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ar-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface ARCommonNode extends ARNode {

moveBy?(by: ARPosition): void;

This comment has been minimized.

Copy link
@Ohadefrat

Ohadefrat Mar 29, 2020

heyy i wanna know how can i move a model by touch. without to move the other models ?


// TODO implement animations
// TODO implement animations (but also: pass in a duration... so the API needs to change)
rotateBy?(by: ARRotation, animated?: boolean): void;

scaleBy?(by: number | ARScale): void;
Expand Down

0 comments on commit 985087c

Please sign in to comment.