Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Explain how to use the extension in the README file #67

Open
@RilDev

Description

@RilDev

Hi there,

I just got started with ThreeJS and the devtool is very nice to experiment with the lights and the scene's composition! Thank you!

I saw on the Chrome Store comments that some users have trouble using the extension though.

Wouldn't it be nice to add an example in the README file to explain to new users how to implement the observer code?

Maybe something like this:

Current API

This API has not been thought out at all, but this will register your
THREE.Scene and THREE.Renderer to be observed by the tools.

// Observe a scene or a renderer
if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: scene }));
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: renderer }));
}

Simply add it at the end of your animate loop, like this:

function animate() {
    requestAnimationFrame(animate);
    // ...
    // Observe a scene or a renderer
    if (typeof __THREE_DEVTOOLS__ !== "undefined") {
      __THREE_DEVTOOLS__.dispatchEvent(
        new CustomEvent("observe", { detail: scene })
      );
      __THREE_DEVTOOLS__.dispatchEvent(
        new CustomEvent("observe", { detail: renderer })
      );
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions