Risparmia 3D Scena come HTML

Contents
[ ]

Risparmia 3D Scena come HTML

Aspose.3D for Java offre HtmlSaveOptions di classe per salvare una scena di 3D di risparmio come HTML. Quando esporti la scena in file HTML5, API esporterà tre file, un file HTML, un file DWeb Aspose3 (. a3dw **) e un file JavaScript reso. Per esportare solo file a3dw, è possibile specificare Aspose3DWeb come tipo di esportazione e riutilizzare il file JavaScript all’interno della propria pagina HTML. Il seguente frammento di codice mostra come salvare una scena di 3D come HTML.

// For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-Java
// Initialize a scene
Scene scene = new Scene();
// Initialize a node
Node node = scene.getRootNode().createChildNode(new Cylinder());
// Set child node properites
LambertMaterial mat = new LambertMaterial();
mat.setDiffuseColor(new Vector3(0.34,0.59, 0.41));
node.setMaterial(mat);
Light light = new Light();
light.setLightType(LightType.POINT);
scene.getRootNode().createChildNode(light).getTransform().setTranslation(10, 0, 10);
// Initialize HTML5SaveOptions
HTML5SaveOptions opt = new HTML5SaveOptions();
// Turn off the grid
opt.setShowGrid(false);
//Turn off the user interface
opt.setShowUI(false);
scene.save(RunExamples.getDataDir() + "html5SaveOption.html", FileFormat.HTML5);
 python3 -m http.server

Allora aprilohttp://localhost:8000/test.html. Il renderer web utilizza WebGL2, è possibile utilizzarehttps://get.webgl.org/webgl2/Per verificare se il tuo browser lo supporta o meno.