Skip to content

Commit d31dad6

Browse files
Julien Moreau-Mathisjulien-moreau
authored andcommitted
fix: use this.mesh.rotate method to rotate mesh in script example of templates
To avoid usage of distinct .rotation and .rotationQuaternion properties
1 parent b1fd284 commit d31dad6

File tree

3 files changed

+31
-34
lines changed

3 files changed

+31
-34
lines changed
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { Mesh } from "@babylonjs/core/Meshes/mesh";
2+
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
23

34
import { IScript, visibleAsNumber } from "babylonjs-editor-tools";
45

56
export default class SceneComponent implements IScript {
6-
@visibleAsNumber("Speed", {
7-
min: 0,
8-
max: 0.1,
9-
})
7+
@visibleAsNumber("Speed", {
8+
min: 0,
9+
max: 0.1,
10+
})
1011
private _speed: number = 0.04;
1112

12-
public constructor(public mesh: Mesh) { }
13+
public constructor(public mesh: Mesh) {}
1314

14-
public onStart(): void {
15+
public onStart(): void {}
1516

16-
}
17-
18-
public onUpdate(): void {
19-
this.mesh.rotation.y += this._speed * this.mesh.getScene().getAnimationRatio();
20-
}
17+
public onUpdate(): void {
18+
this.mesh.rotate(Vector3.UpReadOnly, this._speed * this.mesh.getScene().getAnimationRatio());
19+
}
2120
}
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { Mesh } from "@babylonjs/core/Meshes/mesh";
2+
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
23

34
import { IScript, visibleAsNumber } from "babylonjs-editor-tools";
45

56
export default class SceneComponent implements IScript {
6-
@visibleAsNumber("Speed", {
7-
min: 0,
8-
max: 0.1,
9-
})
7+
@visibleAsNumber("Speed", {
8+
min: 0,
9+
max: 0.1,
10+
})
1011
private _speed: number = 0.04;
1112

12-
public constructor(public mesh: Mesh) { }
13+
public constructor(public mesh: Mesh) {}
1314

14-
public onStart(): void {
15+
public onStart(): void {}
1516

16-
}
17-
18-
public onUpdate(): void {
19-
this.mesh.rotation.y += this._speed * this.mesh.getScene().getAnimationRatio();
20-
}
17+
public onUpdate(): void {
18+
this.mesh.rotate(Vector3.UpReadOnly, this._speed * this.mesh.getScene().getAnimationRatio());
19+
}
2120
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { Mesh } from "@babylonjs/core/Meshes/mesh";
2+
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
23

34
import { IScript, visibleAsNumber } from "babylonjs-editor-tools";
45

56
export default class SceneComponent implements IScript {
6-
@visibleAsNumber("Speed", {
7-
min: 0,
8-
max: 0.1,
9-
})
7+
@visibleAsNumber("Speed", {
8+
min: 0,
9+
max: 0.1,
10+
})
1011
private _speed: number = 0.04;
1112

12-
public constructor(public mesh: Mesh) { }
13+
public constructor(public mesh: Mesh) {}
1314

14-
public onStart(): void {
15+
public onStart(): void {}
1516

16-
}
17-
18-
public onUpdate(): void {
19-
this.mesh.rotation.y += this._speed * this.mesh.getScene().getAnimationRatio();
20-
}
21-
}
17+
public onUpdate(): void {
18+
this.mesh.rotate(Vector3.UpReadOnly, this._speed * this.mesh.getScene().getAnimationRatio());
19+
}
20+
}

0 commit comments

Comments
 (0)