Skip to content

Commit

Permalink
Merge branch 'dev' into feat-melee-weapon
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/client/core/Inventory.ts
#	src/client/core/RemoteItemRenderer.ts
#	src/server/managers/ItemManager.ts
  • Loading branch information
AustinJMann committed Jan 17, 2025
2 parents b3615cc + eeae418 commit 4da2b4f
Show file tree
Hide file tree
Showing 33 changed files with 1,365 additions and 278 deletions.
Binary file added assets/arrow.blend
Binary file not shown.
Binary file added assets/arrow.blend1
Binary file not shown.
13 changes: 8 additions & 5 deletions docs/Items.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Items

Item ID list with implementation info
| ID | Class | Item Description | Inventory | World |
|----|--------------|---------------------------------------|-------------|-------|
| 0 | ItemBase.ts | Base item template (freaky green cube)|||
| 1 | BananaGun.ts | Banana gun |||
| 1 | FishGun.ts | Fish gun >:) |||

| ID | Class | Item Description | Inventory | World |
| -- | ------------ | -------------------------------------- | --------- | ----- |
| 0 | ItemBase.ts | Base item template (freaky green cube) |||
| 1 | BananaGun.ts | Banana gun |||
| 2 | FishGun.ts | Fish gun >:) |||
| 4 | FlagItem.ts | FlagItem used in CTF |||
42 changes: 42 additions & 0 deletions docs/blender-texture-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Reduce Texture Resolution of a Blender File

The following python script reduces the resolution of all textures in a Blender file by 50%.

```python
import bpy

def resize_image(image, scale_factor=0.5):
# Calculate new dimensions
new_width = int(image.size[0] * scale_factor)
new_height = int(image.size[1] * scale_factor)

# Ensure the image is packed or has a file path
if image.packed_file:
image.unpack(method='USE_ORIGINAL')

# Get the file path
filepath = bpy.path.abspath(image.filepath)

# Skip images without a valid file path
if not filepath:
print(f"Skipping image '{image.name}' because it has no valid file path.")
return

# Scale the image
image.scale(new_width, new_height)

# Save the resized image
image.filepath_raw = filepath
image.file_format = 'PNG' # Change format if needed
image.save()

def main():
# Iterate over all images in the Blender file
for image in bpy.data.images:
if image.size[0] > 0 and image.size[1] > 0:
print(f"Processing image: {image.name}")
resize_image(image)

if __name__ == "__main__":
main()
```
18 changes: 13 additions & 5 deletions docs/gltf-compression.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
# GLTF Compression

### use gltf-pipeline for compression

https://github.com/CesiumGS/gltf-pipeline

Can be installed using npm:

```bash
npm install -g gltf-pipeline
```

### sane person compression if it's already stylized:

```bash
gltf-pipeline -i input.glb -o output.glb --draco.compressionLevel 10 --texcomp.quality 50 --texcomp.powerOfTwoImage true
```

This command:

1. Uses Draco compression with maximum level (10)
2. Reduces the precision of various attributes (position, normal, texture coordinates, color, and other generic attributes) by specifying fewer bits for each. This effectively removes data points. 3.
2. Reduces the precision of various attributes (position, normal, texture coordinates, color, and other generic
attributes) by specifying fewer bits for each. This effectively removes data points. 3.
3. Applies the --optimize.simplify flag, which attempts to simplify the geometry while preserving the overall shape.

You can adjust the quantization bits (the numbers after each quantize...Bits option) to be even lower for more aggressive simplification. For example:
You can adjust the quantization bits (the numbers after each quantize...Bits option) to be even lower for more
aggressive simplification. For example:

```bash
--draco.quantizePositionBits 8 --draco.quantizeNormalBits 6 --draco.quantizeTexcoordBits 6 --draco.quantizeColorBits 6 --draco.quantizeGenericBits 6
```


### really abysmal compression to "stylize" something normal
(used for possum and banana so far)- uses 8 for quantization leading to gross blocky look sometimes unintended with holes

(used for possum and banana so far)- uses 8 for quantization leading to gross blocky look sometimes unintended with
holes

```bash
gltf-pipeline -i possum.glb -o simplified_possum.glb --draco.compressionLevel 10 --draco.quantizePositionBits 6 --draco.quantizeNormalBits 4 --draco.quantizeTexcoordBits 4 --draco.quantizeColorBits 4 --draco.quantizeGenericBits 4 --optimize.simplify
```

#### not sure what this one does, added a bunch more flags might break things lmk tho

```bash
gltf-pipeline -i possum.glb -o simplified_possum.glb --draco.compressionLevel 10 --draco.quantizePositionBits 6 --draco.quantizeNormalBits 4 --draco.quantizeTexcoordBits 4 --draco.quantizeColorBits 4 --draco.quantizeGenericBits 4 --optimize.simplify --optimize.pruneUnused --optimize.mergeInstances --optimize.mergeMaterials --optimize.stripJoints
```
```
2 changes: 1 addition & 1 deletion public/gameVersion.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "1.9.1"}
{"version": "1.10.0"}
Binary file added public/models/arrow.glb
Binary file not shown.
Binary file added public/models/flamingo.glb
Binary file not shown.
Binary file added public/models/pizza.glb
Binary file not shown.
Binary file added public/models/simplified_flamingo.glb
Binary file not shown.
Binary file added public/models/simplified_pizza.glb
Binary file not shown.
1 change: 0 additions & 1 deletion src/client/core/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class Game {
this.networking.updatePlayerData();
this.chatOverlay.onFrame();
this.inventoryManager.onFrame();
this.healthIndicator.onFrame();
this.renderer.onFrame(this.localPlayer);
if (this.networking.getServerInfo().mapName) {
this.mapLoader.load('/maps/' + this.networking.getServerInfo().mapName + '/map.glb');
Expand Down
6 changes: 6 additions & 0 deletions src/client/core/Inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ItemBase, ItemType } from '../items/ItemBase.ts';
import { FishGun } from '../items/FishGun.ts';
import { Player } from '../../shared/Player.ts';
import { Bat } from '../items/Bat.ts';
import { FlagItem } from '../items/FlagItem.ts';

export class Inventory {
private inventoryItems: ItemBase[] = [];
Expand Down Expand Up @@ -69,6 +70,11 @@ export class Inventory {
this.inventoryItems.push(bat);
break;
}
case 4: {
const flag = new FlagItem(this.renderer, i, ItemType.InventoryItem);
this.inventoryItems.push(flag);
break;
}
default: {
const testItem = new ItemBase(
ItemType.InventoryItem,
Expand Down
23 changes: 22 additions & 1 deletion src/client/core/Networking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface ServerInfo {
version: string;
gameMode: string;
playerMaxHealth: number;
skyColor: string;
}

interface LastUploadedLocalPlayer {
Expand Down Expand Up @@ -68,6 +69,7 @@ export class Networking {
version: '',
gameMode: '',
playerMaxHealth: 0,
skyColor: '#000000',
};

this.setupSocketListeners();
Expand Down Expand Up @@ -104,7 +106,9 @@ export class Networking {
});

this.socket.on('serverInfo', (data) => {
this.serverInfo = data;
this.serverInfo = {
...data,
};
this.onServerInfo();
});
}
Expand Down Expand Up @@ -176,17 +180,34 @@ export class Networking {
}
if (remotePlayer.health < this.localPlayer.health) this.damagedTimestamp = Date.now() / 1000;
this.localPlayer.health = remotePlayer.health;
this.localPlayer.highlightedVectors = remotePlayer.highlightedVectors.map(
(vec) => new THREE.Vector3(vec.x, vec.y, vec.z),
);
this.localPlayer.directionIndicatorVector = remotePlayer.directionIndicatorVector
? new THREE.Vector3(
remotePlayer.directionIndicatorVector.x,
remotePlayer.directionIndicatorVector.y,
remotePlayer.directionIndicatorVector.z,
)
: undefined;

this.localPlayer.idLastDamagedBy = remotePlayer.idLastDamagedBy;
this.localPlayer.inventory = remotePlayer.inventory;
this.localPlayer.playerSpectating = remotePlayer.playerSpectating;
this.localPlayer.gameMsgs = remotePlayer.gameMsgs;
this.localPlayer.gameMsgs2 = remotePlayer.gameMsgs2;
this.localPlayer.doPhysics = remotePlayer.doPhysics;
continue;
}
if (remotePlayer.chatActive) {
this.messagesBeingTyped.push(`${remotePlayer.name}: ${remotePlayer.chatMsg}`);
}
}
if (
this.getServerInfo().version && this.localPlayer.gameVersion !== this.getServerInfo().version
) {
this.localPlayer.gameMsgs = ['&c Your client may be outdated. Try refreshing the page.'];
}
}

private playersAreEqualEnough(player1: Player, player2: LastUploadedLocalPlayer | null) {
Expand Down
4 changes: 4 additions & 0 deletions src/client/core/RemoteItemRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ItemBase, ItemType } from '../items/ItemBase.ts';
import { BananaGun } from '../items/BananaGun.ts';
import { FishGun } from '../items/FishGun.ts';
import { Bat } from '../items/Bat.ts';
import { FlagItem } from '../items/FlagItem.ts';

// Custom types
type Vector3Data = {
Expand Down Expand Up @@ -92,8 +93,11 @@ export class RemoteItemRenderer {
return new FishGun(this.renderer, this.networking, 0, ItemType.WorldItem);
case 3:
return new Bat(this.renderer, this.networking, 0, ItemType.WorldItem);
case 4:
return new FlagItem(this.renderer, 0, ItemType.WorldItem);
default:
// Return a generic item
console.log('Unknown item type:', itemType);
return new ItemBase(
ItemType.WorldItem,
this.renderer.getEntityScene(),
Expand Down
Loading

0 comments on commit 4da2b4f

Please sign in to comment.