Home>Article>Web Front-end> A brief discussion on css 3d and spatial coordinate axes

A brief discussion on css 3d and spatial coordinate axes

little bottle
little bottle forward
2019-04-30 13:40:44 2722browse

Today I will tell you how to use this CSS 3D, as well as the related knowledge of spatial coordinate axes. Friends who are interested can come and find out, I hope it will be helpful to you.

First the renderings:

Basic idea: three-layer structure:Perspective Container>>Vector>>specific3dimage.

Perspective container:Determines the 3D rendering effect. The pespective attribute here receives parameters in pixels. The larger the value of perspective, the more "The farther the eyes are from the observation object", the smaller the value, which means "The closer the eyes are to the observation object"

Without the perspective attribute, it will not be possible Adjust the viewing angle.

## Carrier

Supports carrying 3D imagesThe biggest difference between this carrier and ordinary html tags is that it has an additional attribute:transform-style:preserve-3d

. Indicates that it supports 3D image display.

If this attribute is missing, the 3D graphics that have been 3D converted will be pressed in a 2D plane and cannot show a 3D effect, because the containers are flat, even if the content It doesn't help that it's 3D.

Specific 3d image

Conversion from 2d to 3dThe 3d image here They are all converted from 2D plane images, so how to convert them. You need to use the translateX, translateY, translateZ attributes, of course the abbreviation is translate-3d, and rotateX, rotateY, rotateZ, etc. The specific rules of translate (translation) and rotate (rotation) are based on the famous reference picture below: the three-dimensional coordinate diagram.

First of all, let’s talk about the rules of translate. There is no need to say more about this. Just compare it and see it. For example, translateZ(-100px) is in this picture In the picture, it is equivalent to the image moving 100px in the direction of the -z axis. To put it more vividly, "is sunken 100px

towards the inside of the screen". translateX, translateY and so on.

The difficulty lies in rotate. Let me tell you a very simple judgment rule:

The forward axis is facing the eye, clockwise the rotation angle is positive, and counterclockwise the rotation The angle is negative.

Or you can use the left-hand rule:Stretch out your left hand, thumb pointing In the direction of the positive axis, the four fingers point to the positive direction of rotation, but be sure to remember that it is theleft hand!## 

Left-handed brother’s town:

It’s that simple. For example, now we want to make a 3D dice. First, the six floor plans are as shown above. As shown in the center of the three-dimensional coordinate system, their sizes are the same as the carrier. To turn it into a dice, the following transformation needs to be done:

(Note: The carrier and The length and width of the 6 faces are all 200px)

Attached are all source codes:

 

Hope this article is helpful to you.

The above is the detailed content of A brief discussion on css 3d and spatial coordinate axes. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete
Previous article:How to use hover in css Next article:How to use hover in css