Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is matter js?

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "what is matter js". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Matter.js is a JavaScript2D physical engine library for Web. The project was born on February 28, 2014 (0.5.0-alpha version) and has been updated and iterated 11 versions (the latest version is 0.12.0). Compared to the old Box2D engine library, Matter.js is more lightweight (the compressed version is only 87KB) and is not inferior in terms of performance and functionality. Any object in Matter.js needs a shelter, and the place where these objects are stored, which we call the world, must be added to the world and then run by the engine.

The usage of Matter.js

Introduced into the 1.html file

two。 Create engines, renderers, add worlds, and generate body models.

VarEngine=Matter.Engine

Render=Matter.Render

World=Matter.World

Bodies=Matter.Bodies

Engine is the engine, Render is the renderer, World is the performance environment, and Bodies can be used to create objects of various shapes.

3. Create engine instances and engine worlds.

Varengine=Engine.create ()

World=engine.world

4. Create an instance of the renderer.

Varrender=Render.create ({

Engine:engine

Element:document.body

})

The physics engine that the render (renderer) will render is the engine you created earlier, and the rendered object is the body of the html web page.

5. Run the renderer, run the engine.

Engine.run (engine)

Render.run (render)

Common modules of Matter.js

The core engine of 1.Matter.Engine / / physics engine, which is equivalent to the eye in the array method.

/ / it can be used to create an engine and manipulate it

2.Matter.World / / the display platform of the physical world, which provides the running platform for the engine, just as the aircraft engine is installed on the airframe to realize the maximum value.

/ / used to create the physical world and operate the world

3.Matter.Body / / create and manipulate objects, more often used to manipulate objects. There are many ways to manipulate rigid bodies in Bodyd objects.

4.Matter.Bodies / / objects used to create rigid bodies, circles / polygons / rectangles / trapezoids / composite shapes

That's all for "what matter js is". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report