Three. js External Model loading and Three. js model Loading

Source: Internet
Author: User

Three. js External Model loading and Three. js model Loading

1.First, go to the official website: Https://threejs.org/Download the three. js compressed package and import three. js under the build folder to our page through the src attribute of the script tag.

2.Create three. js core object

Scene(Scenario)

Camera(CAMERA)

Light(Light Source)

Mesh(Model)

Renderer(Renderer)

The last step is to render the renderer. render (scene, camera) displayed on our page)

3.OBJModel import

<Script type = "text/javascript" src = "js/OBJLoader. js"> </script>

<Script type = "text/javascript" src = "js/MTLLoader. js"> </script>

4.. JSModel import

First, we need to convert the. OBJ model file to the. JS file model.

. ObjThe format is converted to. js using a convert_obj_three.py tool officially provided by threejs.org. To use this tool, you must install the python environment.

Conversion process:

Put convert_obj_three.py, The. obj file to be converted, and The. mtl file in the same directory.

Open cmd and switch to the corresponding directory.

Python convert_obj_three.py-I infile. obj-o outfile. js [-t ascii | binary]

Two encoding methods are available for. js files (binary and ascii)

5.Prepare for Import

Ascii

Binary

Import required

<Script src = "js/BinaryLoader. js"> </script>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.