Skip to content

Commit

Permalink
Use compat to get around wasm weirdness
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Sep 23, 2024
1 parent 07833b5 commit 63c6064
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 40 deletions.
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
"lint": "eslint src/"
},
"dependencies": {
"@dimforge/rapier2d": "^0.14.0",
"@dimforge/rapier2d-compat": "^0.14.0",
"@pixi/sound": "^6.0.1",
"@timohausmann/quadtree-ts": "^2.2.2",
"matter-js": "^0.20.0",
"pathseg": "^1.2.1",
"pixi-viewport": "^5.0.3",
"pixi.js": "^8.4.0",
"pixi.js": "^8.4.1",
"poly-decomp-es": "^0.4.2",
"preact": "^10.23.2",
"vite-plugin-wasm": "^3.3.0"
"preact": "^10.23.2"
},
"devDependencies": {
"@preact/preset-vite": "^2.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/entities/bitmapTerrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IDamageableEntity, IMatterEntity } from "./entity";
import { generateQuadTreeFromTerrain, imageDataToTerrainBoundaries } from "../terrain";
import Flags from "../flags";
import { collisionGroupBitmask, CollisionGroups, GameWorld, PIXELS_PER_METER, RapierPhysicsObject } from "../world";
import { ActiveEvents, Collider, ColliderDesc, Cuboid, RigidBody, RigidBodyDesc, Vector2 } from "@dimforge/rapier2d";
import { ActiveEvents, Collider, ColliderDesc, Cuboid, RigidBody, RigidBodyDesc, Vector2 } from "@dimforge/rapier2d-compat";

Check warning on line 6 in src/entities/bitmapTerrain.ts

View workflow job for this annotation

GitHub Actions / lint

'ActiveEvents' is defined but never used

Check warning on line 6 in src/entities/bitmapTerrain.ts

View workflow job for this annotation

GitHub Actions / lint

'Cuboid' is defined but never used
import { MetersValue } from "../utils/coodinate";

export type OnDamage = () => void;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ShapeContact, Vector2 } from "@dimforge/rapier2d";
import { ShapeContact, Vector2 } from "@dimforge/rapier2d-compat";

Check warning on line 1 in src/entities/entity.ts

View workflow job for this annotation

GitHub Actions / lint

'ShapeContact' is defined but never used
import { Point, UPDATE_PRIORITY } from "pixi.js";

Check warning on line 2 in src/entities/entity.ts

View workflow job for this annotation

GitHub Actions / lint

'Point' is defined but never used
import { MetersValue } from "../utils";

Expand Down
2 changes: 1 addition & 1 deletion src/entities/phys/bazookaShell.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Container, Graphics, Sprite, Texture } from 'pixi.js';
import { TimedExplosive } from "./timedExplosive";
import { GameWorld } from '../../world';
import { ColliderDesc, RigidBodyDesc, Vector2, VectorOps } from '@dimforge/rapier2d';
import { ColliderDesc, RigidBodyDesc, Vector2, VectorOps } from "@dimforge/rapier2d-compat";
import { MetersValue } from '../../utils/coodinate';

// TODO: This is buggy as all hell.
Expand Down
3 changes: 2 additions & 1 deletion src/entities/phys/grenade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IMatterEntity } from '../entity';
import { BitmapTerrain } from '../bitmapTerrain';
import { IMediaInstance, Sound } from '@pixi/sound';
import { collisionGroupBitmask, CollisionGroups, GameWorld, PIXELS_PER_METER } from '../../world';
import { ActiveEvents, ColliderDesc, RigidBodyDesc, ShapeContact, Vector2 } from '@dimforge/rapier2d';
import { ActiveEvents, ColliderDesc, RigidBodyDesc, Vector2 } from '@dimforge/rapier2d-compat';
import { magnitude } from '../../utils';
import { MetersValue } from '../../utils/coodinate';
/**
Expand Down Expand Up @@ -79,6 +79,7 @@ export class Grenade extends TimedExplosive {
this.timerText.rotation = -this.body.body.rotation();
this.timerText.text = this.timerTextValue;
}

}

onCollision(otherEnt: IMatterEntity, contactPoint: Vector2) {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/phys/physicsEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BodyWireframe } from "../../mixins/bodyWireframe.";
import globalFlags from "../../flags";
import { IMediaInstance, Sound } from "@pixi/sound";
import { GameWorld, PIXELS_PER_METER, RapierPhysicsObject } from "../../world";
import { ShapeContact, Vector2 } from "@dimforge/rapier2d";
import { ShapeContact, Vector2 } from "@dimforge/rapier2d-compat";

Check warning on line 8 in src/entities/phys/physicsEntity.ts

View workflow job for this annotation

GitHub Actions / lint

'ShapeContact' is defined but never used

/**
* Any object that is physically present in the world i.e. a worm.
Expand Down
2 changes: 1 addition & 1 deletion src/entities/phys/testDummy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PhysicsEntity } from "./physicsEntity";
import { getAssets } from "../../assets";
import { collisionGroupBitmask, CollisionGroups, GameWorld, PIXELS_PER_METER } from "../../world";
import { add, Coordinate, magnitude, MetersValue, mult, sub } from "../../utils";
import { ActiveEvents, ColliderDesc, RigidBodyDesc, Vector2 } from "@dimforge/rapier2d";
import { ActiveEvents, ColliderDesc, RigidBodyDesc, Vector2 } from "@dimforge/rapier2d-compat";
import { IDamageableEntity } from "../entity";
import { Explosion } from "../explosion";

Expand Down
2 changes: 1 addition & 1 deletion src/entities/phys/timedExplosive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IDamageableEntity, IMatterEntity } from "../entity";
import { PhysicsEntity } from "./physicsEntity";
import { Explosion } from "../explosion";
import { GameWorld, PIXELS_PER_METER, RapierPhysicsObject } from "../../world";
import { Vector2 } from "@dimforge/rapier2d";
import { Vector2 } from "@dimforge/rapier2d-compat";
import { Coordinate, MetersValue } from "../../utils/coodinate";

interface Opts {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/phys/worm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IWeaponDefiniton } from '../../weapons/weapon';
import { WeaponGrenade } from '../../weapons/grenade';
import Controller, { InputKind } from '../../input';
import { GameWorld, PIXELS_PER_METER } from '../../world';
import { ColliderDesc, KinematicCharacterController, RigidBodyDesc, Vector, Vector2 } from '@dimforge/rapier2d';
import { ColliderDesc, KinematicCharacterController, RigidBodyDesc, Vector, Vector2 } from "@dimforge/rapier2d-compat";
import { Coordinate } from '../../utils/coodinate';
import { add } from '../../utils';

Expand Down
2 changes: 1 addition & 1 deletion src/entities/water.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IGameEntity } from "./entity";
import vertex from '../shaders/water.vert?raw';
import fragment from '../shaders/water.frag?raw';
import { collisionGroupBitmask, CollisionGroups, GameWorld, PIXELS_PER_METER, RapierPhysicsObject } from "../world";
import { ColliderDesc, RigidBodyDesc } from "@dimforge/rapier2d";
import { ColliderDesc, RigidBodyDesc } from "@dimforge/rapier2d-compat";
import { MetersValue } from "../utils";

export class Water implements IGameEntity {
Expand Down
8 changes: 5 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
import wasm from 'vite-plugin-wasm'
import assetPlugin from './plugins/assets'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [wasm(), preact(), assetPlugin()],
appType: 'spa'
plugins: [preact(), assetPlugin()],
appType: 'spa',
build: {
minify: false,
},
})
29 changes: 7 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@
"@babel/helper-validator-identifier" "^7.19.1"
to-fast-properties "^2.0.0"

"@dimforge/rapier2d@^0.14.0":
"@dimforge/rapier2d-compat@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@dimforge/rapier2d/-/rapier2d-0.14.0.tgz#20d45a551a7b796950eebe24a95f6a008abb2f9d"
integrity sha512-gqFHPytBONq4/fhQGECa9fr7LnWFg+9fX+YTONrK1zt20y+P3P6qarcq2+vpb0L36dR7W0uyCGI2Lyf5dRko+g==
resolved "https://registry.yarnpkg.com/@dimforge/rapier2d-compat/-/rapier2d-compat-0.14.0.tgz#7d774987090426978b31ea642ba5e55d4dbd44c1"
integrity sha512-sljQVPstRS63hVLnVNphsZUjH51TZoptVM0XlglKAdZ8CT+kWnmA6olwjkF7omPWYrlKMd/nHORxOUdJDOSoAQ==

"@esbuild/[email protected]":
version "0.17.13"
Expand Down Expand Up @@ -513,11 +513,6 @@
estree-walker "^2.0.1"
picomatch "^2.2.2"

"@timohausmann/quadtree-ts@^2.2.2":
version "2.2.2"
resolved "https://registry.yarnpkg.com/@timohausmann/quadtree-ts/-/quadtree-ts-2.2.2.tgz#da3114145a48f0a8bab4910a2e3096575dc56d23"
integrity sha512-emYbmmbTb+S3F75yvt03KQ3pMO3v/4BzjbAVnflbYq3zJfcurTfZHeriK8o7T0lFzBz3kBw2Pn41vlK3pD8spw==

"@types/css-font-loading-module@^0.0.12":
version "0.0.12"
resolved "https://registry.yarnpkg.com/@types/css-font-loading-module/-/css-font-loading-module-0.0.12.tgz#65494833928823f998fbe8e86312821875d80db5"
Expand Down Expand Up @@ -1286,11 +1281,6 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

matter-js@^0.20.0:
version "0.20.0"
resolved "https://registry.yarnpkg.com/matter-js/-/matter-js-0.20.0.tgz#dc3c95c40ea5ef8937788a2770c3f97223b352ed"
integrity sha512-iC9fYR7zVT3HppNnsFsp9XOoQdQN2tUyfaKg4CHLH8bN+j6GT4Gw7IH2rP0tflAebrHFw730RR3DkVSZRX8hwA==

merge2@^1.3.0, merge2@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
Expand Down Expand Up @@ -1426,10 +1416,10 @@ pixi-viewport@^5.0.3:
resolved "https://registry.yarnpkg.com/pixi-viewport/-/pixi-viewport-5.0.3.tgz#75708195f5913f3df2acf36a88da8dd323aa607a"
integrity sha512-DGG7cg2vUltAiL2fanzYPLR+L6qBeoskPfbUXxN6CYKW+fkni5cF9J1t2WBTmyBnC3kVq3ATFE2KDi7zy2FY8A==

pixi.js@^8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/pixi.js/-/pixi.js-8.4.0.tgz#a08b48bdaca6e60a1380d3adab9c7afc8149e3c3"
integrity sha512-IM0YDv7G9XATtD/sPgbEi6FoLg82+XSqejzeCWg575vEyuQGs4RrdVFSV/K/i2PeXr/sLxiHRJDOGuotBUlldA==
pixi.js@^8.4.1:
version "8.4.1"
resolved "https://registry.yarnpkg.com/pixi.js/-/pixi.js-8.4.1.tgz#138c930ede851e3056f32ec08d6a1539caf187b7"
integrity sha512-3ZbEIkLYYi602UB5wuN7kPz3VsGHoJa6nxD8ustvMLRySxHAR9Z8tCAYY8ISgNplpPbaDw03B0yTD4/k9f6cAQ==
dependencies:
"@pixi/colord" "^2.9.6"
"@types/css-font-loading-module" "^0.0.12"
Expand Down Expand Up @@ -1641,11 +1631,6 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

vite-plugin-wasm@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/vite-plugin-wasm/-/vite-plugin-wasm-3.3.0.tgz#2908ef2529bf8f33f4e549c8c6fda26ad273ca15"
integrity sha512-tVhz6w+W9MVsOCHzxo6SSMSswCeIw4HTrXEi6qL3IRzATl83jl09JVO1djBqPSwfjgnpVHNLYcaMbaDX5WB/pg==

vite@^4.2.0:
version "4.2.1"
resolved "https://registry.npmjs.org/vite/-/vite-4.2.1.tgz"
Expand Down

0 comments on commit 63c6064

Please sign in to comment.