<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SVG Triangulation</title>
<script src="https://unpkg.com/three@0.132.2/build/three.js"></script>
</head>
<div id="svg-container" style='width:800px;height:800px;'></div>
<script>
const svgContent = `
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<circle cx="50" cy="50" r="40" fill="red" />
<rect x="90" y="60" width="60" height="80" fill="blue" />
</svg>
`;
const mesh = svgMesh3d(svgContent, {
delaunay: true,
scale: 10
});
const width = 800px;
const height = 800px;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(width, height);
const container = document.getElementById('svg-container');
container.appendChild(renderer.domElement);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(mesh.positions), 3));
const material = new THREE.MeshBasicMaterial({ color: new THREE.Color('red'), side: THREE.DoubleSide });
const meshObject = new THREE.Mesh(geometry, material);
scene.add(meshObject);
camera.position.z = 5;
function animate() {
requestAnimationFrame(animate);
meshObject.rotation.x += 0.01;
meshObject.rotation.y += 0.01;
renderer.render(scene, camera);
}
animate();
</script>
fdsklf
</html>