Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

5.19: Matter.js: Deleting Bodies - The Nature of Code

30.1K views
•
March 8, 2017
by
The Coding Train
YouTube video player
5.19: Matter.js: Deleting Bodies - The Nature of Code

TL;DR

This video focuses on improving the performance of a Matter.js project by removing circles that have left the screen and avoiding flickering issues.

Transcript

okay I'm back for more matter.js it matter.js to me to make never mind it it was going to work but it didn't okay so what I want to do this is what I left off in the last video and the thing that I want to add to this is a mouse constraint but you know what there's something that I really should add first which is that even though um there's all of... Read More

Key Insights

  • 🥺 Accumulation of off-screen circles can lead to performance issues in Matter.js projects.
  • 🚒 Removing circles from the array and the physics engine improves performance by reducing unnecessary calculations.
  • 💻 The "is off screen" function helps identify circles that have left the visible area of the screen.
  • 🔁 Reversing the loop prevents skipping circles when removing them from the array.
  • 🚒 Using Matter.js functions like "remove" ensures the proper removal of circles from the physics engine.
  • ✅ Regular checks and validation help ensure that performance improvements are successful.
  • 🎮 Keeping separate arrays for visual design and management provides greater control over entities in Matter.js projects.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How does removing off-screen circles improve the performance of the Matter.js project?

Removing off-screen circles helps improve performance by reducing the number of calculations the physics engine needs to perform, preventing unnecessary collisions and interactions with objects that are no longer visible.

Q: What is the purpose of using the "is off screen" function in the code?

The "is off screen" function helps identify whether a circle is outside the visible area of the screen. It evaluates the position of the circle's body and checks if its y-coordinate is greater than the height of the screen plus a buffer.

Q: Why does the loop need to be reversed when removing circles from the array?

Reversing the loop ensures that when a circle is removed from the array, the next circle to be checked is not skipped or missed. This avoids flickering issues and ensures that all circles are properly evaluated.

Q: How is the performance improvement validated after implementing the removal of off-screen circles?

The video demonstrates the use of console logging to compare the length of the circles array with the length of the bodies array in Matter.js. The numbers should match when circles are correctly removed from the physics engine.

Summary & Key Takeaways

  • The video addresses the issue of performance slowdown due to the accumulation of off-screen circles in a Matter.js project.

  • The code is modified to remove circles from the array and the physics engine when they are off-screen.

  • The video demonstrates techniques to handle the removal of off-screen circles, including reversing the loop and using Matter.js functions.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from The Coding Train 📚

Text Generation using Spell with Nabil Hassein thumbnail
Text Generation using Spell with Nabil Hassein
The Coding Train
ITP/IMA Winter Show 2018 thumbnail
ITP/IMA Winter Show 2018
The Coding Train
Coding Challenge #126: Toothpicks thumbnail
Coding Challenge #126: Toothpicks
The Coding Train
Classifying Poses with ml5.js Part 2 thumbnail
Classifying Poses with ml5.js Part 2
The Coding Train
Coding Challenge #116: Lissajous Curve Table thumbnail
Coding Challenge #116: Lissajous Curve Table
The Coding Train
Computer Mouse Conference Demos! (node.js + tensorflow.js) thumbnail
Computer Mouse Conference Demos! (node.js + tensorflow.js)
The Coding Train

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots

Company

  • About us
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.