@bornengine/engine 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +231 -0
- package/native/android/Cargo.lock +1848 -0
- package/native/android/Cargo.toml +24 -0
- package/native/android/src/lib.rs +702 -0
- package/native/ios/Cargo.lock +1690 -0
- package/native/ios/Cargo.toml +32 -0
- package/native/ios/src/lib.rs +1267 -0
- package/native/linux/Cargo.lock +3279 -0
- package/native/linux/Cargo.toml +29 -0
- package/native/linux/src/lib.rs +1331 -0
- package/native/macos/Cargo.lock +3310 -0
- package/native/macos/Cargo.toml +46 -0
- package/native/macos/src/lib.rs +1302 -0
- package/native/shared/Cargo.lock +1899 -0
- package/native/shared/Cargo.toml +62 -0
- package/native/shared/assets/default_font.ttf +0 -0
- package/native/shared/build.rs +270 -0
- package/native/shared/shaders/common/clouds.wgsl +122 -0
- package/native/shared/shaders/common/fog.wgsl +16 -0
- package/native/shared/shaders/common/foliage_wind.wgsl +98 -0
- package/native/shared/shaders/common/imposter.wgsl +112 -0
- package/native/shared/shaders/common/pbr.wgsl +186 -0
- package/native/shared/shaders/common/shadows.wgsl +186 -0
- package/native/shared/shaders/common/sky.wgsl +8 -0
- package/native/shared/shaders/common/tonemap.wgsl +25 -0
- package/native/shared/shaders/impulse_field.wgsl +57 -0
- package/native/shared/shaders/material_abi.wgsl +383 -0
- package/native/shared/shaders/materials/test_minimal.wgsl +42 -0
- package/native/shared/src/anim_mixer.rs +61 -0
- package/native/shared/src/attach.rs +263 -0
- package/native/shared/src/audio/decode.rs +123 -0
- package/native/shared/src/audio/mod.rs +863 -0
- package/native/shared/src/audio/render.rs +892 -0
- package/native/shared/src/audio/spsc.rs +156 -0
- package/native/shared/src/audio/stream.rs +226 -0
- package/native/shared/src/custom_shaders.rs +104 -0
- package/native/shared/src/decals.rs +245 -0
- package/native/shared/src/drs.rs +211 -0
- package/native/shared/src/engine.rs +261 -0
- package/native/shared/src/ffi.rs +116 -0
- package/native/shared/src/ffi_core/assets.rs +388 -0
- package/native/shared/src/ffi_core/audio_ffi.rs +184 -0
- package/native/shared/src/ffi_core/draw.rs +334 -0
- package/native/shared/src/ffi_core/game_loop.rs +577 -0
- package/native/shared/src/ffi_core/input.rs +234 -0
- package/native/shared/src/ffi_core/mod.rs +127 -0
- package/native/shared/src/ffi_core/models.rs +1154 -0
- package/native/shared/src/ffi_core/ragdoll_ffi.rs +261 -0
- package/native/shared/src/ffi_core/scene.rs +626 -0
- package/native/shared/src/ffi_core/vfx.rs +212 -0
- package/native/shared/src/ffi_core/visual.rs +691 -0
- package/native/shared/src/frame_callbacks.rs +122 -0
- package/native/shared/src/geometry.rs +236 -0
- package/native/shared/src/handles.rs +182 -0
- package/native/shared/src/input.rs +448 -0
- package/native/shared/src/jolt_sys.rs +822 -0
- package/native/shared/src/lib.rs +55 -0
- package/native/shared/src/models.rs +1093 -0
- package/native/shared/src/models_gltf.rs +1280 -0
- package/native/shared/src/particles.rs +391 -0
- package/native/shared/src/physics_jolt.rs +1908 -0
- package/native/shared/src/picking.rs +298 -0
- package/native/shared/src/postfx.rs +345 -0
- package/native/shared/src/profiler.rs +492 -0
- package/native/shared/src/ragdoll.rs +474 -0
- package/native/shared/src/renderer/atmosphere_lut.rs +573 -0
- package/native/shared/src/renderer/brdf_lut.rs +154 -0
- package/native/shared/src/renderer/draw2d.rs +143 -0
- package/native/shared/src/renderer/formats.rs +822 -0
- package/native/shared/src/renderer/froxel.rs +421 -0
- package/native/shared/src/renderer/gi_bake.rs +653 -0
- package/native/shared/src/renderer/graph.rs +462 -0
- package/native/shared/src/renderer/hiz.rs +269 -0
- package/native/shared/src/renderer/hot_reload.rs +390 -0
- package/native/shared/src/renderer/impulse_field.rs +456 -0
- package/native/shared/src/renderer/lighting.rs +154 -0
- package/native/shared/src/renderer/material_instancing.rs +171 -0
- package/native/shared/src/renderer/material_pipeline.rs +700 -0
- package/native/shared/src/renderer/material_system.rs +1996 -0
- package/native/shared/src/renderer/material_system_tests.rs +601 -0
- package/native/shared/src/renderer/material_system_wasm.rs +41 -0
- package/native/shared/src/renderer/mod.rs +12556 -0
- package/native/shared/src/renderer/model_draw.rs +641 -0
- package/native/shared/src/renderer/occlusion.rs +429 -0
- package/native/shared/src/renderer/planar_pass.rs +593 -0
- package/native/shared/src/renderer/planar_reflection.rs +499 -0
- package/native/shared/src/renderer/post_pass.rs +249 -0
- package/native/shared/src/renderer/postfx_chain.rs +728 -0
- package/native/shared/src/renderer/pt_pass.rs +577 -0
- package/native/shared/src/renderer/scene_pass.rs +607 -0
- package/native/shared/src/renderer/shader_include.rs +205 -0
- package/native/shared/src/renderer/shader_library.rs +135 -0
- package/native/shared/src/renderer/shaders/ao.rs +570 -0
- package/native/shared/src/renderer/shaders/core.rs +1243 -0
- package/native/shared/src/renderer/shaders/env.rs +907 -0
- package/native/shared/src/renderer/shaders/gi.rs +810 -0
- package/native/shared/src/renderer/shaders/mod.rs +19 -0
- package/native/shared/src/renderer/shaders/post.rs +1558 -0
- package/native/shared/src/renderer/shaders/pt.rs +1859 -0
- package/native/shared/src/renderer/shaders/ssgi.rs +1586 -0
- package/native/shared/src/renderer/shadow_pass.rs +731 -0
- package/native/shared/src/renderer/ssgi_pass.rs +392 -0
- package/native/shared/src/renderer/ssr_pass.rs +188 -0
- package/native/shared/src/renderer/texture_store.rs +473 -0
- package/native/shared/src/renderer/transient.rs +591 -0
- package/native/shared/src/renderer/types.rs +941 -0
- package/native/shared/src/renderer/util.rs +152 -0
- package/native/shared/src/scene.rs +1362 -0
- package/native/shared/src/sdf_cache.rs +274 -0
- package/native/shared/src/shadows.rs +1036 -0
- package/native/shared/src/staging.rs +102 -0
- package/native/shared/src/string_header.rs +266 -0
- package/native/shared/src/text_renderer.rs +502 -0
- package/native/shared/src/textures.rs +197 -0
- package/native/tvos/Cargo.lock +1693 -0
- package/native/tvos/Cargo.toml +36 -0
- package/native/tvos/metal-patched/Cargo.toml +178 -0
- package/native/tvos/metal-patched/LICENSE-APACHE +201 -0
- package/native/tvos/metal-patched/LICENSE-MIT +25 -0
- package/native/tvos/metal-patched/src/acceleration_structure.rs +667 -0
- package/native/tvos/metal-patched/src/acceleration_structure_pass.rs +108 -0
- package/native/tvos/metal-patched/src/argument.rs +366 -0
- package/native/tvos/metal-patched/src/blitpass.rs +102 -0
- package/native/tvos/metal-patched/src/buffer.rs +71 -0
- package/native/tvos/metal-patched/src/capturedescriptor.rs +76 -0
- package/native/tvos/metal-patched/src/capturemanager.rs +113 -0
- package/native/tvos/metal-patched/src/commandbuffer.rs +192 -0
- package/native/tvos/metal-patched/src/commandqueue.rs +44 -0
- package/native/tvos/metal-patched/src/computepass.rs +107 -0
- package/native/tvos/metal-patched/src/constants.rs +152 -0
- package/native/tvos/metal-patched/src/counters.rs +119 -0
- package/native/tvos/metal-patched/src/depthstencil.rs +190 -0
- package/native/tvos/metal-patched/src/device.rs +2134 -0
- package/native/tvos/metal-patched/src/drawable.rs +39 -0
- package/native/tvos/metal-patched/src/encoder.rs +2041 -0
- package/native/tvos/metal-patched/src/heap.rs +281 -0
- package/native/tvos/metal-patched/src/indirect_encoder.rs +344 -0
- package/native/tvos/metal-patched/src/lib.rs +657 -0
- package/native/tvos/metal-patched/src/library.rs +902 -0
- package/native/tvos/metal-patched/src/mps.rs +575 -0
- package/native/tvos/metal-patched/src/pipeline/compute.rs +475 -0
- package/native/tvos/metal-patched/src/pipeline/mod.rs +71 -0
- package/native/tvos/metal-patched/src/pipeline/render.rs +762 -0
- package/native/tvos/metal-patched/src/renderpass.rs +443 -0
- package/native/tvos/metal-patched/src/resource.rs +182 -0
- package/native/tvos/metal-patched/src/sampler.rs +165 -0
- package/native/tvos/metal-patched/src/sync.rs +178 -0
- package/native/tvos/metal-patched/src/texture.rs +352 -0
- package/native/tvos/metal-patched/src/types.rs +90 -0
- package/native/tvos/metal-patched/src/vertexdescriptor.rs +250 -0
- package/native/tvos/src/audio_backend.rs +197 -0
- package/native/tvos/src/lib.rs +1891 -0
- package/native/visionos/Cargo.lock +1693 -0
- package/native/visionos/Cargo.toml +40 -0
- package/native/visionos/src/audio_backend.rs +197 -0
- package/native/visionos/src/lib.rs +1887 -0
- package/native/watchos/Cargo.lock +16 -0
- package/native/watchos/Cargo.toml +19 -0
- package/native/watchos/shaders/bloom_postfx.metal +99 -0
- package/native/watchos/src/BloomWatchApp.swift +1267 -0
- package/native/watchos/src/BloomWatchAudio.swift +179 -0
- package/native/watchos/src/audio.rs +55 -0
- package/native/watchos/src/draw_list.rs +229 -0
- package/native/watchos/src/ffi_stubs.rs +915 -0
- package/native/watchos/src/ffi_stubs_manual.rs +35 -0
- package/native/watchos/src/lib.rs +1124 -0
- package/native/watchos/src/models.rs +746 -0
- package/native/watchos/src/postfx.rs +95 -0
- package/native/watchos/src/scene.rs +534 -0
- package/native/watchos/src/textures.rs +184 -0
- package/native/web/Cargo.lock +1657 -0
- package/native/web/Cargo.toml +43 -0
- package/native/web/bloom_glue.js +695 -0
- package/native/web/build.sh +131 -0
- package/native/web/index.html +35 -0
- package/native/web/jolt_bridge.js +1519 -0
- package/native/web/src/input_ffi.rs +286 -0
- package/native/web/src/lib.rs +1796 -0
- package/native/web/src/material_ffi.rs +710 -0
- package/native/web/src/parity_ffi.rs +343 -0
- package/native/web/src/physics_ffi.rs +643 -0
- package/native/web/src/ragdoll_ffi.rs +250 -0
- package/native/web/src/render_settings.rs +98 -0
- package/native/windows/Cargo.lock +1815 -0
- package/native/windows/Cargo.toml +68 -0
- package/native/windows/src/lib.rs +1486 -0
- package/package.json +4279 -0
- package/src/audio/index.ts +315 -0
- package/src/core/colors.ts +63 -0
- package/src/core/index.ts +1206 -0
- package/src/core/keys.ts +63 -0
- package/src/core/types.ts +104 -0
- package/src/index.ts +171 -0
- package/src/math/index.ts +516 -0
- package/src/mobile/index.ts +294 -0
- package/src/models/index.ts +1258 -0
- package/src/physics/index.ts +1134 -0
- package/src/scene/index.ts +698 -0
- package/src/shapes/index.ts +120 -0
- package/src/text/index.ts +48 -0
- package/src/textures/index.ts +187 -0
- package/src/vfx/index.ts +191 -0
- package/src/world/index.ts +24 -0
- package/src/world/loader.ts +423 -0
- package/src/world/prefab.ts +217 -0
- package/src/world/render.ts +172 -0
- package/src/world/saver.ts +108 -0
- package/src/world/serialize.ts +301 -0
- package/src/world/terrain.ts +355 -0
- package/src/world/types.ts +160 -0
- package/src/world/validate.ts +319 -0
- package/src/world/version.ts +114 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Build Bloom Engine for Web
|
|
3
|
+
#
|
|
4
|
+
# Usage:
|
|
5
|
+
# ./native/web/build.sh [game.ts] [--output dist/]
|
|
6
|
+
#
|
|
7
|
+
# Steps:
|
|
8
|
+
# 1. Build bloom_web.wasm via wasm-pack
|
|
9
|
+
# 2. Compile game TypeScript via perry --target wasm (if provided)
|
|
10
|
+
# 3. Assemble output directory with all files needed to serve
|
|
11
|
+
#
|
|
12
|
+
# Prerequisites:
|
|
13
|
+
# - wasm-pack: cargo install wasm-pack
|
|
14
|
+
# - perry: ../../../perry/perry/target/release/perry (or in PATH)
|
|
15
|
+
# - wasm-opt (optional): for binary size optimization
|
|
16
|
+
|
|
17
|
+
set -e
|
|
18
|
+
|
|
19
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
20
|
+
ENGINE_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
21
|
+
WEB_CRATE="$SCRIPT_DIR"
|
|
22
|
+
OUTPUT_DIR="${2:-$ENGINE_DIR/dist/web}"
|
|
23
|
+
GAME_FILE="$1"
|
|
24
|
+
|
|
25
|
+
# Resolve the game file to an absolute path NOW, while still in the caller's
|
|
26
|
+
# working directory — the build cd's into the web crate before compiling, so a
|
|
27
|
+
# relative path like `examples/pong/main.ts` would otherwise no longer resolve.
|
|
28
|
+
if [ -n "$GAME_FILE" ]; then
|
|
29
|
+
if [ -f "$GAME_FILE" ]; then
|
|
30
|
+
GAME_FILE="$(cd "$(dirname "$GAME_FILE")" && pwd)/$(basename "$GAME_FILE")"
|
|
31
|
+
else
|
|
32
|
+
echo "ERROR: game file not found: $GAME_FILE"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
echo "=== Bloom Web Build ==="
|
|
38
|
+
echo ""
|
|
39
|
+
|
|
40
|
+
# 1. Build Bloom WASM via wasm-pack
|
|
41
|
+
echo "[1/4] Building bloom_web.wasm..."
|
|
42
|
+
cd "$WEB_CRATE"
|
|
43
|
+
wasm-pack build --target web --out-dir pkg --no-typescript 2>&1 | tail -3
|
|
44
|
+
echo " Output: $WEB_CRATE/pkg/"
|
|
45
|
+
|
|
46
|
+
# 2. Optimize WASM binary (if wasm-opt is available)
|
|
47
|
+
if command -v wasm-opt &> /dev/null; then
|
|
48
|
+
echo "[2/4] Optimizing WASM with wasm-opt..."
|
|
49
|
+
WASM_FILE="$WEB_CRATE/pkg/bloom_web_bg.wasm"
|
|
50
|
+
ORIG_SIZE=$(wc -c < "$WASM_FILE")
|
|
51
|
+
wasm-opt -Oz "$WASM_FILE" -o "$WASM_FILE.opt"
|
|
52
|
+
mv "$WASM_FILE.opt" "$WASM_FILE"
|
|
53
|
+
OPT_SIZE=$(wc -c < "$WASM_FILE")
|
|
54
|
+
echo " Optimized: $((ORIG_SIZE / 1024))KB → $((OPT_SIZE / 1024))KB"
|
|
55
|
+
else
|
|
56
|
+
echo "[2/4] Skipping wasm-opt (not installed). Install with: cargo install wasm-opt"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# 3. Compile game (if provided)
|
|
60
|
+
PERRY_HTML=""
|
|
61
|
+
if [ -n "$GAME_FILE" ] && [ -f "$GAME_FILE" ]; then
|
|
62
|
+
echo "[3/4] Compiling game: $GAME_FILE"
|
|
63
|
+
|
|
64
|
+
# Find perry compiler
|
|
65
|
+
PERRY=""
|
|
66
|
+
if command -v perry &> /dev/null; then
|
|
67
|
+
PERRY="perry"
|
|
68
|
+
elif [ -f "$ENGINE_DIR/../../perry/perry/target/release/perry" ]; then
|
|
69
|
+
PERRY="$ENGINE_DIR/../../perry/perry/target/release/perry"
|
|
70
|
+
else
|
|
71
|
+
echo " ERROR: perry compiler not found. Install it or add to PATH."
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# Perry emits a self-contained HTML carrying the game WASM (base64) plus its
|
|
76
|
+
# full runtime bridge (the ~280 `rt`-namespace host functions + NaN-boxing +
|
|
77
|
+
# closure dispatch). build.sh later splices the Bloom engine bootstrap into it.
|
|
78
|
+
# Use a temp dir (portable across GNU/BSD mktemp) so cleanup is a single rm.
|
|
79
|
+
PERRY_TMP="$(mktemp -d)"
|
|
80
|
+
PERRY_HTML="$PERRY_TMP/game.html"
|
|
81
|
+
$PERRY "$GAME_FILE" --target wasm -o "$PERRY_HTML"
|
|
82
|
+
echo " Game compiled to WASM ($PERRY_HTML)"
|
|
83
|
+
else
|
|
84
|
+
echo "[3/4] No game file specified, skipping game compilation"
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# 4. Assemble output directory
|
|
88
|
+
echo "[4/4] Assembling output..."
|
|
89
|
+
mkdir -p "$OUTPUT_DIR"
|
|
90
|
+
|
|
91
|
+
# Copy Bloom WASM package
|
|
92
|
+
cp -r "$WEB_CRATE/pkg" "$OUTPUT_DIR/pkg"
|
|
93
|
+
|
|
94
|
+
# Engine bootstrap + Jolt bridge are needed by both the game and engine-only pages.
|
|
95
|
+
cp "$WEB_CRATE/bloom_glue.js" "$OUTPUT_DIR/bloom_glue.js"
|
|
96
|
+
cp "$WEB_CRATE/jolt_bridge.js" "$OUTPUT_DIR/jolt_bridge.js"
|
|
97
|
+
|
|
98
|
+
if [ -n "$PERRY_HTML" ]; then
|
|
99
|
+
# Game build: splice the Bloom bootstrap into Perry's HTML and gate the game's
|
|
100
|
+
# bootPerryWasm() call on engine readiness → dist/web/index.html.
|
|
101
|
+
python3 "$WEB_CRATE/splice_game.py" "$PERRY_HTML" "$OUTPUT_DIR/index.html"
|
|
102
|
+
rm -rf "$PERRY_TMP"
|
|
103
|
+
echo " Spliced game + engine into index.html"
|
|
104
|
+
else
|
|
105
|
+
# No game: ship the engine-only standalone page.
|
|
106
|
+
cp "$WEB_CRATE/index.html" "$OUTPUT_DIR/index.html"
|
|
107
|
+
echo " Copied engine-only index.html (no game compiled)"
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
# Copy game assets (if game directory has an assets/ folder)
|
|
111
|
+
if [ -n "$GAME_FILE" ]; then
|
|
112
|
+
GAME_DIR="$(dirname "$(realpath "$GAME_FILE")")"
|
|
113
|
+
if [ -d "$GAME_DIR/assets" ]; then
|
|
114
|
+
cp -r "$GAME_DIR/assets" "$OUTPUT_DIR/assets"
|
|
115
|
+
echo " Copied assets/ directory"
|
|
116
|
+
fi
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# Calculate total size
|
|
120
|
+
TOTAL_SIZE=$(du -sh "$OUTPUT_DIR" | cut -f1)
|
|
121
|
+
WASM_SIZE=$(wc -c < "$OUTPUT_DIR/pkg/bloom_web_bg.wasm" 2>/dev/null || echo "0")
|
|
122
|
+
|
|
123
|
+
echo ""
|
|
124
|
+
echo "=== Build Complete ==="
|
|
125
|
+
echo " Output: $OUTPUT_DIR"
|
|
126
|
+
echo " WASM size: $((WASM_SIZE / 1024))KB"
|
|
127
|
+
echo " Total size: $TOTAL_SIZE"
|
|
128
|
+
echo ""
|
|
129
|
+
echo "To serve locally:"
|
|
130
|
+
echo " cd $OUTPUT_DIR && python3 -m http.server 8080"
|
|
131
|
+
echo " Open http://localhost:8080"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Bloom Engine</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
html, body { width: 100vw; height: 100vh; overflow: hidden; background: #000; }
|
|
10
|
+
#bloom-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
|
|
11
|
+
#loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
|
12
|
+
color: #fff; font-family: monospace; font-size: 14px; }
|
|
13
|
+
</style>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<canvas id="bloom-canvas"></canvas>
|
|
17
|
+
<div id="loading">Loading Bloom Engine...</div>
|
|
18
|
+
|
|
19
|
+
<!--
|
|
20
|
+
Engine-only page (no compiled game). `build.sh` produces a different page
|
|
21
|
+
for game builds: it splices this same bootstrap into Perry's self-contained
|
|
22
|
+
WASM HTML and gates the game's bootPerryWasm() call on __bloomReady.
|
|
23
|
+
|
|
24
|
+
The promise is created here, synchronously during parse, so any later
|
|
25
|
+
boot script can register `.then()` before the deferred module below runs.
|
|
26
|
+
-->
|
|
27
|
+
<script>
|
|
28
|
+
window.__bloomReady = new Promise((resolve, reject) => {
|
|
29
|
+
window.__bloomReadyResolve = resolve;
|
|
30
|
+
window.__bloomReadyReject = reject;
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
<script type="module" src="./bloom_glue.js"></script>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|