forked from matrix-org/thirdroom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into vite-press-doc
- Loading branch information
Showing
140 changed files
with
8,492 additions
and
3,160 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Production CI | |
on: | ||
push: | ||
branches: | ||
- main | ||
- prod | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Staging CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: yarn | ||
|
||
- name: Install | ||
run: yarn install | ||
|
||
- name: Build | ||
env: | ||
NODE_OPTIONS: --max_old_space_size=4096 | ||
VITE_SENTRY_DSN: "https://[email protected]/50" | ||
VITE_SENTRY_ENVIRONMENT: "staging" | ||
VITE_SENTRY_RELEASE: ${{ github.sha }} | ||
run: yarn build | ||
|
||
- name: Create Deployment | ||
uses: bobheadxi/deployments@v1 | ||
id: deployment | ||
with: | ||
step: start | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
env: Netlify | ||
ref: ${{ github.event.workflow_run.head_sha }} | ||
|
||
- name: Deploy to Netlify | ||
id: netlify | ||
uses: nwtgck/[email protected] | ||
with: | ||
publish-dir: dist | ||
deploy-message: "Staging Deploy from GitHub Actions" | ||
netlify-config-path: ./netlify.toml | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
alias: staging | ||
env: | ||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | ||
timeout-minutes: 1 | ||
|
||
- name: Update deployment status | ||
uses: bobheadxi/deployments@v1 | ||
if: always() | ||
with: | ||
step: finish | ||
override: false | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: ${{ job.status }} | ||
env: ${{ steps.deployment.outputs.env }} | ||
deployment_id: ${{ steps.deployment.outputs.deployment_id }} | ||
env_url: ${{ steps.netlify.outputs.deploy-url }} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const Spinner = world.findComponentStoreByName("Spinner"); | ||
|
||
const spinnerQuery = world.createQuery([Spinner]); | ||
|
||
function setRotationAxis(quat, axis, angle) { | ||
// Ensure the axis is a unit vector | ||
let xAxis = axis[0]; | ||
let yAxis = axis[1]; | ||
let zAxis = axis[2]; | ||
|
||
let len = xAxis * xAxis + yAxis * yAxis + zAxis * zAxis; | ||
|
||
if (len > 0) { | ||
len = 1 / Math.sqrt(len); | ||
} | ||
|
||
xAxis = axis[0] * len; | ||
yAxis = axis[1] * len; | ||
zAxis = axis[2] * len; | ||
|
||
// Calculate the sin and cos values for half of the angle | ||
let halfAngle = angle / 2; | ||
let sinHalfAngle = Math.sin(halfAngle); | ||
let cosHalfAngle = Math.cos(halfAngle); | ||
|
||
// Compute the quaternion components | ||
quat.x = xAxis * sinHalfAngle; | ||
quat.y = yAxis * sinHalfAngle; | ||
quat.z = zAxis * sinHalfAngle; | ||
quat.w = cosHalfAngle; | ||
} | ||
|
||
function SpinnerSystem(time) { | ||
for (const node of spinnerQuery) { | ||
const spinner = node.getComponent(Spinner); | ||
setRotationAxis(node.rotation, spinner.axis, time * spinner.speed); | ||
} | ||
} | ||
|
||
world.onupdate = (dt, time) => { | ||
SpinnerSystem(time); | ||
}; |
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
const Player = world.findComponentStoreByName("Player"); | ||
const Mover = world.findComponentStoreByName("Mover"); | ||
const Spinner = world.findComponentStoreByName("Spinner"); | ||
const Coin = world.findComponentStoreByName("Coin"); | ||
const ExtraLife = world.findComponentStoreByName("ExtraLife"); | ||
const Obstacle = world.findComponentStoreByName("Obstacle"); | ||
const Conveyer = world.findComponentStoreByName("Conveyer"); | ||
const Checkpoint = world.findComponentStoreByName("Checkpoint"); | ||
const Goal = world.findComponentStoreByName("Goal"); | ||
|
||
const moverQuery = world.createQuery([Mover]); | ||
const spinnerQuery = world.createQuery([Spinner]); | ||
const coinQuery = world.createQuery([Coin]); | ||
const extraLifeQuery = world.createQuery([ExtraLife]); | ||
const obstacleQuery = world.createQuery([Obstacle]); | ||
const conveyerQuery = world.createQuery([Conveyer]); | ||
const checkpointQuery = world.createQuery([Checkpoint]); | ||
const goalQuery = world.createQuery([Goal]); | ||
|
||
function MoverSystem(time) { | ||
for (const node of moverQuery) { | ||
node.position.lerp(node.startPosition, node.endPosition, time / node.duration); | ||
} | ||
} | ||
|
||
function SpinnerSystem(time) { | ||
for (const node of spinnerQuery) { | ||
const spinner = node.getComponent(Spinner); | ||
node.rotation.setRotationAxis(spinner.axis, time * spinner.speed); | ||
} | ||
} | ||
|
||
function CoinSystem() { | ||
for (const node of coinQuery) { | ||
for (const collision of node.physicsBody.getCollisions()) { | ||
const coin = node.getComponent(Coin); | ||
const player = collision.node.getComponent(Player); | ||
|
||
if (!coin.taken && player) { | ||
node.audioEmitter.play(); | ||
node.visible = false; | ||
coin.taken = true; | ||
player.coins++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function ExtraLifeSystem() { | ||
for (const node of extraLifeQuery) { | ||
for (const collision of node.physicsBody.getCollisions()) { | ||
const extraLife = node.getComponent(ExtraLife); | ||
const player = collision.node.getComponent(Player); | ||
|
||
if (!extraLife.taken && player) { | ||
node.audioEmitter.play(); | ||
node.visible = false; | ||
extraLife.taken = true; | ||
player.lives++; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function ObstacleSystem() { | ||
for (const node of obstacleQuery) { | ||
for (const collision of node.physicsBody.getCollisions()) { | ||
const player = collision.node.getComponent(Player); | ||
|
||
if (player) { | ||
node.audioEmitter.play(); | ||
player.translation = player.lastSpawnPoint.translation; | ||
player.rotation = player.lastSpawnPoint.rotation; | ||
player.lives--; | ||
|
||
if (player.lives == 0) { | ||
// TODO: Game Over Screen | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
let conveyerMaterial; | ||
const conveyerSpeed = 1; | ||
|
||
function ConveyerSystem() { | ||
for (const node of conveyerQuery) { | ||
for (const collision of node.physicsBody.getCollisions()) { | ||
const player = collision.node.getComponent(Player); | ||
|
||
if (player) { | ||
} | ||
} | ||
} | ||
|
||
conveyerMaterial.baseColorTextureOffset.y += conveyerSpeed * dt; | ||
} | ||
|
||
function ScrollingMaterialSystem(dt) { | ||
for (const material of scrollingMaterialQuery) { | ||
} | ||
} | ||
|
||
function CheckpointSystem() { | ||
for (const node of checkPointQuery) { | ||
for (const collision of node.physicsBody.getCollisions()) { | ||
const player = collision.node.getComponent(Player); | ||
|
||
if (player) { | ||
node.audioEmitter.play(); | ||
player.lastSpawnPoint = node; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function GoalSystem() { | ||
for (const node of goalQuery) { | ||
for (const collision of node.physicsBody.getCollisions()) { | ||
const player = collision.node.getComponent(Player); | ||
|
||
if (player) { | ||
node.audioEmitter.play(); | ||
|
||
// TODO: Show Game Win Screen | ||
} | ||
} | ||
} | ||
} | ||
|
||
world.onload = () => { | ||
conveyerMaterial = world.findMaterialByName("ConveyerMaterial"); | ||
}; | ||
|
||
world.onenter = (playerRig) => { | ||
playerRig.addComponent(Player); | ||
}; | ||
|
||
world.onupdate = (dt, time) => { | ||
MoverSystem(time); | ||
SpinnerSystem(time); | ||
ConveyerSystem(); | ||
ScrollingMaterialSystem(dt); | ||
CoinSystem(); | ||
ExtraLifeSystem(); | ||
ObstacleSystem(); | ||
CheckpointSystem(); | ||
GoalSystem(); | ||
}; |
Oops, something went wrong.