UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 819 B
import{Render as e}from"../../scene/render.js";import{ResourceHandler as r}from"./handler.js";function s(e){const r=this;if(!r.resource)return;const s=e.resource,t=s.renders&&s.renders[r.data.renderIndex];t&&(r.resource.meshes=t.resource.meshes)}function t(e){const r=this;r.registry.off(`load:${e.id}`,s,r),r.registry.on(`load:${e.id}`,s,r),r.registry.off(`remove:${e.id}`,o,r),r.registry.once(`remove:${e.id}`,o,r),e.resource?s.call(r,e):r.registry.load(e)}function o(e){const r=this;r.registry.off(`load:${e.id}`,s,r),r.resource&&r.resource.destroy()}class n extends r{constructor(e){super(e,"render"),this._registry=e.assets}open(r,s){return new e}patch(e,r){if(!e.data.containerAsset)return;const s=r.get(e.data.containerAsset);s?t.call(e,s):r.once(`add:${e.data.containerAsset}`,t,e)}}export{n as RenderHandler};