Skip to content

Commit

Permalink
让 hdr 章节支持 wasm 环境运行
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Jan 1, 2024
1 parent 53f961f commit 7784c15
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
14 changes: 14 additions & 0 deletions code/intermediate/hdr/res/cube.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Blender MTL File: 'cube.blend'
# Material Count: 1

newmtl Material.001
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Bump cube-normal.png
map_Kd cube-diffuse.jpg
1 change: 0 additions & 1 deletion code/intermediate/hdr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ impl State {
label: Some("camera_bind_group"),
});

// 在异步运行时环境中运行异步任务
let obj_model =
resources::load_model("cube.obj", &device, &queue, &texture_bind_group_layout)
.await
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/components/WasmExample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<div class="loading" v-if="loading">
正在加载 WASM 模块 ...
</div>
<button v-if="!exampleStarted" @click="loadExample()" :disabled="loading">点击运行
{{ exampleName }}</button>
<button v-if="!exampleStarted" @click="loadExample()" :disabled="loading">点此运行
{{ exampleName }} 示例</button>
</div>
</template>

Expand Down
10 changes: 0 additions & 10 deletions docs/intermediate/hdr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,6 @@ A little note on the reflection math. The `view_dir` gives us the direction to t

## 示例

<div class="warn">

此示例目前还只能在本地运行,浏览器端加载 hdr 资源时会报错:

```sh
Format error decoding Hdr: Radiance HDR signature not found
```

</div>

<WasmExample example="hdr"></WasmExample>

<AutoGithubLink/>
Binary file added docs/public/pure-sky.hdr
Binary file not shown.
5 changes: 5 additions & 0 deletions run-wasm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ fn main() {
res_dir = res_dir.join("beginner/tutorial9-models/res");
is_need_copy = true;
}
Some("hdr") => {
out_dir = out_dir.join("hdr");
res_dir = res_dir.join("intermediate/hdr/res");
is_need_copy = true;
}
_ => {}
}

Expand Down

0 comments on commit 7784c15

Please sign in to comment.