@soonspacejs/plugin-flow 2.13.11 → 2.13.14
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.
|
@@ -27,7 +27,9 @@ declare class FlowParser extends EventDispatcher<FlowParserEventMap> {
|
|
|
27
27
|
* @param startNode
|
|
28
28
|
* @param ctx
|
|
29
29
|
*/
|
|
30
|
-
run(global?: NodeGlobalType
|
|
30
|
+
run(global?: NodeGlobalType, options?: {
|
|
31
|
+
preload: boolean;
|
|
32
|
+
}): Promise<void>;
|
|
31
33
|
/**
|
|
32
34
|
* 调试流程
|
|
33
35
|
*/
|
|
@@ -40,8 +40,11 @@ declare class Node {
|
|
|
40
40
|
/**
|
|
41
41
|
* 运行节点
|
|
42
42
|
* @param global
|
|
43
|
+
* @param options
|
|
43
44
|
*/
|
|
44
|
-
run(global: NodeGlobalType
|
|
45
|
+
run(global: NodeGlobalType, options?: {
|
|
46
|
+
preload: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
45
48
|
cleanup(): void;
|
|
46
49
|
protected getValue(prop: NodePropType, object?: Object3D | null): any;
|
|
47
50
|
private _mergeUserDataMap;
|
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{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
|
+
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,T;!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"}(T||(T={}));let C=0;const A=[T.MESH,T.MESHES,T.MODEL,T.MODELS,T.POI,T.POIS,T.SPACE,T.SPACES,T.PATH,T.PATHS,T.COLOR,T.NUMBER,T.DATA_EXTRACTION,T.DATA_FILTER,T.USER_DATA_NODE,T.CONDITION_NODE,T.START];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)}),this._mergeUserDataMap()}async exec(t){}async run(t,s={preload:!1}){var e,i,n,o;const{preload:a}=s;try{if(await this.waitForPrevNodes(),this.rejected)throw new Error;this.mergeContext(),await(null===(i=null!==(e=this.onBefore)&&void 0!==e?e:this.parser.onNodeBefore)||void 0===i?void 0:i(this));try{a&&!A.includes(this.type)||(this.execOrder=++C,await this.exec(t))}catch(t){throw this.reject(t),t}await(null===(o=null!==(n=this.onAfter)&&void 0!==n?n:this.parser.onNodeAfter)||void 0===o?void 0:o(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(Et(t.value));if(t.type===f.LOCAL){const{viewport:{scene:e}}=this.ssp;return"objects"===t.name||"models"===t.name||"meshs"===t.name?Et(t.value).map(t=>Ot(this.ssp,t,null!=s?s:e)):"object"===t.name||"model"===t.name||"mesh"===t.name?Ot(this.ssp,Et(t.value),null!=s?s:e):Et(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 g extends E{constructor(t,s){super(t,s)}}class O 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(Et(s.value),Et(t.value))}}class v 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(Et(s.value),Et(t.value))}}const{objectHandle:L}=a.utils;class w extends E{constructor(t,s){super(t,s)}filterHighlightObject(t){const s=[];return L(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:I}=a.utils;class _ extends E{constructor(t,s){super(t,s)}filterUnHighlightObject(t){const s=[];return I(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:x}=a.utils;class P extends E{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:m}=a.utils;class b 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:M}=a.utils;class D extends E{constructor(t,s){super(t,s)}filterUnEmissiveObject(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=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 S=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[S]||(t[S]={});const n=this.findProp("mesh",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){let s=null;const e=Et(n.value),a=Et(o.value),r=t[S][e];if(r)return void(s=r);const c=vt(i,e);c&&(s=c,t[S][e]=c),this.writeContext(a,s)}}}const H=Symbol("meshesCache");class j 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[H]||(t[H]={});const n=this.findProp("meshes",f.LOCAL),o=this.findProp("out",f.WRITE_CTX);if(n&&o){const s=[],e=Et(n.value),a=Et(o.value);e.forEach(e=>{const n=t[H][e];if(n)return void s.push(n);const o=vt(i,e);o&&(s.push(o),t[H][e]=o)}),this.writeContext(a,s)}}}class X 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=Et(t.value),i=Et(s.value);this.writeContext(i,Ot(this.ssp,e))}}}class B 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=Et(t.value),n=Et(s.value);this.writeContext(n,(e=this.ssp,i.map(t=>e.getObjectById(t)).filter(Boolean)))}var e}}class U extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("delay",f.LOCAL);if(t){const s=Et(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=Et(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:W}=a.utils;class F extends E{constructor(t,s){super(t,s)}filterHideObject(t){const s=[];return W(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=>{W(s,s=>{s.visible=t}),this.ssp.render()};e(!1),this.cleanSets.add(()=>e(!0))}}}}const{objectHandle:z}=a.utils;class Y 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;z(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=z(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;z(s,s=>{s.position.copy(i[t++])})})}}}}const{objectHandle:K}=a.utils;class q 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;K(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=K(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;K(s,s=>{s.scale.copy(i[t++])})})}}}}const{objectHandle:J}=a.utils;class Z 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;J(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=J(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;J(t,t=>{t.rotation.copy(i[s++])})})}}}}class Q extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("viewpoint",[f.READ_CTX,f.LOCAL]);if(t){const s=Et(this.getValue(t));s&&this.ssp.setCameraViewpoint(s,!0)}}}class $ 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=Et(t.value),i=Et(s.value);this.writeContext(i,Ot(this.ssp,e))}}}class tt 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=Et(t.value),i=Et(s.value),n=e.map(t=>Ot(this.ssp,t));this.writeContext(i,n)}}}class st 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=Et(s.value),i=Et(e.value);this.writeContext(i,Ot(this.ssp,t))}}}class et 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=Et(s.value),i=Et(e.value),n=t.map(t=>Ot(this.ssp,t));this.writeContext(i,n)}}}class it extends E{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=Et(i.value),o=Et(e.value),a=Et(s.value),r=this.getValue(s);let c=Et(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 nt extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("model",f.LOCAL);if(t){const s=Et(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 ot 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=Et(t.value),i=Et(s.value);this.writeContext(i,Ot(this.ssp,e))}}}class at 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=Et(t.value),i=Et(s.value),n=e.map(t=>Ot(this.ssp,t));this.writeContext(i,n)}}}class rt extends E{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=Et(t.value);const n=Et(s.value),o=Et(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 ct 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(Et(i.value));t=this.readContext(s)}else t=Et(i.value);const s=e.animations[t];s&&(this.ssp.playModelAnimation(e,s),this.cleanSets.add(()=>{this.ssp.stopModelAnimation(e,s)}))}}}class lt 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(Et(i.value));t=this.readContext(s)}else t=Et(i.value);const s=e.animations[t];s&&this.ssp.stopModelAnimation(e,s)}}}const ht=new Map;function dt(t){var s,e;null===(s=ht.get(t))||void 0===s||s.forEach(t=>t.stop()),null===(e=ht.get(t))||void 0===e||e.clear()}class ut 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=Et(i.value),c=Et(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 gt(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);ht.has(n)||ht.set(n,new Set),null===(i=ht.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,o,t),this.cleanSets.add(()=>{dt(t.id),o&&s.decompose(o.position,o.quaternion,o.scale)})},c)}}}}}class pt extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){dt(Et(t.value))}}}const ft=new Map;function Tt(t){var s,e;null===(s=ft.get(t))||void 0===s||s.forEach(t=>t.stop()),null===(e=ft.get(t))||void 0===e||e.clear()}class Ct 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=Et(i.value),c=Et(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=vt(o,t.refId)),s&&await gt(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);ft.has(n)||ft.set(n,new Set),null===(i=ft.get(n))||void 0===i||i.add(a),await a.play(o)}(this.ssp,s,t),this.cleanSets.add(()=>{Tt(t.id),s&&e.decompose(s.position,s.quaternion,s.scale)})}},c)}}}}}}class At extends E{constructor(t,s){super(t,s)}async exec(){const t=this.findProp("animation",f.LOCAL);if(t){Tt(Et(t.value))}}}function Et(t){return JSON.parse(t)}async function gt(t,s){s?await t():t()}function Ot(t,s,e){const i=t.getObjectById(s);if(i)return i;{const{viewport:{scene:i}}=t;return vt(null!=e?e:i,s)}}function vt(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=vt(t.children[e],s);if(null!==i)return i}return null}const{utils:{sleep:Lt}}=a;class wt 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 T.START:return new g(t,s);case T.COLOR:return new O(t,s);case T.NUMBER:return new v(t,s);case T.HIGHLIGHT:return new w(t,s);case T.UN_HIGHLIGHT:return new _(t,s);case T.OPACITY:return new N(t,s);case T.UN_OPACITY:return new P(t,s);case T.EMISSIVE:return new b(t,s);case T.UN_EMISSIVE:return new D(t,s);case T.MESH:return new R(t,s);case T.MESHES:return new j(t,s);case T.MODEL:return new X(t,s);case T.MODELS:return new B(t,s);case T.SPACE:return new $(t,s);case T.SPACES:return new tt(t,s);case T.POIS:return new et(t,s);case T.POI:return new st(t,s);case T.PATH:return new ot(t,s);case T.PATHS:return new at(t,s);case T.DELAY:return new U(t,s);case T.CONDITION_NODE:return new k(t,s);case T.SHOW:return new G(t,s);case T.HIDE:return new F(t,s);case T.CLIP_ANIMATION:return new ct(t,s);case T.UN_CLIP_ANIMATION:return new lt(t,s);case T.TWEEN_ANIMATION:return new ut(t,s);case T.UN_TWEEN_ANIMATION:return new pt(t,s);case T.COMPONENT_TWEEN_ANIMATION:return new Ct(t,s);case T.UN_COMPONENT_TWEEN_ANIMATION:return new At(t,s);case T.TRANSLATE:return new Y(t,s);case T.ROTATE:return new Z(t,s);case T.SCALE:return new q(t,s);case T.FLY_TO:return new Q(t,s);case T.DATA_EXTRACTION:return new it(t,s);case T.DATA_FILTER:return new nt(t,s);case T.USER_DATA_NODE:return new rt(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={},s={preload:!1}){const{preload:e}=s,i=this.nodes.filter(t=>t.prevNodes.length||t.postNodes.length).map(s=>s.run(t,{preload:e}));await Promise.allSettled(i)}async debug(t={},s=1500){const e=this.onNodeAfter;this.onNodeAfter=async t=>{await Lt(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?Et(t.value):null}return null}dispose(){this.stop(),this.cleanup()}}class It extends wt{constructor(t,s){super(t,s),this.flow=s}}var _t,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"}(_t||(_t={})),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={},xt=new i;xt.setRequestHeader(Nt);(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(Nt);async function Pt(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),{groupBy:bt}=a.utils;class Mt{constructor(t,s,e,i){this.disposables=[],this.status="ready",this.ssp=t,this.interaction=s,this.flows=e,this.flowsMap=bt(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||!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: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(),Pt(()=>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 Dt,St,Rt,Ht;!function(t){t.GLOBAL="GLOBAL",t.SELF="SELF",t.OTHER="OTHER"}(Dt||(Dt={})),function(t){t.FLOW="FLOW",t.ANIMATION="ANIMATION",t.DELAY="DELAY"}(St||(St={})),function(t){t.GLOBAL="GLOBAL",t.INSTANCE="INSTANCE",t.FAMILY="FAMILY"}(Rt||(Rt={})),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"}(Ht||(Ht={}));const{groupBy:jt}=a.utils;class Xt extends Mt{constructor(t,s,e,i){super(t,s,e,i),this.flows=e,this.flowsMap=jt(e,"id")}init(){switch(this.interaction.type){case Ht.MOUSE_CLICK:this.initMouseClick();break;case Ht.MOUSE_DB_CLICK:this.initMouseDbClick();break;case Ht.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case Ht.LOADED:this.initLoaded();break;case Ht.THING_PROP_CHANGE:this.initThingPropChange();break;case Ht.THING_EVENT:this.initThingEvent();break;case Ht.MODEL_PROP_CHANGE:this.initModelPropChange()}}async getComponentObsTarget(t){const{obsType:s,obsTargets:e}=this.interaction;if(s===Rt.GLOBAL)return null;if(s===Rt.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 It(this.ssp,e[0]);t.parse(),Pt(()=>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===St.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{It as ComponentFlowParser,Xt as ComponentTrigger,wt as FlowParser,St as InteractionAction,Dt as InteractionActionType,Rt as InteractionObsType,Ht as InteractionType,E as Node,f as NodePropTypeEnum,T as NodeTypeEnum,Mt as Trigger};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-flow",
|
|
3
3
|
"pluginName": "FlowPlugin",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.14",
|
|
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": "
|
|
16
|
+
"gitHead": "71d91773a54276b7cbb0a0525ba5f921345f121f",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.13.
|
|
18
|
+
"soonspacejs": "2.13.14",
|
|
19
19
|
"umanager-animation-parser": "^0.0.6"
|
|
20
20
|
}
|
|
21
21
|
}
|