> For the complete documentation index, see [llms.txt](https://javascriptuse.gitbook.io/javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://javascriptuse.gitbook.io/javascript/advanced/so-sanh-mesh-voi-object3d.md).

# So sánh Mesh với Object3D

Tốt hơn nhiều. Trái đất nhỏ hơn mặt trời và nó quay quanh mặt trời và tự quay.

```
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/javascript" src="./libs/three.js"></script>
  <script type="text/javascript" src="./libs/dat.gui.js"></script>
  <title>Threejs</title>
  <style>
    body {
      margin: 0;
      overflow: hidden;
    }
  </style>
</head>
<body>
  <div id="WebGL-output"></div>
  <script type="module">
    function init() {
      // create a scene, that will hold all our elements such as objects, cameras and lights.
      var scene = new THREE.Scene();
      // create a camera, which defines where we're looking at.
      var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
      camera.position.set(0, 50, 0);
      camera.up.set(0, 0, 1);
      camera.lookAt(0, 0, 0);
      // create a render and set the size
      var renderer = new THREE.WebGLRenderer();
      renderer.setClearColor(new THREE.Color(0xEEEEEE));
      renderer.setSize(window.innerWidth, window.innerHeight);
      {
        const color = 0xFFFFFF;
        const intensity = 3;
        const light = new THREE.PointLight(color, intensity);
        scene.add(light);
      }
      // show axes in the screen
      var axes = new THREE.AxisHelper(50);
      scene.add(axes);
      // create the ground plane
      var planeGeometry = new THREE.PlaneGeometry(60, 20);
      var planeMaterial = new THREE.MeshBasicMaterial({ color: 0xcccccc });
      var plane = new THREE.Mesh(planeGeometry, planeMaterial);
      // rotate and position the plane
      plane.rotation.x = - Math.PI / 2;
      plane.position.x = 30;
      plane.position.y = 0;
      plane.position.z = 0;
      const radius = 1;
      const widthSegments = 6;
      const heightSegments = 6;
      const sphereGeometry = new THREE.SphereGeometry(radius, widthSegments, heightSegments);
      const solarSystem = new THREE.Object3D();
      scene.add(solarSystem);
      const sunMaterial = new THREE.MeshPhongMaterial({ emissive: 0xFFFF00 });
      const sunMesh = new THREE.Mesh(sphereGeometry, sunMaterial);
      sunMesh.scale.set(5, 5, 5);
      solarSystem.add(sunMesh);
      const earthMaterial = new THREE.MeshPhongMaterial({ color: 0x2233FF, emissive: 0x112244 });
      const earthMesh = new THREE.Mesh(sphereGeometry, earthMaterial);
      earthMesh.position.x = 10;
      solarSystem.add(earthMesh);
      // add the plane to the scene
      scene.add(plane);
      camera.position.x = - 30;
      camera.position.y = 40;
      camera.position.z = 30;
      camera.lookAt(scene.position);
      document.getElementById("WebGL-output").appendChild(renderer.domElement);
      var gui = new dat.GUI();
      var controls = new function () {
        this.rotationPlan = 0;
        this.positionX = 30;
        this.positionY = 0;
        this.positionZ = 0;
      };
      gui.add(controls, 'rotationPlan', -6, 6);
      gui.add(controls, 'positionX', -30, 30);
      gui.add(controls, 'positionY', -40, 40);
      gui.add(controls, 'positionZ', -30, 30);
      render();
      function render() {
        plane.rotation.x = controls.rotationPlan;
        plane.position.x = controls.positionX;
        plane.position.y = controls.positionY;
        plane.position.z = controls.positionZ;
        requestAnimationFrame(render);
        renderer.render(scene, camera);
      }
      render();
    }
    init();
  </script>
</body>
</html>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://javascriptuse.gitbook.io/javascript/advanced/so-sanh-mesh-voi-object3d.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
