Comments (4)
测试场景如下:
Engine3D初始化
添加渲染物体,开始渲染
等待5秒钟,销毁所有资源
继续一次上述步骤,Engine3D初始化...
from orillusion.
same as #125
目前引擎还不支持 Engine3D 全局销毁,后面版本会考虑支持
目前只支持 Object3D 和相关几何、贴图数据的销毁
let box = new Object3D()
let mr = box.addComponent(MeshRenderer)
mr.geometry = new BoxGeometry()
mr.material = new LitMaterial()
...
box.destroy(true) // dispose box and its geometry, material, texture ...
// or
box.destroy() // delete box object only, but the geometry and material resource will not be disposed
但实际上 WebGPU/WebGL 的编程中,很多变量和状态都没有提供手动销毁的方法,依赖于浏览器的 GC 管理,所以想做到彻底销毁最好的办法是利用 iframe 隔离管理一个 Engine3D 实例,当iframe 被移除,浏览器会自动回收所有相关内存和显存资源。
目前主流的多实例演示网站,如 orillusion doc, 官方的 webgpu samples,还包括 WebGL 的引擎,如three doc, babylon doc,还有一些做代码 playground 的网站,如 Codepen 都是以 iframe
进行多实例管理,简单高效,避免复杂的状态和内存管理,不用销毁即可
至于利用 react/vue 封装 iframe 就是常规操作了,这里就不展开了,可以自行搜索先关标准和解决方案
from orillusion.
iframe这个思路并不能接受,销毁是个基本操作,iframe只是一种特殊情况,并不能覆盖所有场景。
当产生3d canvas与项目本身的通讯的时候,iframe就是一种阻碍了。
一个最基本的场景:
拉取了ajax数据后,要给3d场景展示这些动态数据?这个数据通讯?
from orillusion.
基于 iframe 的数据交换是很成熟技术,e.g postmessage ,如果是同域名下的操作就更简单。
我们后面会提供 Engine3D 层面的销毁,但以目前 webgpu 的标准,很难自动清除所有的内存和显存状态,创建新的示例仍然会有内存或显存溢出的风险。目前主流的引擎无论webgl/webgpu还是native,都需要开发自己管理释放的工作,总体来说是一件很复杂的工程。尤其是在web上,相比较复杂的内存和显存管理,iframe通信的管理要简单很多,这么多web3d项目都不约而同的选择了用 iframe
来管理页面多实例是经过长期实践的结果。
from orillusion.
Related Issues (20)
- [BUG]: 改变材质的颜色有时失效 HOT 1
- [BUG]: gltf 加载器加载模型失败 原因如下
- [FR]: 想提交一些sample HOT 1
- [BUG]: 开启后期效果BloomPost时,无法用pixel拾取 HOT 1
- [BUG]: Ray射线 r1.at is not a function HOT 2
- [BUG]: Uncaught (in promise) TypeError: Failed to execute 'requestDevice' on 'GPUAdapter': Unsupported feature: bgra8unorm-storage HOT 2
- [BUG]: dev分支,物理模块不能用了 HOT 1
- [FR]: 怎么修改粒子发射器的角度呢?
- [FR]: 如果需要动态修改粒子大小有现成的方法可以调用吗? HOT 6
- [BUG]: FlyCameraController在初始化后setCamera不生效 HOT 2
- 添加的 wordpanel 如何在其他地方从场景中进行销毁 HOT 1
- [BUG]: 这里的代码似乎有问题 HOT 1
- [BUG]: 加载GLTF模型,模型显示错误 HOT 1
- [BUG]: 鼠标右键点击事件无效 HOT 1
- [BUG]: 设置PCF阴影,报错
- [BUG]: 加载obj文件失败
- [FR]: 给assets库添加了四个字体
- [BUG]: Blend首次打开页面不生效 HOT 1
- [BUG]: 控制台发出警告 HOT 2
- [FR]: 请问现在orillusion在绘制场景时,支持的模型文件最大是多少?单场景中模型的面数最大是多少? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orillusion.