@soonspacejs/plugin-flow 2.13.17 → 2.14.0

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.
package/dist/index.esm.js CHANGED
@@ -1 +1,1372 @@
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:!!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=Ot(this.ssp,t);return s||console.warn("Component 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=>{mt(e,t)&&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};
1
+ import { Vector3 as b, Euler as S, EventDispatcher as z } from "three";
2
+ import T from "soonspacejs";
3
+ import { AnimationPlayer as k } from "umanager-animation-parser";
4
+ import { InteractionType as L, InteractionObsType as j, FlowParser as Y, InteractionAction as $ } from "@soonspacejs/plugin-flow";
5
+ class K {
6
+ id;
7
+ source;
8
+ target;
9
+ sourceHandle;
10
+ constructor(t) {
11
+ this.id = t.id, this.source = t.source, this.target = t.target, this.sourceHandle = t.sourceHandle;
12
+ }
13
+ }
14
+ var n = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.READ_CTX = "READ_CTX", e.WRITE_CTX = "WRITE_CTX", e))(n || {}), r = /* @__PURE__ */ ((e) => (e.START = "START", e.COLOR = "COLOR", e.NUMBER = "NUMBER", e.HIGHLIGHT = "HIGHLIGHT", e.UN_HIGHLIGHT = "UN_HIGHLIGHT", e.OPACITY = "OPACITY", e.UN_OPACITY = "UN_OPACITY", e.EMISSIVE = "EMISSIVE", e.UN_EMISSIVE = "UN_EMISSIVE", e.MESH = "MESH", e.MESHES = "MESHES", e.MODEL = "MODEL", e.MODELS = "MODELS", e.SHOW = "SHOW", e.HIDE = "HIDE", e.CLIP_ANIMATION = "CLIP_ANIMATION", e.UN_CLIP_ANIMATION = "UN_CLIP_ANIMATION", e.TWEEN_ANIMATION = "TWEEN_ANIMATION", e.UN_TWEEN_ANIMATION = "UN_TWEEN_ANIMATION", e.COMPONENT_TWEEN_ANIMATION = "COMPONENT_TWEEN_ANIMATION", e.UN_COMPONENT_TWEEN_ANIMATION = "UN_COMPONENT_TWEEN_ANIMATION", e.SPACE = "SPACE", e.SPACES = "SPACES", e.PATH = "PATH", e.PATHS = "PATHS", e.POI = "POI", e.POIS = "POIS", e.FLY_TO = "FLY_TO", e.TRANSLATE = "TRANSLATE", e.ROTATE = "ROTATE", e.SCALE = "SCALE", e.DATA_FILTER = "DATA_FILTER", e.DATA_EXTRACTION = "DATA_EXTRACTION", e.CONDITION_NODE = "CONDITION_NODE", e.DELAY = "DELAY", e.USER_DATA_NODE = "USER_DATA_NODE", e))(r || {});
15
+ let J = 0;
16
+ const q = [
17
+ r.MESH,
18
+ r.MESHES,
19
+ r.MODEL,
20
+ r.MODELS,
21
+ r.POI,
22
+ r.POIS,
23
+ r.SPACE,
24
+ r.SPACES,
25
+ r.PATH,
26
+ r.PATHS,
27
+ r.COLOR,
28
+ r.NUMBER,
29
+ r.DATA_EXTRACTION,
30
+ r.DATA_FILTER,
31
+ r.USER_DATA_NODE,
32
+ r.CONDITION_NODE,
33
+ r.START
34
+ ];
35
+ class f {
36
+ parser;
37
+ ssp;
38
+ id;
39
+ type;
40
+ props;
41
+ // 前置节点
42
+ prevNodes = [];
43
+ // 后置节点
44
+ postNodes = [];
45
+ // 执行顺序
46
+ execOrder = 0;
47
+ // 当前上下文对象
48
+ ctx;
49
+ // 运行结果
50
+ promise;
51
+ resolve;
52
+ reject;
53
+ // 清空队列回调
54
+ cleanSets = /* @__PURE__ */ new Set();
55
+ // 前置钩子
56
+ onBefore = null;
57
+ // 后置钩子
58
+ onAfter = null;
59
+ rejected;
60
+ constructor(t, s) {
61
+ this.parser = t, this.ssp = t.ssp, this.id = s.id, this.type = s.type, this.props = s.props, this.rejected = !1, this.init();
62
+ }
63
+ init() {
64
+ this.ctx = {}, this.promise = new Promise((t, s) => {
65
+ this.resolve = t, this.reject = () => {
66
+ this.rejected = !0, s();
67
+ };
68
+ });
69
+ }
70
+ readContext(t) {
71
+ return this.ctx[t];
72
+ }
73
+ writeContext(t, s) {
74
+ this.ctx[t] = s;
75
+ }
76
+ findProp(t, s) {
77
+ if (s instanceof Array)
78
+ for (const i of s) {
79
+ const o = this.findProp(t, i);
80
+ if (o) return o;
81
+ }
82
+ else
83
+ return this.props.find((i) => i.name === t && i.type === s);
84
+ }
85
+ /**
86
+ * 等待前置节点执行完毕
87
+ */
88
+ async waitForPrevNodes() {
89
+ return await Promise.all(this.prevNodes.map((t) => t.promise));
90
+ }
91
+ /**
92
+ * 合并上下文
93
+ */
94
+ mergeContext() {
95
+ this.prevNodes.forEach((t) => {
96
+ Object.assign(this.ctx, t.ctx);
97
+ }), this._mergeUserDataMap();
98
+ }
99
+ /**
100
+ * 执行节点逻辑
101
+ * @param global
102
+ */
103
+ async exec(t) {
104
+ }
105
+ /**
106
+ * 运行节点
107
+ * @param global
108
+ * @param options
109
+ */
110
+ async run(t, s = { preload: !1 }) {
111
+ const { preload: i } = s;
112
+ try {
113
+ if (await this.waitForPrevNodes(), this.rejected) throw new Error();
114
+ this.mergeContext(), await (this.onBefore ?? this.parser.onNodeBefore)?.(this);
115
+ try {
116
+ (!i || q.includes(this.type)) && (this.execOrder = ++J, await this.exec(t));
117
+ } catch (o) {
118
+ throw this.reject(o), o;
119
+ }
120
+ await (this.onAfter ?? this.parser.onNodeAfter)?.(this), this.resolve();
121
+ } catch (o) {
122
+ this.reject(o);
123
+ }
124
+ }
125
+ // 清空节点逻辑
126
+ cleanup() {
127
+ this.cleanSets.forEach((t) => t()), this.cleanSets.clear();
128
+ }
129
+ getValue(t, s) {
130
+ if (t.type === n.READ_CTX)
131
+ return this.readContext(l(t.value));
132
+ if (t.type === n.LOCAL) {
133
+ const { viewport: { scene: i } } = this.ssp;
134
+ return t.name === "objects" || t.name === "models" || t.name === "meshs" ? l(t.value).map((o) => E(this.ssp, o, s ?? i)) : t.name === "object" || t.name === "model" || t.name === "mesh" ? E(this.ssp, l(t.value), s ?? i) : l(t.value);
135
+ }
136
+ }
137
+ _mergeUserDataMap() {
138
+ if (this.prevNodes.some((t) => t.ctx._userDataMap)) this.ctx._userDataMap = /* @__PURE__ */ new Map();
139
+ else return;
140
+ this.prevNodes.forEach((t) => {
141
+ t.ctx._userDataMap && t.ctx._userDataMap.forEach((s, i) => {
142
+ this.ctx._userDataMap.set(i, Object.assign({}, s));
143
+ });
144
+ });
145
+ }
146
+ }
147
+ class Z extends f {
148
+ constructor(t, s) {
149
+ super(t, s);
150
+ }
151
+ }
152
+ class Q extends f {
153
+ constructor(t, s) {
154
+ super(t, s);
155
+ }
156
+ async exec() {
157
+ const t = this.findProp("color", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
158
+ t && s && this.writeContext(l(s.value), l(t.value));
159
+ }
160
+ }
161
+ class tt extends f {
162
+ constructor(t, s) {
163
+ super(t, s);
164
+ }
165
+ async exec() {
166
+ const t = this.findProp("number", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
167
+ t && s && this.writeContext(l(s.value), l(t.value));
168
+ }
169
+ }
170
+ const { objectHandle: st } = T.utils;
171
+ class et extends f {
172
+ constructor(t, s) {
173
+ super(t, s);
174
+ }
175
+ filterHighlightObject(t) {
176
+ const s = [];
177
+ return st(t, (i) => {
178
+ this.ssp.viewport.scener.selectedObjects.highlight.has(i) || s.push(i);
179
+ }), s;
180
+ }
181
+ async exec(t) {
182
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = this.findProp("color", [n.READ_CTX, n.LOCAL]), o = this.findProp("opacity", [n.READ_CTX, n.LOCAL]), a = await t.getTarget?.(this);
183
+ if (s && i && o) {
184
+ const c = this.getValue(s, a), h = this.getValue(i), u = this.getValue(o);
185
+ if (c) {
186
+ const d = this.filterHighlightObject(c);
187
+ this.ssp.highlightShow(d, { color: h, opacity: u }), this.cleanSets.add(() => {
188
+ this.ssp.unHighlightShow(d);
189
+ });
190
+ }
191
+ }
192
+ }
193
+ }
194
+ const { objectHandle: it } = T.utils;
195
+ class ot extends f {
196
+ constructor(t, s) {
197
+ super(t, s);
198
+ }
199
+ filterUnHighlightObject(t) {
200
+ const s = [];
201
+ return it(t, (i) => {
202
+ this.ssp.viewport.scener.selectedObjects.highlight.has(i) && s.push(i);
203
+ }), s;
204
+ }
205
+ async exec(t) {
206
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = await t.getTarget?.(this);
207
+ if (s) {
208
+ const o = this.getValue(s, i);
209
+ if (o) {
210
+ const a = this.filterUnHighlightObject(o);
211
+ this.ssp.unHighlightShow(a), this.cleanSets.add(() => {
212
+ this.ssp.highlightShow(a);
213
+ });
214
+ }
215
+ }
216
+ }
217
+ }
218
+ const { objectHandle: nt } = T.utils;
219
+ class at extends f {
220
+ constructor(t, s) {
221
+ super(t, s);
222
+ }
223
+ filterOpacityObject(t) {
224
+ const s = [];
225
+ return nt(t, (i) => {
226
+ this.ssp.viewport.scener.selectedObjects.opacity.has(i) || s.push(i);
227
+ }), s;
228
+ }
229
+ async exec(t) {
230
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = this.findProp("color", [n.READ_CTX, n.LOCAL]), o = this.findProp("opacity", [n.READ_CTX, n.LOCAL]), a = await t.getTarget?.(this);
231
+ if (s && i && o) {
232
+ const c = this.getValue(s, a), h = this.getValue(i), u = this.getValue(o);
233
+ if (c) {
234
+ const d = this.filterOpacityObject(c);
235
+ this.ssp.opacityShow(d, { color: h, opacity: u }), this.cleanSets.add(() => {
236
+ this.ssp.unOpacityShow(d);
237
+ });
238
+ }
239
+ }
240
+ }
241
+ }
242
+ const { objectHandle: ct } = T.utils;
243
+ class rt extends f {
244
+ constructor(t, s) {
245
+ super(t, s);
246
+ }
247
+ filterUnOpacityObject(t) {
248
+ const s = [];
249
+ return ct(t, (i) => {
250
+ this.ssp.viewport.scener.selectedObjects.opacity.has(i) && s.push(i);
251
+ }), s;
252
+ }
253
+ async exec(t) {
254
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = await t.getTarget?.(this);
255
+ if (s) {
256
+ const o = this.getValue(s, i);
257
+ if (o) {
258
+ const a = this.filterUnOpacityObject(o);
259
+ this.ssp.unOpacityShow(a), this.cleanSets.add(() => {
260
+ this.ssp.opacityShow(a);
261
+ });
262
+ }
263
+ }
264
+ }
265
+ }
266
+ const { objectHandle: lt } = T.utils;
267
+ class ht extends f {
268
+ constructor(t, s) {
269
+ super(t, s);
270
+ }
271
+ filterEmissiveObject(t) {
272
+ const s = [];
273
+ return lt(t, (i) => {
274
+ this.ssp.viewport.scener.selectedObjects.emissive.has(i) || s.push(i);
275
+ }), s;
276
+ }
277
+ async exec(t) {
278
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = this.findProp("color", [n.READ_CTX, n.LOCAL]), o = this.findProp("baseColor", [n.READ_CTX, n.LOCAL]), a = this.findProp("minOpacity", [n.READ_CTX, n.LOCAL]), c = this.findProp("maxOpacity", [n.READ_CTX, n.LOCAL]), h = this.findProp("duration", [n.READ_CTX, n.LOCAL]), u = await t.getTarget?.(this);
279
+ if (s && i && o && a && c && h) {
280
+ const d = this.getValue(s, u), C = this.getValue(i), P = this.getValue(o), x = this.getValue(a), p = this.getValue(c), O = this.getValue(h);
281
+ if (d) {
282
+ const A = this.filterEmissiveObject(d);
283
+ this.ssp.emissiveShow(A, {
284
+ color: C,
285
+ baseColor: P,
286
+ minOpacity: x,
287
+ maxOpacity: p,
288
+ duration: O
289
+ }), this.cleanSets.add(() => {
290
+ this.ssp.unEmissiveShow(A);
291
+ });
292
+ }
293
+ }
294
+ }
295
+ }
296
+ const { objectHandle: ut } = T.utils;
297
+ class dt extends f {
298
+ constructor(t, s) {
299
+ super(t, s);
300
+ }
301
+ filterUnEmissiveObject(t) {
302
+ const s = [];
303
+ return ut(t, (i) => {
304
+ this.ssp.viewport.scener.selectedObjects.emissive.has(i) && s.push(i);
305
+ }), s;
306
+ }
307
+ async exec(t) {
308
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = await t.getTarget?.(this);
309
+ if (s) {
310
+ const o = this.getValue(s, i);
311
+ if (o) {
312
+ const a = this.filterUnEmissiveObject(o);
313
+ this.ssp.unEmissiveShow(a), this.cleanSets.add(() => {
314
+ this.ssp.emissiveShow(a);
315
+ });
316
+ }
317
+ }
318
+ }
319
+ }
320
+ const y = Symbol("meshCache");
321
+ class pt extends f {
322
+ constructor(t, s) {
323
+ super(t, s);
324
+ }
325
+ async exec(t) {
326
+ const { viewport: { scene: s } } = this.ssp, i = await t.getTarget?.(this) || s;
327
+ t[y] || (t[y] = {});
328
+ const o = this.findProp("mesh", n.LOCAL), a = this.findProp("out", n.WRITE_CTX);
329
+ if (o && a) {
330
+ let c = null;
331
+ const h = l(o.value), u = l(a.value), d = t[y][h];
332
+ if (d) {
333
+ c = d;
334
+ return;
335
+ }
336
+ const C = _(i, h);
337
+ C && (c = C, t[y][h] = C), this.writeContext(u, c);
338
+ }
339
+ }
340
+ }
341
+ const M = Symbol("meshesCache");
342
+ class ft extends f {
343
+ constructor(t, s) {
344
+ super(t, s);
345
+ }
346
+ async exec(t) {
347
+ const { viewport: { scene: s } } = this.ssp, i = await t.getTarget?.(this) || s;
348
+ t[M] || (t[M] = {});
349
+ const o = this.findProp("meshes", n.LOCAL), a = this.findProp("out", n.WRITE_CTX);
350
+ if (o && a) {
351
+ const c = [], h = l(o.value), u = l(a.value);
352
+ h.forEach((d) => {
353
+ const C = t[M][d];
354
+ if (C) {
355
+ c.push(C);
356
+ return;
357
+ }
358
+ const P = _(i, d);
359
+ P && (c.push(P), t[M][d] = P);
360
+ }), this.writeContext(u, c);
361
+ }
362
+ }
363
+ }
364
+ class Ct extends f {
365
+ constructor(t, s) {
366
+ super(t, s);
367
+ }
368
+ async exec() {
369
+ const t = this.findProp("model", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
370
+ if (t && s) {
371
+ const i = l(t.value), o = l(s.value);
372
+ this.writeContext(o, E(this.ssp, i));
373
+ }
374
+ }
375
+ }
376
+ class Ot extends f {
377
+ constructor(t, s) {
378
+ super(t, s);
379
+ }
380
+ async exec() {
381
+ const t = this.findProp("models", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
382
+ if (t && s) {
383
+ const i = l(t.value), o = l(s.value);
384
+ this.writeContext(o, Gt(this.ssp, i));
385
+ }
386
+ }
387
+ }
388
+ class At extends f {
389
+ constructor(t, s) {
390
+ super(t, s);
391
+ }
392
+ async exec() {
393
+ const t = this.findProp("delay", n.LOCAL);
394
+ if (t) {
395
+ const s = l(t.value);
396
+ await T.utils.sleep(s);
397
+ }
398
+ }
399
+ }
400
+ class gt extends f {
401
+ constructor(t, s) {
402
+ super(t, s);
403
+ }
404
+ execFn(t) {
405
+ return new Function("sourceData", t)(this.ctx);
406
+ }
407
+ async exec() {
408
+ const t = this.findProp("conditaion_node", n.LOCAL);
409
+ if (t) {
410
+ const s = l(t.value), i = this.parser.edges.filter((o) => o.source === this.id);
411
+ s.forEach((o) => {
412
+ try {
413
+ if (this.execFn(o.value) !== !0) throw new Error();
414
+ } catch {
415
+ const c = i.find((u) => u.sourceHandle == String(o.id));
416
+ if (!c) return;
417
+ this.postNodes.find((u) => u.id === c.target)?.reject();
418
+ }
419
+ });
420
+ }
421
+ }
422
+ }
423
+ const { objectHandle: X } = T.utils;
424
+ class Pt extends f {
425
+ constructor(t, s) {
426
+ super(t, s);
427
+ }
428
+ filterShowObject(t) {
429
+ const s = [];
430
+ return X(t, (i) => {
431
+ i.visible === !1 && s.push(i);
432
+ }), s;
433
+ }
434
+ async exec(t) {
435
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = await t.getTarget?.(this);
436
+ if (s) {
437
+ const o = this.getValue(s, i);
438
+ if (o) {
439
+ const a = this.filterShowObject(o), c = (h) => {
440
+ X(a, (u) => {
441
+ u.visible = h;
442
+ }), this.ssp.render();
443
+ };
444
+ c(!0), this.cleanSets.add(() => c(!1));
445
+ }
446
+ }
447
+ }
448
+ }
449
+ const { objectHandle: U } = T.utils;
450
+ class Tt extends f {
451
+ constructor(t, s) {
452
+ super(t, s);
453
+ }
454
+ filterHideObject(t) {
455
+ const s = [];
456
+ return U(t, (i) => {
457
+ i.visible === !0 && s.push(i);
458
+ }), s;
459
+ }
460
+ async exec(t) {
461
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = await t.getTarget?.(this);
462
+ if (s) {
463
+ const o = this.getValue(s, i);
464
+ if (o) {
465
+ const a = this.filterHideObject(o), c = (h) => {
466
+ U(a, (u) => {
467
+ u.visible = h;
468
+ }), this.ssp.render();
469
+ };
470
+ c(!1), this.cleanSets.add(() => c(!0));
471
+ }
472
+ }
473
+ }
474
+ }
475
+ const { objectHandle: D } = T.utils;
476
+ class Et extends f {
477
+ constructor(t, s) {
478
+ super(t, s);
479
+ }
480
+ async exec(t) {
481
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = this.findProp("axis", [n.READ_CTX, n.LOCAL]), o = this.findProp("translate", [n.READ_CTX, n.LOCAL]), a = await t.getTarget?.(this);
482
+ if (s && i && o) {
483
+ const c = this.getValue(s, a), h = this.getValue(i), u = this.getValue(o);
484
+ if (c) {
485
+ const d = [];
486
+ D(c, (p) => {
487
+ d.push(p.position.clone());
488
+ });
489
+ const P = (p, O) => {
490
+ switch (h) {
491
+ case "x":
492
+ p.setX(O.x);
493
+ break;
494
+ case "y":
495
+ p.setY(O.y);
496
+ break;
497
+ case "z":
498
+ p.setZ(O.z);
499
+ break;
500
+ }
501
+ };
502
+ await (async () => {
503
+ const p = D(c, async (O) => {
504
+ const A = O.position.clone();
505
+ switch (h) {
506
+ case "x":
507
+ await this.ssp.animation(A, new b().set(A.x + u, A.y, A.z), { duration: 800 }, (g) => P(O.position, g));
508
+ break;
509
+ case "y":
510
+ await this.ssp.animation(A, new b().set(A.x, A.y + u, A.z), { duration: 800 }, (g) => P(O.position, g));
511
+ break;
512
+ case "z":
513
+ await this.ssp.animation(A, new b().set(A.x, A.y, A.z + u), { duration: 800 }, (g) => P(O.position, g));
514
+ break;
515
+ }
516
+ });
517
+ p instanceof Array ? await Promise.all(p) : await p, this.ssp.render();
518
+ })(), this.cleanSets.add(() => {
519
+ let p = 0;
520
+ D(c, (O) => {
521
+ O.position.copy(d[p++]);
522
+ });
523
+ });
524
+ }
525
+ }
526
+ }
527
+ }
528
+ const { objectHandle: v } = T.utils;
529
+ class wt extends f {
530
+ constructor(t, s) {
531
+ super(t, s);
532
+ }
533
+ async exec(t) {
534
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = this.findProp("axis", [n.READ_CTX, n.LOCAL]), o = this.findProp("scale", [n.READ_CTX, n.LOCAL]), a = await t.getTarget?.(this);
535
+ if (s && i && o) {
536
+ const c = this.getValue(s, a), h = this.getValue(i), u = this.getValue(o);
537
+ if (c) {
538
+ const d = [];
539
+ v(c, (p) => {
540
+ d.push(p.scale.clone());
541
+ });
542
+ const P = (p, O) => {
543
+ switch (h) {
544
+ case "x":
545
+ p.setX(O.x);
546
+ break;
547
+ case "y":
548
+ p.setY(O.y);
549
+ break;
550
+ case "z":
551
+ p.setZ(O.z);
552
+ break;
553
+ }
554
+ };
555
+ await (async () => {
556
+ const p = v(c, async (O) => {
557
+ const A = O.scale.clone();
558
+ switch (h) {
559
+ case "x":
560
+ await this.ssp.animation(A, new b().set(A.x * u, A.y, A.z), { duration: 800 }, (g) => P(O.scale, g));
561
+ break;
562
+ case "y":
563
+ await this.ssp.animation(A, new b().set(A.x, A.y * u, A.z), { duration: 800 }, (g) => P(O.scale, g));
564
+ break;
565
+ case "z":
566
+ await this.ssp.animation(A, new b().set(A.x, A.y, A.z * u), { duration: 800 }, (g) => P(O.scale, g));
567
+ break;
568
+ }
569
+ });
570
+ p instanceof Array ? await Promise.all(p) : await p, this.ssp.render();
571
+ })(), this.cleanSets.add(() => {
572
+ let p = 0;
573
+ v(c, (O) => {
574
+ O.scale.copy(d[p++]);
575
+ });
576
+ });
577
+ }
578
+ }
579
+ }
580
+ }
581
+ const { objectHandle: H } = T.utils;
582
+ class Lt extends f {
583
+ constructor(t, s) {
584
+ super(t, s);
585
+ }
586
+ async exec(t) {
587
+ const s = this.findProp("objects", [n.READ_CTX, n.LOCAL]), i = this.findProp("axis", [n.READ_CTX, n.LOCAL]), o = this.findProp("rotation", [n.READ_CTX, n.LOCAL]), a = await t.getTarget?.(this);
588
+ if (s && i && o) {
589
+ const c = this.getValue(s, a), h = this.getValue(i), u = this.getValue(o);
590
+ if (c) {
591
+ const d = [];
592
+ H(c, (p) => {
593
+ d.push(p.rotation.clone());
594
+ });
595
+ const P = (p, O) => {
596
+ switch (h) {
597
+ case "x":
598
+ p.x = O.x;
599
+ break;
600
+ case "y":
601
+ p.y = O.y;
602
+ break;
603
+ case "z":
604
+ p.z = O.z;
605
+ break;
606
+ }
607
+ };
608
+ await (async () => {
609
+ const p = u / 180 * Math.PI, O = H(c, async (A) => {
610
+ const g = A.rotation.clone();
611
+ switch (h) {
612
+ case "x":
613
+ await this.ssp.animation(g, new S().set(g.x + p, g.y, g.z), { duration: 800 }, (m) => P(A.rotation, m));
614
+ break;
615
+ case "y":
616
+ await this.ssp.animation(g, new S().set(g.x, g.y + p, g.z), { duration: 800 }, (m) => P(A.rotation, m));
617
+ break;
618
+ case "z":
619
+ await this.ssp.animation(g, new S().set(g.x, g.y, g.z + p), { duration: 800 }, (m) => P(A.rotation, m));
620
+ break;
621
+ }
622
+ });
623
+ O instanceof Array ? await Promise.all(O) : await O, this.ssp.render();
624
+ })(), this.cleanSets.add(() => {
625
+ let p = 0;
626
+ H(c, (O) => {
627
+ O.rotation.copy(d[p++]);
628
+ });
629
+ });
630
+ }
631
+ }
632
+ }
633
+ }
634
+ class bt extends f {
635
+ constructor(t, s) {
636
+ super(t, s);
637
+ }
638
+ async exec() {
639
+ const t = this.findProp("viewpoint", [n.READ_CTX, n.LOCAL]);
640
+ if (t) {
641
+ const s = l(this.getValue(t));
642
+ s && this.ssp.setCameraViewpoint(s, !0);
643
+ }
644
+ }
645
+ }
646
+ class mt extends f {
647
+ constructor(t, s) {
648
+ super(t, s);
649
+ }
650
+ async exec() {
651
+ const t = this.findProp("space", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
652
+ if (t && s) {
653
+ const i = l(t.value), o = l(s.value);
654
+ this.writeContext(o, E(this.ssp, i));
655
+ }
656
+ }
657
+ }
658
+ class It extends f {
659
+ constructor(t, s) {
660
+ super(t, s);
661
+ }
662
+ async exec() {
663
+ const t = this.findProp("spaces", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
664
+ if (t && s) {
665
+ const i = l(t.value), o = l(s.value), a = i.map((c) => E(this.ssp, c));
666
+ this.writeContext(o, a);
667
+ }
668
+ }
669
+ }
670
+ class Nt extends f {
671
+ constructor(t, s) {
672
+ super(t, s);
673
+ }
674
+ async exec(t) {
675
+ const s = this.findProp("poi", n.LOCAL), i = this.findProp("out", n.WRITE_CTX);
676
+ if (s && i) {
677
+ const o = l(s.value), a = l(i.value);
678
+ this.writeContext(a, E(this.ssp, o));
679
+ }
680
+ }
681
+ }
682
+ class _t extends f {
683
+ constructor(t, s) {
684
+ super(t, s);
685
+ }
686
+ async exec(t) {
687
+ const s = this.findProp("pois", n.LOCAL), i = this.findProp("out", n.WRITE_CTX);
688
+ if (s && i) {
689
+ const o = l(s.value), a = l(i.value), c = o.map((h) => E(this.ssp, h));
690
+ this.writeContext(a, c);
691
+ }
692
+ }
693
+ }
694
+ class xt extends f {
695
+ constructor(t, s) {
696
+ super(t, s);
697
+ }
698
+ async exec() {
699
+ const t = this.findProp("value", n.LOCAL), s = this.findProp("object", n.LOCAL), i = this.findProp("out", n.WRITE_CTX), o = this.findProp("extraction", n.LOCAL);
700
+ if (t && i && o && s) {
701
+ const a = l(o.value), c = l(i.value), h = l(s.value), u = this.getValue(s);
702
+ let d = l(t.value);
703
+ if (this.ctx._userDataMap) {
704
+ const C = this.ctx._userDataMap.get(h);
705
+ C && (d = C[a]);
706
+ } else if (u && u.userData.properties) {
707
+ const C = u.userData.properties.find((P) => P.key === a);
708
+ C && C.value !== void 0 && (d = C.value);
709
+ }
710
+ this.writeContext(c, d);
711
+ }
712
+ }
713
+ }
714
+ class yt extends f {
715
+ constructor(t, s) {
716
+ super(t, s);
717
+ }
718
+ async exec() {
719
+ const t = this.findProp("model", n.LOCAL);
720
+ if (t) {
721
+ const s = l(t.value), i = new Function("sourceData", s);
722
+ for (const o in this.ctx) {
723
+ const a = i(this.ctx[o]);
724
+ (a == null || a === !1) && delete this.ctx[o];
725
+ }
726
+ }
727
+ }
728
+ }
729
+ class Mt extends f {
730
+ constructor(t, s) {
731
+ super(t, s);
732
+ }
733
+ async exec() {
734
+ const t = this.findProp("path", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
735
+ if (t && s) {
736
+ const i = l(t.value), o = l(s.value);
737
+ this.writeContext(o, E(this.ssp, i));
738
+ }
739
+ }
740
+ }
741
+ class St extends f {
742
+ constructor(t, s) {
743
+ super(t, s);
744
+ }
745
+ async exec() {
746
+ const t = this.findProp("paths", n.LOCAL), s = this.findProp("out", n.WRITE_CTX);
747
+ if (t && s) {
748
+ const i = l(t.value), o = l(s.value), a = i.map((c) => E(this.ssp, c));
749
+ this.writeContext(o, a);
750
+ }
751
+ }
752
+ }
753
+ class Dt extends f {
754
+ constructor(t, s) {
755
+ super(t, s);
756
+ }
757
+ async exec() {
758
+ const t = this.findProp("object", [n.READ_CTX, n.LOCAL]), s = this.findProp("data", n.LOCAL), i = this.findProp("source", n.WRITE_CTX);
759
+ if (t && s && i) {
760
+ let o = l(t.value);
761
+ const a = l(s.value), c = l(i.value);
762
+ if (c && (o = c), o && a) {
763
+ this.ctx._userDataMap || (this.ctx._userDataMap = /* @__PURE__ */ new Map());
764
+ const h = this.ctx._userDataMap.get(o);
765
+ h ? Object.assign(h, a) : this.ctx._userDataMap.set(o, a);
766
+ }
767
+ }
768
+ }
769
+ }
770
+ class vt extends f {
771
+ constructor(t, s) {
772
+ super(t, s);
773
+ }
774
+ async exec(t) {
775
+ let s = await t.getTarget?.(this);
776
+ if (!s) {
777
+ const o = this.findProp("model", [n.READ_CTX, n.LOCAL]);
778
+ o && (s = this.getValue(o));
779
+ }
780
+ const i = this.findProp("animation", [n.READ_CTX, n.LOCAL]);
781
+ if (s && i) {
782
+ let o;
783
+ if (i.type === n.READ_CTX) {
784
+ const c = this.parser.getVariableNameById(l(i.value));
785
+ o = this.readContext(c);
786
+ } else
787
+ o = l(i.value);
788
+ const a = s.animations[o];
789
+ a && (this.ssp.playModelAnimation(s, a), this.cleanSets.add(() => {
790
+ this.ssp.stopModelAnimation(s, a);
791
+ }));
792
+ }
793
+ }
794
+ }
795
+ class Ht extends f {
796
+ constructor(t, s) {
797
+ super(t, s);
798
+ }
799
+ async exec(t) {
800
+ let s = await t.getTarget?.(this);
801
+ if (!s) {
802
+ const o = this.findProp("model", [n.READ_CTX, n.LOCAL]);
803
+ o && (s = this.getValue(o));
804
+ }
805
+ const i = this.findProp("animation", [n.READ_CTX, n.LOCAL]);
806
+ if (s && i) {
807
+ let o;
808
+ if (i.type === n.READ_CTX) {
809
+ const c = this.parser.getVariableNameById(l(i.value));
810
+ o = this.readContext(c);
811
+ } else
812
+ o = l(i.value);
813
+ const a = s.animations[o];
814
+ a && this.ssp.stopModelAnimation(s, a);
815
+ }
816
+ }
817
+ }
818
+ const I = /* @__PURE__ */ new Map();
819
+ async function Vt(e, t, s) {
820
+ const { id: i, keyframes: o } = s, a = new k(e, t);
821
+ I.has(i) || I.set(i, /* @__PURE__ */ new Set()), I.get(i)?.add(a), await a.play(o);
822
+ }
823
+ function B(e) {
824
+ I.get(e)?.forEach((t) => t.stop()), I.get(e)?.clear();
825
+ }
826
+ class Rt extends f {
827
+ constructor(t, s) {
828
+ super(t, s);
829
+ }
830
+ async exec(t) {
831
+ const s = this.findProp("model", [n.READ_CTX, n.LOCAL]), i = this.findProp("animation", n.LOCAL), o = this.findProp("wait", n.LOCAL);
832
+ if (s && i && o) {
833
+ const a = this.getValue(s), c = l(i.value), h = l(o.value);
834
+ if (a) {
835
+ const u = await t.getAnimations?.(this, a, c);
836
+ if (u) {
837
+ const d = u.find((C) => C.id === c);
838
+ d && await W(async () => {
839
+ const C = a.matrix.clone();
840
+ await Vt(this.ssp, a, d), this.cleanSets.add(() => {
841
+ B(d.id), a && C.decompose(a.position, a.quaternion, a.scale);
842
+ });
843
+ }, h);
844
+ }
845
+ }
846
+ }
847
+ }
848
+ }
849
+ class jt extends f {
850
+ constructor(t, s) {
851
+ super(t, s);
852
+ }
853
+ async exec() {
854
+ const t = this.findProp("animation", n.LOCAL);
855
+ if (t) {
856
+ const s = l(t.value);
857
+ B(s);
858
+ }
859
+ }
860
+ }
861
+ const N = /* @__PURE__ */ new Map();
862
+ async function Xt(e, t, s) {
863
+ const { id: i, keyframes: o } = s, a = new k(e, t);
864
+ N.has(i) || N.set(i, /* @__PURE__ */ new Set()), N.get(i)?.add(a), await a.play(o);
865
+ }
866
+ function G(e) {
867
+ N.get(e)?.forEach((t) => t.stop()), N.get(e)?.clear();
868
+ }
869
+ class Ut extends f {
870
+ constructor(t, s) {
871
+ super(t, s);
872
+ }
873
+ async exec(t) {
874
+ const s = this.findProp("mesh", [n.READ_CTX, n.LOCAL]), i = this.findProp("animation", n.LOCAL), o = this.findProp("wait", n.LOCAL);
875
+ if (s && i && o) {
876
+ const a = this.getValue(s), c = l(i.value), h = l(o.value);
877
+ if (a) {
878
+ const u = await t.getComponentAnimations?.(this, a, c);
879
+ if (u) {
880
+ const d = u.find((C) => C.id === c);
881
+ if (d) {
882
+ let C = null;
883
+ s.valueType === "Mesh" ? C = a : s.valueType === "Model" && (C = _(a, d.refId)), C && await W(async () => {
884
+ if (C) {
885
+ const P = C.matrix.clone();
886
+ await Xt(this.ssp, C, d), this.cleanSets.add(() => {
887
+ G(d.id), C && P.decompose(C.position, C.quaternion, C.scale);
888
+ });
889
+ }
890
+ }, h);
891
+ }
892
+ }
893
+ }
894
+ }
895
+ }
896
+ }
897
+ class kt extends f {
898
+ constructor(t, s) {
899
+ super(t, s);
900
+ }
901
+ async exec() {
902
+ const t = this.findProp("animation", n.LOCAL);
903
+ if (t) {
904
+ const s = l(t.value);
905
+ G(s);
906
+ }
907
+ }
908
+ }
909
+ function Bt(e, t) {
910
+ switch (t.type) {
911
+ case r.START:
912
+ return new Z(e, t);
913
+ case r.COLOR:
914
+ return new Q(e, t);
915
+ case r.NUMBER:
916
+ return new tt(e, t);
917
+ case r.HIGHLIGHT:
918
+ return new et(e, t);
919
+ case r.UN_HIGHLIGHT:
920
+ return new ot(e, t);
921
+ case r.OPACITY:
922
+ return new at(e, t);
923
+ case r.UN_OPACITY:
924
+ return new rt(e, t);
925
+ case r.EMISSIVE:
926
+ return new ht(e, t);
927
+ case r.UN_EMISSIVE:
928
+ return new dt(e, t);
929
+ // 获取对象
930
+ case r.MESH:
931
+ return new pt(e, t);
932
+ case r.MESHES:
933
+ return new ft(e, t);
934
+ case r.MODEL:
935
+ return new Ct(e, t);
936
+ case r.MODELS:
937
+ return new Ot(e, t);
938
+ case r.SPACE:
939
+ return new mt(e, t);
940
+ case r.SPACES:
941
+ return new It(e, t);
942
+ case r.POIS:
943
+ return new _t(e, t);
944
+ case r.POI:
945
+ return new Nt(e, t);
946
+ case r.PATH:
947
+ return new Mt(e, t);
948
+ case r.PATHS:
949
+ return new St(e, t);
950
+ // 逻辑节点
951
+ case r.DELAY:
952
+ return new At(e, t);
953
+ case r.CONDITION_NODE:
954
+ return new gt(e, t);
955
+ // 显示隐藏
956
+ case r.SHOW:
957
+ return new Pt(e, t);
958
+ case r.HIDE:
959
+ return new Tt(e, t);
960
+ // 动画相关
961
+ case r.CLIP_ANIMATION:
962
+ return new vt(e, t);
963
+ case r.UN_CLIP_ANIMATION:
964
+ return new Ht(e, t);
965
+ case r.TWEEN_ANIMATION:
966
+ return new Rt(e, t);
967
+ case r.UN_TWEEN_ANIMATION:
968
+ return new jt(e, t);
969
+ case r.COMPONENT_TWEEN_ANIMATION:
970
+ return new Ut(e, t);
971
+ case r.UN_COMPONENT_TWEEN_ANIMATION:
972
+ return new kt(e, t);
973
+ // 移动
974
+ case r.TRANSLATE:
975
+ return new Et(e, t);
976
+ case r.ROTATE:
977
+ return new Lt(e, t);
978
+ case r.SCALE:
979
+ return new wt(e, t);
980
+ case r.FLY_TO:
981
+ return new bt(e, t);
982
+ // 数据处理节点
983
+ case r.DATA_EXTRACTION:
984
+ return new xt(e, t);
985
+ case r.DATA_FILTER:
986
+ return new yt(e, t);
987
+ case r.USER_DATA_NODE:
988
+ return new Dt(e, t);
989
+ default:
990
+ return new f(e, t);
991
+ }
992
+ }
993
+ function l(e) {
994
+ return JSON.parse(e);
995
+ }
996
+ async function W(e, t) {
997
+ t ? await e() : e();
998
+ }
999
+ function Gt(e, t) {
1000
+ return t.map((s) => e.getObjectById(s)).filter(Boolean);
1001
+ }
1002
+ function E(e, t, s) {
1003
+ const i = e.getObjectById(t);
1004
+ if (i)
1005
+ return i;
1006
+ {
1007
+ const { viewport: { scene: o } } = e;
1008
+ return _(s ?? o, t);
1009
+ }
1010
+ }
1011
+ function _(e, t) {
1012
+ if (e.userData.key === t || e.uuid === t) return e;
1013
+ for (let s = 0, i = e.children.length; s < i; s++) {
1014
+ const o = e.children[s], a = _(o, t);
1015
+ if (a !== null)
1016
+ return a;
1017
+ }
1018
+ return null;
1019
+ }
1020
+ const { utils: { sleep: Wt } } = T;
1021
+ class Ft extends z {
1022
+ ssp;
1023
+ flow;
1024
+ nodes;
1025
+ nodesMap;
1026
+ edges;
1027
+ edgesMap;
1028
+ onNodeBefore = null;
1029
+ onNodeAfter = null;
1030
+ constructor(t, s) {
1031
+ super(), this.ssp = t, this.flow = s, this.nodes = [], this.nodesMap = /* @__PURE__ */ new Map(), this.edges = [], this.edgesMap = /* @__PURE__ */ new Map();
1032
+ }
1033
+ addNode(t) {
1034
+ this.nodes.push(t), this.nodesMap.set(t.id, t);
1035
+ }
1036
+ addEdge(t) {
1037
+ this.edges.push(t), this.edgesMap.set(t.id, t);
1038
+ }
1039
+ getNodeById(t) {
1040
+ return this.nodesMap.get(t);
1041
+ }
1042
+ getEdgeById(t) {
1043
+ return this.edgesMap.get(t);
1044
+ }
1045
+ clear() {
1046
+ this.nodes.length = 0, this.nodesMap.clear(), this.edges.length = 0, this.edgesMap.clear();
1047
+ }
1048
+ /**
1049
+ * 解析流程
1050
+ */
1051
+ parse() {
1052
+ this.clear();
1053
+ const { nodes: t, edges: s } = this.flow;
1054
+ t.forEach((i) => {
1055
+ const o = Bt(this, i);
1056
+ this.addNode(o);
1057
+ }), s.forEach((i) => {
1058
+ const o = new K(i);
1059
+ this.addEdge(o);
1060
+ const a = this.getNodeById(i.source), c = this.getNodeById(i.target);
1061
+ a && c && (a.postNodes.push(c), c.prevNodes.push(a));
1062
+ });
1063
+ }
1064
+ /**
1065
+ * 执行流程
1066
+ * @param startNode
1067
+ * @param ctx
1068
+ */
1069
+ async run(t = {}, s = { preload: !1 }) {
1070
+ const { preload: i } = s, a = this.nodes.filter((c) => c.prevNodes.length || c.postNodes.length).map((c) => c.run(t, { preload: i }));
1071
+ await Promise.allSettled(a);
1072
+ }
1073
+ /**
1074
+ * 调试流程
1075
+ */
1076
+ async debug(t = {}, s = 1500) {
1077
+ const i = this.onNodeAfter;
1078
+ this.onNodeAfter = async (o) => {
1079
+ await Wt(s), i?.(o);
1080
+ }, await this.run(t);
1081
+ }
1082
+ /**
1083
+ * 停止流程
1084
+ */
1085
+ stop() {
1086
+ this.nodes.forEach((t) => t.reject(new Error("Flow stopped")));
1087
+ }
1088
+ /**
1089
+ * 清理流程
1090
+ */
1091
+ cleanup() {
1092
+ this.nodes.sort((t, s) => s.execOrder - t.execOrder).forEach((t) => t.cleanup());
1093
+ }
1094
+ getVariableNameById(t) {
1095
+ const s = this.nodes.find((i) => i.id === t);
1096
+ if (s) {
1097
+ const i = s.props.find((o) => o.name === "out");
1098
+ return i ? l(i.value) : null;
1099
+ }
1100
+ return null;
1101
+ }
1102
+ dispose() {
1103
+ this.stop(), this.cleanup();
1104
+ }
1105
+ }
1106
+ class zt extends Ft {
1107
+ flow;
1108
+ constructor(t, s) {
1109
+ super(t, s), this.flow = s;
1110
+ }
1111
+ }
1112
+ const R = (e, t) => e.userData.key === t ? e : e.parent ? R(e.parent, t) : !1, { groupBy: Yt, asyncRunWithCode: $t } = T.utils;
1113
+ class Kt {
1114
+ ssp;
1115
+ interaction;
1116
+ flows;
1117
+ flowsMap;
1118
+ options;
1119
+ disposables = [];
1120
+ status = "ready";
1121
+ target;
1122
+ constructor(t, s, i, o) {
1123
+ this.ssp = t, this.interaction = s, this.flows = i, this.flowsMap = Yt(i, "id"), this.options = o || {}, this.init();
1124
+ }
1125
+ init() {
1126
+ switch (this.interaction.type) {
1127
+ case L.MOUSE_CLICK:
1128
+ this.initMouseClick();
1129
+ break;
1130
+ case L.MOUSE_DB_CLICK:
1131
+ this.initMouseDbClick();
1132
+ break;
1133
+ case L.MOUSE_RIGHT_CLICK:
1134
+ this.initMouseRightClick();
1135
+ break;
1136
+ case L.LOADED:
1137
+ this.initLoaded();
1138
+ break;
1139
+ case L.THING_PROP_CHANGE:
1140
+ this.initThingPropChange();
1141
+ break;
1142
+ case L.THING_EVENT:
1143
+ this.initThingEvent();
1144
+ break;
1145
+ case L.MODEL_PROP_CHANGE:
1146
+ this.initModelPropChange();
1147
+ break;
1148
+ }
1149
+ }
1150
+ // 获取交互触发
1151
+ async getObsTarget(t) {
1152
+ const { obsType: s, obsTargets: i, editionId: o } = this.interaction;
1153
+ if (s === j.GLOBAL)
1154
+ return null;
1155
+ if (s === j.INSTANCE) {
1156
+ let a;
1157
+ o ? (a = this.ssp.getModelById(o), a || console.warn("Target not found:", o)) : a = i?.map((c) => {
1158
+ const h = this.ssp.getModelById(c);
1159
+ return h || console.warn("Target not found:", i[0]), h;
1160
+ })[0];
1161
+ }
1162
+ return null;
1163
+ }
1164
+ // 模型事件触发
1165
+ modelHandler(t) {
1166
+ const { target: s, currentTarget: i } = t, o = this.interaction.editionId;
1167
+ o ? (s.sid === o || s.userData.familyId === o) && R(i, this.interaction.modelId) && (this.target = s, this.execBehavior()) : this.interaction.obsTargets?.forEach((a) => {
1168
+ (a === s.userData.id || a === s.userData.sid) && (this.target = s, this.execBehavior());
1169
+ });
1170
+ }
1171
+ runFlowByIds(t) {
1172
+ const s = this.target ? async () => this.target : this.getObsTarget.bind(this);
1173
+ t.forEach((i) => {
1174
+ const o = this.flowsMap.get(i);
1175
+ if (o) {
1176
+ const a = new Y(this.ssp, o[0]);
1177
+ a.parse(), $t(
1178
+ () => a.run({
1179
+ getTarget: s,
1180
+ getAnimations: this.options.getAnimations,
1181
+ getComponentAnimations: this.options.getComponentAnimations
1182
+ })
1183
+ );
1184
+ }
1185
+ });
1186
+ }
1187
+ async execBehavior() {
1188
+ if (this.interaction.active ?? !0)
1189
+ try {
1190
+ this.status = "running";
1191
+ const { behaviors: s } = this.interaction;
1192
+ s?.forEach((i) => {
1193
+ switch (i.action) {
1194
+ case $.FLOW:
1195
+ i.actionRefs && this.runFlowByIds(i.actionRefs);
1196
+ break;
1197
+ }
1198
+ }), this.options?.onTrigger && this.options?.onTrigger(this.interaction);
1199
+ } catch (s) {
1200
+ this.status = "error", this.options?.onError && this.options?.onError(s);
1201
+ }
1202
+ }
1203
+ initMouseClick() {
1204
+ const t = this.modelHandler.bind(this);
1205
+ this.ssp.signals.modelClick.add(t), this.disposables.push(() => this.ssp.signals.modelClick.remove(t));
1206
+ }
1207
+ initMouseDbClick() {
1208
+ const t = this.modelHandler.bind(this);
1209
+ this.ssp.signals.modelDblClick.add(t), this.disposables.push(() => this.ssp.signals.modelDblClick.remove(t));
1210
+ }
1211
+ initMouseRightClick() {
1212
+ const t = this.modelHandler.bind(this);
1213
+ this.ssp.signals.modelRightClick.add(t), this.disposables.push(() => this.ssp.signals.modelRightClick.remove(t));
1214
+ }
1215
+ initLoaded() {
1216
+ (() => {
1217
+ this.execBehavior();
1218
+ })();
1219
+ }
1220
+ modelPropChangeHandler(t) {
1221
+ if (t?.target?.refId && this.ssp.utils.propertiesCtx.source !== "code") {
1222
+ if (t.mode === "component") {
1223
+ const s = this.interaction.obsProps?.[0];
1224
+ if (!s) return;
1225
+ const i = JSON.parse(s);
1226
+ if (!(i.group == t.target?.group && i.key == t.target?.key)) return;
1227
+ } else {
1228
+ const s = t.target?.modelId || t.target?.refId;
1229
+ if (this.interaction.obsTargets) {
1230
+ if (!this.interaction.obsTargets.includes(s)) return;
1231
+ } else {
1232
+ const i = this.ssp.getObjectByUserDataProperty("familyId", this.interaction.editionId)[0];
1233
+ if (!(i && i.userData.id === s)) return;
1234
+ }
1235
+ }
1236
+ this.interaction.editionId && (this.target = this.ssp.getObjectByUserDataProperty("familyId", this.interaction.editionId)[0]), this.execBehavior();
1237
+ }
1238
+ }
1239
+ initModelPropChange() {
1240
+ const t = this.modelPropChangeHandler.bind(this);
1241
+ this.ssp.signals.propertiesChanged.add(t), this.disposables.push(() => this.ssp.signals.propertiesChanged.remove(t));
1242
+ }
1243
+ initThingPropChange() {
1244
+ }
1245
+ initThingEvent() {
1246
+ }
1247
+ dispose() {
1248
+ this.disposables.forEach((t) => t());
1249
+ }
1250
+ }
1251
+ var Jt = /* @__PURE__ */ ((e) => (e.GLOBAL = "GLOBAL", e.SELF = "SELF", e.OTHER = "OTHER", e))(Jt || {}), F = /* @__PURE__ */ ((e) => (e.FLOW = "FLOW", e.ANIMATION = "ANIMATION", e.DELAY = "DELAY", e))(F || {}), V = /* @__PURE__ */ ((e) => (e.GLOBAL = "GLOBAL", e.INSTANCE = "INSTANCE", e.FAMILY = "FAMILY", e))(V || {}), w = /* @__PURE__ */ ((e) => (e.MOUSE_CLICK = "MOUSE_CLICK", e.MOUSE_DB_CLICK = "MOUSE_DB_CLICK", e.MOUSE_RIGHT_CLICK = "MOUSE_RIGHT_CLICK", e.THING_PROP_CHANGE = "THING_PROP_CHANGE", e.THING_EVENT = "THING_EVENT", e.LOADED = "LOADED", e.MODEL_PROP_CHANGE = "MODEL_PROP_CHANGE", e))(w || {});
1252
+ const { groupBy: qt, asyncRunWithCode: Zt } = T.utils;
1253
+ class is extends Kt {
1254
+ flows;
1255
+ flowsMap;
1256
+ constructor(t, s, i, o) {
1257
+ super(t, s, i, o), this.flows = i, this.flowsMap = qt(i, "id");
1258
+ }
1259
+ init() {
1260
+ switch (this.interaction.type) {
1261
+ case w.MOUSE_CLICK:
1262
+ this.initMouseClick();
1263
+ break;
1264
+ case w.MOUSE_DB_CLICK:
1265
+ this.initMouseDbClick();
1266
+ break;
1267
+ case w.MOUSE_RIGHT_CLICK:
1268
+ this.initMouseRightClick();
1269
+ break;
1270
+ case w.LOADED:
1271
+ this.initLoaded();
1272
+ break;
1273
+ case w.THING_PROP_CHANGE:
1274
+ this.initThingPropChange();
1275
+ break;
1276
+ case w.THING_EVENT:
1277
+ this.initThingEvent();
1278
+ break;
1279
+ case w.MODEL_PROP_CHANGE:
1280
+ this.initModelPropChange();
1281
+ break;
1282
+ }
1283
+ }
1284
+ // 获取交互触发的Mesh
1285
+ async getComponentObsTarget(t) {
1286
+ const { obsType: s, obsTargets: i } = this.interaction;
1287
+ if (s === V.GLOBAL)
1288
+ return null;
1289
+ if (s === V.INSTANCE) {
1290
+ const o = i?.map((a) => {
1291
+ const c = E(this.ssp, a);
1292
+ return c || console.warn("Component Target not found:", a), c;
1293
+ });
1294
+ return o ? o[0] : null;
1295
+ }
1296
+ return null;
1297
+ }
1298
+ // 模型事件触发
1299
+ modelHandler(t) {
1300
+ const { currentTarget: s } = t;
1301
+ this.interaction.obsTargets?.forEach((i) => {
1302
+ R(s, i) && this.execBehavior();
1303
+ });
1304
+ }
1305
+ // 物模型事件触发
1306
+ componentThingModelHandler(t) {
1307
+ const { propKey: s } = t;
1308
+ this.interaction.obsProps?.forEach((i) => {
1309
+ i === s && this.execBehavior();
1310
+ });
1311
+ }
1312
+ runFlowByIds(t) {
1313
+ const s = this.getComponentObsTarget.bind(this);
1314
+ t.forEach((i) => {
1315
+ const o = this.flowsMap.get(i);
1316
+ if (o) {
1317
+ const a = new zt(this.ssp, o[0]);
1318
+ a.parse(), Zt(
1319
+ () => a.run({
1320
+ getTarget: s
1321
+ })
1322
+ );
1323
+ }
1324
+ });
1325
+ }
1326
+ async execBehavior() {
1327
+ try {
1328
+ const { behaviors: t } = this.interaction;
1329
+ t?.forEach((s) => {
1330
+ switch (s.action) {
1331
+ case F.FLOW:
1332
+ s.actionRefs && this.runFlowByIds(s.actionRefs);
1333
+ break;
1334
+ }
1335
+ }), this.options?.onTrigger && this.options?.onTrigger(this.interaction);
1336
+ } catch (t) {
1337
+ this.options?.onError && this.options?.onError(t);
1338
+ }
1339
+ }
1340
+ initLoaded() {
1341
+ const t = () => {
1342
+ this.execBehavior();
1343
+ };
1344
+ this.getComponentObsTarget().then((s) => {
1345
+ s && (s.addEventListener("load", t), this.disposables.push(() => s.removeEventListener("load", t)));
1346
+ });
1347
+ }
1348
+ initThingPropChange() {
1349
+ const t = this.componentThingModelHandler.bind(this);
1350
+ this.ssp.signals.thingModelPropsChange.add(t), this.disposables.push(() => this.ssp.signals.thingModelPropsChange.remove(t));
1351
+ }
1352
+ initThingEvent() {
1353
+ }
1354
+ onThingPropChange(t) {
1355
+ this.ssp.signals.thingModelPropsChange.dispatch({
1356
+ propKey: t
1357
+ });
1358
+ }
1359
+ }
1360
+ export {
1361
+ zt as ComponentFlowParser,
1362
+ is as ComponentTrigger,
1363
+ Ft as FlowParser,
1364
+ F as InteractionAction,
1365
+ Jt as InteractionActionType,
1366
+ V as InteractionObsType,
1367
+ w as InteractionType,
1368
+ f as Node,
1369
+ n as NodePropTypeEnum,
1370
+ r as NodeTypeEnum,
1371
+ Kt as Trigger
1372
+ };