Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add debug component docs
  • Loading branch information
ngokevin committed Jul 18, 2016
commit 1e06cabb610a67e06c42f64bc3b1dbb24589e35e
30 changes: 30 additions & 0 deletions docs/components/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: debug
type: components
layout: docs
parent_section: components
---

The debug component enables component-to-DOM serialization.

## Example

```html
<a-scene debug></a-scene>
```

## Component-to-DOM Serialization

By default, for performance reasons, A-Frame does not update the DOM with component data. If we open the browser's DOM inspector, we will see that many entities will have only the component name visible:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmarcos explained to me when exactly the perf is impaired. JSON.parse + JSON.stringify being costly with animations is an example. that's probably a technical detail I'm just curious about, but now I'm not as surprised or confused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this here is good enough?


```html
<a-entity geometry material position rotation></a-entity>
```

The component data is stored internally. Updating the DOM takes CPU time for converting component data, which is stored internally, to strings. However, when we want to see the DOM update for debugging purposes, we can attach the `debug` component to the scene. Components will check whether the `debug` component is enabled before trying to serialize to the DOM. Then we will be able to view component data in the DOM:

```html
<a-entity geometry="primitive: box" material="color: red" position="1 2 3" rotation="0 180 0"></a-entity>
```

Make sure that this component is not active in production.