1. World coordinate system

2. Parent object coordinate system

3. Own coordinate system

To control the spatial position of a 3D visual object, you first need to understand the spatial coordinate system. In The ThingJS development platform, a right-handed coordinate system is used, with the X and Z axes on the horizontal axis and the Y axis on the vertical axis (the position coordinates obtained by ThingJS are all in meters). To describe or control the position of a 3D visual object, the following three coordinate systems are used in different cases: 1. World coordinate system 2. Parent object coordinate system 3. The following is my study of the world coordinate system, parent object coordinate system and self coordinate system and some of my own understanding. Welcome to correct and discuss any mistakes.

1. World coordinate system

The world coordinate system is the absolute coordinate system of the system. When the 3D visual scene (not the park) is created, a position is plotted in the whole scene space, and the coordinate system of the scene space is the world coordinate system.

Use the position property to control the position of an object in the world coordinate system, as in:

Obj. Position =,0,10 [10]Copy the code

Gets the position of the object in the world coordinate system, also using the position property directly, as in:

console.log(obj.position) 
Copy the code

2. Parent object coordinate system

The parent object coordinate system refers to the relative coordinate system centered on the parent object. For example, when the park is created in the 3D visualization scene, an airplane is placed in the park, and the airplane is a child object of the park. I want to set the location of the airplane in the coordinate system of the 3D visualization park, and the coordinate system of the park is the parent object coordinate system of the airplane.

An object is set or obtained in the parent object coordinate system using the localPosition property.

3. Own coordinate system

A coordinate system centered on the object itself. Sometimes, it is also hoped to control in the coordinate system with itself. For example, if the forklift moves forward 2 meters, it sets the coordinate [0,0,2] in its own coordinate system (the z-axis of the object itself is positive, which can be understood as the direction of the front of the object, such as the orientation of our own face).

An object controls its position in its own coordinate system using the following interface:

Obj. Translate (,0,2 [0]);Copy the code

Normally, children move with the parent, but you can control the child by setting the inheritPosition attribute of the child to false.

In addition, ThingJS provides the following coordinate conversion methods:

SelfToWorld (pos) // selfToWorld(pos) // selfToWorld(pos)Copy the code

I just began to learn the coordinate system, also feel very dizzy, I believe that many beginners like me, but think carefully is just to understand the meaning of three coordinate system and coordinate system transformation, understand the space coordinate system, can achieve the purpose of controlling the space position of 3D visualization object.