وفِّر 3D مشهد بـ HTML
Contents
[
Hide
]
Tويدعم ميزة له من قبل الإصدار 19.9 أو أكبر.
وفِّر 3D مشهد بـ HTML
Aspose.3D for Java provides HtmlSaveOptions
class to save a save 3D scene as HTML. When you export the scene into HTML5 file, API will export three files, an HTML
file, an Aspose3DWeb file(*.a3dw*), and a rendered JavaScript
file. In order to export a3dw file only, you can specify Aspose3DWeb as the export type, and reuse the JavaScript file within your own HTML page. The following code snippet shows how to save a 3D scene as HTML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
نظرًا لحدود أمان المتصفح ، لا يمكن فتح ملف HTML الذي تم تصديره مباشرة ، تحتاج إلى فتحه من خلال خادم ويب ، إذا كان لديك تثبيت python3 ، يمكنك بدء تشغيل خادم الويب في سطر الأوامر في الدليل الذي تم تصديره
python3 -m http.server
Tالدجاجة فتحهhttp://localhost:8000/test.html. The يستخدم بائع الويب ebebGL2 ، يمكنك استخدامhttps://get.webgl.org/webgl2/للتحقق مما إذا كان المتصفح يدعم ذلك أم لا.