Skip to content

Commit

Permalink
Make r138 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Jun 11, 2022
1 parent 35ba408 commit 6b6e8bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/examples/camera-lerping-and-player-controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@
}
if (this.keys.w.isDown) {
const speed = 4
const rotation = this.player.getWorldDirection(this.player.rotation.toVector3())
const rotation = this.player.getWorldDirection(
new THREE.Vector3()?.setFromEuler?.(this.player.rotation) || this.player.rotation.toVector3()
)
const theta = Math.atan2(rotation.x, rotation.z)

const x = Math.sin(theta) * speed,
Expand Down
6 changes: 4 additions & 2 deletions src/examples/enemy-patrols-on-platform.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<body>
<script>
const { enable3d, Scene3D, Canvas, ExtendedObject3D } = ENABLE3D
const { enable3d, Scene3D, Canvas, ExtendedObject3D, THREE } = ENABLE3D

class MainScene extends Scene3D {
constructor() {
Expand Down Expand Up @@ -106,7 +106,9 @@
update() {
if (this.robot && this.robot.body) {
const speed = 4
const rotation = this.robot.getWorldDirection(this.robot.rotation.toVector3())
const rotation = this.robot.getWorldDirection(
new THREE.Vector3()?.setFromEuler?.(this.robot.rotation) || this.robot.rotation.toVector3()
)
const theta = Math.atan2(rotation.x, rotation.z)

const x = Math.sin(theta) * speed,
Expand Down

0 comments on commit 6b6e8bc

Please sign in to comment.