google / model-viewer

Easily display interactive 3D models on the web and in AR!
https://modelviewer.dev
Apache License 2.0
6.68k stars 799 forks source link

addon boilerplate? #4784

Closed coderofsalvation closed 1 month ago

coderofsalvation commented 1 month ago

Description

First of all thanks for all the work on this wonderful project. Can somebody be so kind to provide some boilerplate for addons to get the scene, camera & renderer? I've looked at the effects-composer addon, but I wasn't able to understand the Symbol magic. In the console I tried retrieving the THREEjs scene on the modelviewer.dev page:

Live Demo

  const enableAddon = (modelviewer) => {
    modelviewer.addEventListener('before-render', function(e){
      let sceneSymbol = 'Symbol("scene")'
      let symbols = Object.getOwnPropertySymbols(this);
      let sceneValue = this[symbols.find(symbol => symbol === sceneSymbol)];
      console.log(sceneSymbol)
      console.dir(symbols)
      console.dir(sceneValue)
    })
  }

  let els = [ ...document.body.querySelectorAll('model-viewer') ]
  els.map( enableAddon )

But I can't seem to access those symbols...any idea? My main interest is: THREE's camera, scene and renderer

Version

model-viewer: v3.5.0

Browser Affected

OS