@soonspacejs/plugin-flow 2.13.10 → 2.13.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/flows/ComponentFlowParser.d.ts +8 -8
  2. package/dist/flows/FlowParser.d.ts +46 -46
  3. package/dist/flows/edges/index.d.ts +9 -9
  4. package/dist/flows/index.d.ts +4 -4
  5. package/dist/flows/nodes/ColorNode.d.ts +8 -8
  6. package/dist/flows/nodes/ConditionNode.d.ts +9 -9
  7. package/dist/flows/nodes/DataExtractionNode.d.ts +8 -8
  8. package/dist/flows/nodes/DataFilterNode.d.ts +8 -8
  9. package/dist/flows/nodes/DelayNode.d.ts +8 -8
  10. package/dist/flows/nodes/EmissiveNode.d.ts +10 -10
  11. package/dist/flows/nodes/FlyToNode.d.ts +8 -8
  12. package/dist/flows/nodes/HideNode.d.ts +10 -10
  13. package/dist/flows/nodes/HighlightNode.d.ts +10 -10
  14. package/dist/flows/nodes/MeshNode.d.ts +8 -8
  15. package/dist/flows/nodes/MeshesNode.d.ts +8 -8
  16. package/dist/flows/nodes/ModelNode.d.ts +8 -8
  17. package/dist/flows/nodes/ModelsNode.d.ts +8 -8
  18. package/dist/flows/nodes/Node.d.ts +49 -48
  19. package/dist/flows/nodes/NumberNode.d.ts +8 -8
  20. package/dist/flows/nodes/OpacityNode.d.ts +10 -10
  21. package/dist/flows/nodes/POINode.d.ts +8 -8
  22. package/dist/flows/nodes/POISNode.d.ts +8 -8
  23. package/dist/flows/nodes/PathNode.d.ts +8 -8
  24. package/dist/flows/nodes/PathsNode.d.ts +8 -8
  25. package/dist/flows/nodes/RotateNode.d.ts +8 -8
  26. package/dist/flows/nodes/ScaleNode.d.ts +8 -8
  27. package/dist/flows/nodes/ShowNode.d.ts +10 -10
  28. package/dist/flows/nodes/SpaceNode.d.ts +8 -8
  29. package/dist/flows/nodes/SpacesNode.d.ts +8 -8
  30. package/dist/flows/nodes/StartNode.d.ts +7 -7
  31. package/dist/flows/nodes/TranslateNode.d.ts +8 -8
  32. package/dist/flows/nodes/UnEmissiveNode.d.ts +10 -10
  33. package/dist/flows/nodes/UnHighlightNode.d.ts +10 -10
  34. package/dist/flows/nodes/UnOpacityNode.d.ts +10 -10
  35. package/dist/flows/nodes/UserDataNode.d.ts +8 -0
  36. package/dist/flows/nodes/clip-animation/ClipAnimationNode.d.ts +8 -8
  37. package/dist/flows/nodes/clip-animation/UnClipAnimationNode.d.ts +8 -8
  38. package/dist/flows/nodes/clip-animation/index.d.ts +2 -2
  39. package/dist/flows/nodes/component-tween-animation/ComponentTweenAnimationNode.d.ts +8 -8
  40. package/dist/flows/nodes/component-tween-animation/UnComponentTweenAnimationNode.d.ts +8 -8
  41. package/dist/flows/nodes/component-tween-animation/index.d.ts +2 -2
  42. package/dist/flows/nodes/component-tween-animation/utils.d.ts +5 -5
  43. package/dist/flows/nodes/index.d.ts +34 -33
  44. package/dist/flows/nodes/tween-animation/TweenAnimationNode.d.ts +8 -8
  45. package/dist/flows/nodes/tween-animation/UnTweenAnimationNode.d.ts +8 -8
  46. package/dist/flows/nodes/tween-animation/index.d.ts +2 -2
  47. package/dist/flows/nodes/tween-animation/utils.d.ts +5 -5
  48. package/dist/flows/types.d.ts +107 -106
  49. package/dist/flows/utils.d.ts +12 -12
  50. package/dist/index.d.ts +3 -3
  51. package/dist/index.esm.js +1 -1
  52. package/dist/triggers/ComponentTrigger.d.ts +23 -18
  53. package/dist/triggers/Trigger.d.ts +28 -27
  54. package/dist/triggers/index.d.ts +3 -3
  55. package/dist/triggers/types.d.ts +54 -54
  56. package/dist/triggers/utils.d.ts +2 -2
  57. package/dist/types.d.ts +16 -16
  58. package/package.json +3 -3
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{Vector3 as t,Euler as s,EventDispatcher as e,FileLoader as i,ImageLoader as n,TextureLoader as o}from"three";import a from"soonspacejs";import{AnimationPlayer as r}from"umanager-animation-parser";import{FlowParser as c,InteractionAction as l,InteractionType as h,InteractionObsType as d}from"@soonspacejs/plugin-flow";import{RGBELoader as u}from"three/examples/jsm/loaders/RGBELoader.js";import"three/examples/jsm/exporters/GLTFExporter.js";class p{constructor(t){this.id=t.id,this.source=t.source,this.target=t.target,this.sourceHandle=t.sourceHandle}}var f,C;!function(t){t.LOCAL="LOCAL",t.READ_CTX="READ_CTX",t.WRITE_CTX="WRITE_CTX"}(f||(f={})),function(t){t.START="START",t.COLOR="COLOR",t.NUMBER="NUMBER",t.HIGHLIGHT="HIGHLIGHT",t.UN_HIGHLIGHT="UN_HIGHLIGHT",t.OPACITY="OPACITY",t.UN_OPACITY="UN_OPACITY",t.EMISSIVE="EMISSIVE",t.UN_EMISSIVE="UN_EMISSIVE",t.MESH="MESH",t.MESHES="MESHES",t.MODEL="MODEL",t.MODELS="MODELS",t.SHOW="SHOW",t.HIDE="HIDE",t.CLIP_ANIMATION="CLIP_ANIMATION",t.UN_CLIP_ANIMATION="UN_CLIP_ANIMATION",t.TWEEN_ANIMATION="TWEEN_ANIMATION",t.UN_TWEEN_ANIMATION="UN_TWEEN_ANIMATION",t.COMPONENT_TWEEN_ANIMATION="COMPONENT_TWEEN_ANIMATION",t.UN_COMPONENT_TWEEN_ANIMATION="UN_COMPONENT_TWEEN_ANIMATION",t.SPACE="SPACE",t.SPACES="SPACES",t.PATH="PATH",t.PATHS="PATHS",t.POI="POI",t.POIS="POIS",t.FLY_TO="FLY_TO",t.TRANSLATE="TRANSLATE",t.ROTATE="ROTATE",t.SCALE="SCALE",t.DATA_FILTER="DATA_FILTER",t.DATA_EXTRACTION="DATA_EXTRACTION",t.CONDITION_NODE="CONDITION_NODE",t.DELAY="DELAY"}(C||(C={}));let T=0;class E{constructor(t,s){this.prevNodes=[],this.postNodes=[],this.execOrder=0,this.cleanSets=new Set,this.onBefore=null,this.onAfter=null,this.parser=t,this.ssp=t.ssp,this.id=s.id,this.type=s.type,this.props=s.props,this.rejected=!1,this.init()}init(){this.ctx={},this.promise=new Promise(((t,s)=>{this.resolve=t,this.reject=()=>{this.rejected=!0,s()}}))}readContext(t){return this.ctx[t]}writeContext(t,s){this.ctx[t]=s}findProp(t,s){if(!(s instanceof Array))return this.props.find((e=>e.name===t&&e.type===s));for(const e of s){const s=this.findProp(t,e);if(s)return s}}async waitForPrevNodes(){return await Promise.all(this.prevNodes.map((t=>t.promise)))}mergeContext(){this.prevNodes.forEach((t=>{Object.assign(this.ctx,t.ctx)}))}async exec(t){}async run(t){var s,e,i,n;try{if(await this.waitForPrevNodes(),this.rejected)throw new Error;this.mergeContext(),await(null===(e=null!==(s=this.onBefore)&&void 0!==s?s:this.parser.onNodeBefore)||void 0===e?void 0:e(this));try{this.execOrder=++T,await this.exec(t)}catch(t){throw this.reject(t),t}await(null===(n=null!==(i=this.onAfter)&&void 0!==i?i:this.parser.onNodeAfter)||void 0===n?void 0:n(this)),this.resolve()}catch(t){this.reject()}}cleanup(){this.cleanSets.forEach((t=>t())),this.cleanSets.clear()}getValue(t,s){if(t.type===f.READ_CTX)return this.readContext(Tt(t.value));if(t.type===f.LOCAL){const{viewport:{scene:e}}=this.ssp;return"objects"===t.name||"models"===t.name||"meshs"===t.name?Tt(t.value).map((t=>At(this.ssp,t,null!=s?s:e))):"object"===t.name||"model"===t.name||"mesh"===t.name?At(this.ssp,Tt(t.value),null!=s?s:e):Tt(t.value)}}}class A extends E{constructor(t,s){super(t,s)}}class g extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("color",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);t&&s&&this.writeContext(Tt(s.value),Tt(t.value))}}class O extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("number",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);t&&s&&this.writeContext(Tt(s.value),Tt(t.value))}}const{objectHandle:v}=a.utils;class L extends E{constructor(t,s){super(t,s)}filterHighlightObject(t){const s=[];return v(t,(t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)||s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("opacity",[f.READ_CTX,f.LOCAL]),o=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n){const t=this.getValue(e,o),s=this.getValue(i),a=this.getValue(n);if(t){const e=this.filterHighlightObject(t);this.ssp.highlightShow(e,{color:s,opacity:a}),this.cleanSets.add((()=>{this.ssp.unHighlightShow(e)}))}}}}const{objectHandle:w}=a.utils;class I extends E{constructor(t,s){super(t,s)}filterUnHighlightObject(t){const s=[];return w(t,(t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnHighlightObject(t);this.ssp.unHighlightShow(s),this.cleanSets.add((()=>{this.ssp.highlightShow(s)}))}}}}const{objectHandle:y}=a.utils;class N extends E{constructor(t,s){super(t,s)}filterOpacityObject(t){const s=[];return y(t,(t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)||s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("opacity",[f.READ_CTX,f.LOCAL]),o=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n){const t=this.getValue(e,o),s=this.getValue(i),a=this.getValue(n);if(t){const e=this.filterOpacityObject(t);this.ssp.opacityShow(e,{color:s,opacity:a}),this.cleanSets.add((()=>{this.ssp.unOpacityShow(e)}))}}}}const{objectHandle:P}=a.utils;class x extends E{constructor(t,s){super(t,s)}filterUnOpacityObject(t){const s=[];return P(t,(t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnOpacityObject(t);this.ssp.unOpacityShow(s),this.cleanSets.add((()=>{this.ssp.opacityShow(s)}))}}}}const{objectHandle:m}=a.utils;class _ extends E{constructor(t,s){super(t,s)}filterEmissiveObject(t){const s=[];return m(t,(t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)||s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("baseColor",[f.READ_CTX,f.LOCAL]),o=this.findProp("minOpacity",[f.READ_CTX,f.LOCAL]),a=this.findProp("maxOpacity",[f.READ_CTX,f.LOCAL]),r=this.findProp("duration",[f.READ_CTX,f.LOCAL]),c=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n&&o&&a&&r){const t=this.getValue(e,c),s=this.getValue(i),l=this.getValue(n),h=this.getValue(o),d=this.getValue(a),u=this.getValue(r);if(t){const e=this.filterEmissiveObject(t);this.ssp.emissiveShow(e,{color:s,baseColor:l,minOpacity:h,maxOpacity:d,duration:u}),this.cleanSets.add((()=>{this.ssp.unEmissiveShow(e)}))}}}}const{objectHandle:b}=a.utils;class S extends E{constructor(t,s){super(t,s)}filterUnEmissiveObject(t){const s=[];return b(t,(t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnEmissiveObject(t);this.ssp.unEmissiveShow(s),this.cleanSets.add((()=>{this.ssp.emissiveShow(s)}))}}}}const M=Symbol("meshCache");class R extends E{constructor(t,s){super(t,s)}async exec(t){var s;const{viewport:{scene:e}}=this.ssp,i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this))||e;t[M]||(t[M]={});const n=this.findProp("mesh",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){let s=null;const e=Tt(n.value),a=Tt(o.value),r=t[M][e];if(r)return void(s=r);const c=gt(i,e);c&&(s=c,t[M][e]=c),this.writeContext(a,s)}}}const D=Symbol("meshesCache");class H extends E{constructor(t,s){super(t,s)}async exec(t){var s;const{viewport:{scene:e}}=this.ssp,i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this))||e;t[D]||(t[D]={});const n=this.findProp("meshes",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){const s=[],e=Tt(n.value),a=Tt(o.value);e.forEach((e=>{const n=t[D][e];if(n)return void s.push(n);const o=gt(i,e);o&&(s.push(o),t[D][e]=o)})),this.writeContext(a,s)}}}class j extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,At(this.ssp,e))}}}class X extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("models",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const i=Tt(t.value),n=Tt(s.value);this.writeContext(n,(e=this.ssp,i.map((t=>e.getObjectById(t))).filter(Boolean)))}var e}}class B extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("delay",f.LOCAL);if(t){const s=Tt(t.value);await a.utils.sleep(s)}}}class k extends E{constructor(t,s){super(t,s)}execFn(t){return new Function("sourceData",t)(this.ctx)}async exec(){const t=this.findProp("conditaion_node",f.LOCAL);if(t){const s=Tt(t.value),e=this.parser.edges.filter((t=>t.source===this.id));s.forEach((t=>{try{if(!0!==this.execFn(t.value))throw new Error}catch(s){const i=e.find((s=>s.sourceHandle==String(t.id)));if(!i)return;const n=this.postNodes.find((t=>t.id===i.target));null==n||n.reject()}}))}}}const{objectHandle:V}=a.utils;class G extends E{constructor(t,s){super(t,s)}filterShowObject(t){const s=[];return V(t,(t=>{!1===t.visible&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterShowObject(t),e=t=>{V(s,(s=>{s.visible=t})),this.ssp.render()};e(!0),this.cleanSets.add((()=>e(!1)))}}}}const{objectHandle:U}=a.utils;class W extends E{constructor(t,s){super(t,s)}filterHideObject(t){const s=[];return U(t,(t=>{!0===t.visible&&s.push(t)})),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterHideObject(t),e=t=>{U(s,(s=>{s.visible=t})),this.ssp.render()};e(!1),this.cleanSets.add((()=>e(!0)))}}}}const{objectHandle:F}=a.utils;class z extends E{constructor(t,s){super(t,s)}async exec(s){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("translate",[f.READ_CTX,f.LOCAL]),a=await(null===(e=s.getTarget)||void 0===e?void 0:e.call(s,this));if(i&&n&&o){const s=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(s){const i=[],n=800;F(s,(t=>{i.push(t.position.clone())}));const o=(t,s)=>{switch(e){case"x":t.setX(s.x);break;case"y":t.setY(s.y);break;case"z":t.setZ(s.z)}},a=async()=>{const i=F(s,(async s=>{const i=s.position.clone();switch(e){case"x":await this.ssp.animation(i,(new t).set(i.x+r,i.y,i.z),{duration:n},(t=>o(s.position,t)));break;case"y":await this.ssp.animation(i,(new t).set(i.x,i.y+r,i.z),{duration:n},(t=>o(s.position,t)));break;case"z":await this.ssp.animation(i,(new t).set(i.x,i.y,i.z+r),{duration:n},(t=>o(s.position,t)))}}));i instanceof Array?await Promise.all(i):await i,this.ssp.render()};await a(),this.cleanSets.add((()=>{let t=0;F(s,(s=>{s.position.copy(i[t++])}))}))}}}}const{objectHandle:Y}=a.utils;class K extends E{constructor(t,s){super(t,s)}async exec(s){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("scale",[f.READ_CTX,f.LOCAL]),a=await(null===(e=s.getTarget)||void 0===e?void 0:e.call(s,this));if(i&&n&&o){const s=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(s){const i=[],n=800;Y(s,(t=>{i.push(t.scale.clone())}));const o=(t,s)=>{switch(e){case"x":t.setX(s.x);break;case"y":t.setY(s.y);break;case"z":t.setZ(s.z)}},a=async()=>{const i=Y(s,(async s=>{const i=s.scale.clone();switch(e){case"x":await this.ssp.animation(i,(new t).set(i.x*r,i.y,i.z),{duration:n},(t=>o(s.scale,t)));break;case"y":await this.ssp.animation(i,(new t).set(i.x,i.y*r,i.z),{duration:n},(t=>o(s.scale,t)));break;case"z":await this.ssp.animation(i,(new t).set(i.x,i.y,i.z*r),{duration:n},(t=>o(s.scale,t)))}}));i instanceof Array?await Promise.all(i):await i,this.ssp.render()};await a(),this.cleanSets.add((()=>{let t=0;Y(s,(s=>{s.scale.copy(i[t++])}))}))}}}}const{objectHandle:q}=a.utils;class J extends E{constructor(t,s){super(t,s)}async exec(t){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("rotation",[f.READ_CTX,f.LOCAL]),a=await(null===(e=t.getTarget)||void 0===e?void 0:e.call(t,this));if(i&&n&&o){const t=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(t){const i=[],n=800;q(t,(t=>{i.push(t.rotation.clone())}));const o=(t,s)=>{switch(e){case"x":t.x=s.x;break;case"y":t.y=s.y;break;case"z":t.z=s.z}},a=async()=>{const i=r/180*Math.PI,a=q(t,(async t=>{const a=t.rotation.clone();switch(e){case"x":await this.ssp.animation(a,(new s).set(a.x+i,a.y,a.z),{duration:n},(s=>o(t.rotation,s)));break;case"y":await this.ssp.animation(a,(new s).set(a.x,a.y+i,a.z),{duration:n},(s=>o(t.rotation,s)));break;case"z":await this.ssp.animation(a,(new s).set(a.x,a.y,a.z+i),{duration:n},(s=>o(t.rotation,s)))}}));a instanceof Array?await Promise.all(a):await a,this.ssp.render()};await a(),this.cleanSets.add((()=>{let s=0;q(t,(t=>{t.rotation.copy(i[s++])}))}))}}}}class Z extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("viewpoint",[f.READ_CTX,f.LOCAL]);if(t){const s=Tt(this.getValue(t));s&&this.ssp.setCameraViewpoint(s,!0)}}}class Q extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("space",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,At(this.ssp,e))}}}class $ extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("spaces",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value),n=e.map((t=>At(this.ssp,t)));this.writeContext(i,n)}}}class tt extends E{constructor(t,s){super(t,s)}async exec(t){const s=this.findProp("poi",f.LOCAL),e=this.findProp("out",f.WRITE_CTX);if(s&&e){const t=Tt(s.value),i=Tt(e.value);this.writeContext(i,At(this.ssp,t))}}}class st extends E{constructor(t,s){super(t,s)}async exec(t){const s=this.findProp("pois",f.LOCAL),e=this.findProp("out",f.WRITE_CTX);if(s&&e){const t=Tt(s.value),i=Tt(e.value),n=t.map((t=>At(this.ssp,t)));this.writeContext(i,n)}}}class et extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("value",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,e)}}}class it extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL);if(t){const s=Tt(t.value),e=new Function("sourceData",s);for(const t in this.ctx){const s=e(this.ctx[t]);null!=s&&!1!==s||delete this.ctx[t]}}}}class nt extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("path",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value);this.writeContext(i,At(this.ssp,e))}}}class ot extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("paths",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=Tt(t.value),i=Tt(s.value),n=e.map((t=>At(this.ssp,t)));this.writeContext(i,n)}}}class at extends E{constructor(t,s){super(t,s)}async exec(t){var s;let e=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(!e){const t=this.findProp("model",[f.READ_CTX,f.LOCAL]);t&&(e=this.getValue(t))}const i=this.findProp("animation",[f.READ_CTX,f.LOCAL]);if(e&&i){let t;if(i.type===f.READ_CTX){const s=this.parser.getVariableNameById(Tt(i.value));t=this.readContext(s)}else t=Tt(i.value);const s=e.animations[t];s&&(this.ssp.playModelAnimation(e,s),this.cleanSets.add((()=>{this.ssp.stopModelAnimation(e,s)})))}}}class rt extends E{constructor(t,s){super(t,s)}async exec(t){var s;let e=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(!e){const t=this.findProp("model",[f.READ_CTX,f.LOCAL]);t&&(e=this.getValue(t))}const i=this.findProp("animation",[f.READ_CTX,f.LOCAL]);if(e&&i){let t;if(i.type===f.READ_CTX){const s=this.parser.getVariableNameById(Tt(i.value));t=this.readContext(s)}else t=Tt(i.value);const s=e.animations[t];s&&this.ssp.stopModelAnimation(e,s)}}}const ct=new Map;function lt(t){var s,e;null===(s=ct.get(t))||void 0===s||s.forEach((t=>t.stop())),null===(e=ct.get(t))||void 0===e||e.clear()}class ht extends E{constructor(t,s){super(t,s)}async exec(t){var s;const e=this.findProp("model",[f.READ_CTX,f.LOCAL]),i=this.findProp("animation",f.LOCAL),n=this.findProp("wait",f.LOCAL);if(e&&i&&n){const o=this.getValue(e),a=Tt(i.value),c=Tt(n.value);if(o){const e=await(null===(s=t.getAnimations)||void 0===s?void 0:s.call(t,this,o,a));if(e){const t=e.find((t=>t.id===a));t&&await Et((async()=>{const s=o.matrix.clone();await async function(t,s,e){var i;const{id:n,keyframes:o}=e,a=new r(t,s);ct.has(n)||ct.set(n,new Set),null===(i=ct.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,o,t),this.cleanSets.add((()=>{lt(t.id),o&&s.decompose(o.position,o.quaternion,o.scale)}))}),c)}}}}}class dt extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){lt(Tt(t.value))}}}const ut=new Map;function pt(t){var s,e;null===(s=ut.get(t))||void 0===s||s.forEach((t=>t.stop())),null===(e=ut.get(t))||void 0===e||e.clear()}class ft extends E{constructor(t,s){super(t,s)}async exec(t){var s;const e=this.findProp("mesh",[f.READ_CTX,f.LOCAL]),i=this.findProp("animation",f.LOCAL),n=this.findProp("wait",f.LOCAL);if(e&&i&&n){const o=this.getValue(e),a=Tt(i.value),c=Tt(n.value);if(o){const i=await(null===(s=t.getComponentAnimations)||void 0===s?void 0:s.call(t,this,o,a));if(i){const t=i.find((t=>t.id===a));if(t){let s=null;"Mesh"===e.valueType?s=o:"Model"===e.valueType&&(s=gt(o,t.refId)),s&&await Et((async()=>{if(s){const e=s.matrix.clone();await async function(t,s,e){var i;const{id:n,keyframes:o}=e,a=new r(t,s);ut.has(n)||ut.set(n,new Set),null===(i=ut.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,s,t),this.cleanSets.add((()=>{pt(t.id),s&&e.decompose(s.position,s.quaternion,s.scale)}))}}),c)}}}}}}class Ct extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){pt(Tt(t.value))}}}function Tt(t){return JSON.parse(t)}async function Et(t,s){s?await t():t()}function At(t,s,e){const i=t.getObjectById(s);if(i)return i;{const{viewport:{scene:i}}=t;return gt(null!=e?e:i,s)}}function gt(t,s){if(t.userData.key===s||t.uuid===s)return t;for(let e=0,i=t.children.length;e<i;e++){const i=gt(t.children[e],s);if(null!==i)return i}return null}const{utils:{sleep:Ot}}=a;class vt extends e{constructor(t,s){super(),this.onNodeBefore=null,this.onNodeAfter=null,this.ssp=t,this.flow=s,this.nodes=[],this.nodesMap=new Map,this.edges=[],this.edgesMap=new Map}addNode(t){this.nodes.push(t),this.nodesMap.set(t.id,t)}addEdge(t){this.edges.push(t),this.edgesMap.set(t.id,t)}getNodeById(t){return this.nodesMap.get(t)}getEdgeById(t){return this.edgesMap.get(t)}clear(){this.nodes.length=0,this.nodesMap.clear(),this.edges.length=0,this.edgesMap.clear()}parse(){this.clear();const{nodes:t,edges:s}=this.flow;t.forEach((t=>{const s=function(t,s){switch(s.type){case C.START:return new A(t,s);case C.COLOR:return new g(t,s);case C.NUMBER:return new O(t,s);case C.HIGHLIGHT:return new L(t,s);case C.UN_HIGHLIGHT:return new I(t,s);case C.OPACITY:return new N(t,s);case C.UN_OPACITY:return new x(t,s);case C.EMISSIVE:return new _(t,s);case C.UN_EMISSIVE:return new S(t,s);case C.MESH:return new R(t,s);case C.MESHES:return new H(t,s);case C.MODEL:return new j(t,s);case C.MODELS:return new X(t,s);case C.SPACE:return new Q(t,s);case C.SPACES:return new $(t,s);case C.POIS:return new st(t,s);case C.POI:return new tt(t,s);case C.PATH:return new nt(t,s);case C.PATHS:return new ot(t,s);case C.DELAY:return new B(t,s);case C.CONDITION_NODE:return new k(t,s);case C.SHOW:return new G(t,s);case C.HIDE:return new W(t,s);case C.CLIP_ANIMATION:return new at(t,s);case C.UN_CLIP_ANIMATION:return new rt(t,s);case C.TWEEN_ANIMATION:return new ht(t,s);case C.UN_TWEEN_ANIMATION:return new dt(t,s);case C.COMPONENT_TWEEN_ANIMATION:return new ft(t,s);case C.UN_COMPONENT_TWEEN_ANIMATION:return new Ct(t,s);case C.TRANSLATE:return new z(t,s);case C.ROTATE:return new J(t,s);case C.SCALE:return new K(t,s);case C.FLY_TO:return new Z(t,s);case C.DATA_EXTRACTION:return new et(t,s);case C.DATA_FILTER:return new it(t,s);default:return new E(t,s)}}(this,t);this.addNode(s)})),s.forEach((t=>{const s=new p(t);this.addEdge(s);const e=this.getNodeById(t.source),i=this.getNodeById(t.target);e&&i&&(e.postNodes.push(i),i.prevNodes.push(e))}))}async run(t={}){const s=this.nodes.filter((t=>t.prevNodes.length||t.postNodes.length)).map((s=>s.run(t)));await Promise.allSettled(s)}async debug(t={},s=1500){const e=this.onNodeAfter;this.onNodeAfter=async t=>{await Ot(s),null==e||e(t)},await this.run(t)}stop(){this.nodes.forEach((t=>t.reject(new Error("Flow stopped"))))}cleanup(){this.nodes.sort(((t,s)=>s.execOrder-t.execOrder)).forEach((t=>t.cleanup()))}getVariableNameById(t){const s=this.nodes.find((s=>s.id===t));if(s){const t=s.props.find((t=>"out"===t.name));return t?Tt(t.value):null}return null}dispose(){this.stop(),this.cleanup()}}class Lt extends vt{constructor(t,s){super(t,s),this.flow=s}}function wt(t,s,e,i){if("a"===e&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof s?t!==s||!i:!s.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?i:"a"===e?i.call(t):i?i.value:s.get(t)}var It,yt;"function"==typeof SuppressedError&&SuppressedError,function(t){t.Group="Group",t.Light="Light",t.Model="Model",t.Poi="Poi",t.PoiNode="PoiNode",t.Canvas3D="Canvas3D",t.Topology="Topology",t.Helper="Helper",t.Decal="Decal",t.PluginObject="PluginObject"}(It||(It={})),function(t){t.sbm="SBM",t.sbmx="SBMX",t.glb="GLB",t.gltf="GLTF",t.fbx="FBX",t.obj="OBJ",t.stl="STL"}(yt||(yt={})),new t,new t,new t;const Nt={},Pt=new i;Pt.setRequestHeader(Nt);(new n).load=(t,s,e,i)=>{const n=new Image;return Pt.setResponseType("blob"),Pt.load(t,(function(t){n.src=URL.createObjectURL(t),n.onload=()=>{URL.revokeObjectURL(n.src),null==s||s(n)}}),e,i),n};(new o).setRequestHeader(Nt);async function xt(t){return async function(t,s){return await s()}(0,t)}(new u).setRequestHeader(Nt),new t,new t,new t;const mt=(t,s)=>t.userData.key===s||!!t.parent&&mt(t.parent,s);var _t,bt,St;const{groupBy:Mt}=a.utils;class Rt{constructor(t,s,e,i){_t.add(this),this.disposables=[],this.status="ready",this.ssp=t,this.interaction=s,this.flows=e,this.flowsMap=Mt(e,"id"),this.options=i||{},wt(this,_t,"m",bt).call(this)}modelHandler(t){var s;const{target:e,currentTarget:i}=t,n=this.interaction.editionId;n?e.sid!==n&&e.userData.familyId!==n||!mt(i,this.interaction.modelId)||(this.target=e,this.execBehavior()):null===(s=this.interaction.obsTargets)||void 0===s||s.forEach((t=>{t!==e.userData.id&&t!==e.userData.sid||(this.target=e,this.execBehavior())}))}runFlowByIds(t){const s=this.target?async()=>this.target:wt(this,_t,"m",St).bind(this);t.forEach((t=>{const e=this.flowsMap.get(t);if(e){const t=new c(this.ssp,e[0]);t.parse(),xt((()=>t.run({getTarget:s,getAnimations:this.options.getAnimations,getComponentAnimations:this.options.getComponentAnimations})))}}))}async execBehavior(){var t,s,e,i,n;if(null===(t=this.interaction.active)||void 0===t||t)try{this.status="running";const{behaviors:t}=this.interaction;null==t||t.forEach((t=>{if(t.action===l.FLOW)t.actionRefs&&this.runFlowByIds(t.actionRefs)})),(null===(s=this.options)||void 0===s?void 0:s.onTrigger)&&(null===(e=this.options)||void 0===e||e.onTrigger(this.interaction))}catch(t){this.status="error",(null===(i=this.options)||void 0===i?void 0:i.onError)&&(null===(n=this.options)||void 0===n||n.onError(t))}}initMouseClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelClick.add(t),this.disposables.push((()=>this.ssp.signals.modelClick.remove(t)))}initMouseDbClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelDblClick.add(t),this.disposables.push((()=>this.ssp.signals.modelDblClick.remove(t)))}initMouseRightClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelRightClick.add(t),this.disposables.push((()=>this.ssp.signals.modelRightClick.remove(t)))}initLoaded(){(()=>{this.execBehavior()})()}modelPropChangeHandler(t){var s,e;(null===(s=null==t?void 0:t.target)||void 0===s?void 0:s.refId)&&"code"!==this.ssp.utils.propertiesCtx.source&&(null===(e=t.target)||void 0===e||e.refId,this.interaction.editionId&&(this.target=this.ssp.getObjectByUserDataProperty("familyId",this.interaction.editionId)[0]),this.execBehavior())}initModelPropChange(){const t=this.modelPropChangeHandler.bind(this);this.ssp.signals.propertiesChanged.add(t),this.disposables.push((()=>this.ssp.signals.propertiesChanged.remove(t)))}initThingPropChange(){}initThingEvent(){}dispose(){this.disposables.forEach((t=>t()))}}var Dt,Ht,jt,Xt,Bt,kt,Vt,Gt;_t=new WeakSet,bt=function(){switch(this.interaction.type){case h.MOUSE_CLICK:this.initMouseClick();break;case h.MOUSE_DB_CLICK:this.initMouseDbClick();break;case h.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case h.LOADED:this.initLoaded();break;case h.THING_PROP_CHANGE:this.initThingPropChange();break;case h.THING_EVENT:this.initThingEvent();break;case h.MODEL_PROP_CHANGE:this.initModelPropChange()}},St=async function(t){const{obsType:s,obsTargets:e,editionId:i}=this.interaction;if(s===d.GLOBAL)return null;if(s===d.INSTANCE){let t;i?(t=this.ssp.getModelById(i),t||console.warn("Target not found:",i)):t=null==e?void 0:e.map((t=>{const s=this.ssp.getModelById(t);return s||console.warn("Target not found:",e[0]),s}))[0]}return null},function(t){t.GLOBAL="GLOBAL",t.SELF="SELF",t.OTHER="OTHER"}(Dt||(Dt={})),function(t){t.FLOW="FLOW",t.ANIMATION="ANIMATION",t.DELAY="DELAY"}(Ht||(Ht={})),function(t){t.GLOBAL="GLOBAL",t.INSTANCE="INSTANCE",t.FAMILY="FAMILY"}(jt||(jt={})),function(t){t.MOUSE_CLICK="MOUSE_CLICK",t.MOUSE_DB_CLICK="MOUSE_DB_CLICK",t.MOUSE_RIGHT_CLICK="MOUSE_RIGHT_CLICK",t.THING_PROP_CHANGE="THING_PROP_CHANGE",t.THING_EVENT="THING_EVENT",t.LOADED="LOADED",t.MODEL_PROP_CHANGE="MODEL_PROP_CHANGE"}(Xt||(Xt={}));const{groupBy:Ut}=a.utils;class Wt extends Rt{constructor(t,s,e,i){super(t,s,e,i),Bt.add(this),this.flows=e,this.flowsMap=Ut(e,"id"),wt(this,Bt,"m",kt).call(this)}modelHandler(t){var s;const{currentTarget:e}=t;null===(s=this.interaction.obsTargets)||void 0===s||s.forEach((t=>{t===e.userData.key&&this.execBehavior()}))}runFlowByIds(t){const s=wt(this,Bt,"m",Vt).bind(this);t.forEach((t=>{const e=this.flowsMap.get(t);if(e){const t=new Lt(this.ssp,e[0]);t.parse(),xt((()=>t.run({getTarget:s})))}}))}async execBehavior(){var t,s,e,i;try{const{behaviors:e}=this.interaction;null==e||e.forEach((t=>{if(t.action===Ht.FLOW)t.actionRefs&&this.runFlowByIds(t.actionRefs)})),(null===(t=this.options)||void 0===t?void 0:t.onTrigger)&&(null===(s=this.options)||void 0===s||s.onTrigger(this.interaction))}catch(t){(null===(e=this.options)||void 0===e?void 0:e.onError)&&(null===(i=this.options)||void 0===i||i.onError(t))}}initLoaded(){const t=()=>{this.execBehavior()};wt(this,Bt,"m",Vt).call(this).then((s=>{s&&(s.addEventListener("load",t),this.disposables.push((()=>s.removeEventListener("load",t))))}))}initThingPropChange(){const t=wt(this,Bt,"m",Gt).bind(this);this.ssp.signals.thingModelPropsChange.add(t),this.disposables.push((()=>this.ssp.signals.thingModelPropsChange.remove(t)))}initThingEvent(){}onThingPropChange(t){this.ssp.signals.thingModelPropsChange.dispatch({propKey:t})}}Bt=new WeakSet,kt=function(){switch(this.interaction.type){case Xt.MOUSE_CLICK:this.initMouseClick();break;case Xt.MOUSE_DB_CLICK:this.initMouseDbClick();break;case Xt.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case Xt.LOADED:this.initLoaded();break;case Xt.THING_PROP_CHANGE:this.initThingPropChange();break;case Xt.THING_EVENT:this.initThingEvent();break;case Xt.MODEL_PROP_CHANGE:this.initModelPropChange()}},Vt=async function(t){console.log("currentNode",t);const{obsType:s,obsTargets:e}=this.interaction;if(s===jt.GLOBAL)return null;if(s===jt.INSTANCE){const t=null==e?void 0:e.map((t=>{const s=this.ssp.getModelById(t);return s||console.warn("Target not found:",t),s}));return t?t[0]:null}return null},Gt=function(t){var s;const{propKey:e}=t;null===(s=this.interaction.obsProps)||void 0===s||s.forEach((t=>{t===e&&this.execBehavior()}))};export{Lt as ComponentFlowParser,Wt as ComponentTrigger,vt as FlowParser,Ht as InteractionAction,Dt as InteractionActionType,jt as InteractionObsType,Xt as InteractionType,E as Node,f as NodePropTypeEnum,C as NodeTypeEnum,Rt as Trigger};
1
+ import{Vector3 as t,Euler as s,EventDispatcher as e,FileLoader as i,ImageLoader as n,TextureLoader as o}from"three";import a from"soonspacejs";import{AnimationPlayer as r}from"umanager-animation-parser";import{InteractionType as c,InteractionObsType as l,FlowParser as h,InteractionAction as d}from"@soonspacejs/plugin-flow";import{RGBELoader as u}from"three/examples/jsm/loaders/RGBELoader.js";import"three/examples/jsm/exporters/GLTFExporter.js";class p{constructor(t){this.id=t.id,this.source=t.source,this.target=t.target,this.sourceHandle=t.sourceHandle}}var f,C;!function(t){t.LOCAL="LOCAL",t.READ_CTX="READ_CTX",t.WRITE_CTX="WRITE_CTX"}(f||(f={})),function(t){t.START="START",t.COLOR="COLOR",t.NUMBER="NUMBER",t.HIGHLIGHT="HIGHLIGHT",t.UN_HIGHLIGHT="UN_HIGHLIGHT",t.OPACITY="OPACITY",t.UN_OPACITY="UN_OPACITY",t.EMISSIVE="EMISSIVE",t.UN_EMISSIVE="UN_EMISSIVE",t.MESH="MESH",t.MESHES="MESHES",t.MODEL="MODEL",t.MODELS="MODELS",t.SHOW="SHOW",t.HIDE="HIDE",t.CLIP_ANIMATION="CLIP_ANIMATION",t.UN_CLIP_ANIMATION="UN_CLIP_ANIMATION",t.TWEEN_ANIMATION="TWEEN_ANIMATION",t.UN_TWEEN_ANIMATION="UN_TWEEN_ANIMATION",t.COMPONENT_TWEEN_ANIMATION="COMPONENT_TWEEN_ANIMATION",t.UN_COMPONENT_TWEEN_ANIMATION="UN_COMPONENT_TWEEN_ANIMATION",t.SPACE="SPACE",t.SPACES="SPACES",t.PATH="PATH",t.PATHS="PATHS",t.POI="POI",t.POIS="POIS",t.FLY_TO="FLY_TO",t.TRANSLATE="TRANSLATE",t.ROTATE="ROTATE",t.SCALE="SCALE",t.DATA_FILTER="DATA_FILTER",t.DATA_EXTRACTION="DATA_EXTRACTION",t.CONDITION_NODE="CONDITION_NODE",t.DELAY="DELAY",t.USER_DATA_NODE="USER_DATA_NODE"}(C||(C={}));let T=0;class g{constructor(t,s){this.prevNodes=[],this.postNodes=[],this.execOrder=0,this.cleanSets=new Set,this.onBefore=null,this.onAfter=null,this.parser=t,this.ssp=t.ssp,this.id=s.id,this.type=s.type,this.props=s.props,this.rejected=!1,this.init()}init(){this.ctx={},this.promise=new Promise((t,s)=>{this.resolve=t,this.reject=()=>{this.rejected=!0,s()}})}readContext(t){return this.ctx[t]}writeContext(t,s){this.ctx[t]=s}findProp(t,s){if(!(s instanceof Array))return this.props.find(e=>e.name===t&&e.type===s);for(const e of s){const s=this.findProp(t,e);if(s)return s}}async waitForPrevNodes(){return await Promise.all(this.prevNodes.map(t=>t.promise))}mergeContext(){this.prevNodes.forEach(t=>{Object.assign(this.ctx,t.ctx)}),this._mergeUserDataMap()}async exec(t){}async run(t){var s,e,i,n;try{if(await this.waitForPrevNodes(),this.rejected)throw new Error;this.mergeContext(),await(null===(e=null!==(s=this.onBefore)&&void 0!==s?s:this.parser.onNodeBefore)||void 0===e?void 0:e(this));try{this.execOrder=++T,await this.exec(t)}catch(t){throw this.reject(t),t}await(null===(n=null!==(i=this.onAfter)&&void 0!==i?i:this.parser.onNodeAfter)||void 0===n?void 0:n(this)),this.resolve()}catch(t){this.reject(t)}}cleanup(){this.cleanSets.forEach(t=>t()),this.cleanSets.clear()}getValue(t,s){if(t.type===f.READ_CTX)return this.readContext(gt(t.value));if(t.type===f.LOCAL){const{viewport:{scene:e}}=this.ssp;return"objects"===t.name||"models"===t.name||"meshs"===t.name?gt(t.value).map(t=>Et(this.ssp,t,null!=s?s:e)):"object"===t.name||"model"===t.name||"mesh"===t.name?Et(this.ssp,gt(t.value),null!=s?s:e):gt(t.value)}}_mergeUserDataMap(){this.prevNodes.some(t=>t.ctx._userDataMap)&&(this.ctx._userDataMap=new Map,this.prevNodes.forEach(t=>{t.ctx._userDataMap&&t.ctx._userDataMap.forEach((t,s)=>{this.ctx._userDataMap.set(s,Object.assign({},t))})}))}}class A extends g{constructor(t,s){super(t,s)}}class E extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("color",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);t&&s&&this.writeContext(gt(s.value),gt(t.value))}}class O extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("number",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);t&&s&&this.writeContext(gt(s.value),gt(t.value))}}const{objectHandle:v}=a.utils;class L extends g{constructor(t,s){super(t,s)}filterHighlightObject(t){const s=[];return v(t,t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)||s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("opacity",[f.READ_CTX,f.LOCAL]),o=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n){const t=this.getValue(e,o),s=this.getValue(i),a=this.getValue(n);if(t){const e=this.filterHighlightObject(t);this.ssp.highlightShow(e,{color:s,opacity:a}),this.cleanSets.add(()=>{this.ssp.unHighlightShow(e)})}}}}const{objectHandle:w}=a.utils;class I extends g{constructor(t,s){super(t,s)}filterUnHighlightObject(t){const s=[];return w(t,t=>{this.ssp.viewport.scener.selectedObjects.highlight.has(t)&&s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnHighlightObject(t);this.ssp.unHighlightShow(s),this.cleanSets.add(()=>{this.ssp.highlightShow(s)})}}}}const{objectHandle:y}=a.utils;class _ extends g{constructor(t,s){super(t,s)}filterOpacityObject(t){const s=[];return y(t,t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)||s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("opacity",[f.READ_CTX,f.LOCAL]),o=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n){const t=this.getValue(e,o),s=this.getValue(i),a=this.getValue(n);if(t){const e=this.filterOpacityObject(t);this.ssp.opacityShow(e,{color:s,opacity:a}),this.cleanSets.add(()=>{this.ssp.unOpacityShow(e)})}}}}const{objectHandle:x}=a.utils;class N extends g{constructor(t,s){super(t,s)}filterUnOpacityObject(t){const s=[];return x(t,t=>{this.ssp.viewport.scener.selectedObjects.opacity.has(t)&&s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnOpacityObject(t);this.ssp.unOpacityShow(s),this.cleanSets.add(()=>{this.ssp.opacityShow(s)})}}}}const{objectHandle:P}=a.utils;class m extends g{constructor(t,s){super(t,s)}filterEmissiveObject(t){const s=[];return P(t,t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)||s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=this.findProp("color",[f.READ_CTX,f.LOCAL]),n=this.findProp("baseColor",[f.READ_CTX,f.LOCAL]),o=this.findProp("minOpacity",[f.READ_CTX,f.LOCAL]),a=this.findProp("maxOpacity",[f.READ_CTX,f.LOCAL]),r=this.findProp("duration",[f.READ_CTX,f.LOCAL]),c=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e&&i&&n&&o&&a&&r){const t=this.getValue(e,c),s=this.getValue(i),l=this.getValue(n),h=this.getValue(o),d=this.getValue(a),u=this.getValue(r);if(t){const e=this.filterEmissiveObject(t);this.ssp.emissiveShow(e,{color:s,baseColor:l,minOpacity:h,maxOpacity:d,duration:u}),this.cleanSets.add(()=>{this.ssp.unEmissiveShow(e)})}}}}const{objectHandle:b}=a.utils;class M extends g{constructor(t,s){super(t,s)}filterUnEmissiveObject(t){const s=[];return b(t,t=>{this.ssp.viewport.scener.selectedObjects.emissive.has(t)&&s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterUnEmissiveObject(t);this.ssp.unEmissiveShow(s),this.cleanSets.add(()=>{this.ssp.emissiveShow(s)})}}}}const D=Symbol("meshCache");class S extends g{constructor(t,s){super(t,s)}async exec(t){var s;const{viewport:{scene:e}}=this.ssp,i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this))||e;t[D]||(t[D]={});const n=this.findProp("mesh",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){let s=null;const e=gt(n.value),a=gt(o.value),r=t[D][e];if(r)return void(s=r);const c=Ot(i,e);c&&(s=c,t[D][e]=c),this.writeContext(a,s)}}}const R=Symbol("meshesCache");class H extends g{constructor(t,s){super(t,s)}async exec(t){var s;const{viewport:{scene:e}}=this.ssp,i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this))||e;t[R]||(t[R]={});const n=this.findProp("meshes",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){const s=[],e=gt(n.value),a=gt(o.value);e.forEach(e=>{const n=t[R][e];if(n)return void s.push(n);const o=Ot(i,e);o&&(s.push(o),t[R][e]=o)}),this.writeContext(a,s)}}}class j extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=gt(t.value),i=gt(s.value);this.writeContext(i,Et(this.ssp,e))}}}class X extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("models",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const i=gt(t.value),n=gt(s.value);this.writeContext(n,(e=this.ssp,i.map(t=>e.getObjectById(t)).filter(Boolean)))}var e}}class B extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("delay",f.LOCAL);if(t){const s=gt(t.value);await a.utils.sleep(s)}}}class U extends g{constructor(t,s){super(t,s)}execFn(t){return new Function("sourceData",t)(this.ctx)}async exec(){const t=this.findProp("conditaion_node",f.LOCAL);if(t){const s=gt(t.value),e=this.parser.edges.filter(t=>t.source===this.id);s.forEach(t=>{try{if(!0!==this.execFn(t.value))throw new Error}catch(s){const i=e.find(s=>s.sourceHandle==String(t.id));if(!i)return;const n=this.postNodes.find(t=>t.id===i.target);null==n||n.reject()}})}}}const{objectHandle:k}=a.utils;class V extends g{constructor(t,s){super(t,s)}filterShowObject(t){const s=[];return k(t,t=>{!1===t.visible&&s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterShowObject(t),e=t=>{k(s,s=>{s.visible=t}),this.ssp.render()};e(!0),this.cleanSets.add(()=>e(!1))}}}}const{objectHandle:G}=a.utils;class W extends g{constructor(t,s){super(t,s)}filterHideObject(t){const s=[];return G(t,t=>{!0===t.visible&&s.push(t)}),s}async exec(t){var s;const e=this.findProp("objects",[f.READ_CTX,f.LOCAL]),i=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(e){const t=this.getValue(e,i);if(t){const s=this.filterHideObject(t),e=t=>{G(s,s=>{s.visible=t}),this.ssp.render()};e(!1),this.cleanSets.add(()=>e(!0))}}}}const{objectHandle:F}=a.utils;class z extends g{constructor(t,s){super(t,s)}async exec(s){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("translate",[f.READ_CTX,f.LOCAL]),a=await(null===(e=s.getTarget)||void 0===e?void 0:e.call(s,this));if(i&&n&&o){const s=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(s){const i=[],n=800;F(s,t=>{i.push(t.position.clone())});const o=(t,s)=>{switch(e){case"x":t.setX(s.x);break;case"y":t.setY(s.y);break;case"z":t.setZ(s.z)}},a=async()=>{const i=F(s,async s=>{const i=s.position.clone();switch(e){case"x":await this.ssp.animation(i,(new t).set(i.x+r,i.y,i.z),{duration:n},t=>o(s.position,t));break;case"y":await this.ssp.animation(i,(new t).set(i.x,i.y+r,i.z),{duration:n},t=>o(s.position,t));break;case"z":await this.ssp.animation(i,(new t).set(i.x,i.y,i.z+r),{duration:n},t=>o(s.position,t))}});i instanceof Array?await Promise.all(i):await i,this.ssp.render()};await a(),this.cleanSets.add(()=>{let t=0;F(s,s=>{s.position.copy(i[t++])})})}}}}const{objectHandle:Y}=a.utils;class K extends g{constructor(t,s){super(t,s)}async exec(s){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("scale",[f.READ_CTX,f.LOCAL]),a=await(null===(e=s.getTarget)||void 0===e?void 0:e.call(s,this));if(i&&n&&o){const s=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(s){const i=[],n=800;Y(s,t=>{i.push(t.scale.clone())});const o=(t,s)=>{switch(e){case"x":t.setX(s.x);break;case"y":t.setY(s.y);break;case"z":t.setZ(s.z)}},a=async()=>{const i=Y(s,async s=>{const i=s.scale.clone();switch(e){case"x":await this.ssp.animation(i,(new t).set(i.x*r,i.y,i.z),{duration:n},t=>o(s.scale,t));break;case"y":await this.ssp.animation(i,(new t).set(i.x,i.y*r,i.z),{duration:n},t=>o(s.scale,t));break;case"z":await this.ssp.animation(i,(new t).set(i.x,i.y,i.z*r),{duration:n},t=>o(s.scale,t))}});i instanceof Array?await Promise.all(i):await i,this.ssp.render()};await a(),this.cleanSets.add(()=>{let t=0;Y(s,s=>{s.scale.copy(i[t++])})})}}}}const{objectHandle:q}=a.utils;class J extends g{constructor(t,s){super(t,s)}async exec(t){var e;const i=this.findProp("objects",[f.READ_CTX,f.LOCAL]),n=this.findProp("axis",[f.READ_CTX,f.LOCAL]),o=this.findProp("rotation",[f.READ_CTX,f.LOCAL]),a=await(null===(e=t.getTarget)||void 0===e?void 0:e.call(t,this));if(i&&n&&o){const t=this.getValue(i,a),e=this.getValue(n),r=this.getValue(o);if(t){const i=[],n=800;q(t,t=>{i.push(t.rotation.clone())});const o=(t,s)=>{switch(e){case"x":t.x=s.x;break;case"y":t.y=s.y;break;case"z":t.z=s.z}},a=async()=>{const i=r/180*Math.PI,a=q(t,async t=>{const a=t.rotation.clone();switch(e){case"x":await this.ssp.animation(a,(new s).set(a.x+i,a.y,a.z),{duration:n},s=>o(t.rotation,s));break;case"y":await this.ssp.animation(a,(new s).set(a.x,a.y+i,a.z),{duration:n},s=>o(t.rotation,s));break;case"z":await this.ssp.animation(a,(new s).set(a.x,a.y,a.z+i),{duration:n},s=>o(t.rotation,s))}});a instanceof Array?await Promise.all(a):await a,this.ssp.render()};await a(),this.cleanSets.add(()=>{let s=0;q(t,t=>{t.rotation.copy(i[s++])})})}}}}class Z extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("viewpoint",[f.READ_CTX,f.LOCAL]);if(t){const s=gt(this.getValue(t));s&&this.ssp.setCameraViewpoint(s,!0)}}}class Q extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("space",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=gt(t.value),i=gt(s.value);this.writeContext(i,Et(this.ssp,e))}}}class $ extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("spaces",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=gt(t.value),i=gt(s.value),n=e.map(t=>Et(this.ssp,t));this.writeContext(i,n)}}}class tt extends g{constructor(t,s){super(t,s)}async exec(t){const s=this.findProp("poi",f.LOCAL),e=this.findProp("out",f.WRITE_CTX);if(s&&e){const t=gt(s.value),i=gt(e.value);this.writeContext(i,Et(this.ssp,t))}}}class st extends g{constructor(t,s){super(t,s)}async exec(t){const s=this.findProp("pois",f.LOCAL),e=this.findProp("out",f.WRITE_CTX);if(s&&e){const t=gt(s.value),i=gt(e.value),n=t.map(t=>Et(this.ssp,t));this.writeContext(i,n)}}}class et extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("value",f.LOCAL),s=this.findProp("object",f.LOCAL),e=this.findProp("out",f.WRITE_CTX),i=this.findProp("extraction",f.LOCAL);if(t&&e&&i&&s){const n=gt(i.value),o=gt(e.value),a=gt(s.value),r=this.getValue(s);let c=gt(t.value);if(this.ctx._userDataMap){const t=this.ctx._userDataMap.get(a);t&&(c=t[n])}else if(r&&r.userData.properties){const t=r.userData.properties.find(t=>t.key===n);t&&void 0!==t.value&&(c=t.value)}this.writeContext(o,c)}}}class it extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL);if(t){const s=gt(t.value),e=new Function("sourceData",s);for(const t in this.ctx){const s=e(this.ctx[t]);null!=s&&!1!==s||delete this.ctx[t]}}}}class nt extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("path",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=gt(t.value),i=gt(s.value);this.writeContext(i,Et(this.ssp,e))}}}class ot extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("paths",f.LOCAL),s=this.findProp("out",f.WRITE_CTX);if(t&&s){const e=gt(t.value),i=gt(s.value),n=e.map(t=>Et(this.ssp,t));this.writeContext(i,n)}}}class at extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("object",[f.READ_CTX,f.LOCAL]),s=this.findProp("data",f.LOCAL),e=this.findProp("source",f.WRITE_CTX);if(t&&s&&e){let i=gt(t.value);const n=gt(s.value),o=gt(e.value);if(o&&(i=o),i&&n){this.ctx._userDataMap||(this.ctx._userDataMap=new Map);const t=this.ctx._userDataMap.get(i);t?Object.assign(t,n):this.ctx._userDataMap.set(i,n)}}}}class rt extends g{constructor(t,s){super(t,s)}async exec(t){var s;let e=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(!e){const t=this.findProp("model",[f.READ_CTX,f.LOCAL]);t&&(e=this.getValue(t))}const i=this.findProp("animation",[f.READ_CTX,f.LOCAL]);if(e&&i){let t;if(i.type===f.READ_CTX){const s=this.parser.getVariableNameById(gt(i.value));t=this.readContext(s)}else t=gt(i.value);const s=e.animations[t];s&&(this.ssp.playModelAnimation(e,s),this.cleanSets.add(()=>{this.ssp.stopModelAnimation(e,s)}))}}}class ct extends g{constructor(t,s){super(t,s)}async exec(t){var s;let e=await(null===(s=t.getTarget)||void 0===s?void 0:s.call(t,this));if(!e){const t=this.findProp("model",[f.READ_CTX,f.LOCAL]);t&&(e=this.getValue(t))}const i=this.findProp("animation",[f.READ_CTX,f.LOCAL]);if(e&&i){let t;if(i.type===f.READ_CTX){const s=this.parser.getVariableNameById(gt(i.value));t=this.readContext(s)}else t=gt(i.value);const s=e.animations[t];s&&this.ssp.stopModelAnimation(e,s)}}}const lt=new Map;function ht(t){var s,e;null===(s=lt.get(t))||void 0===s||s.forEach(t=>t.stop()),null===(e=lt.get(t))||void 0===e||e.clear()}class dt extends g{constructor(t,s){super(t,s)}async exec(t){var s;const e=this.findProp("model",[f.READ_CTX,f.LOCAL]),i=this.findProp("animation",f.LOCAL),n=this.findProp("wait",f.LOCAL);if(e&&i&&n){const o=this.getValue(e),a=gt(i.value),c=gt(n.value);if(o){const e=await(null===(s=t.getAnimations)||void 0===s?void 0:s.call(t,this,o,a));if(e){const t=e.find(t=>t.id===a);t&&await At(async()=>{const s=o.matrix.clone();await async function(t,s,e){var i;const{id:n,keyframes:o}=e,a=new r(t,s);lt.has(n)||lt.set(n,new Set),null===(i=lt.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,o,t),this.cleanSets.add(()=>{ht(t.id),o&&s.decompose(o.position,o.quaternion,o.scale)})},c)}}}}}class ut extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){ht(gt(t.value))}}}const pt=new Map;function ft(t){var s,e;null===(s=pt.get(t))||void 0===s||s.forEach(t=>t.stop()),null===(e=pt.get(t))||void 0===e||e.clear()}class Ct extends g{constructor(t,s){super(t,s)}async exec(t){var s;const e=this.findProp("mesh",[f.READ_CTX,f.LOCAL]),i=this.findProp("animation",f.LOCAL),n=this.findProp("wait",f.LOCAL);if(e&&i&&n){const o=this.getValue(e),a=gt(i.value),c=gt(n.value);if(o){const i=await(null===(s=t.getComponentAnimations)||void 0===s?void 0:s.call(t,this,o,a));if(i){const t=i.find(t=>t.id===a);if(t){let s=null;"Mesh"===e.valueType?s=o:"Model"===e.valueType&&(s=Ot(o,t.refId)),s&&await At(async()=>{if(s){const e=s.matrix.clone();await async function(t,s,e){var i;const{id:n,keyframes:o}=e,a=new r(t,s);pt.has(n)||pt.set(n,new Set),null===(i=pt.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,s,t),this.cleanSets.add(()=>{ft(t.id),s&&e.decompose(s.position,s.quaternion,s.scale)})}},c)}}}}}}class Tt extends g{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){ft(gt(t.value))}}}function gt(t){return JSON.parse(t)}async function At(t,s){s?await t():t()}function Et(t,s,e){const i=t.getObjectById(s);if(i)return i;{const{viewport:{scene:i}}=t;return Ot(null!=e?e:i,s)}}function Ot(t,s){if(t.userData.key===s||t.uuid===s)return t;for(let e=0,i=t.children.length;e<i;e++){const i=Ot(t.children[e],s);if(null!==i)return i}return null}const{utils:{sleep:vt}}=a;class Lt extends e{constructor(t,s){super(),this.onNodeBefore=null,this.onNodeAfter=null,this.ssp=t,this.flow=s,this.nodes=[],this.nodesMap=new Map,this.edges=[],this.edgesMap=new Map}addNode(t){this.nodes.push(t),this.nodesMap.set(t.id,t)}addEdge(t){this.edges.push(t),this.edgesMap.set(t.id,t)}getNodeById(t){return this.nodesMap.get(t)}getEdgeById(t){return this.edgesMap.get(t)}clear(){this.nodes.length=0,this.nodesMap.clear(),this.edges.length=0,this.edgesMap.clear()}parse(){this.clear();const{nodes:t,edges:s}=this.flow;t.forEach(t=>{const s=function(t,s){switch(s.type){case C.START:return new A(t,s);case C.COLOR:return new E(t,s);case C.NUMBER:return new O(t,s);case C.HIGHLIGHT:return new L(t,s);case C.UN_HIGHLIGHT:return new I(t,s);case C.OPACITY:return new _(t,s);case C.UN_OPACITY:return new N(t,s);case C.EMISSIVE:return new m(t,s);case C.UN_EMISSIVE:return new M(t,s);case C.MESH:return new S(t,s);case C.MESHES:return new H(t,s);case C.MODEL:return new j(t,s);case C.MODELS:return new X(t,s);case C.SPACE:return new Q(t,s);case C.SPACES:return new $(t,s);case C.POIS:return new st(t,s);case C.POI:return new tt(t,s);case C.PATH:return new nt(t,s);case C.PATHS:return new ot(t,s);case C.DELAY:return new B(t,s);case C.CONDITION_NODE:return new U(t,s);case C.SHOW:return new V(t,s);case C.HIDE:return new W(t,s);case C.CLIP_ANIMATION:return new rt(t,s);case C.UN_CLIP_ANIMATION:return new ct(t,s);case C.TWEEN_ANIMATION:return new dt(t,s);case C.UN_TWEEN_ANIMATION:return new ut(t,s);case C.COMPONENT_TWEEN_ANIMATION:return new Ct(t,s);case C.UN_COMPONENT_TWEEN_ANIMATION:return new Tt(t,s);case C.TRANSLATE:return new z(t,s);case C.ROTATE:return new J(t,s);case C.SCALE:return new K(t,s);case C.FLY_TO:return new Z(t,s);case C.DATA_EXTRACTION:return new et(t,s);case C.DATA_FILTER:return new it(t,s);case C.USER_DATA_NODE:return new at(t,s);default:return new g(t,s)}}(this,t);this.addNode(s)}),s.forEach(t=>{const s=new p(t);this.addEdge(s);const e=this.getNodeById(t.source),i=this.getNodeById(t.target);e&&i&&(e.postNodes.push(i),i.prevNodes.push(e))})}async run(t={}){const s=this.nodes.filter(t=>t.prevNodes.length||t.postNodes.length).map(s=>s.run(t));await Promise.allSettled(s)}async debug(t={},s=1500){const e=this.onNodeAfter;this.onNodeAfter=async t=>{await vt(s),null==e||e(t)},await this.run(t)}stop(){this.nodes.forEach(t=>t.reject(new Error("Flow stopped")))}cleanup(){this.nodes.sort((t,s)=>s.execOrder-t.execOrder).forEach(t=>t.cleanup())}getVariableNameById(t){const s=this.nodes.find(s=>s.id===t);if(s){const t=s.props.find(t=>"out"===t.name);return t?gt(t.value):null}return null}dispose(){this.stop(),this.cleanup()}}class wt extends Lt{constructor(t,s){super(t,s),this.flow=s}}var It,yt;!function(t){t.Group="Group",t.Light="Light",t.Model="Model",t.Poi="Poi",t.PoiNode="PoiNode",t.Canvas3D="Canvas3D",t.Topology="Topology",t.Helper="Helper",t.Decal="Decal",t.PluginObject="PluginObject"}(It||(It={})),function(t){t.sbm="SBM",t.sbmx="SBMX",t.glb="GLB",t.gltf="GLTF",t.fbx="FBX",t.obj="OBJ",t.stl="STL"}(yt||(yt={})),new t,new t,new t;const _t={},xt=new i;xt.setRequestHeader(_t);(new n).load=(t,s,e,i)=>{const n=new Image;return xt.setResponseType("blob"),xt.load(t,function(t){n.src=URL.createObjectURL(t),n.onload=()=>{URL.revokeObjectURL(n.src),null==s||s(n)}},e,i),n};(new o).setRequestHeader(_t);async function Nt(t){return async function(t,s){return await s()}(0,t)}(new u).setRequestHeader(_t),new t,new t,new t;const Pt=(t,s)=>t.userData.key===s||!!t.parent&&Pt(t.parent,s),{groupBy:mt}=a.utils;class bt{constructor(t,s,e,i){this.disposables=[],this.status="ready",this.ssp=t,this.interaction=s,this.flows=e,this.flowsMap=mt(e,"id"),this.options=i||{},this.init()}init(){switch(this.interaction.type){case c.MOUSE_CLICK:this.initMouseClick();break;case c.MOUSE_DB_CLICK:this.initMouseDbClick();break;case c.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case c.LOADED:this.initLoaded();break;case c.THING_PROP_CHANGE:this.initThingPropChange();break;case c.THING_EVENT:this.initThingEvent();break;case c.MODEL_PROP_CHANGE:this.initModelPropChange()}}async getObsTarget(t){const{obsType:s,obsTargets:e,editionId:i}=this.interaction;if(s===l.GLOBAL)return null;if(s===l.INSTANCE){let t;i?(t=this.ssp.getModelById(i),t||console.warn("Target not found:",i)):t=null==e?void 0:e.map(t=>{const s=this.ssp.getModelById(t);return s||console.warn("Target not found:",e[0]),s})[0]}return null}modelHandler(t){var s;const{target:e,currentTarget:i}=t,n=this.interaction.editionId;n?e.sid!==n&&e.userData.familyId!==n||!Pt(i,this.interaction.modelId)||(this.target=e,this.execBehavior()):null===(s=this.interaction.obsTargets)||void 0===s||s.forEach(t=>{t!==e.userData.id&&t!==e.userData.sid||(this.target=e,this.execBehavior())})}runFlowByIds(t){const s=this.target?async()=>this.target:this.getObsTarget.bind(this);t.forEach(t=>{const e=this.flowsMap.get(t);if(e){const t=new h(this.ssp,e[0]);t.parse(),Nt(()=>t.run({getTarget:s,getAnimations:this.options.getAnimations,getComponentAnimations:this.options.getComponentAnimations}))}})}async execBehavior(){var t,s,e,i,n;if(null===(t=this.interaction.active)||void 0===t||t)try{this.status="running";const{behaviors:t}=this.interaction;null==t||t.forEach(t=>{if(t.action===d.FLOW)t.actionRefs&&this.runFlowByIds(t.actionRefs)}),(null===(s=this.options)||void 0===s?void 0:s.onTrigger)&&(null===(e=this.options)||void 0===e||e.onTrigger(this.interaction))}catch(t){this.status="error",(null===(i=this.options)||void 0===i?void 0:i.onError)&&(null===(n=this.options)||void 0===n||n.onError(t))}}initMouseClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelClick.add(t),this.disposables.push(()=>this.ssp.signals.modelClick.remove(t))}initMouseDbClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelDblClick.add(t),this.disposables.push(()=>this.ssp.signals.modelDblClick.remove(t))}initMouseRightClick(){const t=this.modelHandler.bind(this);this.ssp.signals.modelRightClick.add(t),this.disposables.push(()=>this.ssp.signals.modelRightClick.remove(t))}initLoaded(){(()=>{this.execBehavior()})()}modelPropChangeHandler(t){var s,e,i,n,o,a;if((null===(s=null==t?void 0:t.target)||void 0===s?void 0:s.refId)&&"code"!==this.ssp.utils.propertiesCtx.source){if("component"===t.mode){const s=null===(e=this.interaction.obsProps)||void 0===e?void 0:e[0];if(!s)return;const o=JSON.parse(s);if(o.group!=(null===(i=t.target)||void 0===i?void 0:i.group)||o.key!=(null===(n=t.target)||void 0===n?void 0:n.key))return}else{const s=(null===(o=t.target)||void 0===o?void 0:o.modelId)||(null===(a=t.target)||void 0===a?void 0:a.refId);if(this.interaction.obsTargets){if(!this.interaction.obsTargets.includes(s))return}else{const t=this.ssp.getObjectByUserDataProperty("familyId",this.interaction.editionId)[0];if(!t||t.userData.id!==s)return}}this.interaction.editionId&&(this.target=this.ssp.getObjectByUserDataProperty("familyId",this.interaction.editionId)[0]),this.execBehavior()}}initModelPropChange(){const t=this.modelPropChangeHandler.bind(this);this.ssp.signals.propertiesChanged.add(t),this.disposables.push(()=>this.ssp.signals.propertiesChanged.remove(t))}initThingPropChange(){}initThingEvent(){}dispose(){this.disposables.forEach(t=>t())}}var Mt,Dt,St,Rt;!function(t){t.GLOBAL="GLOBAL",t.SELF="SELF",t.OTHER="OTHER"}(Mt||(Mt={})),function(t){t.FLOW="FLOW",t.ANIMATION="ANIMATION",t.DELAY="DELAY"}(Dt||(Dt={})),function(t){t.GLOBAL="GLOBAL",t.INSTANCE="INSTANCE",t.FAMILY="FAMILY"}(St||(St={})),function(t){t.MOUSE_CLICK="MOUSE_CLICK",t.MOUSE_DB_CLICK="MOUSE_DB_CLICK",t.MOUSE_RIGHT_CLICK="MOUSE_RIGHT_CLICK",t.THING_PROP_CHANGE="THING_PROP_CHANGE",t.THING_EVENT="THING_EVENT",t.LOADED="LOADED",t.MODEL_PROP_CHANGE="MODEL_PROP_CHANGE"}(Rt||(Rt={}));const{groupBy:Ht}=a.utils;class jt extends bt{constructor(t,s,e,i){super(t,s,e,i),this.flows=e,this.flowsMap=Ht(e,"id")}init(){switch(this.interaction.type){case Rt.MOUSE_CLICK:this.initMouseClick();break;case Rt.MOUSE_DB_CLICK:this.initMouseDbClick();break;case Rt.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case Rt.LOADED:this.initLoaded();break;case Rt.THING_PROP_CHANGE:this.initThingPropChange();break;case Rt.THING_EVENT:this.initThingEvent();break;case Rt.MODEL_PROP_CHANGE:this.initModelPropChange()}}async getComponentObsTarget(t){const{obsType:s,obsTargets:e}=this.interaction;if(s===St.GLOBAL)return null;if(s===St.INSTANCE){const t=null==e?void 0:e.map(t=>{const s=this.ssp.getModelById(t);return s||console.warn("Target not found:",t),s});return t?t[0]:null}return null}modelHandler(t){var s;const{currentTarget:e}=t;null===(s=this.interaction.obsTargets)||void 0===s||s.forEach(t=>{t===e.userData.key&&this.execBehavior()})}componentThingModelHandler(t){var s;const{propKey:e}=t;null===(s=this.interaction.obsProps)||void 0===s||s.forEach(t=>{t===e&&this.execBehavior()})}runFlowByIds(t){const s=this.getComponentObsTarget.bind(this);t.forEach(t=>{const e=this.flowsMap.get(t);if(e){const t=new wt(this.ssp,e[0]);t.parse(),Nt(()=>t.run({getTarget:s}))}})}async execBehavior(){var t,s,e,i;try{const{behaviors:e}=this.interaction;null==e||e.forEach(t=>{if(t.action===Dt.FLOW)t.actionRefs&&this.runFlowByIds(t.actionRefs)}),(null===(t=this.options)||void 0===t?void 0:t.onTrigger)&&(null===(s=this.options)||void 0===s||s.onTrigger(this.interaction))}catch(t){(null===(e=this.options)||void 0===e?void 0:e.onError)&&(null===(i=this.options)||void 0===i||i.onError(t))}}initLoaded(){const t=()=>{this.execBehavior()};this.getComponentObsTarget().then(s=>{s&&(s.addEventListener("load",t),this.disposables.push(()=>s.removeEventListener("load",t)))})}initThingPropChange(){const t=this.componentThingModelHandler.bind(this);this.ssp.signals.thingModelPropsChange.add(t),this.disposables.push(()=>this.ssp.signals.thingModelPropsChange.remove(t))}initThingEvent(){}onThingPropChange(t){this.ssp.signals.thingModelPropsChange.dispatch({propKey:t})}}export{wt as ComponentFlowParser,jt as ComponentTrigger,Lt as FlowParser,Dt as InteractionAction,Mt as InteractionActionType,St as InteractionObsType,Rt as InteractionType,g as Node,f as NodePropTypeEnum,C as NodeTypeEnum,bt as Trigger};
@@ -1,18 +1,23 @@
1
- import SoonSpace, { ModelEventParams } from 'soonspacejs';
2
- import { Trigger } from './Trigger';
3
- import { Interaction, TriggerOptions } from './types';
4
- import { ComponentFlowType } from '../flows/types';
5
- declare class ComponentTrigger extends Trigger {
6
- #private;
7
- flows: ComponentFlowType[];
8
- flowsMap: Map<string, ComponentFlowType[]>;
9
- constructor(ssp: SoonSpace, interaction: Interaction, flows: ComponentFlowType[], options: TriggerOptions);
10
- modelHandler(params: ModelEventParams): void;
11
- runFlowByIds(flowIds: string[]): void;
12
- execBehavior(): Promise<void>;
13
- initLoaded(): void;
14
- initThingPropChange(): void;
15
- initThingEvent(): void;
16
- onThingPropChange(newProps: string): void;
17
- }
18
- export { ComponentTrigger, };
1
+ import SoonSpace, { ModelEventParams } from 'soonspacejs';
2
+ import { Trigger } from './Trigger';
3
+ import { Interaction, TriggerOptions } from './types';
4
+ import { ComponentFlowType } from '../flows/types';
5
+ import { Node } from '../flows';
6
+ declare class ComponentTrigger extends Trigger {
7
+ flows: ComponentFlowType[];
8
+ flowsMap: Map<string, ComponentFlowType[]>;
9
+ constructor(ssp: SoonSpace, interaction: Interaction, flows: ComponentFlowType[], options: TriggerOptions);
10
+ protected init(): void;
11
+ getComponentObsTarget(currentNode?: Node): Promise<import("soonspacejs").Model | null>;
12
+ modelHandler(params: ModelEventParams): void;
13
+ componentThingModelHandler(params: {
14
+ propKey: string;
15
+ }): void;
16
+ runFlowByIds(flowIds: string[]): void;
17
+ execBehavior(): Promise<void>;
18
+ initLoaded(): void;
19
+ initThingPropChange(): void;
20
+ initThingEvent(): void;
21
+ onThingPropChange(newProps: string): void;
22
+ }
23
+ export { ComponentTrigger, };
@@ -1,27 +1,28 @@
1
- import SoonSpace, { Model, ModelEventParams } from 'soonspacejs';
2
- import { FlowType, Interaction, TriggerOptions } from '@soonspacejs/plugin-flow';
3
- declare class Trigger {
4
- #private;
5
- ssp: SoonSpace;
6
- interaction: Interaction;
7
- flows: FlowType[];
8
- flowsMap: Map<string, FlowType[]>;
9
- options: TriggerOptions;
10
- disposables: (() => void)[];
11
- status: 'ready' | 'running' | 'error';
12
- target?: Model;
13
- constructor(ssp: SoonSpace, interaction: Interaction, flows: FlowType[], options: TriggerOptions);
14
- modelHandler(params: ModelEventParams): void;
15
- runFlowByIds(flowIds: string[]): void;
16
- execBehavior(): Promise<void>;
17
- initMouseClick(): void;
18
- initMouseDbClick(): void;
19
- initMouseRightClick(): void;
20
- initLoaded(): void;
21
- modelPropChangeHandler(properties: any): void;
22
- initModelPropChange(): void;
23
- initThingPropChange(): void;
24
- initThingEvent(): void;
25
- dispose(): void;
26
- }
27
- export { Trigger, };
1
+ import SoonSpace, { Model, ModelEventParams } from 'soonspacejs';
2
+ import { FlowType, Interaction, Node, TriggerOptions } from '@soonspacejs/plugin-flow';
3
+ declare class Trigger {
4
+ ssp: SoonSpace;
5
+ interaction: Interaction;
6
+ flows: FlowType[];
7
+ flowsMap: Map<string, FlowType[]>;
8
+ options: TriggerOptions;
9
+ disposables: (() => void)[];
10
+ status: 'ready' | 'running' | 'error';
11
+ target?: Model;
12
+ constructor(ssp: SoonSpace, interaction: Interaction, flows: FlowType[], options: TriggerOptions);
13
+ protected init(): void;
14
+ getObsTarget(currentNode: Node): Promise<null>;
15
+ modelHandler(params: ModelEventParams): void;
16
+ runFlowByIds(flowIds: string[]): void;
17
+ execBehavior(): Promise<void>;
18
+ initMouseClick(): void;
19
+ initMouseDbClick(): void;
20
+ initMouseRightClick(): void;
21
+ initLoaded(): void;
22
+ modelPropChangeHandler(properties: any): void;
23
+ initModelPropChange(): void;
24
+ initThingPropChange(): void;
25
+ initThingEvent(): void;
26
+ dispose(): void;
27
+ }
28
+ export { Trigger, };
@@ -1,3 +1,3 @@
1
- export { Trigger, } from './Trigger';
2
- export { ComponentTrigger, } from './ComponentTrigger';
3
- export * from './types';
1
+ export { Trigger, } from './Trigger';
2
+ export { ComponentTrigger, } from './ComponentTrigger';
3
+ export * from './types';
@@ -1,54 +1,54 @@
1
- import { Object3D } from 'three';
2
- import { IAnimation, IComponentAnimation } from '../types';
3
- import { Node } from '../flows';
4
- export declare enum InteractionActionType {
5
- GLOBAL = "GLOBAL",
6
- SELF = "SELF",
7
- OTHER = "OTHER"
8
- }
9
- export declare enum InteractionAction {
10
- FLOW = "FLOW",
11
- ANIMATION = "ANIMATION",
12
- DELAY = "DELAY"
13
- }
14
- export declare enum InteractionObsType {
15
- GLOBAL = "GLOBAL",
16
- INSTANCE = "INSTANCE",
17
- FAMILY = "FAMILY"
18
- }
19
- export declare enum InteractionType {
20
- MOUSE_CLICK = "MOUSE_CLICK",
21
- MOUSE_DB_CLICK = "MOUSE_DB_CLICK",
22
- MOUSE_RIGHT_CLICK = "MOUSE_RIGHT_CLICK",
23
- THING_PROP_CHANGE = "THING_PROP_CHANGE",
24
- THING_EVENT = "THING_EVENT",
25
- LOADED = "LOADED",
26
- MODEL_PROP_CHANGE = "MODEL_PROP_CHANGE"
27
- }
28
- export type InteractionBehavior = {
29
- id: string;
30
- uuid: string;
31
- actionType: InteractionActionType;
32
- action: InteractionAction;
33
- actionTargets: string[] | null;
34
- actionRefs: string[] | null;
35
- };
36
- export type Interaction = {
37
- id: string;
38
- sid: string;
39
- name: string;
40
- modelId: string;
41
- type: InteractionType;
42
- obsType: InteractionObsType;
43
- obsTargets: string[] | null;
44
- obsProps: string[] | null;
45
- behaviors: InteractionBehavior[] | null;
46
- active: boolean;
47
- editionId?: string;
48
- };
49
- export type TriggerOptions = {
50
- onError?: (e: Error) => void;
51
- onTrigger?: (interaction: Interaction) => void;
52
- getAnimations?: (currentNode: Node, object: Object3D, animationId: string) => Promise<IAnimation[] | null>;
53
- getComponentAnimations?: (currentNode: Node, object: Object3D, animationId: string) => Promise<IComponentAnimation[] | null>;
54
- };
1
+ import { Object3D } from 'three';
2
+ import { IAnimation, IComponentAnimation } from '../types';
3
+ import { Node } from '../flows';
4
+ export declare enum InteractionActionType {
5
+ GLOBAL = "GLOBAL",
6
+ SELF = "SELF",
7
+ OTHER = "OTHER"
8
+ }
9
+ export declare enum InteractionAction {
10
+ FLOW = "FLOW",
11
+ ANIMATION = "ANIMATION",
12
+ DELAY = "DELAY"
13
+ }
14
+ export declare enum InteractionObsType {
15
+ GLOBAL = "GLOBAL",
16
+ INSTANCE = "INSTANCE",
17
+ FAMILY = "FAMILY"
18
+ }
19
+ export declare enum InteractionType {
20
+ MOUSE_CLICK = "MOUSE_CLICK",
21
+ MOUSE_DB_CLICK = "MOUSE_DB_CLICK",
22
+ MOUSE_RIGHT_CLICK = "MOUSE_RIGHT_CLICK",
23
+ THING_PROP_CHANGE = "THING_PROP_CHANGE",
24
+ THING_EVENT = "THING_EVENT",
25
+ LOADED = "LOADED",
26
+ MODEL_PROP_CHANGE = "MODEL_PROP_CHANGE"
27
+ }
28
+ export type InteractionBehavior = {
29
+ id: string;
30
+ uuid: string;
31
+ actionType: InteractionActionType;
32
+ action: InteractionAction;
33
+ actionTargets: string[] | null;
34
+ actionRefs: string[] | null;
35
+ };
36
+ export type Interaction = {
37
+ id: string;
38
+ sid: string;
39
+ name: string;
40
+ modelId: string;
41
+ type: InteractionType;
42
+ obsType: InteractionObsType;
43
+ obsTargets: string[] | null;
44
+ obsProps: string[] | null;
45
+ behaviors: InteractionBehavior[] | null;
46
+ active: boolean;
47
+ editionId?: string;
48
+ };
49
+ export type TriggerOptions = {
50
+ onError?: (e: Error) => void;
51
+ onTrigger?: (interaction: Interaction) => void;
52
+ getAnimations?: (currentNode: Node, object: Object3D, animationId: string) => Promise<IAnimation[] | null>;
53
+ getComponentAnimations?: (currentNode: Node, object: Object3D, animationId: string) => Promise<IComponentAnimation[] | null>;
54
+ };
@@ -1,2 +1,2 @@
1
- import { Object3D } from 'three';
2
- export declare const findObjectFromTarget: (target: Object3D, key: string) => boolean;
1
+ import { Object3D } from 'three';
2
+ export declare const findObjectFromTarget: (target: Object3D, key: string) => boolean;
package/dist/types.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { TAnimationFrame } from 'umanager-animation-parser';
2
- export interface IComponentAnimation {
3
- id: string;
4
- sid: string;
5
- name: string;
6
- refId: string;
7
- editionId: string;
8
- keyframes: TAnimationFrame[];
9
- }
10
- export interface IAnimation {
11
- id: string;
12
- sid: string;
13
- modelId: string;
14
- name: string;
15
- keyframes: TAnimationFrame[];
16
- }
1
+ import { TAnimationFrame } from 'umanager-animation-parser';
2
+ export interface IComponentAnimation {
3
+ id: string;
4
+ sid: string;
5
+ name: string;
6
+ refId: string;
7
+ editionId: string;
8
+ keyframes: TAnimationFrame[];
9
+ }
10
+ export interface IAnimation {
11
+ id: string;
12
+ sid: string;
13
+ modelId: string;
14
+ name: string;
15
+ keyframes: TAnimationFrame[];
16
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-flow",
3
3
  "pluginName": "FlowPlugin",
4
- "version": "2.13.10",
4
+ "version": "2.13.12",
5
5
  "description": "FlowPlugin plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,9 +13,9 @@
13
13
  ],
14
14
  "author": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "6bca3b98477ef9c2fa0ba5f67d461561896bb0ff",
16
+ "gitHead": "aa34f472ae1520b537b0a5a1d67f4a746f41236a",
17
17
  "peerDependencies": {
18
- "soonspacejs": "2.13.10",
18
+ "soonspacejs": "2.13.12",
19
19
  "umanager-animation-parser": "^0.0.6"
20
20
  }
21
21
  }