Closed kfarr closed 1 year ago
and
based on the first link in toolbar re a-frame inspector raycaster restarting while editor pauses, it may be necessary to restart (play) each entity in the scene that needs to play during the editor while the rest are paused
scene.pause()
will call pause()
on all entities recursively so calling pause()
on all components, same for play()
. Main purpose of this is unregistering listeners and registering them back if you unpause. Some listeners may conflicts with the editor.
events defined in a component events object are also paused/unpaused, play()
and pause()
component methods are wrapped functions, see https://github.com/aframevr/aframe/blob/76904ca8737d4eb71736421dfb022e718e660072/src/core/component.js#L793
In the editor, there is indeed one exception of component that is unpaused, that's the cursor. Here when you open the inspector; https://github.com/aframevr/aframe-inspector/blob/3281f978eb6186b98f008416d1f43b8522f0021f/src/index.js#L256-L263 and here when you close it: https://github.com/aframevr/aframe-inspector/blob/3281f978eb6186b98f008416d1f43b8522f0021f/src/index.js#L290-L294 and from the toolbar where you can pause or unpause: https://github.com/aframevr/aframe-inspector/blob/3281f978eb6186b98f008416d1f43b8522f0021f/src/components/scenegraph/Toolbar.js#L87-L98
There is several solutions here if you don't want to unregister a listener when the scene pause:
init()
and unregister it in remove()
scene.pause()
If there is still a component you can't modify with the above tips, we could generalize the unpause trick to other entities having a data-editor-no-pause
attribute like you suggest, that would unpause all components that are on the entity.
thanks @vincentfretin the specific issue here is a screenshot component that uses tock
method which appears to no longer be called when an entity is paused. (The component is aptly named screentock) Does a system have the concept tock? Looks like yes:
https://github.com/aframevr/aframe/blob/v1.4.2/src/core/system.js#L108
although it's not documented as such:
https://aframe.io/docs/1.4.0/core/systems.html#methods
So one solution could be migrating the screentock component to being a system?
Yes tock
is executed on systems https://github.com/aframevr/aframe/blob/ac5d2f76caee008723009f5d3dd4a0062d8702a7/src/core/scene/a-scene.js#L722-L727
so converting your screentock
component to a system should work. It's really a one line change to test it, replacing registerComponent
by registerSystem
Thanks @vincentfretin unfortunately it wasn't that simple to just change to a system, so I used another method to manually play()
the entity that screentock component is assigned to and that worked as a short-term hack. PR: https://github.com/3DStreet/3dstreet-editor/pull/227/files
if a entity has
data-entity-no-pause: true
as a component (attribute) then do not pause this component when entering the editor (inspector)** Or is this at the component level? If a component has a magic schema property it will not pause? Or maybe it's a list of components that will never be paused?
components this should apply to: