📅  最后修改于: 2023-12-03 15:00:40.963000             🧑  作者: Mango
Eyeshot JavaScript版本是一个强大的3D CAD组件库,针对Web应用程序的构建而设计,支持各种主流浏览器和框架。
<script src="eyeshot.min.js"></script>
<div id="viewport"></div>
var viewport = new eyeshot.Viewport(document.getElementById('viewport'));
var model = new eyeshot.Model();
model.readFile('myModel.dwg', function () {
viewport.render(model);
});
// 创建一个含有一个立方体的3D模型
var model = new eyeshot.Model();
var cube = new eyeshot.Mesh();
cube.vertices.push(new eyeshot.Point3D(-1, 1, 1));
cube.vertices.push(new eyeshot.Point3D(1, 1, 1));
cube.vertices.push(new eyeshot.Point3D(1, -1, 1));
cube.vertices.push(new eyeshot.Point3D(-1, -1, 1));
cube.vertices.push(new eyeshot.Point3D(-1, 1, -1));
cube.vertices.push(new eyeshot.Point3D(1, 1, -1));
cube.vertices.push(new eyeshot.Point3D(1, -1, -1));
cube.vertices.push(new eyeshot.Point3D(-1, -1, -1));
cube.faces.push(new eyeshot.MeshFace(0, 1, 2, 3));
cube.faces.push(new eyeshot.MeshFace(0, 4, 5, 1));
cube.faces.push(new eyeshot.MeshFace(1, 5, 6, 2));
cube.faces.push(new eyeshot.MeshFace(2, 6, 7, 3));
cube.faces.push(new eyeshot.MeshFace(3, 7, 4, 0));
cube.faces.push(new eyeshot.MeshFace(4, 7, 6, 5));
model.entities.push(cube);
// 在HTML中添加Viewport容器
var viewport = new eyeshot.Viewport(document.getElementById('viewport'));
// 在Viewport中渲染模型
viewport.render(model);