1 Star 0 Fork 0

ing10010/verge3d-code-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webgl_test_memory.html 2.37 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<title>Verge3D - webgl memory test I</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="main.css">
<style>
body {
background-color: #fff;
color: #000;
}
a {
color: #08f;
}
</style>
</head>
<body>
<div id="info">
<a href="https://www.soft8soft.com/verge3d" target="_blank" rel="noopener">Verge3D</a> - memory test I
</div>
<script type="module">
import * as v3d from '../build/v3d.module.js';
let camera, scene, renderer;
init();
animate();
function init() {
const container = document.createElement('div');
document.body.appendChild(container);
camera = new v3d.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 200;
scene = new v3d.Scene();
scene.background = new v3d.Color(0xffffff);
renderer = new v3d.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
}
function createImage() {
const canvas = document.createElement('canvas');
canvas.width = 256;
canvas.height = 256;
const context = canvas.getContext('2d');
context.fillStyle = 'rgb(' + Math.floor(Math.random() * 256) + ',' + Math.floor(Math.random() * 256) + ',' + Math.floor(Math.random() * 256) + ')';
context.fillRect(0, 0, 256, 256);
return canvas;
}
//
function animate() {
requestAnimationFrame(animate);
render();
}
function render() {
const geometry = new v3d.SphereBufferGeometry(50, Math.random() * 64, Math.random() * 32);
const texture = new v3d.CanvasTexture(createImage());
const material = new v3d.MeshBasicMaterial({ map: texture, wireframe: true });
const mesh = new v3d.Mesh(geometry, material);
scene.add(mesh);
renderer.render(scene, camera);
scene.remove(mesh);
// clean up
geometry.dispose();
material.dispose();
texture.dispose();
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/ing/verge3d-code-examples.git
git@gitee.com:ing/verge3d-code-examples.git
ing
verge3d-code-examples
verge3d-code-examples
master

搜索帮助