@galacean/cli 2.0.0-alpha.12 → 2.0.0-alpha.15
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/cli.bundle.cjs +154 -140
- package/dist/viewport-client/_static/Accordion-930aedee.js +1 -0
- package/dist/viewport-client/_static/{AmbientLightAsset-f70b95f1.js → AmbientLightAsset-f9c1eb91.js} +2 -2
- package/dist/viewport-client/_static/AnimationClipAsset-61699477.js +1 -0
- package/dist/viewport-client/_static/AnimatorControllerAsset-1c05f4db.js +1 -0
- package/dist/viewport-client/_static/AnimatorStore-6a3679e5.js +1 -0
- package/dist/viewport-client/_static/{AssetViewer-bc198e16.js → AssetViewer-0ce46fa1.js} +1 -1
- package/dist/viewport-client/_static/AudioAsset-5127eeec.js +1 -0
- package/dist/viewport-client/_static/AudioComponent-18a3e59f.js +1 -0
- package/dist/viewport-client/_static/{Callout-cb4a55ff.js → Callout-b6ac1af7.js} +1 -1
- package/dist/viewport-client/_static/CameraComponent-0a115258.js +1 -0
- package/dist/viewport-client/_static/{Component-f923abb1.js → Component-746be670.js} +1 -1
- package/dist/viewport-client/_static/DirectLight-4c53e9f6.js +1 -0
- package/dist/viewport-client/_static/FontAsset-a3a92f7d.js +5 -0
- package/dist/viewport-client/_static/FormItemArray-a2f72cf1.js +6 -0
- package/dist/viewport-client/_static/{GlTFAsset-9c68f862.js → GlTFAsset-5f37feef.js} +9 -9
- package/dist/viewport-client/_static/IconEdit-2c768a0a.js +6 -0
- package/dist/viewport-client/_static/{IconPointFilled-a304fd34.js → IconPointFilled-209638e2.js} +1 -1
- package/dist/viewport-client/_static/LightBaseComponent-51d498ea.js +1 -0
- package/dist/viewport-client/_static/LottieAnimationComponent-bff0244b.js +1 -0
- package/dist/viewport-client/_static/LottieAsset-9d3ef507.js +6 -0
- package/dist/viewport-client/_static/MarkdownAsset-a17933fb.js +1 -0
- package/dist/viewport-client/_static/MaterialAsset-3b56ac00.js +1 -0
- package/dist/viewport-client/_static/MaterialInspector-a36197f2.js +1 -0
- package/dist/viewport-client/_static/Menu-0a7dbec0.js +17 -0
- package/dist/viewport-client/_static/MeshAsset-2cf47eb2.js +1 -0
- package/dist/viewport-client/_static/MeshRendererBaseComponent-4a3af376.js +1 -0
- package/dist/viewport-client/_static/MeshRendererComponent-ac4c3954.js +1 -0
- package/dist/viewport-client/_static/{MeshThumbnail-49273f71.js → MeshThumbnail-25cd4a13.js} +1 -1
- package/dist/viewport-client/_static/ParticleRendererComponent-0a470dee.js +26 -0
- package/dist/viewport-client/_static/PhysicsMaterialAsset-d87d35aa.js +1 -0
- package/dist/viewport-client/_static/PhysicsStore-c283b2be.js +1 -0
- package/dist/viewport-client/_static/PointLight-b7de209f.js +1 -0
- package/dist/viewport-client/_static/PostProcessComponent-d4c9ef58.js +6 -0
- package/dist/viewport-client/_static/PrefabAsset-d0c0cd25.js +1 -0
- package/dist/viewport-client/_static/PrimitiveMesh-35092ad0.js +1 -0
- package/dist/viewport-client/_static/ProxyConfigs-ad92ebc7.js +1 -0
- package/dist/viewport-client/_static/{ReferencedMaterial-a87818f3.js → ReferencedMaterial-800a1955.js} +1 -1
- package/dist/viewport-client/_static/RenderTargetAsset-a003f9f5.js +1 -0
- package/dist/viewport-client/_static/SceneAsset-87f2ea92.js +1 -0
- package/dist/viewport-client/_static/{ShaderAsset-cb3ff628.js → ShaderAsset-98ce1f70.js} +6 -6
- package/dist/viewport-client/_static/ShaderChunkAsset-e9072307.js +5 -0
- package/dist/viewport-client/_static/{ShaderUIScriptAsset-d13fa4e2.js → ShaderUIScriptAsset-ac824e68.js} +5 -5
- package/dist/viewport-client/_static/SkinnedMeshRendererComponent-5f34bf46.js +1 -0
- package/dist/viewport-client/_static/SpineAnimationComponent-7c5db747.js +1 -0
- package/dist/viewport-client/_static/SpineSkeletonDataAsset-5b202ba0.js +1 -0
- package/dist/viewport-client/_static/SpotLight-2b4e593e.js +1 -0
- package/dist/viewport-client/_static/SpriteAsset-4e895da5.js +6 -0
- package/dist/viewport-client/_static/SpriteAtlasAsset-c2894c12.js +1 -0
- package/dist/viewport-client/_static/SpriteBaseComponent-a75e84c1.js +1 -0
- package/dist/viewport-client/_static/SpriteMaskComponent-a31f3384.js +1 -0
- package/dist/viewport-client/_static/SpriteRendererComponent-c2123918.js +1 -0
- package/dist/viewport-client/_static/{TextBaseComponent-69233798.js → TextBaseComponent-95846acf.js} +2 -2
- package/dist/viewport-client/_static/TextRendererComponent-429cf17b.js +1 -0
- package/dist/viewport-client/_static/TextureAsset-93475ade.js +36 -0
- package/dist/viewport-client/_static/Tooltip-dfde37c6.js +1 -0
- package/dist/viewport-client/_static/TrailRendererComponent-112b1618.js +1 -0
- package/dist/viewport-client/_static/TransformBaseComponent-a8050787.js +1 -0
- package/dist/viewport-client/_static/TransformComponent-c95e25c2.js +1 -0
- package/dist/viewport-client/_static/XRReferenceImageAsset-dbf129aa.js +1 -0
- package/dist/viewport-client/_static/audio-10589bb4.js +1 -0
- package/dist/viewport-client/_static/glTFIO-79bbca27.js +1 -0
- package/dist/viewport-client/_static/index-010da0b3.js +1 -0
- package/dist/viewport-client/_static/index-07bbf729.js +31 -0
- package/dist/viewport-client/_static/index-1e23212d.js +11487 -0
- package/dist/viewport-client/_static/index-2cdbb69f.js +1 -0
- package/dist/viewport-client/_static/index-31b7a6d3.js +1 -0
- package/dist/viewport-client/_static/index-3439012b.js +1 -0
- package/dist/viewport-client/_static/index-48760ac4.js +2 -0
- package/dist/viewport-client/_static/index-65a103b6.js +1 -0
- package/dist/viewport-client/_static/{index-e46ec5b1.js → index-77b1de5c.js} +7 -7
- package/dist/viewport-client/_static/index-92830754.js +1 -0
- package/dist/viewport-client/_static/{index-237c84cd.js → index-93eab932.js} +3 -3
- package/dist/viewport-client/_static/index-b259cf2e.js +1 -0
- package/dist/viewport-client/_static/{index-98982ce2.js → index-b2e1cba4.js} +1 -1
- package/dist/viewport-client/_static/index-b7bf2586.js +1 -0
- package/dist/viewport-client/_static/index-c20fc198.js +1 -0
- package/dist/viewport-client/_static/index-dc62ba4b.js +1 -0
- package/dist/viewport-client/_static/index-ea9ea505.js +1 -0
- package/dist/viewport-client/_static/ktx2-encoder-075abd75.js +1 -0
- package/dist/viewport-client/_static/{module-6406b050.js → module-251ecc50.js} +1 -1
- package/dist/viewport-client/_static/{module-107b7430.js → module-498119f3.js} +1 -1
- package/dist/viewport-client/_static/{module-5c85b07e.js → module-c6e2d190.js} +1 -1
- package/dist/viewport-client/_static/postmen-9e1e15bd.js +1 -0
- package/dist/viewport-client/index.html +2 -2
- package/package.json +1 -1
- package/dist/viewport-client/_static/Accordion-4897319b.js +0 -6
- package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +0 -1
- package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +0 -1
- package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +0 -1
- package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +0 -6
- package/dist/viewport-client/_static/AudioAsset-eae03324.js +0 -1
- package/dist/viewport-client/_static/AudioComponent-44070c2c.js +0 -1
- package/dist/viewport-client/_static/CameraComponent-907ac745.js +0 -1
- package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +0 -1
- package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +0 -1
- package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +0 -5
- package/dist/viewport-client/_static/FormItemArray-66be8701.js +0 -1
- package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +0 -6
- package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +0 -1
- package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +0 -1
- package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +0 -1
- package/dist/viewport-client/_static/LottieAsset-377c1419.js +0 -1
- package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +0 -1
- package/dist/viewport-client/_static/MaterialAsset-74a15124.js +0 -1
- package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +0 -1
- package/dist/viewport-client/_static/Menu-cd3be298.js +0 -17
- package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +0 -1
- package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +0 -1
- package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +0 -1
- package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +0 -21
- package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +0 -1
- package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +0 -1
- package/dist/viewport-client/_static/PointLight-0e1d1546.js +0 -1
- package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +0 -1
- package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +0 -1
- package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +0 -1
- package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +0 -1
- package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +0 -1
- package/dist/viewport-client/_static/SceneAsset-8917c210.js +0 -1
- package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +0 -5
- package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +0 -1
- package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +0 -1
- package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +0 -1
- package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +0 -1
- package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +0 -1
- package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +0 -1
- package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +0 -1
- package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +0 -1
- package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +0 -1
- package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +0 -1
- package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +0 -36
- package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +0 -1
- package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +0 -1
- package/dist/viewport-client/_static/Tooltip-33f770ba.js +0 -1
- package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +0 -1
- package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +0 -1
- package/dist/viewport-client/_static/TransformComponent-96106065.js +0 -1
- package/dist/viewport-client/_static/ViewerManager-202b570a.js +0 -1
- package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +0 -1
- package/dist/viewport-client/_static/audio-244358e2.js +0 -1
- package/dist/viewport-client/_static/glTFIO-45ff9a17.js +0 -1
- package/dist/viewport-client/_static/index-0a8702e2.js +0 -11217
- package/dist/viewport-client/_static/index-37c74ae9.js +0 -26
- package/dist/viewport-client/_static/index-4cca0201.js +0 -1
- package/dist/viewport-client/_static/index-59732f86.js +0 -1
- package/dist/viewport-client/_static/index-6c8198f6.js +0 -2
- package/dist/viewport-client/_static/index-6f827618.js +0 -1
- package/dist/viewport-client/_static/index-803ca489.js +0 -1
- package/dist/viewport-client/_static/index-85a6cf6a.js +0 -1
- package/dist/viewport-client/_static/index-b3d51f87.js +0 -1
- package/dist/viewport-client/_static/index-be6bc38a.js +0 -177
- package/dist/viewport-client/_static/index-c403cbcd.js +0 -1
- package/dist/viewport-client/_static/index-e73966ae.js +0 -1
- package/dist/viewport-client/_static/index-e95b4498.js +0 -1
- package/dist/viewport-client/_static/index-f5a67a46.js +0 -1
- package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +0 -1
- package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.js +0 -1
- package/dist/viewport-client/_static/postmen-45d4c238.js +0 -1
- package/dist/viewport-client/_static/utilities-e09052e3.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as de,as as he,at as me,au as pe,av as ve,I as Se,H as v,a5 as ue,aw as we,X as ke,ax as q,ay as U,b as j,az as Q,aA as be,aB as ye}from"./index-0a8702e2.js";function ce(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ce=function(){return!!e})()}function V(e,r){return V=Object.setPrototypeOf||function(n,t){return n.__proto__=t,n},V(e,r)}function R(e,r,a){return ce()?R=Reflect.construct:R=function(t,i,s){var o=[null];o.push.apply(o,i);var h=Function.bind.apply(t,o),u=new h;return s&&V(u,s.prototype),u},R.apply(null,arguments)}function X(e,r){for(var a=0;a<r.length;a++){var n=r[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,r,a){return r&&X(e.prototype,r),a&&X(e,a),e}function p(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&V(e,r)}function ee(e,r){return r!=null&&typeof Symbol<"u"&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}var M=function(e){return e[e.Controller=0]="Controller",e[e.LeftController=1]="LeftController",e[e.RightController=2]="RightController",e[e.Camera=3]="Camera",e[e.LeftCamera=4]="LeftCamera",e[e.RightCamera=5]="RightCamera",e[e.LeftHand=6]="LeftHand",e[e.RightHand=7]="RightHand",e}({}),k=function(e){return e[e.None=0]="None",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized",e[e.Running=3]="Running",e[e.Paused=4]="Paused",e}({}),Me=function(){function e(a){this._xrManager=a}var r=e.prototype;return r.attachCamera=function(n,t){var i=this._xrManager.inputManager.getTrackedDevice(n),s=i._camera;if(s!==t){switch(s&&(s._cameraType=q.Normal),n){case M.Camera:t._cameraType=q.XRCenterCamera;break;case M.LeftCamera:t._cameraType=q.XRLeftCamera;break;case M.RightCamera:t._cameraType=q.XRRightCamera;break}i._camera=t}},r.detachCamera=function(n){var t=this._xrManager.inputManager.getTrackedDevice(n),i=t._camera;return i&&(i._cameraType=q.Normal),t._camera=null,i},r._onSessionStart=function(){},r._onUpdate=function(){for(var n=this._xrManager.inputManager._cameras,t=this._xrManager.sessionManager._platformSession,i=0,s=n.length;i<s;i++){var o=n[i],h=o._camera;if(h){var u=h.entity.transform,c=o.pose;u.position=c.position,u.rotationQuaternion=c.rotation;var f=h.viewport,_=o.viewport,l=_.x,g=_.y,d=_.width,m=_.height;l===f.x&&g===f.y&&d===f.z&&m===f.w||(h.viewport=f.set(l,g,d,m)),U.equals(h.projectionMatrix,o.projectionMatrix)||(h.projectionMatrix=o.projectionMatrix),h.renderTarget||h._adjustPixelViewport(t.framebufferWidth,t.framebufferHeight)}}},r._onSessionExit=function(){for(var n=this._xrManager.inputManager._cameras,t=0,i=n.length;t<i;t++){var s;(s=n[t]._camera)==null||s._updatePixelViewport()}},r._getIgnoreClearFlags=function(n){return n===q.XRCenterCamera?this._xrManager.sessionManager.state===k.Running?j.Color:j.None:j.None},r._onDestroy=function(){},A(e,[{key:"fixedFoveation",get:function(){var n=this._xrManager.sessionManager,t=n._platformSession;if(t)return t.getFixedFoveation();throw new Error("XR session is not available.")},set:function(n){var t=this._xrManager.sessionManager,i=t._platformSession;if(i)i.setFixedFoveation(n);else throw new Error("XR session is not available.")}}]),e}(),O=function(){this.position=new v,this.rotation=new ye,this.matrix=new U,this.inverseMatrix=new U},w=function(e){return e[e.NotTracking=0]="NotTracking",e[e.Tracking=1]="Tracking",e[e.TrackingLost=2]="TrackingLost",e}({}),fe=function(r){this.type=r,this.trackingState=w.NotTracking},xe=function(e){p(r,e);function r(){var a;return a=e.apply(this,arguments)||this,a.pose=new O,a.viewport=new be,a.projectionMatrix=new U,a}return r}(fe),b=function(e){return e[e.None=0]="None",e[e.Select=1]="Select",e[e.Trigger=1]="Trigger",e[e.Squeeze=2]="Squeeze",e[e.TouchPad=4]="TouchPad",e[e.AButton=8]="AButton",e[e.BButton=16]="BButton",e}({}),Ce=function(e){p(r,e);function r(){var n;return n=e.apply(this,arguments)||this,n.gripPose=new O,n.targetRayPose=new O,n.pressedButtons=b.None,n.down=b.None,n.up=b.None,n}var a=r.prototype;return a.isButtonDown=function(t){return(this.down&t)!==0},a.isButtonUp=function(t){return(this.up&t)!==0},a.isButtonHeldDown=function(t){return(this.pressedButtons&t)!==0},r}(fe),P=function(e){return e[e.SelectStart=0]="SelectStart",e[e.Select=1]="Select",e[e.SelectEnd=2]="SelectEnd",e[e.SqueezeStart=3]="SqueezeStart",e[e.Squeeze=4]="Squeeze",e[e.SqueezeEnd=5]="SqueezeEnd",e}({}),te=function(e){return e[e.Gaze=0]="Gaze",e[e.TrackedPointer=1]="TrackedPointer",e[e.Screen=2]="Screen",e}({}),Ee=function(){function e(a,n){this._xrManager=a,this._engine=n,this.onTrackedDeviceChanged=new Q,this._cameras=[],this._controllers=[],this._added=[],this._removed=[],this._trackedDevices=[],this._statusSnapshot=[];for(var t=this,i=t._trackedDevices,s=t._controllers,o=t._cameras,h=0;h<6;h++)switch(h){case M.Camera:case M.LeftCamera:case M.RightCamera:o.push(i[h]=new xe(h));break;case M.Controller:case M.LeftController:case M.RightController:s.push(i[h]=new Ce(h));break}this._statusSnapshot.fill(w.NotTracking,0,i.length)}var r=e.prototype;return r.getTrackedDevice=function(n){return this._trackedDevices[n]},r._onUpdate=function(){var n=this,t=n._added,i=n._removed,s=n._statusSnapshot,o=this,h=o._trackedDevices,u=o._controllers;t.length=i.length=0;for(var c=0,f=u.length;c<f;c++){var _=u[c];_.down=_.up=0}for(var l=this._xrManager.sessionManager,g=l._platformSession,d=g.events,m=0,S=d.length;m<S;m++)this._handleEvent(d[m]);g.resetEvents(),g.frame.updateInputs(h);for(var x=0,z=h.length;x<z;x++){var F=h[x];if(F){var E=F.trackingState;s[x]===w.Tracking?E!==w.Tracking&&i.push(F):E===w.Tracking&&t.push(F),s[x]=E}}(t.length>0||i.length>0)&&this.onTrackedDeviceChanged.invoke(t,i)},r._onDestroy=function(){this.onTrackedDeviceChanged.removeAll()},r._handleEvent=function(n){var t=this._trackedDevices[n.input];switch(n.targetRayMode){case te.TrackedPointer:switch(n.type){case P.SelectStart:t.down|=b.Select,t.pressedButtons|=b.Select;break;case P.SelectEnd:t.up|=b.Select,t.pressedButtons&=~b.Select;break;case P.SqueezeStart:t.down|=b.Squeeze,t.pressedButtons|=b.Squeeze;break;case P.SqueezeEnd:t.up|=b.Squeeze,t.pressedButtons&=~b.Squeeze;break}break;case te.Screen:var i=this,s=i._engine,o=s.inputManager._pointerManager._target,h=s.canvas._webCanvas,u=h.clientWidth,c=h.clientHeight,f=u*(n.x+1)*.5,_=c*(n.y+1)*.5;switch(n.type){case P.SelectStart:o.dispatchEvent(this._makeUpPointerEvent("pointerdown",n.id,f,_));break;case P.Select:o.dispatchEvent(this._makeUpPointerEvent("pointermove",n.id,f,_));break;case P.SelectEnd:o.dispatchEvent(this._makeUpPointerEvent("pointerup",n.id,f,_)),o.dispatchEvent(this._makeUpPointerEvent("pointerleave",n.id,f,_));break}break}},r._makeUpPointerEvent=function(n,t,i,s){var o={pointerId:t,clientX:i,clientY:s};switch(n){case"pointerdown":o.button=0,o.buttons=1;break;case"pointermove":o.button=-1,o.buttons=1;break;case"pointerup":o.button=0,o.buttons=0;break;case"pointerleave":o.button=0,o.buttons=0;break}return new PointerEvent(n,o)},r.addTrackedDeviceChangedListener=function(n){this.onTrackedDeviceChanged.on(n)},r.removeTrackedDeviceChangedListener=function(n){this.onTrackedDeviceChanged.off(n)},e}(),_e=function(e){return e[e.None=0]="None",e[e.AR=1]="AR",e[e.VR=2]="VR",e}({}),Pe=function(){function e(a,n){this._xrManager=a,this._engine=n,this.onStateChanged=new Q,this._mode=_e.None,this._state=k.None,this._rhi=n._hardwareRenderer,this._raf=requestAnimationFrame.bind(window),this._caf=cancelAnimationFrame.bind(window),this._onSessionExit=this._onSessionExit.bind(this)}var r=e.prototype;return r.isSupportedMode=function(n){return this._xrManager._platformDevice.isSupportedSessionMode(n)},r.run=function(){var n=this,t=n._platformSession,i=n._engine;if(!t)throw new Error("Without session to run.");t.start(),this._setState(k.Running),this._xrManager._onSessionStart(),i.isPaused||(i.pause(),i.resume())},r.stop=function(){var n=this,t=n._platformSession,i=n._engine,s=n._rhi;if(!t)throw new Error("Without session to stop.");if(this._state!==k.Running)throw new Error("Session is not running.");s._mainFrameBuffer=null,s._mainFrameWidth=s._mainFrameHeight=0,t.stop(),this._setState(k.Paused),this._xrManager._onSessionStop(),i.isPaused||(i.pause(),i.resume())},r._setState=function(n){this._state=n,this.onStateChanged.invoke(n)},r._initialize=function(n,t){var i=this;return new Promise(function(s,o){for(var h=i._xrManager,u=[],c=0,f=t.length;c<f;c++){var _=t[c],l=_._platformFeature;l&&u.push(l)}h._platformDevice.requestSession(i._rhi,n,u).then(function(g){i._mode=n,i._platformSession=g,i._setState(k.Initialized),g.setSessionExitCallBack(i._onSessionExit),g.addEventListener(),h._onSessionInit(),s()},o)})},r._onUpdate=function(){var n=this,t=n._rhi,i=n._platformSession;t._mainFrameBuffer=i.framebuffer,t._mainFrameWidth=i.framebufferWidth,t._mainFrameHeight=i.framebufferHeight},r._getRequestAnimationFrame=function(){return this._state===k.Running?this._platformSession.requestAnimationFrame:this._raf},r._getCancelAnimationFrame=function(){return this._state===k.Running?this._platformSession.cancelAnimationFrame:this._caf},r._exit=function(){var n=this,t=n._platformSession;return t?t.end():Promise.reject("Without session to stop.")},r._onSessionExit=function(){var n=this,t=n._rhi,i=n._platformSession,s=n._engine;t._mainFrameBuffer=null,t._mainFrameWidth=t._mainFrameHeight=0,i.removeEventListener(),this._platformSession=null,this._setState(k.None),this._xrManager._onSessionExit(),s.isPaused||(s.pause(),s.resume())},r._onDestroy=function(){this.onStateChanged.removeAll(),this._raf=this._caf=null},r.addStateChangedListener=function(n){this.onStateChanged.on(n)},r.removeStateChangedListener=function(n){this.onStateChanged.off(n)},A(e,[{key:"mode",get:function(){return this._mode}},{key:"state",get:function(){return this._state}},{key:"supportedFrameRate",get:function(){return this._platformSession.supportedFrameRates}},{key:"frameRate",get:function(){return this._platformSession.frameRate}}]),e}(),J=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}var a=r.prototype;return a.isSupportedFeature=function(t){return this._platformDevice.isSupportedFeature(r._featureMap.get(t))},a.addFeature=function(t){for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(this.sessionManager._platformSession)throw new Error("Cannot add feature when the session is initialized.");if(!this._platformDevice.isSupportedFeature(r._featureMap.get(t)))throw new Error("The feature is not supported");for(var h=this.features,u=0,c=h.length;u<c;u++)if(ee(h[u],t))throw new Error("The feature has been added");var f=R(t,[].concat([this],s));return h.push(f),f},a.getFeature=function(t){for(var i=this.features,s=0,o=i.length;s<o;s++){var h=i[s];if(ee(h,t))return h}},a.enterXR=function(t,i){var s=this;i===void 0&&(i=!0);var o=this.sessionManager;if(o._platformSession)throw new Error("Please exit XR immersive mode first.");if(!this._origin)throw new Error("Please set origin before enter XR.");return new Promise(function(h,u){o.isSupportedMode(t).then(function(){o._setState(k.Initializing),o._initialize(t,s.features).then(function(){i&&o.run(),h()},u)},u)})},a.exitXR=function(){var t=this;return new Promise(function(i,s){t.sessionManager._exit().then(function(){i()},s)})},a._initialize=function(t,i){this._features=[],this._platformDevice=i,this.sessionManager=new Pe(this,t),this.inputManager=new Ee(this,t),this.cameraManager=new Me(this)},a._update=function(){var t=this.sessionManager;if(t.state===k.Running){t._onUpdate(),this.inputManager._onUpdate(),this.cameraManager._onUpdate();for(var i=this.features,s=0,o=i.length;s<o;s++){var h=i[s];h.enabled&&h._onUpdate()}}},a._destroy=function(){var t=this;this.sessionManager._platformSession?this.exitXR().then(function(){t.sessionManager._onDestroy(),t.inputManager._onDestroy(),t.cameraManager._onDestroy()}):(this.sessionManager._onDestroy(),this.inputManager._onDestroy(),this.cameraManager._onDestroy())},a._getRequestAnimationFrame=function(){return this.sessionManager._getRequestAnimationFrame()},a._getCancelAnimationFrame=function(){return this.sessionManager._getCancelAnimationFrame()},a._getCameraIgnoreClearFlags=function(t){return this.cameraManager._getIgnoreClearFlags(t)},a._onSessionStop=function(){for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionStop()}},a._onSessionInit=function(){for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionInit()}},a._onSessionStart=function(){this.cameraManager._onSessionStart();for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionStart()}},a._onSessionExit=function(){this.cameraManager._onSessionExit();for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionExit(),o._onDestroy()}t.length=0},A(r,[{key:"features",get:function(){return this._features}},{key:"origin",get:function(){return this._origin},set:function(t){if(this.sessionManager._platformSession)throw new Error("Cannot set origin when the session is initialized.");this._origin=t}}]),r}(he);J._featureMap=new Map;function W(e){return function(r){J._featureMap.set(r,e)}}function Te(e,r){r.forEach(function(a){Object.getOwnPropertyNames(a.prototype).forEach(function(n){Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(a.prototype,n)||Object.create(null))})})}Te(he,[J]);var le=function(){function e(a,n){for(var t=arguments.length,i=new Array(t>2?t-2:0),s=2;s<t;s++)i[s-2]=arguments[s];var o;this._xrManager=a,this._type=n,this._enabled=!0,this._platformFeature=(o=a._platformDevice).createPlatformFeature.apply(o,[].concat([n],i)),this._onEnable()}var r=e.prototype;return r._onEnable=function(){},r._onDisable=function(){},r._onUpdate=function(){},r._onSessionInit=function(){},r._onSessionStart=function(){},r._onSessionStop=function(){},r._onSessionExit=function(){},r._onDestroy=function(){},A(e,[{key:"enabled",get:function(){return this._enabled},set:function(n){this.enabled!==n&&(this._enabled=n,n?this._onEnable():this._onDisable())}}]),e}(),y=function(e){return e[e.AnchorTracking=0]="AnchorTracking",e[e.ImageTracking=1]="ImageTracking",e[e.PlaneTracking=2]="PlaneTracking",e[e.HitTest=3]="HitTest",e}({}),H=function(e){return e[e.None=0]="None",e[e.Submitted=1]="Submitted",e[e.Resolved=2]="Resolved",e[e.Rejected=3]="Rejected",e[e.Destroyed=4]="Destroyed",e[e.WaitingDestroy=5]="WaitingDestroy",e}({}),T=function(e){p(r,e);function r(){var n;return n=e.apply(this,arguments)||this,n.onChanged=new Q,n._requestTrackings=[],n._tracked=[],n._added=[],n._updated=[],n._removed=[],n._statusSnapshot={},n}var a=r.prototype;return a._onUpdate=function(){var t=this._xrManager.sessionManager,i=t._platformSession,s=i.frame,o=this,h=o._platformFeature,u=o._requestTrackings,c=o._statusSnapshot,f=o._tracked,_=o._added,l=o._updated,g=o._removed;if(!(!s||!u.length)&&h.checkAvailable(i,s,u)){_.length=l.length=g.length=0,h.getTrackedResult(i,s,u,this._generateTracked);for(var d=0,m=u.length;d<m;d++){var S=u[d];switch(S.state){case H.Destroyed:for(var x=S.tracked,z=0,F=x.length;z<F;z++){var E=x[z],$=E.id;c[$]===w.Tracking&&(g.push(E),f.splice(f.indexOf(E),1)),c[$]=w.NotTracking}break;case H.Resolved:for(var Y=S.tracked,B=0,ge=Y.length;B<ge;B++){var C=Y[B],L=C.id;C.state===w.Tracking?c[L]===w.Tracking?l.push(C):(_.push(C),c[L]=w.Tracking,f.push(C)):(c[L]===w.Tracking&&(g.push(C),f.splice(f.indexOf(C),1)),c[L]=C.state)}break}}for(var N=u.length-1;N>=0;N--)u[N].state===H.Destroyed&&u.splice(N,1);(_.length>0||l.length>0||g.length>0)&&this.onChanged.invoke(_,l,g)}},a._onSessionStop=function(){this._added.length=this._updated.length=this._removed.length=0},a._onSessionExit=function(){this._requestTrackings.length=this._tracked.length=this._added.length=this._updated.length=this._removed.length=0,this.onChanged.removeAll()},a._addRequestTracking=function(t){var i=this,s=i._platformFeature;if(this._xrManager.sessionManager._platformSession&&!s.canModifyRequestTrackingAfterInit)throw new Error(y[this._type]+" request tracking cannot be modified after initialization.");this._requestTrackings.push(t),s.onAddRequestTracking(t)},a._removeRequestTracking=function(t){var i=this,s=i._platformFeature;if(this._xrManager.sessionManager._platformSession&&!s.canModifyRequestTrackingAfterInit)throw new Error(y[this._type]+" request tracking cannot be modified after initialization.");s.onDelRequestTracking(t)},a._removeAllRequestTrackings=function(){var t=this,i=t._platformFeature;if(this._xrManager.sessionManager._platformSession&&!i.canModifyRequestTrackingAfterInit)throw new Error(y[this._type]+" request tracking cannot be modified after initialization.");for(var s=this,o=s._requestTrackings,h=0,u=o.length;h<u;h++)i.onDelRequestTracking(o[h])},a.addChangedListener=function(t){this.onChanged.on(t)},a.removeChangedListener=function(t){this.onChanged.off(t)},r}(le);T._uuid=0;var K=function(){this.pose=new O,this.state=w.NotTracking},ne=function(e){return e[e.Plane=1]="Plane",e[e.All=1]="All",e}({}),Ae=function(){this.point=new v,this.normal=new v};function D(e,r,a,n){var t=arguments.length,i=t<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,a):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,r,a,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(i=(t<3?s(i):t>3?s(r,a,i):s(r,a))||i);return t>3&&i&&Object.defineProperty(r,a,i),i}var Fe=function(e){return e[e.None=0]="None",e[e.Horizontal=1]="Horizontal",e[e.Vertical=2]="Vertical",e[e.EveryThing=3]="EveryThing",e}({}),Z=function(){this.state=H.None,this.tracked=[]},qe=function(e){p(r,e);function r(a){var n;return n=e.call(this)||this,n.detectionMode=a,n}return r}(Z),De=function(e){p(r,e);function r(){var a;return a=e.apply(this,arguments)||this,a.polygon=[],a.attributesDirty=!1,a}return r}(K),I=function(e){p(r,e);function r(n,t){t===void 0&&(t=Fe.EveryThing);var i;return i=e.call(this,n,y.PlaneTracking,t)||this,i._addRequestTracking(new qe(t)),i}var a=r.prototype;return a._generateTracked=function(){var t=new De;return t.id=T._uuid++,t},A(r,[{key:"detectionMode",get:function(){return this._requestTrackings[0].detectionMode}},{key:"trackedPlanes",get:function(){return this._tracked}}]),r}(T);I=D([W(y.PlaneTracking)],I);var re=function(e){p(r,e);function r(n){var t;return t=e.call(this,n,y.HitTest)||this,t._tempRay=new pe,t._tempPlane=new ve,t._tempVec2=new Se,t._tempVec30=new v,t._tempVec31=new v,t._tempVec32=new v,t._tempVec33=new v,t._tempVec34=new v,t._tempVec35=new v,t}var a=r.prototype;return a.hitTest=function(t,i){var s=[];return i&ne.Plane&&this._hitTestPlane(t,s),s},a.screenHitTest=function(t,i,s){var o=this,h=o._xrManager;if(h.sessionManager.mode!==_e.AR)throw new Error("Only AR mode supports using screen ray hit test.");var u=h.inputManager.getTrackedDevice(M.Camera),c=u._camera;if(!c)throw new Error("No camera available.");var f=c.screenPointToRay(this._tempVec2.set(t,i),this._tempRay);return this.hitTest(f,s)},a._hitTestPlane=function(t,i){var s=this._xrManager.getFeature(I);if(!s||!s.enabled)throw new Error("The plane estimation function needs to be turned on for plane hit test.");for(var o=this,h=o._tempPlane,u=o._tempVec30,c=o._tempVec31,f=o._tempVec32,_=s.trackedPlanes,l=0,g=_.length;l<g;l++){var d=_[l];u.set(0,1,0).transformNormal(d.pose.matrix),h.normal.copyFrom(u),h.distance=-v.dot(u,d.pose.position);var m=t.intersectPlane(h);if(m>=0&&(t.getPoint(m,c),v.transformToVec3(c,d.pose.inverseMatrix,f),this._checkPointerWithinPlane(f,d))){var S=new Ae;S.point.copyFrom(c),S.normal.copyFrom(u),S.distance=m,S.trackedObject=d,S.trackableType=ne.Plane,i.push(S)}}},a._checkPointerWithinPlane=function(t,i){for(var s=this,o=s._tempVec33,h=s._tempVec34,u=s._tempVec35,c=i.polygon,f=c.length,_=c[f-1],l=0,g=0;g<f;g++){var d=c[g];v.subtract(d,_,o),v.subtract(t,_,h),v.cross(o,h,u);var m=u.y;if(l===0)m>0?l=1:m<0&&(l=-1);else if(m>0&&l<0||m<0&&l>0)return!1;_=d}return!0},r}(le);re=D([W(y.HitTest)],re);var ze=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}return r}(K),Le=function(e){p(r,e);function r(a,n){var t;return t=e.call(this)||this,t.position=a,t.rotation=n,t}return r}(Z),ae=function(e){p(r,e);function r(n){var t;return t=e.call(this,n,y.AnchorTracking)||this,t._anchors=[],t}var a=r.prototype;return a.addAnchor=function(t,i){if(!this._enabled)throw new Error("Cannot add an anchor from a disabled anchor manager.");var s=this,o=s._anchors,h=new Le(t,i),u=this._generateTracked();return h.tracked[0]=u,this._addRequestTracking(h),o.push(u),u},a.removeAnchor=function(t){if(!this._enabled)throw new Error("Cannot remove an anchor from a disabled anchor manager.");for(var i=this,s=i._requestTrackings,o=i._anchors,h=0,u=s.length;h<u;h++){var c=s[h];if(c.tracked[0]===t){this._removeRequestTracking(c);break}}o.splice(o.indexOf(t),1)},a.clearAnchors=function(){if(!this._enabled)throw new Error("Cannot remove anchors from a disabled anchor manager.");this._removeAllRequestTrackings()},a._generateTracked=function(){var t=new ze;return t.id=T._uuid++,t},A(r,[{key:"trackingAnchors",get:function(){return this._anchors}},{key:"trackedAnchors",get:function(){return this._tracked}}]),r}(T);ae=D([W(y.AnchorTracking)],ae);var Ne=function(e){p(r,e);function r(a){var n;return n=e.call(this)||this,n.image=a,n}return r}(Z),Re=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}return r}(K),ie=function(e){p(r,e);function r(n,t){var i;i=e.call(this,n,y.ImageTracking,t)||this,i._trackingImages=t;var s=t?t.length:0;if(s>0)for(var o=0,h=t.length;o<h;o++)i._addRequestTracking(new Ne(t[o]));else console.warn("No image to be tracked.");return i}var a=r.prototype;return a._generateTracked=function(){var t=new Re;return t.id=T._uuid++,t},A(r,[{key:"trackingImages",get:function(){return this._trackingImages}},{key:"trackedImages",get:function(){return this._tracked}}]),r}(T);ie=D([W(y.ImageTracking)],ie);var He=function(r,a,n){this.name=r,this.imageSource=a,this.physicalWidth=n},oe=function(){function e(){}return e.decode=function(a,n){return new ue(function(t,i){var s=n.nextFloat32();n.nextUint8();var o=new Image;o.onload=function(){t(new He("",o,s))},o.src=URL.createObjectURL(new window.Blob([n.nextImagesData(1)[0]]))})},e}();oe=D([me("XRReferenceImage")],oe);function G(){return G=Object.assign||function(r){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},G.apply(this,arguments)}var se=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}var a=r.prototype;return a.load=function(t,i){return new ue(function(s,o){i._request(t.url,G({},t,{type:"arraybuffer"})).then(function(h){we(h,i.engine).then(function(u){s(u)})}).catch(o)})},r}(ke);se=D([de("XRReferenceImage",[])],se);export{He as X,_e as a,M as b,k as c,ae as d,ie as e,I as f,Fe as g};
|
|
1
|
+
import{W as de,as as he,at as me,au as pe,av as ve,N as Se,K as v,a5 as ue,aw as we,X as ke,ax as q,ay as H,b as j,az as Q,aA as be,aB as ye}from"./index-1e23212d.js";function ce(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ce=function(){return!!e})()}function V(e,r){return V=Object.setPrototypeOf||function(n,t){return n.__proto__=t,n},V(e,r)}function R(e,r,a){return ce()?R=Reflect.construct:R=function(t,i,s){var o=[null];o.push.apply(o,i);var h=Function.bind.apply(t,o),u=new h;return s&&V(u,s.prototype),u},R.apply(null,arguments)}function X(e,r){for(var a=0;a<r.length;a++){var n=r[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function A(e,r,a){return r&&X(e.prototype,r),a&&X(e,a),e}function p(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&V(e,r)}function ee(e,r){return r!=null&&typeof Symbol<"u"&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}var M=function(e){return e[e.Controller=0]="Controller",e[e.LeftController=1]="LeftController",e[e.RightController=2]="RightController",e[e.Camera=3]="Camera",e[e.LeftCamera=4]="LeftCamera",e[e.RightCamera=5]="RightCamera",e[e.LeftHand=6]="LeftHand",e[e.RightHand=7]="RightHand",e}({}),k=function(e){return e[e.None=0]="None",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized",e[e.Running=3]="Running",e[e.Paused=4]="Paused",e}({}),Me=function(){function e(a){this._xrManager=a}var r=e.prototype;return r.attachCamera=function(n,t){var i=this._xrManager.inputManager.getTrackedDevice(n),s=i._camera;if(s!==t){switch(s&&(s._cameraType=q.Normal),n){case M.Camera:t._cameraType=q.XRCenterCamera;break;case M.LeftCamera:t._cameraType=q.XRLeftCamera;break;case M.RightCamera:t._cameraType=q.XRRightCamera;break}i._camera=t}},r.detachCamera=function(n){var t=this._xrManager.inputManager.getTrackedDevice(n),i=t._camera;return i&&(i._cameraType=q.Normal),t._camera=null,i},r._onSessionStart=function(){},r._onUpdate=function(){for(var n=this._xrManager.inputManager._cameras,t=this._xrManager.sessionManager._platformSession,i=0,s=n.length;i<s;i++){var o=n[i],h=o._camera;if(h){var u=h.entity.transform,c=o.pose;u.position=c.position,u.rotationQuaternion=c.rotation;var f=h.viewport,_=o.viewport,l=_.x,g=_.y,d=_.width,m=_.height;l===f.x&&g===f.y&&d===f.z&&m===f.w||(h.viewport=f.set(l,g,d,m)),H.equals(h.projectionMatrix,o.projectionMatrix)||(h.projectionMatrix=o.projectionMatrix),h.renderTarget||h._adjustPixelViewport(t.framebufferWidth,t.framebufferHeight)}}},r._onSessionExit=function(){for(var n=this._xrManager.inputManager._cameras,t=0,i=n.length;t<i;t++){var s;(s=n[t]._camera)==null||s._updatePixelViewport()}},r._getIgnoreClearFlags=function(n){return n===q.XRCenterCamera?this._xrManager.sessionManager.state===k.Running?j.Color:j.None:j.None},r._onDestroy=function(){},A(e,[{key:"fixedFoveation",get:function(){var n=this._xrManager.sessionManager,t=n._platformSession;if(t)return t.getFixedFoveation();throw new Error("XR session is not available.")},set:function(n){var t=this._xrManager.sessionManager,i=t._platformSession;if(i)i.setFixedFoveation(n);else throw new Error("XR session is not available.")}}]),e}(),O=function(){this.position=new v,this.rotation=new ye,this.matrix=new H,this.inverseMatrix=new H},w=function(e){return e[e.NotTracking=0]="NotTracking",e[e.Tracking=1]="Tracking",e[e.TrackingLost=2]="TrackingLost",e}({}),fe=function(r){this.type=r,this.trackingState=w.NotTracking},xe=function(e){p(r,e);function r(){var a;return a=e.apply(this,arguments)||this,a.pose=new O,a.viewport=new be,a.projectionMatrix=new H,a}return r}(fe),b=function(e){return e[e.None=0]="None",e[e.Select=1]="Select",e[e.Trigger=1]="Trigger",e[e.Squeeze=2]="Squeeze",e[e.TouchPad=4]="TouchPad",e[e.AButton=8]="AButton",e[e.BButton=16]="BButton",e}({}),Ce=function(e){p(r,e);function r(){var n;return n=e.apply(this,arguments)||this,n.gripPose=new O,n.targetRayPose=new O,n.pressedButtons=b.None,n.down=b.None,n.up=b.None,n}var a=r.prototype;return a.isButtonDown=function(t){return(this.down&t)!==0},a.isButtonUp=function(t){return(this.up&t)!==0},a.isButtonHeldDown=function(t){return(this.pressedButtons&t)!==0},r}(fe),P=function(e){return e[e.SelectStart=0]="SelectStart",e[e.Select=1]="Select",e[e.SelectEnd=2]="SelectEnd",e[e.SqueezeStart=3]="SqueezeStart",e[e.Squeeze=4]="Squeeze",e[e.SqueezeEnd=5]="SqueezeEnd",e}({}),te=function(e){return e[e.Gaze=0]="Gaze",e[e.TrackedPointer=1]="TrackedPointer",e[e.Screen=2]="Screen",e}({}),Ee=function(){function e(a,n){this._xrManager=a,this._engine=n,this.onTrackedDeviceChanged=new Q,this._cameras=[],this._controllers=[],this._added=[],this._removed=[],this._trackedDevices=[],this._statusSnapshot=[];for(var t=this,i=t._trackedDevices,s=t._controllers,o=t._cameras,h=0;h<6;h++)switch(h){case M.Camera:case M.LeftCamera:case M.RightCamera:o.push(i[h]=new xe(h));break;case M.Controller:case M.LeftController:case M.RightController:s.push(i[h]=new Ce(h));break}this._statusSnapshot.fill(w.NotTracking,0,i.length)}var r=e.prototype;return r.getTrackedDevice=function(n){return this._trackedDevices[n]},r._onUpdate=function(){var n=this,t=n._added,i=n._removed,s=n._statusSnapshot,o=this,h=o._trackedDevices,u=o._controllers;t.length=i.length=0;for(var c=0,f=u.length;c<f;c++){var _=u[c];_.down=_.up=0}for(var l=this._xrManager.sessionManager,g=l._platformSession,d=g.events,m=0,S=d.length;m<S;m++)this._handleEvent(d[m]);g.resetEvents(),g.frame.updateInputs(h);for(var x=0,z=h.length;x<z;x++){var F=h[x];if(F){var E=F.trackingState;s[x]===w.Tracking?E!==w.Tracking&&i.push(F):E===w.Tracking&&t.push(F),s[x]=E}}(t.length>0||i.length>0)&&this.onTrackedDeviceChanged.invoke(t,i)},r._onDestroy=function(){this.onTrackedDeviceChanged.removeAll()},r._handleEvent=function(n){var t=this._trackedDevices[n.input];switch(n.targetRayMode){case te.TrackedPointer:switch(n.type){case P.SelectStart:t.down|=b.Select,t.pressedButtons|=b.Select;break;case P.SelectEnd:t.up|=b.Select,t.pressedButtons&=~b.Select;break;case P.SqueezeStart:t.down|=b.Squeeze,t.pressedButtons|=b.Squeeze;break;case P.SqueezeEnd:t.up|=b.Squeeze,t.pressedButtons&=~b.Squeeze;break}break;case te.Screen:var i=this,s=i._engine,o=s.inputManager._pointerManager._target,h=s.canvas._webCanvas,u=h.clientWidth,c=h.clientHeight,f=u*(n.x+1)*.5,_=c*(n.y+1)*.5;switch(n.type){case P.SelectStart:o.dispatchEvent(this._makeUpPointerEvent("pointerdown",n.id,f,_));break;case P.Select:o.dispatchEvent(this._makeUpPointerEvent("pointermove",n.id,f,_));break;case P.SelectEnd:o.dispatchEvent(this._makeUpPointerEvent("pointerup",n.id,f,_)),o.dispatchEvent(this._makeUpPointerEvent("pointerleave",n.id,f,_));break}break}},r._makeUpPointerEvent=function(n,t,i,s){var o={pointerId:t,clientX:i,clientY:s};switch(n){case"pointerdown":o.button=0,o.buttons=1;break;case"pointermove":o.button=-1,o.buttons=1;break;case"pointerup":o.button=0,o.buttons=0;break;case"pointerleave":o.button=0,o.buttons=0;break}return new PointerEvent(n,o)},r.addTrackedDeviceChangedListener=function(n){this.onTrackedDeviceChanged.on(n)},r.removeTrackedDeviceChangedListener=function(n){this.onTrackedDeviceChanged.off(n)},e}(),_e=function(e){return e[e.None=0]="None",e[e.AR=1]="AR",e[e.VR=2]="VR",e}({}),Pe=function(){function e(a,n){this._xrManager=a,this._engine=n,this.onStateChanged=new Q,this._mode=_e.None,this._state=k.None,this._rhi=n._hardwareRenderer,this._raf=requestAnimationFrame.bind(window),this._caf=cancelAnimationFrame.bind(window),this._onSessionExit=this._onSessionExit.bind(this)}var r=e.prototype;return r.isSupportedMode=function(n){return this._xrManager._platformDevice.isSupportedSessionMode(n)},r.run=function(){var n=this,t=n._platformSession,i=n._engine;if(!t)throw new Error("Without session to run.");t.start(),this._setState(k.Running),this._xrManager._onSessionStart(),i.isPaused||(i.pause(),i.resume())},r.stop=function(){var n=this,t=n._platformSession,i=n._engine,s=n._rhi;if(!t)throw new Error("Without session to stop.");if(this._state!==k.Running)throw new Error("Session is not running.");s._mainFrameBuffer=null,s._mainFrameWidth=s._mainFrameHeight=0,t.stop(),this._setState(k.Paused),this._xrManager._onSessionStop(),i.isPaused||(i.pause(),i.resume())},r._setState=function(n){this._state=n,this.onStateChanged.invoke(n)},r._initialize=function(n,t){var i=this;return new Promise(function(s,o){for(var h=i._xrManager,u=[],c=0,f=t.length;c<f;c++){var _=t[c],l=_._platformFeature;l&&u.push(l)}h._platformDevice.requestSession(i._rhi,n,u).then(function(g){i._mode=n,i._platformSession=g,i._setState(k.Initialized),g.setSessionExitCallBack(i._onSessionExit),g.addEventListener(),h._onSessionInit(),s()},o)})},r._onUpdate=function(){var n=this,t=n._rhi,i=n._platformSession;t._mainFrameBuffer=i.framebuffer,t._mainFrameWidth=i.framebufferWidth,t._mainFrameHeight=i.framebufferHeight},r._getRequestAnimationFrame=function(){return this._state===k.Running?this._platformSession.requestAnimationFrame:this._raf},r._getCancelAnimationFrame=function(){return this._state===k.Running?this._platformSession.cancelAnimationFrame:this._caf},r._exit=function(){var n=this,t=n._platformSession;return t?t.end():Promise.reject("Without session to stop.")},r._onSessionExit=function(){var n=this,t=n._rhi,i=n._platformSession,s=n._engine;t._mainFrameBuffer=null,t._mainFrameWidth=t._mainFrameHeight=0,i.removeEventListener(),this._platformSession=null,this._setState(k.None),this._xrManager._onSessionExit(),s.isPaused||(s.pause(),s.resume())},r._onDestroy=function(){this.onStateChanged.removeAll(),this._raf=this._caf=null},r.addStateChangedListener=function(n){this.onStateChanged.on(n)},r.removeStateChangedListener=function(n){this.onStateChanged.off(n)},A(e,[{key:"mode",get:function(){return this._mode}},{key:"state",get:function(){return this._state}},{key:"supportedFrameRate",get:function(){return this._platformSession.supportedFrameRates}},{key:"frameRate",get:function(){return this._platformSession.frameRate}}]),e}(),K=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}var a=r.prototype;return a.isSupportedFeature=function(t){return this._platformDevice.isSupportedFeature(r._featureMap.get(t))},a.addFeature=function(t){for(var i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(this.sessionManager._platformSession)throw new Error("Cannot add feature when the session is initialized.");if(!this._platformDevice.isSupportedFeature(r._featureMap.get(t)))throw new Error("The feature is not supported");for(var h=this.features,u=0,c=h.length;u<c;u++)if(ee(h[u],t))throw new Error("The feature has been added");var f=R(t,[].concat([this],s));return h.push(f),f},a.getFeature=function(t){for(var i=this.features,s=0,o=i.length;s<o;s++){var h=i[s];if(ee(h,t))return h}},a.enterXR=function(t,i){var s=this;i===void 0&&(i=!0);var o=this.sessionManager;if(o._platformSession)throw new Error("Please exit XR immersive mode first.");if(!this._origin)throw new Error("Please set origin before enter XR.");return new Promise(function(h,u){o.isSupportedMode(t).then(function(){o._setState(k.Initializing),o._initialize(t,s.features).then(function(){i&&o.run(),h()},u)},u)})},a.exitXR=function(){var t=this;return new Promise(function(i,s){t.sessionManager._exit().then(function(){i()},s)})},a._initialize=function(t,i){this._features=[],this._platformDevice=i,this.sessionManager=new Pe(this,t),this.inputManager=new Ee(this,t),this.cameraManager=new Me(this)},a._update=function(){var t=this.sessionManager;if(t.state===k.Running){t._onUpdate(),this.inputManager._onUpdate(),this.cameraManager._onUpdate();for(var i=this.features,s=0,o=i.length;s<o;s++){var h=i[s];h.enabled&&h._onUpdate()}}},a._destroy=function(){var t=this;this.sessionManager._platformSession?this.exitXR().then(function(){t.sessionManager._onDestroy(),t.inputManager._onDestroy(),t.cameraManager._onDestroy()}):(this.sessionManager._onDestroy(),this.inputManager._onDestroy(),this.cameraManager._onDestroy())},a._getRequestAnimationFrame=function(){return this.sessionManager._getRequestAnimationFrame()},a._getCancelAnimationFrame=function(){return this.sessionManager._getCancelAnimationFrame()},a._getCameraIgnoreClearFlags=function(t){return this.cameraManager._getIgnoreClearFlags(t)},a._onSessionStop=function(){for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionStop()}},a._onSessionInit=function(){for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionInit()}},a._onSessionStart=function(){this.cameraManager._onSessionStart();for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionStart()}},a._onSessionExit=function(){this.cameraManager._onSessionExit();for(var t=this.features,i=0,s=t.length;i<s;i++){var o=t[i];o.enabled&&o._onSessionExit(),o._onDestroy()}t.length=0},A(r,[{key:"features",get:function(){return this._features}},{key:"origin",get:function(){return this._origin},set:function(t){if(this.sessionManager._platformSession)throw new Error("Cannot set origin when the session is initialized.");this._origin=t}}]),r}(he);K._featureMap=new Map;function W(e){return function(r){K._featureMap.set(r,e)}}function Te(e,r){r.forEach(function(a){Object.getOwnPropertyNames(a.prototype).forEach(function(n){Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(a.prototype,n)||Object.create(null))})})}Te(he,[K]);var le=function(){function e(a,n){for(var t=arguments.length,i=new Array(t>2?t-2:0),s=2;s<t;s++)i[s-2]=arguments[s];var o;this._xrManager=a,this._type=n,this._enabled=!0,this._platformFeature=(o=a._platformDevice).createPlatformFeature.apply(o,[].concat([n],i)),this._onEnable()}var r=e.prototype;return r._onEnable=function(){},r._onDisable=function(){},r._onUpdate=function(){},r._onSessionInit=function(){},r._onSessionStart=function(){},r._onSessionStop=function(){},r._onSessionExit=function(){},r._onDestroy=function(){},A(e,[{key:"enabled",get:function(){return this._enabled},set:function(n){this.enabled!==n&&(this._enabled=n,n?this._onEnable():this._onDisable())}}]),e}(),y=function(e){return e[e.AnchorTracking=0]="AnchorTracking",e[e.ImageTracking=1]="ImageTracking",e[e.PlaneTracking=2]="PlaneTracking",e[e.HitTest=3]="HitTest",e}({}),U=function(e){return e[e.None=0]="None",e[e.Submitted=1]="Submitted",e[e.Resolved=2]="Resolved",e[e.Rejected=3]="Rejected",e[e.Destroyed=4]="Destroyed",e[e.WaitingDestroy=5]="WaitingDestroy",e}({}),T=function(e){p(r,e);function r(){var n;return n=e.apply(this,arguments)||this,n.onChanged=new Q,n._requestTrackings=[],n._tracked=[],n._added=[],n._updated=[],n._removed=[],n._statusSnapshot={},n}var a=r.prototype;return a._onUpdate=function(){var t=this._xrManager.sessionManager,i=t._platformSession,s=i.frame,o=this,h=o._platformFeature,u=o._requestTrackings,c=o._statusSnapshot,f=o._tracked,_=o._added,l=o._updated,g=o._removed;if(!(!s||!u.length)&&h.checkAvailable(i,s,u)){_.length=l.length=g.length=0,h.getTrackedResult(i,s,u,this._generateTracked);for(var d=0,m=u.length;d<m;d++){var S=u[d];switch(S.state){case U.Destroyed:for(var x=S.tracked,z=0,F=x.length;z<F;z++){var E=x[z],$=E.id;c[$]===w.Tracking&&(g.push(E),f.splice(f.indexOf(E),1)),c[$]=w.NotTracking}break;case U.Resolved:for(var Y=S.tracked,B=0,ge=Y.length;B<ge;B++){var C=Y[B],L=C.id;C.state===w.Tracking?c[L]===w.Tracking?l.push(C):(_.push(C),c[L]=w.Tracking,f.push(C)):(c[L]===w.Tracking&&(g.push(C),f.splice(f.indexOf(C),1)),c[L]=C.state)}break}}for(var N=u.length-1;N>=0;N--)u[N].state===U.Destroyed&&u.splice(N,1);(_.length>0||l.length>0||g.length>0)&&this.onChanged.invoke(_,l,g)}},a._onSessionStop=function(){this._added.length=this._updated.length=this._removed.length=0},a._onSessionExit=function(){this._requestTrackings.length=this._tracked.length=this._added.length=this._updated.length=this._removed.length=0,this.onChanged.removeAll()},a._addRequestTracking=function(t){var i=this,s=i._platformFeature;if(this._xrManager.sessionManager._platformSession&&!s.canModifyRequestTrackingAfterInit)throw new Error(y[this._type]+" request tracking cannot be modified after initialization.");this._requestTrackings.push(t),s.onAddRequestTracking(t)},a._removeRequestTracking=function(t){var i=this,s=i._platformFeature;if(this._xrManager.sessionManager._platformSession&&!s.canModifyRequestTrackingAfterInit)throw new Error(y[this._type]+" request tracking cannot be modified after initialization.");s.onDelRequestTracking(t)},a._removeAllRequestTrackings=function(){var t=this,i=t._platformFeature;if(this._xrManager.sessionManager._platformSession&&!i.canModifyRequestTrackingAfterInit)throw new Error(y[this._type]+" request tracking cannot be modified after initialization.");for(var s=this,o=s._requestTrackings,h=0,u=o.length;h<u;h++)i.onDelRequestTracking(o[h])},a.addChangedListener=function(t){this.onChanged.on(t)},a.removeChangedListener=function(t){this.onChanged.off(t)},r}(le);T._uuid=0;var J=function(){this.pose=new O,this.state=w.NotTracking},ne=function(e){return e[e.Plane=1]="Plane",e[e.All=1]="All",e}({}),Ae=function(){this.point=new v,this.normal=new v};function D(e,r,a,n){var t=arguments.length,i=t<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,a):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,r,a,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(i=(t<3?s(i):t>3?s(r,a,i):s(r,a))||i);return t>3&&i&&Object.defineProperty(r,a,i),i}var Fe=function(e){return e[e.None=0]="None",e[e.Horizontal=1]="Horizontal",e[e.Vertical=2]="Vertical",e[e.EveryThing=3]="EveryThing",e}({}),Z=function(){this.state=U.None,this.tracked=[]},qe=function(e){p(r,e);function r(a){var n;return n=e.call(this)||this,n.detectionMode=a,n}return r}(Z),De=function(e){p(r,e);function r(){var a;return a=e.apply(this,arguments)||this,a.polygon=[],a.attributesDirty=!1,a}return r}(J),I=function(e){p(r,e);function r(n,t){t===void 0&&(t=Fe.EveryThing);var i;return i=e.call(this,n,y.PlaneTracking,t)||this,i._addRequestTracking(new qe(t)),i}var a=r.prototype;return a._generateTracked=function(){var t=new De;return t.id=T._uuid++,t},A(r,[{key:"detectionMode",get:function(){return this._requestTrackings[0].detectionMode}},{key:"trackedPlanes",get:function(){return this._tracked}}]),r}(T);I=D([W(y.PlaneTracking)],I);var re=function(e){p(r,e);function r(n){var t;return t=e.call(this,n,y.HitTest)||this,t._tempRay=new pe,t._tempPlane=new ve,t._tempVec2=new Se,t._tempVec30=new v,t._tempVec31=new v,t._tempVec32=new v,t._tempVec33=new v,t._tempVec34=new v,t._tempVec35=new v,t}var a=r.prototype;return a.hitTest=function(t,i){var s=[];return i&ne.Plane&&this._hitTestPlane(t,s),s},a.screenHitTest=function(t,i,s){var o=this,h=o._xrManager;if(h.sessionManager.mode!==_e.AR)throw new Error("Only AR mode supports using screen ray hit test.");var u=h.inputManager.getTrackedDevice(M.Camera),c=u._camera;if(!c)throw new Error("No camera available.");var f=c.screenPointToRay(this._tempVec2.set(t,i),this._tempRay);return this.hitTest(f,s)},a._hitTestPlane=function(t,i){var s=this._xrManager.getFeature(I);if(!s||!s.enabled)throw new Error("The plane estimation function needs to be turned on for plane hit test.");for(var o=this,h=o._tempPlane,u=o._tempVec30,c=o._tempVec31,f=o._tempVec32,_=s.trackedPlanes,l=0,g=_.length;l<g;l++){var d=_[l];u.set(0,1,0).transformNormal(d.pose.matrix),h.normal.copyFrom(u),h.distance=-v.dot(u,d.pose.position);var m=t.intersectPlane(h);if(m>=0&&(t.getPoint(m,c),v.transformToVec3(c,d.pose.inverseMatrix,f),this._checkPointerWithinPlane(f,d))){var S=new Ae;S.point.copyFrom(c),S.normal.copyFrom(u),S.distance=m,S.trackedObject=d,S.trackableType=ne.Plane,i.push(S)}}},a._checkPointerWithinPlane=function(t,i){for(var s=this,o=s._tempVec33,h=s._tempVec34,u=s._tempVec35,c=i.polygon,f=c.length,_=c[f-1],l=0,g=0;g<f;g++){var d=c[g];v.subtract(d,_,o),v.subtract(t,_,h),v.cross(o,h,u);var m=u.y;if(l===0)m>0?l=1:m<0&&(l=-1);else if(m>0&&l<0||m<0&&l>0)return!1;_=d}return!0},r}(le);re=D([W(y.HitTest)],re);var ze=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}return r}(J),Le=function(e){p(r,e);function r(a,n){var t;return t=e.call(this)||this,t.position=a,t.rotation=n,t}return r}(Z),ae=function(e){p(r,e);function r(n){var t;return t=e.call(this,n,y.AnchorTracking)||this,t._anchors=[],t}var a=r.prototype;return a.addAnchor=function(t,i){if(!this._enabled)throw new Error("Cannot add an anchor from a disabled anchor manager.");var s=this,o=s._anchors,h=new Le(t,i),u=this._generateTracked();return h.tracked[0]=u,this._addRequestTracking(h),o.push(u),u},a.removeAnchor=function(t){if(!this._enabled)throw new Error("Cannot remove an anchor from a disabled anchor manager.");for(var i=this,s=i._requestTrackings,o=i._anchors,h=0,u=s.length;h<u;h++){var c=s[h];if(c.tracked[0]===t){this._removeRequestTracking(c);break}}o.splice(o.indexOf(t),1)},a.clearAnchors=function(){if(!this._enabled)throw new Error("Cannot remove anchors from a disabled anchor manager.");this._removeAllRequestTrackings()},a._generateTracked=function(){var t=new ze;return t.id=T._uuid++,t},A(r,[{key:"trackingAnchors",get:function(){return this._anchors}},{key:"trackedAnchors",get:function(){return this._tracked}}]),r}(T);ae=D([W(y.AnchorTracking)],ae);var Ne=function(e){p(r,e);function r(a){var n;return n=e.call(this)||this,n.image=a,n}return r}(Z),Re=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}return r}(J),ie=function(e){p(r,e);function r(n,t){var i;i=e.call(this,n,y.ImageTracking,t)||this,i._trackingImages=t;var s=t?t.length:0;if(s>0)for(var o=0,h=t.length;o<h;o++)i._addRequestTracking(new Ne(t[o]));else console.warn("No image to be tracked.");return i}var a=r.prototype;return a._generateTracked=function(){var t=new Re;return t.id=T._uuid++,t},A(r,[{key:"trackingImages",get:function(){return this._trackingImages}},{key:"trackedImages",get:function(){return this._tracked}}]),r}(T);ie=D([W(y.ImageTracking)],ie);var Ue=function(r,a,n){this.name=r,this.imageSource=a,this.physicalWidth=n},oe=function(){function e(){}return e.decode=function(a,n){return new ue(function(t,i){var s=n.nextFloat32();n.nextUint8();var o=new Image;o.onload=function(){t(new Ue("",o,s))},o.src=URL.createObjectURL(new window.Blob([n.nextImagesData(1)[0]]))})},e}();oe=D([me("XRReferenceImage")],oe);function G(){return G=Object.assign||function(r){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},G.apply(this,arguments)}var se=function(e){p(r,e);function r(){return e.apply(this,arguments)||this}var a=r.prototype;return a.load=function(t,i){return new ue(function(s,o){i._request(t.url,G({},t,{type:"arraybuffer"})).then(function(h){we(h,i.engine).then(function(u){s(u)})}).catch(o)})},r}(ke);se=D([de("XRReferenceImage",[])],se);export{Ue as X,_e as a,M as b,k as c,ae as d,ie as e,I as f,Fe as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as r}from"./index-1e23212d.js";import"./index-92830754.js";r.createPublisher();
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
<style>
|
|
8
8
|
html, body, #app { margin: 0; width: 100%; height: 100%; overflow: hidden; }
|
|
9
9
|
canvas { width: 100%; height: 100%; display: block; }
|
|
10
|
-
#status { position: fixed; left: 8px; top: 8px; background: rgba(0,0,0,0.6); color: #fff; padding: 6px 8px; font: 12px/1.4 monospace; z-index: 10;
|
|
10
|
+
#status { position: fixed; left: 8px; top: 8px; background: rgba(0,0,0,0.6); color: #fff; padding: 6px 8px; font: 12px/1.4 monospace; z-index: 10; }
|
|
11
11
|
</style>
|
|
12
|
-
<script type="module" crossorigin src="/_static/index-
|
|
12
|
+
<script type="module" crossorigin src="/_static/index-1e23212d.js"></script>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="app">
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{aC as oe,bE as te,bF as re,bG as T,bx as c,aD as r,bH as D,bI as ne,bJ as ie,bK as ae,bL as M,bM as ce,bN as se,bO as de,bP as le,bQ as O,aH as b,bR as pe}from"./index-0a8702e2.js";/**
|
|
2
|
-
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/var Ne=oe("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]),u="Accordion",ue=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[H,he,fe]=te(u),[C,Te]=re(u,[fe,T]),P=T(),V=c.forwardRef((o,i)=>{const{type:e,...n}=o,a=n,t=n;return r.jsx(H.Provider,{scope:o.__scopeAccordion,children:e==="multiple"?r.jsx(xe,{...t,ref:i}):r.jsx(me,{...a,ref:i})})});V.displayName=u;var[L,ge]=C(u),[B,be]=C(u,{collapsible:!1}),me=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},collapsible:t=!1,...s}=o,[d,l]=D({prop:e,defaultProp:n,onChange:a});return r.jsx(L,{scope:o.__scopeAccordion,value:d?[d]:[],onItemOpen:l,onItemClose:c.useCallback(()=>t&&l(""),[t,l]),children:r.jsx(B,{scope:o.__scopeAccordion,collapsible:t,children:r.jsx(K,{...s,ref:i})})})}),xe=c.forwardRef((o,i)=>{const{value:e,defaultValue:n,onValueChange:a=()=>{},...t}=o,[s=[],d]=D({prop:e,defaultProp:n,onChange:a}),l=c.useCallback(g=>d((h=[])=>[...h,g]),[d]),f=c.useCallback(g=>d((h=[])=>h.filter($=>$!==g)),[d]);return r.jsx(L,{scope:o.__scopeAccordion,value:s,onItemOpen:l,onItemClose:f,children:r.jsx(B,{scope:o.__scopeAccordion,collapsible:!0,children:r.jsx(K,{...t,ref:i})})})}),[ve,A]=C(u),K=c.forwardRef((o,i)=>{const{__scopeAccordion:e,disabled:n,dir:a,orientation:t="vertical",...s}=o,d=c.useRef(null),l=ne(d,i),f=he(e),h=ie(a)==="ltr",$=ae(o.onKeyDown,m=>{var E;if(!ue.includes(m.key))return;const Z=m.target,I=f().filter(j=>{var N;return!((N=j.ref.current)!=null&&N.disabled)}),x=I.findIndex(j=>j.ref.current===Z),z=I.length;if(x===-1)return;m.preventDefault();let p=x;const S=0,w=z-1,y=()=>{p=x+1,p>w&&(p=S)},R=()=>{p=x-1,p<S&&(p=w)};switch(m.key){case"Home":p=S;break;case"End":p=w;break;case"ArrowRight":t==="horizontal"&&(h?y():R());break;case"ArrowDown":t==="vertical"&&y();break;case"ArrowLeft":t==="horizontal"&&(h?R():y());break;case"ArrowUp":t==="vertical"&&R();break}const ee=p%z;(E=I[ee].ref.current)==null||E.focus()});return r.jsx(ve,{scope:e,disabled:n,direction:a,orientation:t,children:r.jsx(H.Slot,{scope:e,children:r.jsx(M.div,{...s,"data-orientation":t,ref:l,onKeyDown:n?void 0:$})})})}),v="AccordionItem",[Ce,k]=C(v),G=c.forwardRef((o,i)=>{const{__scopeAccordion:e,value:n,...a}=o,t=A(v,e),s=ge(v,e),d=P(e),l=ce(),f=n&&s.value.includes(n)||!1,g=t.disabled||o.disabled;return r.jsx(Ce,{scope:e,open:f,disabled:g,triggerId:l,children:r.jsx(se,{"data-orientation":t.orientation,"data-state":Y(f),...d,...a,ref:i,disabled:g,open:f,onOpenChange:h=>{h?s.onItemOpen(n):s.onItemClose(n)}})})});G.displayName=v;var U="AccordionHeader",W=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(U,e);return r.jsx(M.h3,{"data-orientation":a.orientation,"data-state":Y(t.open),"data-disabled":t.disabled?"":void 0,...n,ref:i})});W.displayName=U;var _="AccordionTrigger",F=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(_,e),s=be(_,e),d=P(e);return r.jsx(H.ItemSlot,{scope:e,children:r.jsx(de,{"aria-disabled":t.open&&!s.collapsible||void 0,"data-orientation":a.orientation,id:t.triggerId,...d,...n,ref:i})})});F.displayName=_;var J="AccordionContent",Q=c.forwardRef((o,i)=>{const{__scopeAccordion:e,...n}=o,a=A(u,e),t=k(J,e),s=P(e);return r.jsx(le,{role:"region","aria-labelledby":t.triggerId,"data-orientation":a.orientation,...s,...n,ref:i,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...o.style}})});Q.displayName=J;function Y(o){return o?"open":"closed"}var Ae=V,$e=G,Ie=W,Se=F,we=Q;const ye=O({from:{height:0,opacity:0},to:{height:"var(--radix-accordion-content-height)",opacity:1}}),Re=O({from:{height:"var(--radix-accordion-content-height)",opacity:1},to:{height:0,opacity:0}}),q=c.createContext({size:"sm"}),je=b(Ae,{width:"100%",display:"flex",flexDirection:"column"}),_e=b($e,{position:"relative",boxSizing:"border-box",width:"100%",backgroundColor:"$surface",border:"1px solid $border",borderBottom:"none",overflow:"hidden","&:first-child":{borderTopLeftRadius:"$sm",borderTopRightRadius:"$sm"},"&:last-child":{borderBottomLeftRadius:"$sm",borderBottomRightRadius:"$sm",borderBottom:"1px solid $border"},"&[data-state=open]":{borderColor:"$borderStrong","&:not(:first-child)":{borderTopColor:"$borderStrong"},"& + &":{borderTopColor:"$borderStrong"}},"&:has(+ [data-state=open])":{borderBottomColor:"$borderStrong"}}),X=b(pe,{width:"$iconSm",height:"$iconSm",color:"currentColor",flexShrink:0,transform:"rotate(0deg)",transition:"transform .2s ease, color .2s ease"}),He=b(Ie,{all:"unset",display:"block"}),Pe=b(Se,{all:"unset",display:"flex",width:"100%",minHeight:"30px",padding:"0 $3",alignItems:"center",justifyContent:"space-between",gap:"$2",fontSize:"$2",lineHeight:"$lineHeights$2",fontWeight:500,color:"$text",overflow:"hidden",boxSizing:"border-box",userSelect:"none",backgroundColor:"$grayA2",transition:"$backgroundColor, $borderColor, $color","& > span":{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'&[data-state="open"]':{[`& ${X}`]:{transform:"rotate(90deg)"}},"&:hover":{backgroundColor:"$grayA3",color:"$textStrong"},"&:focus-visible":{outline:"none",boxShadow:"$focus"},variants:{size:{sm:{minHeight:"27px",padding:"0 $2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{minHeight:"30px",padding:"0 $3",fontSize:"$2",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),ke=b(we,{overflow:"hidden",fontSize:"$1",color:"$text",backgroundColor:"$grayA2",'&[data-state="open"]':{animation:`${ye} 200ms cubic-bezier(0.16, 1, 0.3, 1)`},'&[data-state="closed"]':{animation:`${Re} 180ms cubic-bezier(0.16, 1, 0.3, 1)`},"@media (prefers-reduced-motion: reduce)":{'&[data-state="open"], &[data-state="closed"]':{animation:"none"}}}),ze=b("div",{color:"$text",borderTop:"1px solid $border",variants:{size:{sm:{padding:"$2",fontSize:"$1",lineHeight:"$lineHeights$1"},md:{padding:"$3",fontSize:"$1",lineHeight:"$lineHeights$2"}}},defaultVariants:{size:"sm"}}),De=function(i){const{size:e="sm",...n}=i;return r.jsx(q.Provider,{value:{size:e},children:r.jsx(je,{...n})})};function Me(o){const{size:i}=c.useContext(q),{children:e,title:n,arrow:a=!0,...t}=o;return r.jsxs(_e,{...t,children:[r.jsx(He,{children:r.jsxs(Pe,{size:i,children:[r.jsx("span",{children:n}),a&&r.jsx(X,{"aria-hidden":!0})]})}),r.jsx(ke,{children:r.jsx(ze,{size:i,children:e})})]})}export{De as A,Ne as I,Me as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var ht=Object.defineProperty;var ut=(_,t,n)=>t in _?ht(_,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):_[t]=n;var g=(_,t,n)=>(ut(_,typeof t!="symbol"?t+"":t,n),n);import{aT as X,aD as V,b8 as yt,e as j,cX as et,cH as dt,aV as mt,aH as ft,aK as gt,o as st,S as ot,u as D,J as E,bb as Pt,be as _t,bC as vt,bA as bt,O as Ct,cY as Tt,cQ as wt,cZ as Et,c_ as At,c$ as St,$ as xt,a1 as Mt,d0 as Vt,d1 as It,d2 as Ot,d3 as jt,d4 as Rt,d5 as Bt,d6 as Ft,d7 as Dt,d8 as Lt,d9 as $t,da as Kt,db as Nt,dc as kt,dd as zt,w as y,de as Ut,cO as I,df as Ht,dg as Gt,dh as Jt,di as Qt,dj as Wt,dk as qt,dl as Yt,dm as Xt,dn as Zt,dp as te,dq as ee,j as re,dr as O,ds as H,bT as W,dt as x,cb as q,du as ne,dv as rt,aw as ae,dw as se,am as nt,dx as F,H as at,dy as oe,X as ie,dz as pe,aA as ce,aB as le,V as he,I as ue,x as ye,dA as G,cR as de,m as me,b0 as fe,bp as ge,dB as Pe}from"./index-0a8702e2.js";import{b as it,a as _e,A as ve}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import{A as be}from"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as Ce}from"./AssetViewer-bc198e16.js";import{o as Te}from"./assetEditorActions-c4e5962f.js";import{e as pt}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{L as we}from"./module-6406b050.js";import{a as Ee}from"./module-107b7430.js";import{n as Y}from"./index-be6bc38a.js";const Ae=X(()=>{const _=it("animationClipStore"),{selectedEvent:t}=_,{paramType:n}=t;return V.jsxs("div",{children:[V.jsx(yt,{label:j("animation.clip.param-type.title"),options:[{value:"string",label:String(j("animation.clip.param-type.string"))},{value:"number",label:String(j("animation.clip.param-type.number"))},{value:"null",label:String(j("animation.clip.param-type.null"))}],value:n||"null",onChange:r=>{t.paramType=r,_.updateEvents([t])}}),V.jsx(et,{label:j("animation.clip.function-name"),value:t.functionName,onChange:r=>{t.functionName=r,_.updateEvents([t])}}),n==="number"&&V.jsx(dt,{label:j("animation.clip.number"),value:t.number,onChange:r=>{t.number=r,_.updateEvents([t])}}),n==="string"&&V.jsx(et,{label:j("animation.clip.string"),value:t.string,onChange:r=>{t.string=r,_.updateEvents([t])}})]})}),Se=X(function(){const t=it("animationClipStore"),{selectedEvent:n}=t;return n?V.jsx(mt,{title:j("animation.clip.event"),defaultOpen:!0,children:V.jsx(V.Fragment,{children:V.jsx(Ae,{})})}):null});var xe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,N=(_,t,n,r)=>{for(var e=r>1?void 0:r?Me(t,n):t,a=_.length-1,o;a>=0;a--)(o=_[a])&&(e=(r?o(t,n,e):o(e))||e);return r&&e&&xe(t,n,e),e};const Ve=ft(gt,{position:"absolute",top:0,left:0,margin:"auto",width:"100%",height:228,alignItems:"center",justifyContent:"center"});class $ extends Ce{constructor(){super();g(this,"frameTime",0);g(this,"duration",0);g(this,"playing",!1);g(this,"_clip");g(this,"_updateComponent");g(this,"animationNames");g(this,"overridePreviewer",X(({asset:n,viewer:r})=>V.jsx(V.Fragment,{children:n.isSubAsset||n.root.sceneUIStore.lastSelectedId?V.jsx(be,{asset:n,viewer:r}):V.jsx(Ve,{children:V.jsx(V.Fragment,{children:j("animation.clip.select-entity-preview")})})})));st(this)}selectAnimation(n){}async setViewAsset(n,r){var o,s;let e;if(n.isSubAsset){const i=await n.root.assetStore.getAssetByRef({refId:n.mainId}),{defaultSceneRoot:c}=i.engineObject;e=((o=n.root.sceneStore.lastSelectedEntity)==null?void 0:o.engineObject)||c}else e=(s=n.root.sceneStore.lastSelectedEntity)==null?void 0:s.engineObject;if(!e)return;this._clip=n.engineObject,this.animationNames=[n.name],this._entity=e.clone(),r.addChild(this._entity);const a=this;this._updateComponent=this._entity.addComponent(class extends ot{onUpdate(i){a._onUpdate(100/3)}}),this.frameTime=0,this.duration=this._clip.length}stopViewAsset(){var n;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(n=this._updateComponent)==null||n.destroy()}setFrameTime(n){this.frameTime=n,this._sampleAnimation()}playAnimation(){this._clip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(n){!this.playing||!this._clip||!this.duration||(this.frameTime+=n/1e3,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this._clip._sampleAnimation(this._entity,this.frameTime)}catch(n){console.warn(n)}}}N([D],$.prototype,"frameTime",2);N([D],$.prototype,"duration",2);N([D],$.prototype,"playing",2);N([E],$.prototype,"setViewAsset",1);N([E],$.prototype,"setFrameTime",1);N([E],$.prototype,"playAnimation",1);N([E],$.prototype,"pauseAnimation",1);N([E],$.prototype,"_onUpdate",1);const K=new Map([[Pt,"Transform"],[_t,"Animator"],[vt,"DirectLight"],[bt,"Camera"],[Ct,"MeshRenderer"],[Tt,"SkinnedMeshRenderer"],[wt,"ParticleRenderer"],[Et,"PointLight"],[At,"SpotLight"],[ot,"Script"],[St,"SpriteMask"],[xt,"SpriteRenderer"],[Mt,"TextRenderer"],[Vt,"UITransform"],[It,"UICanvas"],[Ot,"UIGroup"],[jt,"Button"],[Rt,"Image"],[Bt,"Text"],[Ft,"DynamicCollider"],[Dt,"StaticCollider"],[Lt,"CharacterController"],[$t,"SpringJoint"],[Kt,"FixedJoint"],[Nt,"HingeJoint"],[kt,"AudioSource"],[zt,"PostProcess"],[Ee,"SpineAnimationRenderer"],[we,"LottieAnimation"]]);var Ie=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,T=(_,t,n,r)=>{for(var e=r>1?void 0:r?Oe(t,n):t,a=_.length-1,o;a>=0;a--)(o=_[a])&&(e=(r?o(t,n,e):o(e))||e);return r&&e&&Ie(t,n,e),e};const Z=new Map([[y.Float,{curveClass:Ut,name:"AnimationFloatCurve",defaultInterpolation:I.Hermite}],[y.FloatArray,{curveClass:Ht,name:"AnimationFloatArrayCurve",defaultInterpolation:I.Hermite}],[y.Vector2,{curveClass:Gt,name:"AnimationVector2Curve",defaultInterpolation:I.Hermite}],[y.Vector3,{curveClass:Jt,name:"AnimationVector3Curve",defaultInterpolation:I.Hermite}],[y.Vector4,{curveClass:Qt,name:"AnimationVector4Curve",defaultInterpolation:I.Hermite}],[y.Quaternion,{curveClass:Wt,name:"AnimationQuaternionCurve",defaultInterpolation:I.Hermite}],[y.Color,{curveClass:qt,name:"AnimationColorCurve",defaultInterpolation:I.Hermite}],[y.ReferResource,{curveClass:Yt,name:"AnimationRefCurve",defaultInterpolation:I.Step}],[y.Rect,{curveClass:Xt,name:"AnimationRectCurve",defaultInterpolation:I.Step}],[y.Boolean,{curveClass:Zt,name:"AnimationBoolCurve",defaultInterpolation:I.Step}],[y.String,{curveClass:te,name:"AnimationStringCurve",defaultInterpolation:I.Step}],[y.Array,{curveClass:ee,name:"AnimationArrayCurve",defaultInterpolation:I.Hermite}]]),ct=new Map;Z.forEach((_,t)=>{ct.set(_.curveClass,t)});const lt=new Map;Z.forEach(_=>{lt.set(_.curveClass,_.name)});let C=class extends re{constructor(t){super(t);g(this,"samples",60);g(this,"properties",[]);g(this,"pathPropertyMap",new Map);g(this,"keyframeDataList",[]);g(this,"events",{});g(this,"data");g(this,"selectedEventId");g(this,"rootEntityId");g(this,"showEditor");g(this,"readOnly",!1);g(this,"_propertyCurveMap",{});g(this,"_originValueStore",new Map);g(this,"_initKeyframeDataPromise");g(this,"_parseKeyframeValuePromise");g(this,"_colorList",["#3477FA","#67FEBB","#C201BF","#F6ED17","#FE6C02","#FD86C2","#A2B44B","#68D8F0","#008225","#A56A02"]);g(this,"_colorIndex",0);g(this,"_openIndex",0);g(this,"_componentsChangedListenerDisposer");g(this,"_propertyPathCache",new Map);g(this,"_propertyLabelMap",new Map);g(this,"_editorPathCache",new Map);st(this),this.onDoubleClick=this.onDoubleClick.bind(this)}get rootEntity(){return this.root.sceneStore.entities.get(this.rootEntityId)}get addedPropertiesTreeData(){return this.properties.map(t=>this._convertPropertyToTreeItem(t))}persistMainViaFacade(){this.root.assetFacade.persistAssetMain(this.id)}persistMetaViaFacade(){this.root.assetFacade.persistAssetMeta(this.id)}addProperty(t){const{type:n,parentProperty:r}=t,e=F(t),a=this.pathPropertyMap.get(e),o=this.properties;let s;if(a)Y.error(j("animation.clip.error.property-existed"));else{if(n===O.Property)s=this._addPropertyToList(o,t,null);else{const i=o.find(c=>c.propertyPath===r.propertyPath&&c.relativePath===r.relativePath&&c.componentType===r.componentType);if(i)i.properties.find(p=>p.path===e)?Y.error(j("animation.clip.error.sub-property-existed")):s=this._addPropertyToList(i.properties,t,i);else{const c=this._addPropertyToList(o,r,null,!1);s=this._addPropertyToList(c.properties,t,c)}}return this._sortProperties(),this.properties=o.slice(0),this._updateCurveBindings(),this.persistMetaViaFacade(),this.persistMainViaFacade(),s}}delProperty(t){const n=new Set;t.forEach(r=>{if(n.add(r.path),this.pathPropertyMap.delete(r.path),r.type===O.Property)r.properties.forEach(e=>{n.add(e.path),this.pathPropertyMap.delete(e.path)}),this._delPropertyFromList(this.properties,r);else{const e=this.properties.find(a=>a.path===r.parentPath);e&&(this._delPropertyFromList(e.properties,r),e.hasSubProperty&&!e.properties.length&&this._delPropertyFromList(this.properties,e))}}),this._sortProperties(),this.properties=this.properties.slice(0),this._removeCurveBindings(n),this._updateCurveBindings(),this.updateKeyframes(this.keyframeDataList.filter(r=>!n.has(r.path))),this.persistMetaViaFacade(),this.persistMainViaFacade()}async addKeyframe(t,n){const{rootEntity:r}=this,e=this.pathPropertyMap.get(n),{type:a,path:o,parentPath:s,properties:i,supported:c}=e;if(!c){Y.error(j("animation.clip.error.property-not-supported"));return}const p=a===O.SubProperty?this.pathPropertyMap.get(s):null,{editorReference:h,editorPropertyPath:u,propertyPos:d}=await this._getReferenceAndActualPropertyPath(r,e),l=u[d],m=H(h)[l];let f=h[l];m!=null&&m.getActualEditorValue&&(f=m.getActualEditorValue(f));let A=e.valueType;a===O.Property&&(m!=null&&m.valueType)&&(A=m.valueType),a===O.SubProperty&&(f=f[u[d+1]]);const P=W(f);if(i.length)i.forEach(b=>{const{path:v}=b,w=P[b.name],S=this.keyframeDataList.find(M=>M.path===v&&M.frame===t);if(S)S.value=w,S.inTangentMode=x.Linear,S.outTangentMode=x.Linear;else{const M=this._createKeyframeData(t,w,b.valueType,void 0,void 0,b,e);this.keyframeDataList.push(M)}});else{const b=this.keyframeDataList.find(v=>v.path===o&&v.frame===t);if(b)b.value=P,b.inTangent=void 0,b.outTangent=void 0;else{const v=this._createKeyframeData(t,P,A,void 0,void 0,e,a===O.SubProperty?p:null);this.keyframeDataList.push(v)}}this.updateKeyframes(this.keyframeDataList)}addKeyframeByRecording(t,n){const r=this._ensurePropertyExists(n);r&&this.addKeyframe(t,r.path)}deleteKeyframes(t){t.forEach(n=>{const r=this.keyframeDataList.indexOf(n);r>-1&&this.keyframeDataList.splice(r,1)}),this.updateKeyframes(this.keyframeDataList)}updateKeyframes(t,n=!0){const r={};t.length&&t.sort((e,a)=>e.frame-a.frame),t.forEach(e=>{const a=e.path;r[a]??(r[a]=[]),r[a].push(e),r[a].sort((o,s)=>o.frame-s.frame)});for(const e in r)for(let a=0,o=r[e].length;a<o;++a){const s=r[e][a];if(s.interpolationType===I.Step)continue;const i=r[e][a-1],c=r[e][a+1];s.isFirst=a===0,s.isLast=a===o-1,a>0&&(s.frame-i.frame===0?s.linearInTangent=0:s.linearInTangent=(s.value-i.value)/((s.frame-i.frame)/this.samples),s.inTangent=s.inTangentMode===x.Linear?s.linearInTangent:s.inTangent,isNaN(s.inTangent)&&(s.inTangent=-1/0)),a<o-1&&(c.frame-s.frame===0?s.linearOutTangent=0:s.linearOutTangent=(c.value-s.value)/((c.frame-s.frame)/this.samples),s.outTangent=s.outTangentMode===x.Linear?s.linearOutTangent:s.outTangent,isNaN(s.outTangent)&&(s.outTangent=-1/0))}this.keyframeDataList=t.slice(0),this.isSubAsset||(this._generateEngineKeyframes(t),n&&this.persistMainViaFacade())}addEvent(t){const n={id:q(),time:t/this.samples,functionName:"onEvent"};this.events[n.id]=n,this.updateEvents(this.events)}deleteEvent(t){delete this.events[t.id],this.updateEvents(this.events)}updateEvents(t,n=!0){const r=this.engineObject;if(this.events={...t},r.clearEvents(),Object.values(this.events).map(e=>{const a=e.paramType==="string"?e.string:e.number;r.addEvent(e.functionName,e.time,a)}),this.data.events=Object.values(this.events).map(e=>({time:e.time,functionName:e.functionName,parameter:e.paramType==="string"?e.string:e.number})),n){const{isSubAsset:e}=this;if(e){const{assets:a}=this.root.assetStore,o=a[this.mainId];if(o){const s=o.engineObject.animations.indexOf(this._engineObject);o.updateAnimationEvents(s,this.data.events)}}this.persistMainViaFacade()}}updateSamples(t){this.samples=+t.toFixed(0)}updateRootEntity(t){if(!(!t||t.id===this.rootEntityId)){if(this.rootEntityId=t.id,this.engineObject){this._clearPropertyMappings();const n=this._init().then(async()=>{await this._generateKeyframeDataList(),await this._updateCurveBindings(),this.showEditor&&(await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}).catch(r=>{console.warn("AnimationClipAsset:updateRootEntity rebuild failed",this.name,r)});this._initKeyframeDataPromise=n}this._listenRootEntityChanged(),this.persistMetaViaFacade()}}setTangentMode(t,n,r){t.forEach(e=>{if(n===ne.In)switch(e.inTangentMode=r,r){case x.Linear:e.inTangent=e.linearInTangent;break;case x.Constant:e.inTangent=-1/0;break;case x.Free:break}else switch(e.outTangentMode=r,r){case x.Linear:e.outTangent=e.linearOutTangent;break;case x.Constant:e.outTangent=-1/0;break;case x.Free:break}}),this.persistMetaViaFacade(),this.updateKeyframes(this.keyframeDataList)}async checkPropertiesSupport(t){const{properties:n}=this;let r=!1;const e=n.map(async a=>{const o=!!a.supported,{editorReference:s}=await this._getReferenceAndActualPropertyPath(t,a);s?a.supported=!0:a.supported=!1,!o&&a.supported&&(r=!0)});await Promise.all(e),r&&(this.properties=this.properties.slice(0),await this._generateKeyframeDataList(),this.updateKeyframes(this.keyframeDataList,!1),await this.saveEditorOriginValue(),await this.sampleAnimation(this.root.animationClipStore.currentFrame))}updateSelectedEvent(t){this.selectedEventId=t}async openEditor(t){if(t&&!this.showEditor){this._initKeyframeDataPromise||(this._initKeyframeDataPromise=this._generateKeyframeDataList()),this.showEditor=t,this.root.projectStore.animationEditing=t;const n=++this._openIndex;if(await this._initKeyframeDataPromise,n!==this._openIndex)return;this.saveEditorOriginValue(),this.sampleAnimation(this.root.animationClipStore.currentFrame),rt()}!t&&this.showEditor&&(this.showEditor=t,this.root.projectStore.animationEditing=t,this.revertValue())}async sampleAnimation(t){const n=this.rootEntity;if(n){const r=n.engineObject;try{await this._parseKeyframeValuePromise,this.engineObject._sampleAnimation(r,t/this.samples),this._syncToEditor()}catch(e){console.warn(e)}}}async saveEditorOriginValue(){const{_originValueStore:t}=this,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:o,property:s}=e,i=K.get(o),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:i,propertyPath:s});if(!c)return;const u=p[h];if(!t.has(e)){let d=u;u==="rotationQuaternion"&&(d="rotation"),t.set(e,W(c[d]))}});await Promise.all(r)}async revertValue(){const{_originValueStore:t}=this,n=Array.from(t).map(async([r,e])=>{const{relativePath:a,type:o,property:s}=r,i=K.get(o),{editorReference:c,editorPropertyPath:p,propertyPos:h}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:a,componentType:i,propertyPath:s});if(!c)return;const u=p[h];let d=u;u==="rotationQuaternion"&&(d="rotation"),this._setEditorValue(c,d,e)});await Promise.all(n),t.clear()}async initByMain(t){const{engine:n,meta:r}=this;r.rootEntityId&&(this.rootEntityId=r.rootEntityId),this._listenRootEntityChanged();try{const e=JSON.parse(await t.text()),a=pt(e,{type:"AnimationClip",name:e.name}),o=await ae(a,n);this.bindEngineObject(o),await this._init()}catch(e){console.error(`[AnimationClipAsset] Failed to load "${this.name}"`,e)}}async initByEngineObject(t){this.bindEngineObject(t),this._name=t.name,await this._init()}async initByCreation(t,n){this.setNameByIncrease(n||"AnimationClip");const r=new se(this.name);return this.bindEngineObject(r),this.data={name:this.name,curveBindings:r.curveBindings,events:[]},await this._init(),this.getMainData()}_clearPropertyMappings(){this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyPathCache.clear(),this._propertyLabelMap.clear(),this._editorPathCache.clear(),this.properties.length=0,this._colorIndex=0,this._originValueStore.clear()}_sortProperties(){this.properties.sort((t,n)=>(t.level??0)-(n.level??0))}async _init(){const t=this.engineObject;this._clearPropertyMappings();const r=(await this._groupCurveBindingsByParent(t.curveBindings)).map(async a=>{if(await this._generatePropertiesFromBindingGroup(a),this.isSubAsset)return Promise.resolve();const o=a.bindings.flatMap(s=>{const{curve:i}=s;return i.keys.map(c=>this._editorValueToEngineValue(c.value,this._getValueTypeByCurve(i)).then(p=>{c.value=p}))});return Promise.all(o)});if(!this.isSubAsset){const{properties:a,pathPropertyMap:o}=this;a.forEach(s=>{s.properties.length||this._colorIndex++,o.set(s.path,s),s.properties.forEach(i=>{this._colorIndex++,o.set(i.path,i)})})}await Promise.all(r),this._sortProperties();const e={};t.events.forEach(a=>{const o=q(),s=a.parameter?typeof a.parameter:"null";e[o]={id:o,time:a.time,functionName:a.functionName,paramType:s,string:s==="string"?a.parameter:void 0,number:s==="number"?a.parameter:void 0}}),this.data={name:t.name,curveBindings:t.curveBindings,events:[]},this.updateEvents(e,!1)}async onDoubleClick(){Te(this.root,"AnimationClip",{afterOpen:()=>{rt()}})}getMainData(){const t=this.data,n={...t,curveBindings:t.curveBindings.map(r=>{const{curve:e}=r,a=lt.get(e.constructor);return{...r,type:K.get(r.type)||r.type,curveType:a,curve:{interpolation:e.interpolation,keys:e.keys.map(o=>{const s=o.value,i=s instanceof nt?this.root.assetStore.engineObjectToAssetMap.get(s).getCurrentRef():s;return{...o,value:W(i)}})}}})};return JSON.stringify(n)}async _syncToEditor(){const t=this.rootEntity,{curveBindings:n}=this.engineObject,r=n.map(async e=>{const{relativePath:a,type:o,property:s,getProperty:i}=e,c=K.get(o);if(!e.curve.keys.length)return;const p=await this._getActualPropertyPath(i??s,a,c),{editorReference:h,engineGetReference:u,editorPropertyPath:d,enginePropertyGetPath:l,propertyPos:m}=await this._getReferenceAndActualPropertyPath(t,{relativePath:a,componentType:c,propertyPath:p});if(!u||!h)return;const f=F({relativePath:a,componentType:c,propertyPath:d.slice(0,m+1).join(".")}),A=this.pathPropertyMap.get(f);let P=d[m],b=this._getEngineValue(u,l[m]),v=A.valueType;P==="rotationQuaternion"&&(P="rotation",b=b.toEuler(new at).scale(180/Math.PI),v=y.Vector3);const w=this._engineValueToEditorValue(b,v,!1);this._setEditorValue(h,P,w)});await Promise.all(r)}async _setEditorValue(t,n,r){var o,s;const e=(o=oe(t))==null?void 0:o[n],a=(s=H(t))==null?void 0:s[n];if(a!=null&&a.getEditorValue&&(r=a.getEditorValue(r)),a!=null&&a.setActualEditorValue?a==null||a.setActualEditorValue(t,n,r):t[n]=r,e!=null&&e.onChange){const i=r!=null&&r.refId?await t.root.assetStore.getAssetByRef(r):r;await e.onChange(t,n,i)}}_removeCurveBindings(t){const n=this.engineObject;if(!n)return;const r=new Set;for(const e of t){const a=this._propertyCurveMap[e];a&&(r.add(a),delete this._propertyCurveMap[e])}if(r.size>0){const e=n.curveBindings;for(let a=e.length-1;a>=0;a--){const o=e[a];r.has(o.curve)&&(e.splice(a,1),this._originValueStore.delete(o))}}}async _updateCurveBindings(){var n;const t=this.rootEntity;if(t)for(const r of this.properties)try{const{relativePath:e,componentType:a,valueType:o,properties:s,interpolationType:i}=r,c=F(r),p=await this._getReferenceAndActualPropertyPath(t,r),{editorReference:h,enginePropertySetPath:u,enginePropertyGetPath:d,editorPropertyPath:l,propertyPos:m}=p||{};if(!h||!u||!d||m===void 0)continue;const f=l[m],A=(n=H(h))==null?void 0:n[f],P=u.join("."),b=d.join(".");if(s.length)for(const v of s){const w=F(v),S=this._createCurve(w,v.valueType,v.interpolationType),M=v.name;await this._addCurveBinding(e,a,`${P}.${M}`,`${b}.${M}`,S),this._propertyCurveMap[w]=S}else{let v=o;A!=null&&A.valueType&&(v=A.valueType);const w=this._createCurve(c,v,i);await this._addCurveBinding(e,a,P,b,w),this._propertyCurveMap[c]=w}}catch(e){console.warn("updateCurveBindings skipped property (unresolved):",r==null?void 0:r.propertyPath,e);continue}}_createCurve(t,n,r){let e=this._propertyCurveMap[t];if(!e){const a=Z.get(n);a?(e=new a.curveClass,e.interpolation=r??a.defaultInterpolation):console.warn(`Unsupported curve value type: ${n}`)}return e}async _addCurveBinding(t,n,r,e,a){const o=ie.getClass(n),s=this.engineObject;let i=!0;for(let c=0,p=s.curveBindings.length;c<p;++c){const h=s.curveBindings[c];h.relativePath===t&&h.type===o&&h.property===r&&h.getProperty===e&&(h.curve=a,i=!1)}i&&(s.addCurveBinding(t,o,r,e,a),await this.saveEditorOriginValue())}_addPropertyToList(t,n,r,e=!0){var i;const a=this._covertToPropertyData(n,r),o=t.push(a),s=t[o-1];return this.pathPropertyMap.set(s.path,s),e&&((i=n.children)!=null&&i.length)&&n.children.forEach(c=>{this._addPropertyToList(s.properties,c,s,e)}),s}_delPropertyFromList(t,n){const r=t.findIndex(e=>e.path===n.path);r>-1&&(t.splice(r,1),this.pathPropertyMap.delete(n.path))}_covertToPropertyData(t,n){const{name:r,label:e,relativePath:a,componentType:o,propertyPath:s,type:i,valueType:c,interpolationType:p,children:h}=t,u=F(t),d=F(n),l=a.split("/").length-1;return{name:e||r,level:l,path:u,type:i,valueType:c,interpolationType:p,propertyPath:s,componentType:o,relativePath:a,hasSubProperty:h.length>0,curveColor:c===y.Float?this._getRandomColor():null,supported:!0,properties:[],parentPath:d}}async _getReferenceAndActualPropertyPath(t,n){if(!t)return{};const{relativePath:r,componentType:e,propertyPath:a}=n,o=t.findByPath(r);if(!o)return{};const s=o.getComponentByTypeName(e);if(!s)return{};const i=[],c=[],p=[],h=a.split("."),u=h.length-1;let d=-1,l=s;for(let P=0,b=u;P<=b;++P){const v=h[P];if(!l)return{};const w=H(l);let S="",M=v,k=v,z=v,B=P;for(let R=P,J=u;R<=J;++R){S+=h[R];const Q=(w==null?void 0:w[S])||{},{getPath:U,setPath:L,editorKey:tt}=Q;L&&(k=L,B=R),(U||L)&&(R===u&&L?k=L:k=U??L,z=U??L,B=R),tt&&(M=tt,B=R),R<u&&(S+=".")}P=B,c.push(k),p.push(z),i.push(M),pe(l,M)&&(d=i.length-1),P<u&&(l=l[M],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l)))}const m=d>-1?d-1:i.length-1;l=s;for(let P=0,b=m;P<b;++P)l=l[i[P]],l!=null&&l.refId&&(l=await this.root.assetStore.getAssetByRef(l));const f=this._getEngineValue(s.engineObject,c.slice(0,m).join(".")),A=this._getEngineValue(s.engineObject,p.slice(0,m).join("."));return{editorReference:l,engineSetReference:f,engineGetReference:A,enginePropertySetPath:c,enginePropertyGetPath:p,editorPropertyPath:i,propertyPos:m,subPropertyPos:d}}_getEngineValue(t,n){if(!n)return t;let r=t;const e=n.split(".");for(let a=0,o=e.length;a<o;a++){const s=e[a];if(s.indexOf("[")>-1){const i=s.indexOf("[");r=r[s.slice(0,i)],r=r[parseInt(s.slice(i+1,-1))]}else if(s.endsWith(")")){const i=s.slice(0,s.indexOf("(")),c=s.match(/\w+\(([^)]*)\)/)[1].split(",").map(p=>p.trim().replace(/['"]+/g,"")).filter(p=>p!=="");r=r[i](...c)}else r=r[s]}return r}async _generateKeyframeDataList(){const t=this.engineObject,n=[],r=this.pathPropertyMap,e=t.curveBindings.map(async a=>{const{relativePath:o,type:s,getProperty:i,property:c,curve:p}=a,h=K.get(s),u=i??c,d=await this._convertPropertyProxyPath(u,h,o),m=F({relativePath:o,componentType:h,propertyPath:d||u});d||console.warn(`无法转换引擎路径到编辑器路径: ${u},使用原路径`);const f=r.get(m);if(!f){d&&console.warn(`转换后的路径仍未找到属性定义: ${m}, 原引擎路径: ${u}`);return}this._propertyCurveMap[m]=p;const A=f.valueType;p.keys.forEach(P=>{const{time:b,value:v,inTangent:w,outTangent:S}=P,M=Math.floor(b*this.samples),k=this._engineValueToEditorValue(v,A,!0),z=this._getSubProperties(A,p);if(z)z.forEach(B=>{const R=`${m}.${B}`,J=r.get(R),Q=w&&w[B],U=S&&S[B],L=this._createKeyframeData(M,k[B],y.Float,Q,U,J,f);n.push(L)});else{const B=r.get(f.parentPath),R=this._createKeyframeData(M,k,A,w,S,f,B);n.push(R)}})});await Promise.all(e),this.updateKeyframes(n,!1)}_createKeyframeData(t,n,r,e,a,o,s){const{path:i,curveColor:c}=o,{path:p=""}=s||{};return{id:q(),frame:t,path:i,value:n,isActive:!0,valueType:r??y.Float,curveColor:c,parentPath:p,inTangent:e,outTangent:a,interpolationType:o.interpolationType,inTangentMode:e===void 0?x.Linear:e===-1/0?x.Constant:x.Free,outTangentMode:a===void 0?x.Linear:a===-1/0?x.Constant:x.Free}}_generateEngineKeyframes(t){const{_propertyCurveMap:n,samples:r,engineObject:e}=this,a=this._groupKeyframesByPath(t),s=this._collectPathsToSync(n,a).map(i=>this._syncCurveForPath(i,n[i],a.get(i)||[],r,e));this._parseKeyframeValuePromise=Promise.all(s)}_groupKeyframesByPath(t){return t.reduce((n,r)=>{const e=n.get(r.path)||[];return e.push(r),n.set(r.path,e),n},new Map)}_collectPathsToSync(t,n){const r=new Set;return Object.keys(t).forEach(e=>r.add(e)),n.forEach((e,a)=>r.add(a)),Array.from(r)}async _syncCurveForPath(t,n,r,e,a){if(!n)return;const o=await this._convertToEngineKeyframes(r,e);this._removeObsoleteKeyframes(n,o),this._addOrUpdateKeyframes(n,o,a)}async _convertToEngineKeyframes(t,n){const r=new Map;for(const e of t){const a=e.frame/n,o=await this._editorValueToEngineValue(e.value,e.valueType);o===void 0&&e.valueType===y.ReferResource||r.set(a,{value:o,inTangent:e.inTangent,outTangent:e.outTangent})}return r}_removeObsoleteKeyframes(t,n){const r=new Set(n.keys());for(let e=t.keys.length-1;e>=0;e--){const a=t.keys[e];r.has(a.time)||t.keys.splice(e,1)}}_addOrUpdateKeyframes(t,n,r){const e=new Map;t.keys.forEach(a=>{e.set(a.time,a)});for(const[a,{value:o,inTangent:s,outTangent:i}]of n){const c=e.get(a);if(c)c.value=o,c.inTangent=s,c.outTangent=i;else{const p=new Pe;p.time=a,p.value=o,p.inTangent=s,p.outTangent=i,t.addKey(p)}a>r._length&&(r._length=a)}}async _editorValueToEngineValue(t,n){var r;switch(n){case y.ReferResource:return t!=null&&t.refId?(r=await this.root.assetStore.getAssetByRef(t))==null?void 0:r.engineObject:t;case y.Color:return new ye(t.r,t.g,t.b,t.a);case y.Vector2:return new ue(t.x,t.y);case y.Vector3:return new at(t.x,t.y,t.z);case y.Vector4:return new he(t.x,t.y,t.z,t.w);case y.Quaternion:return new le(t.x,t.y,t.z,t.w);case y.Rect:return new ce(t.x,t.y,t.width,t.height);case y.Float:return t;default:return t}}_engineValueToEditorValue(t,n,r){var a,o,s;let e;switch(n){case y.MethodParam:{if(e=[],r)for(let i=0,c=t.length;i<c;i++){const p=t[i];e[i]??(e[i]=[]);for(let h=0,u=p.length;h<u;h++){const d=p[h];e[i][h]=((a=this.root.assetStore.engineObjectToAssetMap.get(d))==null?void 0:a.getCurrentRef())??d}}else t&&t instanceof nt?e=[[((o=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:o.getCurrentRef())??t]]:t instanceof Array?e=t:e=[[t]];break}case y.ReferResource:{e=(s=this.root.assetStore.engineObjectToAssetMap.get(t))==null?void 0:s.getCurrentRef();break}case y.Color:{e={r:t.r,g:t.g,b:t.b,a:t.a},["r","g","b","a"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Vector2:{e={x:t.x,y:t.y},["x","y"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Vector3:{e={x:t.x,y:t.y,z:t.z},["x","y","z"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Vector4:case y.Quaternion:{e={x:t.x,y:t.y,z:t.z,w:t.w},["x","y","z","w"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Rect:{e={x:t.x,y:t.y,width:t.width,height:t.height},["x","y","width","height"].forEach(i=>{e[i]=Math.round(e[i]*1e3)/1e3});break}case y.Float:{e=Math.round(t*1e3)/1e3;break}default:e=t}return e}_getValueTypeByCurve(t){return ct.get(t.constructor)}_parsePropertyPath(t){const n=this._propertyPathCache.get(t);if(n)return n;const r=t.lastIndexOf("."),e=r===-1?{parentPath:t,subProperty:null}:{parentPath:t.substring(0,r),subProperty:t.substring(r+1)};return this._propertyPathCache.set(t,e),e}_isSubPropertyName(t){return/^([xyzw]|[rgba]|width|height)$/.test(t)}async _convertPropertyProxyPath(t,n,r){try{const e=this._resolveProxyHost(n,r,t);if(!e)return null;const a=`${r}|${n}|${t}`;if(this._editorPathCache.has(a))return this._editorPathCache.get(a);const o=await this._recursiveConvert(t,e,0);return o&&o!==t&&await this._buildLabelMappingsForPath(o,r,n,e),this._editorPathCache.set(a,o??null),o}catch{const a=`${r}|${n}|${t}`;return this._editorPathCache.set(a,null),null}}async _buildLabelMappingsForPath(t,n,r,e){try{const a=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t}),o=(a==null?void 0:a.editorPropertyPath)||t.split("."),s=typeof(a==null?void 0:a.propertyPos)=="number"?a.propertyPos:o.length-1;for(let i=0;i<=s;i++){const c=o.slice(0,i+1).join("."),p=F({relativePath:n,componentType:r,propertyPath:c});if(!this._propertyLabelMap.has(p)){const h=await this._extractLabelForPartialPath(c,e);h&&this._propertyLabelMap.set(p,h)}}}catch(a){console.warn("建立标签映射失败:",a)}}async _extractLabelForPartialPath(t,n){try{const r=t.split("."),e=r[r.length-1];let a=n,o=null;for(let s=0;s<r.length;s++){const i=r[s],c=a==null?void 0:a[G];if(c&&c[i]){const p=c[i];p.label&&(o=p.label),s<r.length-1&&(a=await this._getNextObject(a,i))}else break}return o||e}catch{return t.split(".").pop()||t}}async _recursiveConvert(t,n,r){if(r>6)return t;const e=n[G];if(!e)return t;for(const[a,o]of Object.entries(e)){if(!this._isPathMatch(t,o))continue;const s=o.getPath||o.setPath;if(s){if(s.endsWith("()")&&t.startsWith(s+".")){const i=t.substring(s.length+1),c=await this._getNextObject(n,a);if(!c)return`${a}.${i}`;const p=await this._recursiveConvert(i,c,r+1);return p?`${a}.${p}`:`${a}.${i}`}return this._buildEditorPath(a,t,o)}}return t}async _getNextObject(t,n){var r;try{let e=t[n];if(!e){const a=`get${n.charAt(0).toUpperCase()+n.slice(1)}`;typeof t[a]=="function"&&(e=t[a]())}if(e!=null&&e.refId&&((r=this.root)!=null&&r.assetStore)){let a=this.root.assetStore.engineObjectToAssetMap.get(e);if(!a)try{a=await this.root.assetStore.getAssetByRef(e)}catch{return e}if(a)return a}return e}catch{return null}}_resolveProxyHost(t,n,r){try{if(!this.rootEntity)return null;const e=n?this.rootEntity.findByPath(n):this.rootEntity;if(!e)return null;const a=e.getComponentByTypeName(t);return a?r?this._resolvePropertyProxyHolder(a,r):a:null}catch(e){return console.warn(`获取代理宿主失败: ${t}, ${n}`,r,e),null}}_resolvePropertyProxyHolder(t,n){try{const r=[t];this._addRelatedObjectCandidates(t,r);for(const e of r)if(this._hasMatchingProxyConfig(e,n))return e;return t}catch(r){return console.warn(`解析 PropertyProxy 持有者失败: ${n}`,r),t}}_addRelatedObjectCandidates(t,n){try{const r=t[G];if(!r)return;const e=new Set;for(const a of Object.values(r)){const o=this._extractObjectPathFromConfig(a);o&&e.add(o)}for(const a of e){const o=this._getEngineValue(t.engineObject,a);if(o){const s=this.root.assetStore.engineObjectToAssetMap.get(o);s&&!n.includes(s)&&n.push(s)}}}catch{}}_extractObjectPathFromConfig(t){const n=t.getPath||t.setPath;if(!n)return null;const r=n.match(/^([^.]+\([^)]*\))/);return r?r[1]:null}_hasMatchingProxyConfig(t,n){const r=t[G];if(!r)return!1;for(const e of Object.values(r))if(this._isPathMatch(n,e))return!0;return!1}_isPathMatch(t,n){return n?n.getPath&&this._isExactPathMatch(t,n.getPath)||n.setPath&&this._isExactPathMatch(t,n.setPath)||n.engineKey&&t.includes(n.engineKey):!1}_isExactPathMatch(t,n){if(!n)return!1;const r=p=>p.replace(/['"`\s]/g,""),e=p=>{let h="";for(let u=0;u<p.length;u++){const d=p[u];if(d==="("){for(;u<p.length&&p[u]!==")";)u++;h+="()"}else h+=d}return h},a=p=>e(r(p).replace(/\$value/g,"value")),o=a(t),s=a(n);if(o===s||((p,h)=>p.startsWith(h+".")||p.startsWith(h+"["))(o,s))return!0;if(!n.includes(".")&&!n.includes("(")&&!n.includes("[")){const p=o.split(".");for(const h of p){const u=h.indexOf("[");if((u>=0?h.slice(0,u):h)===s)return!0}}return!1}_buildEditorPath(t,n,r){if(!r)return t;const e=r.getPath||r.setPath;if(!e)return t;if(e.endsWith("()")&&n.startsWith(e+".")){const s=n.substring(e.length+1);return`${t}.${s}`}const a=n.replace(/['"`]/g,"").replace(/\$value/g,"value"),o=e.replace(/['"`]/g,"").replace(/\$value/g,"value");if(a.includes(o))return a.replace(o,t);if(!e.includes(".")&&!e.includes("(")){const s=n.match(/\.([a-zA-Z_]\w*)$/);if(s){const i=s[1];if(i!==e)return`${t}.${i}`}}return t}_validateCurveBinding(t){const{relativePath:n,type:r,getProperty:e,property:a}=t;return K.get(r)?e??a?!0:(console.warn(`绑定缺少属性路径: ${n}`),!1):(console.warn(`未知组件类型: ${r},跳过绑定`),!1)}async _groupCurveBindingsByParent(t){const n=new Map;return await Promise.all(t.map(async r=>{if(!this._validateCurveBinding(r))return;const{relativePath:e,type:a,getProperty:o,property:s}=r,i=K.get(a),c=o??s,h=await this._convertPropertyProxyPath(c,i,e)||c,u=this._parsePropertyPath(h),d=u.subProperty&&this._isSubPropertyName(u.subProperty);let l,m;d&&u.subProperty?(m=u.parentPath,l=`${e}.${i}.${m}`):(m=h,l=`${e}.${i}.${h}`),n.has(l)||n.set(l,{parentPath:m,relativePath:e,componentType:i,bindings:[]}),n.get(l).bindings.push(r)})),Array.from(n.values())}_validateAndGetParentValueType(t){if(t.length===1){const l=t[0],m=l.getProperty??l.property,{subProperty:f}=this._parsePropertyPath(m);return!f||!this._isSubPropertyName(f)?null:y.Float}if(!t.every(l=>this._getValueTypeByCurve(l.curve)===y.Float)){const l=t.map(m=>this._getValueTypeByCurve(m.curve));return console.warn(`分组中的绑定类型不一致: ${l.join(", ")},无法创建父属性`),null}const r=t.map(l=>l.curve.interpolation),e=r[0];r.every(l=>l===e)||console.warn(`子属性插值类型不一致: ${r.join(", ")}`);const o=t.map(l=>{const m=l.getProperty??l.property,f=m.lastIndexOf(".");return f===-1?null:m.substring(f+1)}).filter(Boolean).sort(),s=o.join(",");switch(s){case"x,y":return y.Vector2;case"x,y,z":return y.Vector3;case"w,x,y,z":return y.Vector4;case"a,b,g,r":return y.Color;case"height,width,x,y":return y.Rect}const i=new Set(["x","y","z","w"]),c=new Set(["r","g","b","a"]),p=new Set(["x","y","width","height"]),h=o.every(l=>i.has(l)),u=o.every(l=>c.has(l)),d=o.every(l=>p.has(l));return h?o.some(l=>l==="w")?y.Vector4:o.some(l=>l==="z")?y.Vector3:y.Vector2:u?y.Color:d?y.Rect:(console.warn(`无法识别的子属性组合: ${s}`),null)}_validateBindingGroup(t){const{bindings:n}=t;return n.every(r=>this._validateCurveBinding(r))&&this._validateAndGetParentValueType(n)!==null}_createParentProperty(t,n){const{parentPath:r,relativePath:e,componentType:a}=t,o=F({relativePath:e,componentType:a,propertyPath:r}),s=I.Linear,i=this._propertyLabelMap.get(o),c=r.split(".").pop()||r;return{name:i||c,level:e.split("/").length-1,path:o,type:O.Property,valueType:n,interpolationType:s,componentType:a,relativePath:e,hasSubProperty:!0,curveColor:null,supported:!0,properties:[],propertyPath:r}}async _createSubPropertiesFromBindings(t,n,r,e){return Promise.all(t.map(async a=>{const{getProperty:o,property:s,curve:i}=a,c=o??s,p=await this._convertPropertyProxyPath(c,e,r)||c,h=p.lastIndexOf("."),u=h===-1?p:p.substring(h+1),d=`${n}.${u}`,l={name:u,level:r.split("/").length,path:d,type:O.SubProperty,valueType:y.Float,interpolationType:i.interpolation,componentType:e,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p,parentPath:n};return this.pathPropertyMap.set(d,l),l}))}_registerPropertyGroup(t,n){t.properties=n,this.pathPropertyMap.has(t.path)&&console.warn(`覆盖已存在的属性路径: ${t.path}`),this.pathPropertyMap.set(t.path,t),this.properties.push(t)}async _generatePropertiesFromBindingGroup(t){const{parentPath:n,relativePath:r,componentType:e,bindings:a}=t;if(!this.rootEntity){await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const o=await this._convertPropertyProxyPath(n,e,r)||n;if(!this._validateBindingGroup(t)){this.rootEntity&&a.length>1&&console.debug("AnimationClipAsset: grouping skipped",this.name,e,r,n),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const s=this._validateAndGetParentValueType(a);if(s===null){console.error("验证通过但获取不到父属性类型"),await Promise.all(a.map(p=>this._generatePropertyByEngineObject(p)));return}const i=this._createParentProperty({...t,parentPath:o},s),c=await this._createSubPropertiesFromBindings(a,i.path,r,e);this._registerPropertyGroup(i,c)}async _generatePropertyByEngineObject(t){const{pathPropertyMap:n}=this,{relativePath:r,type:e,curve:a,getProperty:o,property:s}=t,i=K.get(e),c=o??s,p=await this._convertPropertyProxyPath(c,i,r)??c,h=this._getValueTypeByCurve(a),u=F({relativePath:r,componentType:i,propertyPath:p}),d=this._propertyLabelMap.get(u),l=p.lastIndexOf("."),m=l===-1?p:p.substring(l+1),f={name:d||m,level:r.split("/").length-1,path:u,type:O.Property,valueType:h,interpolationType:a.interpolation,componentType:i,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:p},A=this._getSubProperties(h,a);A&&(f.curveColor=null,f.hasSubProperty=!0,f.properties=A.map(P=>{const b=`${u}.${P}`,v={name:P,level:r.split("/").length,path:b,type:O.SubProperty,valueType:y.Float,interpolationType:a.interpolation,componentType:i,relativePath:r,hasSubProperty:!1,curveColor:this._getRandomColor(),supported:!0,properties:[],propertyPath:`${p}.${P}`};return n.set(b,v),v})),n.set(u,f),this.properties.push(f)}async _getActualPropertyPath(t,n,r){if(!this.isSubAsset){const{editorPropertyPath:e=[]}=await this._getReferenceAndActualPropertyPath(this.rootEntity,{relativePath:n,componentType:r,propertyPath:t});t=e.join(".")}return t}_getRandomColor(){const{_colorList:t}=this,n=(e,a)=>{const o=parseInt(e.slice(1),16),s=parseInt(a.slice(1),16);return`#${parseInt(`${(o+s)/2}`).toString(16).toUpperCase()}`},r=()=>{const e=[];for(let o=0,s=t.length-1;o<s;o++){const i=n(t[o],t[o+1]);e.push(i)}const a=t.slice(0,t.length-1);for(let o=0,s=a.length+e.length;o<s;o++)t[o]=o%2===0?a[o/2]:e[(o-1)/2]};for(;this._colorIndex>=t.length;)r();return t[this._colorIndex++]}_getSubProperties(t,n){let r;switch(t){case y.Vector2:{r=["x","y"];break}case y.Vector3:{r=["x","y","z"];break}case y.Vector4:{r=["x","y","z","w"];break}case y.Quaternion:{r=["x","y","z","w"];break}case y.Color:{r=["r","g","b","a"];break}case y.Array:case y.FloatArray:n.keys[0]&&(r=Array.from(n.keys[0].value).map((e,a)=>a))}return r}_listenRootEntityChanged(){var n;const t=this.rootEntity;t&&(this.showEditor&&(this.openEditor(!1),this.openEditor(!0)),(n=this._componentsChangedListenerDisposer)==null||n.call(this),this._componentsChangedListenerDisposer=de(()=>t.components.length,()=>{this.checkPropertiesSupport(t),this.engineObject.curveBindings.forEach(r=>{r._tempCurveOwner={}})}))}_convertPropertyToTreeItem(t){var m;const{name:n,label:r,properties:e=[],relativePath:a,componentType:o,path:s,type:i,curveColor:c,supported:p,level:h}=t,u=((m=this.rootEntity.findByPath(a))==null?void 0:m.name)||a.split("/").pop(),d=r||n;return{name:i===O.Property?`${u}:${o}.${d}`:d,id:s,canAddKeyframe:i===O.Property||i===O.SubProperty,curveColor:c,supported:p,level:h,children:e.map(f=>this._convertPropertyToTreeItem(f))}}_ensurePropertyExists(t){const n=F(t);let r=this.pathPropertyMap.get(n);return r||(r=this.addProperty(t)),t.children&&t.children.length&&t.children.forEach(e=>{this._ensurePropertyExists(e)}),r}destroy(){var t;super.destroy(),(t=this._componentsChangedListenerDisposer)==null||t.call(this),this._propertyPathCache.clear(),this.pathPropertyMap.clear(),this._propertyCurveMap={},this._propertyLabelMap.clear(),this._editorPathCache.clear(),this._originValueStore.clear()}};T([D],C.prototype,"samples",2);T([D],C.prototype,"properties",2);T([D],C.prototype,"keyframeDataList",2);T([D],C.prototype,"events",2);T([me()],C.prototype,"data",2);T([D],C.prototype,"selectedEventId",2);T([D,fe()],C.prototype,"rootEntityId",2);T([D],C.prototype,"readOnly",2);T([ge],C.prototype,"addedPropertiesTreeData",1);T([E],C.prototype,"addProperty",1);T([E],C.prototype,"delProperty",1);T([E],C.prototype,"addKeyframe",1);T([E],C.prototype,"deleteKeyframes",1);T([E],C.prototype,"updateKeyframes",1);T([E],C.prototype,"addEvent",1);T([E],C.prototype,"deleteEvent",1);T([E],C.prototype,"updateEvents",1);T([E],C.prototype,"updateSamples",1);T([E],C.prototype,"updateRootEntity",1);T([E],C.prototype,"setTangentMode",1);T([E],C.prototype,"checkPropertiesSupport",1);T([E],C.prototype,"updateSelectedEvent",1);T([E],C.prototype,"openEditor",1);C=T([_e({type:"AnimationClip",label:j("asset.animation-clip.title"),icon:"animate-clip",extname:"anim",importMenuConfig:{type:ve.Add},customInspector:Se,viewer:$,async bundle({content:_},t,n){var a;const r=JSON.parse(await _.text());for(const o of r.curveBindings)if(o.curveType==="AnimationRefCurve"){for(const s of o.curve.keys)if((a=s.value)!=null&&a.refId){const i=n.resolveRef(s.value.refId);i&&(s.value=i)}}const e=pt(r,{type:"AnimationClip",name:r.name});return{content:new Blob([e])}}})],C);export{C as A,Se as a,$ as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var j=Object.defineProperty;var O=(r,t,a)=>t in r?j(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a;var c=(r,t,a)=>(O(r,typeof t!="symbol"?t+"":t,a),a);import{aT as v,aU as x,aJ as N,aD as S,aK as B,aI as I,j as L,aZ as U,a_ as z,a$ as F,u as M,b0 as R,m as _,b1 as J,e as V,n as $,b2 as K}from"./index-0a8702e2.js";import{u as W,a as Z,A as k}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import"./meshopt_simplifier.module-cd99529d.js";import{b as q}from"./bundlers-9b0d37fc.js";import{o as G}from"./assetEditorActions-c4e5962f.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";const H=v(function(){const{layoutStore:t}=W(),{t:a}=x(),e=N.useCallback(()=>{t.toggleTabVisibility("AnimatorController")},[]);return S.jsx(B,{align:"both",css:{padding:"$1"},fullWidth:!0,children:S.jsx(I,{size:"sm",onClick:e,children:a("animation.animator-controller.editor.open")})})});var Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,y=(r,t,a,e)=>{for(var s=e>1?void 0:e?X(t,a):t,o=r.length-1,i;o>=0;o--)(i=r[o])&&(s=(e?i(t,a,s):i(s))||s);return e&&s&&Q(t,a,s),s};let d=class extends L{constructor(t){super(t);c(this,"statesNameMap",{});c(this,"internalDataUpdated",!1);c(this,"layers",[]);c(this,"parameters",[]);c(this,"_syncing");c(this,"_syncingPromise");this.onDoubleClick=this.onDoubleClick.bind(this)}applyPropertyFromDomain(t,a){super.applyPropertyFromDomain(t,a),(t==="layers"||t==="parameters")&&this.applyControllerData().catch(e=>{console.error("[AnimatorControllerAsset] applyControllerData failed:",e)})}initByEngineObject(t){return this.setNameByIncrease("AnimatorController"),this.bindEngineObject(t),this.layers=t.layers.map(a=>{const e=a.stateMachine,o={states:e.states.map(i=>({name:i.name,speed:i.speed,wrapMode:i.wrapMode,clipStartNormalizedTime:i.clipStartTime,clipEndNormalizedTime:i.clipEndTime,clip:this.root.assetStore.engineObjectToAssetMap.get(i.clip).getCurrentRef(),transitions:[],scripts:[],isEntryState:i===e.defaultState,isExitState:!1,isAnyState:!1})),transitions:[],entryTransitions:[],anyTransitions:[]};return{name:a.name,blendingMode:a.blendingMode,weight:a.weight,stateMachine:o}}),this.internalDataUpdated=!0,this.getMainData()}async initByMain(t){const{internalDataUpdated:a}=this.meta;a&&(this.internalDataUpdated=!0);const e=JSON.parse(await t.text()),s=new U(this.engine);this.bindEngineObject(s),this.layers=e.layers||[],this.parameters=e.parameters||[],await this.applyControllerData()}async applyControllerData(){this._syncing&&await this._syncingPromise,this._syncing=!0;try{this.statesNameMap={};const t=this.engineObject;t.clearLayers(),t._parameters.length=0,t._parametersMap={};const{layers:a,parameters:e}=this;this._syncingPromise=Promise.all(a.map((s,o)=>{const{name:i,blendingMode:m,weight:u}=s,l=new z(i);return t.addLayer(l),l.blendingMode=m,l.weight=u,this._applyStateMachineData(o)})),e.forEach(s=>{const{isTrigger:o,name:i,defaultValue:m}=s;o?t.addTriggerParameter(i):t.addParameter(i,m)}),await this._syncingPromise}finally{this._syncing=!1}}async initByCreation(){return this.layers=[{name:"Base",weight:1,blendingMode:F.Override,stateMachine:{states:[],transitions:[],entryTransitions:[],anyTransitions:[]}}],this.getMainData()}onDoubleClick(){G(this.root,"AnimatorController",{clearSceneSelection:!0})}async _applyStateMachineData(t){const a=this.engineObject.layers[t],{stateMachine:e}=this.layers[t],s=a.stateMachine;if(e){const{states:o=[],transitions:i=[],entryTransitions:m=[],anyTransitions:u=[]}=e,l={},T={},w=o.map(async n=>{var A,E;const{id:h,name:f,speed:b,wrapMode:g,clipStartNormalizedTime:P,clipEndNormalizedTime:D,clip:C}=n;(A=this.statesNameMap)[t]||(A[t]={}),this.statesNameMap[t][n.name]=n;const p=s.addState(f);p.speed=b,p.wrapMode=g,p.clipStartTime=P,p.clipEndTime=D,l[h]=p,C&&(p.clip=(E=await this.root.assetStore.getAssetByRef(C))==null?void 0:E.engineObject)});i.forEach(n=>{const h=this._createTransition(n,l[n.destinationStateId]);T[n.id]=h}),o.forEach(n=>{const{id:h,transitions:f}=n;f.forEach(b=>{const g=T[b];g&&l[h].addTransition(g)})}),m.forEach(n=>{s.addEntryStateTransition(this._createTransition(n,l[n.destinationStateId]))}),u.forEach(n=>{s.addAnyStateTransition(this._createTransition(n,l[n.destinationStateId]))}),await Promise.all(w),this.engineObject._updateFlagManager.dispatch()}}_createTransition(t,a){const e=new K;return e.duration=t.duration,e.offset=t.offset,e.exitTime=t.exitTime,e.solo=t.solo,e.mute=t.mute,e.hasExitTime=t.hasExitTime,e._isExit=t.isExit,e.destinationState=a,t.conditions.forEach(s=>{e.addCondition(s.parameterName,s.mode,s.threshold)}),e}};y([M,R()],d.prototype,"internalDataUpdated",2);y([_(),M],d.prototype,"layers",2);y([_(),M],d.prototype,"parameters",2);y([J],d.prototype,"applyPropertyFromDomain",1);d=y([Z({type:"AnimatorController",label:V("asset.animator-controller.title"),icon:"animate-controller",extname:"animCtrl",importMenuConfig:{type:k.Add},dragLayer:$.AnimationController,customInspector:H,async bundle({content:r}){return{content:new Blob([q(await r.text())])}}})],d);export{d as AnimatorControllerAsset};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var P=(n,o,t)=>o in n?f(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t;var i=(n,o,t)=>(P(n,typeof o!="symbol"?o+"":o,t),t);import{E as y,bc as u,s as m,p as c,C as d,t as h,e as C,bd as _,be as v,o as g,bf as S,bg as O}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as A}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";var w=Object.defineProperty,E=Object.getOwnPropertyDescriptor,p=(n,o,t,r)=>{for(var e=r>1?void 0:r?E(o,t):o,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(o,t,e):l(e))||e);return r&&e&&w(o,t,e),e};let s=class extends y{constructor(o,t){super(o,t);i(this,"animatorController",null);i(this,"cullingMode",u.None);i(this,"speed",1)}async bindEngineObject(o){await super.bindEngineObject(o),o.enabled=!1}};p([m(),c({type:d.AssetPicker,assetType:"AnimatorController",label:"animation.animator-controller.controller.title",info:"animation.animator-controller.controller.info",bindPath:"animatorController"})],s.prototype,"animatorController",2);p([m(),c({type:d.Select,label:"animation.animator-controller.culling-mode.title",info:"animation.animator-controller.culling-mode.info",options:h(u,void 0,n=>C(`animation.animator-controller.culling-mode.${n.toLowerCase()}`)),bindPath:"cullingMode"})],s.prototype,"cullingMode",2);p([m(),c({type:d.Number,label:"animation.animator-controller.speed.title",info:"animation.animator-controller.speed.info",bindPath:"speed"})],s.prototype,"speed",2);s=p([A({type:"Animator",componentsMenu:{label:"component.animator.title"},unique:!0})],s);class M extends _{constructor(){super(...arguments);i(this,"_animatorComponents",[]);i(this,"onScriptPlay")}init(t){this.onScriptPlay=t.onScriptPlay}onPlay(t){this.engine.sceneManager.scenes[0].rootEntities.forEach(e=>{e.getComponentsIncludeChildren(v,this._animatorComponents)}),this._animatorComponents.forEach(e=>{e.enabled=t,t||e._reset()}),this.onScriptPlay&&this.onScriptPlay(t)}}var j=Object.defineProperty,D=Object.getOwnPropertyDescriptor,$=(n,o,t,r)=>{for(var e=r>1?void 0:r?D(o,t):o,a=n.length-1,l;a>=0;a--)(l=n[a])&&(e=(r?l(o,t,e):l(e))||e);return r&&e&&j(o,t,e),e};let b=class{constructor(n){i(this,"script");i(this,"root");g(this),this.root=n}init(){this.script=S.addScript(M),this.script.init({onScriptPlay:n=>{var o;(o=this.root.animatorControllerStore)==null||o.updateGlobalPlayState(n)}})}};b=$([O({type:"animatorStore"})],b);export{s as A,b as a};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{aC as p,aH as l,aT as o,aD as i,b4 as u,aG as d,aM as x,b5 as g,b6 as m,aJ as r}from"./index-0a8702e2.js";import{I as h}from"./IconPlayerPlayFilled-b058c98f.js";/**
|
|
2
|
-
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/var y=p("filled","player-pause-filled","IconPlayerPauseFilled",[["path",{d:"M9 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z",key:"svg-0"}],["path",{d:"M17 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z",key:"svg-1"}]]);const f=l("div",{position:"absolute",top:0,padding:"$1",backgroundColor:"$panelBg",width:"100%",variants:{sticky:{true:{position:"absolute",top:0}}}}),S=l("div",{height:"220px",width:"100%",border:"1px solid $gray5",borderRadius:"$4",overflow:"hidden"}),j=l("div",{position:"absolute",bottom:"$3",left:0,width:"100%",textAlign:"center",color:"#ddd",textShadow:"0 0 2px #000",fontWeight:"bold",fontSize:"$2"}),z=({asset:t,viewer:e})=>{const a=r.useRef(null),[n,s]=r.useState("");return r.useEffect(()=>{t.startViewer(a.current),s(e.getDescription(t));const c=()=>s(e.getDescription(t));return t.addPropertyChangeListener("engineObjectReady",c),()=>{t.removePropertyChangeListener("engineObjectReady",c),t.stopViewer()}},[t]),i.jsxs(f,{children:[i.jsx(S,{ref:a}),i.jsx($,{asset:t,viewerWithAnimations:e}),n&&i.jsxs(j,{children:[n," "]})]})},v=l("div",{position:"absolute",bottom:8,left:8,right:8,display:"grid",gap:"$1",marginTop:"$1 $2",variants:{hasClips:{true:{gridTemplateColumns:"100px 18px 1fr"},false:{gridTemplateColumns:"$4_5 1fr"}}}}),b=o(function(t){const{frameTime:e,duration:a}=t.clipState;return i.jsx(u,{size:"xs",startSlot:i.jsx(d,{size:"sm",css:{color:"$grayA10"},children:e.toFixed(2).replace(".",":")}),endSlot:i.jsx(d,{size:"sm",css:{color:"$grayA10"},children:a.toFixed(2).replace(".",":")}),tooltip:!1,min:0,max:a||0,disabled:a===0,step:.01,defaultValue:[0],value:[e],onValueChange:n=>{t.clipState.setFrameTime(n[0])},css:{flex:1}})}),C=o(function(t){const e=t.clipState;return i.jsx(x,{size:"xs",onClick:()=>{e.playing=!e.playing,e.playing?e.playAnimation():e.pauseAnimation()},children:e.playing?i.jsx(y,{}):i.jsx(h,{})})}),P=o(function(t){const{animationNames:e,animationIndex:a=0}=t.clipState;return i.jsxs(v,{hasClips:!!e.length,children:[i.jsx(g,{value:a,onValueChange:n=>{t.clipState.selectAnimation&&t.clipState.selectAnimation(n)},valueType:"number",size:"xs",sideOffset:8,children:e.map((n,s)=>n?i.jsx(m,{value:s,children:n},s):null)}),t.children]})}),$=o(function({asset:t,viewerWithAnimations:e}){var n;if(!t.getViewerReady())return null;const a=((n=e.animationNames)==null?void 0:n.length)>0;return a&&e.selectAnimation&&e.selectAnimation(0),a?i.jsxs(P,{clipState:e,children:[i.jsx(C,{clipState:e}),i.jsx(b,{clipState:e})]}):null});export{z as A,y as I};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var b=Object.defineProperty;var m=(t,e,r)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>(m(t,typeof e!="symbol"?e+"":e,r),r);import{aH as y,aT as c,aD as n,o as f,u as d,j as A,a7 as O,e as j}from"./index-0a8702e2.js";import{a as w,A as P}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as _}from"./AssetViewer-bc198e16.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var g=Object.defineProperty,h=Object.getOwnPropertyDescriptor,v=(t,e,r,s)=>{for(var o=s>1?void 0:s?h(e,r):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=(s?a(e,r,o):a(o))||o);return s&&o&&g(e,r,o),o};const x=y("div",{position:"absolute",top:"100px",backgroundColor:"$panelBg",variants:{sticky:{true:{position:"absolute",top:0}}}}),R=c(({asset:t})=>n.jsx(x,{children:n.jsx("audio",{src:t.url,controls:!0,children:"Your browser does not support the audio element."})}));class l extends _{constructor(){super();p(this,"duration",0);p(this,"playing",!1);p(this,"audioName");p(this,"overridePreviewer",c(({asset:r})=>n.jsx(R,{asset:r})));f(this)}setViewAsset(r,s){}}v([d],l.prototype,"duration",2);v([d],l.prototype,"playing",2);var D=Object.defineProperty,U=Object.getOwnPropertyDescriptor,C=(t,e,r,s)=>{for(var o=s>1?void 0:s?U(e,r):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=(s?a(e,r,o):a(o))||o);return s&&o&&D(e,r,o),o};let u=class extends A{constructor(e){super(e);p(this,"urlObj")}async initByMain(e){this.urlObj=e;const r=URL.createObjectURL(e);try{const s=await this.engine.resourceManager.load({url:r,type:O.Audio});this.bindEngineObject(s)}finally{URL.revokeObjectURL(r)}}};u=C([w({type:"Audio",label:j("asset.audio.title"),loaderType:"Audio",importMenuConfig:{type:P.Upload,tooltip:"请上传音频文件(支持 OGG, WAV, MP3)",accept:".ogg,.wav,.mp3"},viewer:l,bundle({content:t}){return{content:t}}})],u);export{u as AudioAsset};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var b=Object.defineProperty;var d=(p,o,e)=>o in p?b(p,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[o]=e;var n=(p,o,e)=>(d(p,typeof o!="symbol"?o+"":o,e),e);import{E as f,p as r,C as a,s as m}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var P=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(p,o,e,u)=>{for(var t=u>1?void 0:u?v(o,e):o,s=p.length-1,y;s>=0;s--)(y=p[s])&&(t=(u?y(o,e,t):y(t))||t);return u&&t&&P(o,e,t),t};let l=class extends f{constructor(o,e){super(o,e);n(this,"clip",null);n(this,"playOnEnabled",!0);n(this,"loop",!0);n(this,"volume",0);n(this,"mute",!1)}};i([r({label:"Audio resource",info:"Audio resource info",type:a.AssetPicker,assetType:"Audio",bindPath:"clip"}),m()],l.prototype,"clip",2);i([r({label:"playOnEnabled",info:"playOnEnabled info",type:a.Toggle,bindPath:"playOnEnabled"}),m()],l.prototype,"playOnEnabled",2);i([r({label:"IsLooping",info:"IsLooping info",type:a.Toggle,bindPath:"loop"}),m()],l.prototype,"loop",2);i([r({label:"Volume",info:"Volume info",type:a.Slider,min:0,max:1,bindPath:"volume"}),m()],l.prototype,"volume",2);i([r({label:"Mute",info:"Mute info",type:a.Toggle,bindPath:"mute"}),m()],l.prototype,"mute",2);l=i([c({type:"AudioSource",componentsMenu:{label:"component.audio.title"}})],l);export{l as AudioComponent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var _=Object.defineProperty;var q=(e,l,a)=>l in e?_(e,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[l]=a;var t=(e,l,a)=>(q(e,typeof l!="symbol"?l+"":l,a),a);import{L as m,a as f,E as k,V as L,b as w,d as P,D as C,c as x,A as O,M as A,C as s,s as o,p as i,t as g,e as b,l as R,g as S,f as M,h as E,r as D,S as F}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as z}from"./Component-f923abb1.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var V=Object.defineProperty,j=Object.getOwnPropertyDescriptor,n=(e,l,a,p)=>{for(var c=p>1?void 0:p?j(l,a):l,u=e.length-1,h;u>=0;u--)(h=e[u])&&(c=(p?h(l,a,c):h(c))||c);return p&&c&&V(l,a,c),c};const d=[...Object.values(m),f.Nothing,f.Everything];class T extends F{constructor(){super(...arguments);t(this,"_originalMask");t(this,"_onEndRenderOnce",null)}onBeginRender(a){this._originalMask=a.cullingMask,a.cullingMask&=~(m.Viewport|m.Outline|m.NavigationGizmo|m.Gizmo)}onEndRender(a){if(a.cullingMask=this._originalMask,this._onEndRenderOnce){const p=this._onEndRenderOnce;this._onEndRenderOnce=null,p(a)}}executeAfterRender(a){this._onEndRenderOnce=a}}let r=class extends k{constructor(){super(...arguments);t(this,"_lastRTAsset",null);t(this,"isOrthographic",!1);t(this,"nearClipPlane",.1);t(this,"farClipPlane",100);t(this,"fieldOfView",45);t(this,"orthographicSize",10);t(this,"viewport",new L(0,0,1,1));t(this,"priority",0);t(this,"enableFrustumCulling",!0);t(this,"clearFlags",w.All);t(this,"cullingMask",P(f.Everything,d));t(this,"postProcessMask",P(f.Everything,d));t(this,"depthTextureMode",C.None);t(this,"opaqueTextureEnabled",!1);t(this,"opaqueTextureDownsampling",x.TwoX);t(this,"antiAliasing",O.None);t(this,"msaaSamples",A.FourX);t(this,"enableHDR",!1);t(this,"enablePostProcess",!0);t(this,"isAlphaOutputRequired",!1);t(this,"renderTarget",null)}onEnabled(){this.applyBoundPathChange("enabled",s.Toggle,!1)}onInitComplete(){if(this.engineObject.entity.addComponent(T),this.renderTarget){const l=this.root.assetStore.assets[this.renderTarget.refId];if(l){this._lastRTAsset=l;const a=this.engineObject.entity.getComponent(T);a&&a.executeAfterRender(()=>{var p;l.updateThumbnail(),(p=l.subAssets)==null||p.forEach(c=>c.updateThumbnail())})}}else this.applyBoundPathChange("enabled",s.Toggle,!1)}};n([o(),i({label:"camera.is-orthographic",bindPath:"isOrthographic"})],r.prototype,"isOrthographic",2);n([o(),i({label:"camera.near-clip-plane",bindPath:"nearClipPlane"})],r.prototype,"nearClipPlane",2);n([o(),i({label:"camera.far-clip-plane",bindPath:"farClipPlane"})],r.prototype,"farClipPlane",2);n([o(),i({label:"camera.field-of-view",bindPath:"fieldOfView",when:e=>!e.isOrthographic})],r.prototype,"fieldOfView",2);n([o(),i({label:"camera.orthographic-size",bindPath:"orthographicSize",when:e=>e.isOrthographic})],r.prototype,"orthographicSize",2);n([o(),i({type:s.Vector4,min:0,max:1,label:"camera.viewport.title",bindPath:"viewport"})],r.prototype,"viewport",2);n([o(),i({label:"camera.priority.title",bindPath:"priority"})],r.prototype,"priority",2);n([o(),i({label:"camera.enable-frustum-culling",bindPath:"enableFrustumCulling"})],r.prototype,"enableFrustumCulling",2);n([o(),i({label:"camera.clear-flags.title",bindPath:"clearFlags",type:s.Select,options:g(w,void 0,e=>b(`camera.clear-flags.${e.toLocaleLowerCase()}`))})],r.prototype,"clearFlags",2);n([o(R(d)),i({label:"camera.culling-mask",bindPath:"cullingMask",type:s.Select,...S(d)}),M(E(d))],r.prototype,"cullingMask",2);n([o(R(d)),i({label:"camera.post-process-mask",bindPath:"postProcessMask",type:s.Select,...S(d)}),M(E(d))],r.prototype,"postProcessMask",2);n([o(),i({label:"camera.depth-texture-mode.title",info:"camera.depth-texture-mode.info",bindPath:"depthTextureMode",type:s.Select,options:g(C,void 0,e=>b(`camera.depth-texture-mode.${e.toLowerCase()}`))})],r.prototype,"depthTextureMode",2);n([o(),i({label:"camera.opaque-texture-enabled.title",info:"camera.opaque-texture-enabled.info",bindPath:"opaqueTextureEnabled",type:s.Toggle})],r.prototype,"opaqueTextureEnabled",2);n([o(),i({label:"camera.opaque-texture-down-sampling.title",info:"camera.opaque-texture-down-sampling.info",bindPath:"opaqueTextureDownsampling",type:s.Select,options:g(x,void 0,e=>b(`camera.opaque-texture-down-sampling.${e.toLowerCase()}`)),when:e=>e.opaqueTextureEnabled})],r.prototype,"opaqueTextureDownsampling",2);n([o(),i({label:"camera.anti-aliasing.title",info:"camera.anti-aliasing.info",bindPath:"antiAliasing",type:s.Select,options:g(O,void 0,e=>b(`camera.anti-aliasing.${e.toLowerCase()}`))})],r.prototype,"antiAliasing",2);n([o(),i({label:"camera.msaa-samples.title",info:"camera.msaa-samples.info",bindPath:"msaaSamples",type:s.Select,options:g(A,void 0,e=>b(`camera.msaa-samples.${e.toLowerCase()}`))})],r.prototype,"msaaSamples",2);n([o(),i({label:"camera.enable-hdr.title",info:"camera.enable-hdr.info",bindPath:"enableHDR",type:s.Toggle})],r.prototype,"enableHDR",2);n([o(),i({label:"camera.enable-post-process.title",info:"camera.enable-post-process.info",bindPath:"enablePostProcess",type:s.Toggle})],r.prototype,"enablePostProcess",2);n([o(),i({label:"camera.is-alpha-output-required.title",info:"camera.is-alpha-output-required.info",bindPath:"isAlphaOutputRequired",type:s.Toggle})],r.prototype,"isAlphaOutputRequired",2);n([i({label:"camera.render-target.title",type:s.AssetPicker,assetType:"RenderTarget",onChange:async(e,l,a)=>{var h;const p=e._lastRTAsset;p&&!a&&D(()=>{var y;p.thumbnailUrl="",(y=p.subAssets)==null||y.forEach(v=>{v.thumbnailUrl=""})}),e._lastRTAsset=a??null,e.renderTarget=a?a.getCurrentRef():null,await e.applyBoundPathChange("renderTarget",s.AssetPicker,e.renderTarget);const c=e.root.projectStore.currentViewport.previewManager;c.hasUserRT=!!a;const u=e.engineObject;a?(u.enabled=!0,a.updateThumbnail(),(h=a.subAssets)==null||h.forEach(y=>y.updateThumbnail())):c.isPreviewOn||(u.enabled=!1)}}),o()],r.prototype,"renderTarget",2);r=n([z({type:"Camera",componentsMenu:{label:"component.camera.title"}})],r);export{r as CameraComponent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var v=Object.defineProperty;var y=(c,t,e)=>t in c?v(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var i=(c,t,e)=>(y(c,typeof t!="symbol"?t+"":t,e),e);import{bq as p,H as h,ay as u,S as C,bA as b,I as g,U as w,bB as z,bC as M,x as f,bD as P,bu as T,bw as E,bv as D}from"./index-0a8702e2.js";import"./AssetPreviewer-24e31d97.js";const x=p.zeroTolerance,d=class d{constructor(t=1,e=0,a=0){i(this,"_matrix",new u);i(this,"_matrixInv",new u);this.radius=t,this.phi=e,this.theta=a}makeSafe(){const t=Math.floor(this.phi/Math.PI);return this.phi=p.clamp(this.phi,t*Math.PI+x,(t+1)*Math.PI-x),this}set(t,e,a){return this.radius=t,this.phi=e,this.theta=a,this}setYAxis(t){const{_xAxis:e,_yAxis:a,_zAxis:n}=d;h.equals(e.set(1,0,0),a.copyFrom(t).normalize())&&e.set(0,1,0),h.cross(e,a,n),n.normalize(),h.cross(a,n,e);const{elements:s}=this._matrix;s[0]=e.x,s[1]=e.y,s[2]=e.z,s[4]=a.x,s[5]=a.y,s[6]=a.z,s[8]=n.x,s[9]=n.y,s[10]=n.z;const{elements:r}=this._matrixInv;r[0]=e.x,r[4]=e.y,r[8]=e.z,r[1]=a.x,r[5]=a.y,r[9]=a.z,r[2]=n.x,r[6]=n.y,r[10]=n.z}setFromVec3(t,e=!1){return t.transformNormal(this._matrixInv),this.radius=t.length(),this.radius===0?(this.theta=0,this.phi=0):e?(this.phi=2*Math.PI-Math.acos(p.clamp(t.y/this.radius,-1,1)),this.theta=Math.atan2(-t.x,-t.z)):(this.phi=Math.acos(p.clamp(t.y/this.radius,-1,1)),this.theta=Math.atan2(t.x,t.z)),this}setToVec3(t){const{radius:e,phi:a,theta:n}=this,s=Math.sin(a)*e;return this.phi-=Math.floor(this.phi/Math.PI/2)*Math.PI*2,t.set(s*Math.sin(n),e*Math.cos(a),s*Math.cos(n)),t.transformNormal(this._matrix),this.phi>Math.PI}};i(d,"_xAxis",new h),i(d,"_yAxis",new h),i(d,"_zAxis",new h);let _=d;class A extends C{constructor(e){super(e);i(this,"domElement");i(this,"camera");i(this,"cameraTransform");i(this,"autoRotate",!1);i(this,"autoRotateSpeed",Math.PI);i(this,"enableDamping",!0);i(this,"rotateSpeed",2);i(this,"zoomSpeed",1);i(this,"keyPanSpeed",7);i(this,"dampingFactor",.2);i(this,"zoomFactor",.2);i(this,"minDistance",.1);i(this,"maxDistance",1/0);i(this,"minZoom",0);i(this,"maxZoom",1/0);i(this,"minPolarAngle",1/180*Math.PI);i(this,"maxPolarAngle",179/180*Math.PI);i(this,"minAzimuthAngle",-1/0);i(this,"maxAzimuthAngle",1/0);i(this,"_enableKeys",!0);i(this,"_up",new h(0,1,0));i(this,"_target",new h);i(this,"_atTheBack",!1);i(this,"_spherical",new _);i(this,"_sphericalDelta",new _);i(this,"_sphericalDump",new _);i(this,"_zoomFrag",0);i(this,"_scale",1);i(this,"_panOffset",new h);i(this,"_tempVec3",new h);i(this,"_enableHandler",7);i(this,"_isRotating",!1);this.domElement=e.engine.canvas._webCanvas}get up(){return this._up}set up(e){this._up.copyFrom(e),this._spherical.setYAxis(e),this._atTheBack=!1}get target(){return this._target}set target(e){this._target.copyFrom(e),this._atTheBack=!1}get enableRotate(){return(this._enableHandler&1)!==0}set enableRotate(e){e?this._enableHandler|=1:this._enableHandler&=-2}get enableZoom(){return(this._enableHandler&2)!==0}set enableZoom(e){e?this._enableHandler|=2:this._enableHandler&=-3}get enablePan(){return(this._enableHandler&4)!==0}set enablePan(e){e?this._enableHandler|=4:this._enableHandler&=-5}onAwake(){const{engine:e,entity:a}=this;this.input=e.inputManager,this.camera=a.getComponent(b),this.cameraTransform=a.transform,this._spherical.setYAxis(this._up),this._atTheBack=!1}onUpdate(e){this._updateTransform()}rotate(e){if(!(this._enableHandler&1))return;const a=2*Math.PI*e.x/this.domElement.clientWidth*this.rotateSpeed;this._sphericalDelta.theta-=a;const n=2*Math.PI*e.y/this.domElement.clientHeight*this.rotateSpeed;this._sphericalDelta.phi-=n,this._sphericalDump.theta=-a,this._sphericalDump.phi=-n,this._isRotating=!0}zoom(e){this._enableHandler&2&&(e>0?this._scale/=Math.pow(.95,this.zoomSpeed):e<0&&(this._scale*=Math.pow(.95,this.zoomSpeed)))}pan(e){if(!(this._enableHandler&4))return;const{cameraTransform:a}=this,{elements:n}=a.worldMatrix,{clientHeight:s}=this.domElement,r=h.distance(a.position,this.target)*(this.camera.fieldOfView/2)*(Math.PI/180),o=-2*e.x*(r/s),m=2*e.y*(r/s);this._panOffset.x+=n[0]*o+n[4]*m,this._panOffset.y+=n[1]*o+n[5]*m,this._panOffset.z+=n[2]*o+n[6]*m}_updateTransform(){const{cameraTransform:e,target:a,_tempVec3:n,_spherical:s,_sphericalDump:r,_sphericalDelta:o,_panOffset:m}=this;this.enableDamping&&!this._isRotating&&(o.theta=r.theta*=1-this.dampingFactor,o.phi=r.phi*=1-this.dampingFactor),h.subtract(e.position,a,n),s.setFromVec3(n,this._atTheBack),s.theta+=o.theta,s.phi+=o.phi,s.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,s.theta)),s.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,s.phi)),s.makeSafe(),this._scale!==1&&(this._zoomFrag=s.radius*(this._scale-1)),s.radius+=this._zoomFrag,s.radius=Math.max(this.minDistance,Math.min(this.maxDistance,s.radius)),this._atTheBack=s.setToVec3(n),h.add(a.add(m),n,e.worldPosition),e.lookAt(a,n.copyFrom(this.up).scale(this._atTheBack?-1:1)),this._zoomFrag=0,this._scale=1,o.set(0,0,0),m.set(0,0,0),this._isRotating=!1}addDefaultControl(){const e=new g,a=new g,n=this.domElement,s=l=>{e.set(l.clientX,l.clientY),document.addEventListener("pointermove",r),document.addEventListener("pointerup",o)},r=l=>{a.set(l.clientX,l.clientY).subtract(e),this.rotate(a),e.set(l.clientX,l.clientY)},o=()=>{document.removeEventListener("pointerup",o),document.removeEventListener("pointermove",r)},m=l=>{this.zoom(l.deltaY)};return n.addEventListener("pointerdown",s),n.addEventListener("wheel",m,{passive:!1}),()=>{n.removeEventListener("pointerdown",s),document.removeEventListener("pointerup",o),document.removeEventListener("pointermove",r),n.removeEventListener("wheel",m)}}}function I({currentRenderTarget:c,width:t,height:e,createRenderTarget:a,createImageData:n}){if(c&&c.width===t&&c.height===e)return{renderTarget:c,imageData:null,reused:!0};if(c){const o=c.getColorTexture(0);o==null||o.destroy(),c.destroy()}const s=a(t,e),r=new Uint8ClampedArray(t*e*4);return{renderTarget:s,imageData:n(r,t,e),reused:!1}}class S{constructor(t,e,a,n=!1){i(this,"_engine");i(this,"_renderTarget");i(this,"_scene");i(this,"_rootEntity");i(this,"_camera");i(this,"_canvas",null);i(this,"_imageData");i(this,"_curBoundingBox",new w);i(this,"_tempSizeVec3",new h);i(this,"_tempCenterVec",new h);i(this,"_orbitControl",null);i(this,"_resizeObserver");i(this,"_preventWheelCallback");i(this,"_renderComponent");i(this,"_container");t=t>>0,e=e>>0;const s=this._createCanvas(t,e);this._canvas=s,this._engine=a,this._createScene(a);const r=this.createRenderTarget(a,t,e);this._renderTarget=r,n&&this._addOrbitControl()}get engine(){return this._engine}get width(){return this._canvas.width}get height(){return this._canvas.height}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get rootEntity(){return this._rootEntity}_createCanvas(t,e){const a=document.createElement("canvas");return a.width=t,a.height=e,a}_createScene(t){var m;const e=new z(t),a=e.createRootEntity("root"),n=a.createChild("light");n.transform.setPosition(-9,15,17),n.transform.lookAt(new h(0,0,0));const s=n.addComponent(M);s.color=new f(1,1,1,1);const o=a.createChild("camera_entity").addComponent(b);return e.ambientLight=(m=t.sceneManager.activeScene)==null?void 0:m.ambientLight,e.background.solidColor=new f(.0157,.0157,.0157,0),this._scene=e,this._camera=o,o.nearClipPlane=.1,o.farClipPlane=100,this._rootEntity=a,{scene:e,camera:o,rootEntity:a}}_addOrbitControl(){const t=this._camera.entity,e=t.addComponent(A);e.domElement=this._canvas,e.addDefaultControl(),e.maxDistance=1/0,this._orbitControl=e;const a=this;this._renderComponent=t.addComponent(class extends C{onEndRender(){a._render()}}),this._renderComponent.enabled=!1,this._preventWheelCallback=n=>{n.stopPropagation(),n.preventDefault()}}renderOneFrame(t,e){const a=this._engine,n=this._scene;a.sceneManager.addScene(n),this._resetCamera(),this.setCamera(t/e),a.update(),this._render(),a.sceneManager.removeScene(n)}setCamera(t){this._camera.aspectRatio=t,this._camera.renderTarget=this._renderTarget}_resetCamera(t,e){var a,n;if(e!=null&&e.getSize){const{width:s,height:r}=e.getSize(),o=new g(s,r).length();this._camera.entity.transform.setPosition(0,0,o*1.2),(a=this._orbitControl)==null||a.target.set(0,0,0)}else{P(t||this._rootEntity,this._curBoundingBox),this._curBoundingBox.getExtent(this._tempSizeVec3),this._curBoundingBox.getCenter(this._tempCenterVec);const{_tempCenterVec:s}=this,r=this._camera.entity,o=this._tempSizeVec3.length();this._camera.farClipPlane=o*1e3,r.transform.setPosition(s.x,s.y,o*1.8),(n=this._orbitControl)==null||n.target.set(s.x,s.y,s.z)}}createRenderTarget(t,e,a){const n=I({currentRenderTarget:this._renderTarget,width:e,height:a,createRenderTarget:(s,r)=>{const o=new T(t,s,r,void 0,!1);return new E(t,s,r,o,D.Depth,4)},createImageData:(s,r,o)=>new ImageData(new Uint8ClampedArray(s),r,o)});return n.reused||(this._imageData=n.imageData,this._renderTarget=n.renderTarget),n.renderTarget}_render(){if(!this._renderTarget)return;const t=this._renderTarget;t.getColorTexture(0).getPixelBuffer(0,0,t.width,t.height,0,this._imageData.data),this._canvas.getContext("2d").putImageData(this._imageData,0,0)}async createImageUrl(){return new Promise(t=>{this._canvas.toBlob(e=>{const a=URL.createObjectURL(new Blob([e],{type:"image/png"}));t(a)})})}addToContainer(t,e,a){this._renderComponent.enabled=!0,this._container=t,t.appendChild(this._canvas);const n=new ResizeObserver(()=>{this._onCanvasResize(t.clientWidth,t.clientHeight),this._resetCamera(a,e)});n.observe(t),this._resizeObserver=n,e._requestResetCamera=()=>this._resetCamera(a,e),t.addEventListener("mousewheel",this._preventWheelCallback,{passive:!1})}removeFromContainer(){this._renderComponent.enabled=!1,this._resizeObserver.disconnect(),this._canvas.remove(),this._container.removeEventListener("mousewheel",this._preventWheelCallback)}_onCanvasResize(t,e){const a=Math.round(t*window.devicePixelRatio),n=Math.round(e*window.devicePixelRatio),s=this._canvas;s.width=a,s.height=n,this.createRenderTarget(this._engine,a,n),this.setCamera(a/n),this._engine.sceneManager.addScene(this._scene)}}export{S as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var g=Object.defineProperty;var y=(e,a,o)=>a in e?g(e,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[a]=o;var r=(e,a,o)=>(y(e,typeof a!="symbol"?a+"":a,o),o);import{i as f,e as m,p as h,C as i,t as b,s as l,v as c}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as P}from"./Component-f923abb1.js";import{L as N}from"./LightBaseComponent-fbc3ae49.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var u=Object.defineProperty,S=Object.getOwnPropertyDescriptor,p=(e,a,o,n)=>{for(var t=n>1?void 0:n?S(a,o):a,d=e.length-1,w;d>=0;d--)(w=e[d])&&(t=(n?w(a,o,t):w(t))||t);return n&&t&&u(a,o,t),t};let s=class extends N{constructor(a,o){super(a,o);r(this,"shadowType",f.None);r(this,"shadowBias",1);r(this,"shadowNormalBias",1);r(this,"shadowNearPlaneOffset",.1);r(this,"shadowStrength",1);this.formSchema.addGroup(m("light.shadow.title"),["shadowType","shadowBias","shadowNormalBias","shadowNearPlaneOffset","shadowStrength"],{collapsible:!1})}};p([h({type:i.Select,options:b(f,void 0,e=>m(`light.shadow.type.${e.toLowerCase()}`)),bindPath:"shadowType",property:"shadowType",label:"light.shadow.type.label",info:"light.shadow.type.info"}),l(),c()],s.prototype,"shadowType",2);p([h({type:i.Number,bindPath:"shadowBias",property:"shadowBias",dragStep:.01,label:"light.shadow.bias.label",info:"light.shadow.bias.info"}),l()],s.prototype,"shadowBias",2);p([h({type:i.Number,bindPath:"shadowNormalBias",property:"shadowNormalBias",dragStep:.01,label:"light.shadow.normal-bias.label",info:"light.shadow.normal-bias.info"}),l()],s.prototype,"shadowNormalBias",2);p([h({type:i.Number,bindPath:"shadowNearPlaneOffset",property:"shadowNearPlaneOffset",dragStep:.01,label:"light.shadow.near-plane-offset.label",info:"light.shadow.near-plane-offset.info"}),l()],s.prototype,"shadowNearPlaneOffset",2);p([h({type:i.Slider,bindPath:"shadowStrength",property:"shadowStrength",min:0,max:1,dragStep:.01,label:"light.shadow.strength.label",info:"light.shadow.strength.info"}),l()],s.prototype,"shadowStrength",2);s=p([P({type:"DirectLight",componentsMenu:{group:"light",label:"component.light.direct.title"}})],s);export{s as DirectLightComponent};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var m=(s,e,t)=>e in s?d(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(m(s,typeof e!="symbol"?e+"":e,t),t);import{cc as u,cd as y,ce as h,aT as w,aD as b,a1 as f,j as v,a7 as x,e as j}from"./index-0a8702e2.js";import{a as O,A}from"./InstanceEditorAsset-a70e73fe.js";import{A as F}from"./AssetPreviewer-24e31d97.js";import{n as R}from"./index-be6bc38a.js";import{A as U}from"./AssetViewer-bc198e16.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";async function g(s){const e={uploadFiles:[],errors:[]};for(const t in s){const n=s[t],r=n.name.toLocaleLowerCase();(r.endsWith(".ttf")||r.endsWith(".otf")||r.endsWith(".woff"))&&e.uploadFiles.push({main:n})}return e}async function C(s){const e=s.main;try{const t=e.name,n=u(t),r=y(t,n),o=await h.uploadBlob(`${t}.json`,e),i={fontName:r,fontUrl:encodeURI(o.url).replace(/\(/g,"%28").replace(/\)/g,"%29")};return new File([JSON.stringify(i)],r)}catch(t){console.error(t),R.error(`parse font file fail ${t}`)}return e}class p extends U{constructor(){super()}setViewAsset(e,t){const n=t.createChild("font_entity"),r=n.addComponent(f);r.font=e.engineObject,r.text=`ABCDEFGHIJKLM
|
|
2
|
-
NOPQRSTUVWXYZ
|
|
3
|
-
abcdefghijklm
|
|
4
|
-
nopqrstuvwxyz
|
|
5
|
-
1234567890`,this._entity=n}}const L=w(({asset:s})=>b.jsx(F,{asset:s}));p.previewer=L;class c{static update(e,t){this.entity?this.entity.isActive=!0:this.initScene(e),this.textRenderer.font=t.engineObject}static clear(){this.entity.isActive=!1}static initScene(e){const t=this.entity=e.createChild("font"),n=this.textRenderer=t.addComponent(f);n.text="Aa",n.fontSize=60}}a(c,"entity"),a(c,"textRenderer");var P=Object.defineProperty,T=Object.getOwnPropertyDescriptor,_=(s,e,t,n)=>{for(var r=n>1?void 0:n?T(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&P(e,t,r),r};let l=class extends v{constructor(e){super(e);a(this,"urlObj")}async initByMain(e){this.urlObj=e;const t=URL.createObjectURL(e),n=await this.engine.resourceManager.load({url:t,type:x.Font});URL.revokeObjectURL(t),this.bindEngineObject(n)}};l=_([O({type:"Font",label:j("asset.font.title"),loaderType:"Font",extname:"font",viewer:p,thumbnail:c,importMenuConfig:{type:A.Upload,tooltip:"请上传字体文件(支持 TTF, OTF, WOFF)",accept:".ttf,.otf,.woff"},filterUploadFiles:g,preUpload:C})],l);export{l as FontAsset};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aH as p,aI as m,aJ as h,aD as e,aE as f,aF as b,aK as i,aL as j,aM as l,aN as I}from"./index-0a8702e2.js";import{A as v,a as A,I as g}from"./Accordion-4897319b.js";const D=p(m,{width:"100%",border:"none",position:"relative",borderRadius:0,"& > svg":{marginRight:"$1"},"&::after":{content:"''",position:"absolute",top:0,left:0,width:"100%",borderTop:"1px solid $grayA2"}});function z(r){const{renameable:n,onDelete:s,removable:o}=r;return e.jsxs(i,{align:"v",css:{flex:1,justifyContent:"space-between"},children:[e.jsx("span",{children:r.title}),e.jsxs(i,{gap:"xxs",children:[n&&e.jsx(l,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:t=>{t.preventDefault(),t.stopPropagation(),s&&s()},children:e.jsx(g,{size:"14px"})}),o&&e.jsx(l,{as:"div",variant:"subtle","aria-hidden":!0,tabIndex:-1,size:"xs",onClick:t=>{t.preventDefault(),t.stopPropagation(),s&&s()},children:e.jsx(I,{size:"14px"})})]})]})}function w(r){const{items:n=[],onAdd:s,onDelete:o,addItemText:t="Add Item",defaultValue:d,addable:c=!1}=r,u=a=>()=>{o&&o(a)},x=h.useMemo(()=>n.length?n.map(a=>`${a.id}`):[],[n]);return e.jsx(f,{...b(r),direction:"column",children:e.jsxs(v,{type:"multiple",defaultValue:d??x,children:[n.map(a=>e.jsx(A,{value:`${a.id}`,title:e.jsx(z,{title:a.name,onDelete:u(a),removable:a.removable,renameable:a.renameable}),arrow:!!a.children,children:a.children&&e.jsx(i,{direction:"column",children:a.children})},a.id)),c&&e.jsxs(D,{size:"sm",variant:"soft",onClick:s,children:[e.jsx(j,{size:"12px"})," ",t]})]})})}export{w as F};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{aC as a}from"./index-0a8702e2.js";/**
|
|
2
|
-
* @license @tabler/icons-react v3.24.0 - MIT
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/var e=a("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);export{e as I};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var w=Object.defineProperty;var x=(i,t,e)=>t in i?w(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var c=(i,t,e)=>(x(i,typeof t!="symbol"?t+"":t,e),e);import{dC as D,aJ as g,j as p,aX as A,cj as B,e as R,n as E,dD as y,o as F,dE as _,u as C,bp as z,J as O,H as P,U as k,S as L,bD as M}from"./index-0a8702e2.js";import{r as T}from"./ThumbnailRegistry-495c18c9.js";let b=null;function l(){return b??(b=new D),b}const j=new Proxy({},{get(i,t,e){const s=l(),n=Reflect.get(s,t,s);return typeof n=="function"?n.bind(s):n},set(i,t,e,s){return Reflect.set(l(),t,e),!0},has(i,t){return Reflect.has(l(),t)},ownKeys(){return Reflect.ownKeys(l())},getOwnPropertyDescriptor(i,t){const e=Reflect.getOwnPropertyDescriptor(l(),t);return e||{configurable:!0,enumerable:!0,writable:!0,value:l()[t]}}}),v=g.createContext(j);function $(){const i=g.useContext(v);if(!i)throw new Error("useRootStore must be used within a RootProvider");return i}const q=i=>g.useContext(v)[i],K=B("Plugin Asset");var S=(i=>(i[i.Add=1]="Add",i[i.Upload=2]="Upload",i))(S||{});function U(i){return t=>{var e;K.info("register",i.type,"verbose"),typeof i.icon=="string"?(i.icon,i.icon=void 0):(e=i==null?void 0:i.icon)!=null&&e.fallback&&i.icon.fallback,p.registerAssetMeta(t,{...i,targetConstructor:t}),i.viewer&&A(i.type,new i.viewer),i.thumbnail&&T(i.type,i.thumbnail),i.dragLayer&&(t.dragLayer=i.dragLayer)}}var N=Object.defineProperty,J=Object.getOwnPropertyDescriptor,h=(i,t,e,s)=>{for(var n=s>1?void 0:s?J(t,e):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(n=(s?a(t,e,n):a(n))||n);return s&&n&&N(t,e,n),n};let u=class extends p{constructor(t){super(t);c(this,"isRoot",!1);c(this,"isFolder",!0);c(this,"hidden",!1);c(this,"extname","");c(this,"childrenId",[]);c(this,"acceptDragLayer",E.MainAsset);F(this)}get thumbnailUrl(){return this.locked?y.FolderLocked:y.Folder}get children(){const t=[];return this.childrenId.forEach(e=>{const s=this.root.assetStore.assets[e];s&&t.push(s)}),t}afterDelete(){const t=this.root.assetStore.assets;for(;this.childrenId.length;){const e=this.childrenId[0],s=t[e];s.loadingStatus==="success"&&s.beforeDelete&&s.beforeDelete(),this.childrenId.splice(0,1),delete this.root.assetStore.assets[e],s.loadingStatus==="success"&&s.afterDelete&&s.afterDelete()}}async initByMeta(t){super.initByMeta(t),this.isRoot=!!t.isRoot,t.hidden!=null&&(this.hidden=t.hidden),this.initObjectProperties()}async initByMain(t){}initByCreation(t,e,s){return Promise.resolve()}onDoubleClick(){this.root.assetStore.openFolder(this.id)}saveMain(){return null}recursive(t,e=!1){const s=this.children,n=[];for(let r=0;r<s.length;r++){const a=s[r];a.isFolder?(n.push(a),e&&t(a)):t(a)}return n.forEach(r=>r.recursive(t,e))}async asyncRecursive(t,e=!1){const s=this.children,n=[];for(let r=0;r<s.length;r++){const a=s[r];a.isFolder?(n.push(a),e&&await t(a)):await t(a)}for(let r=0;r<n.length;r++)await n[r].asyncRecursive(t,e)}_onDrop(t,e){if(!e||this.id===e.id)return;const{assetStore:s,assetUIStore:n,assetFacade:r}=this.root;if(this.dropping=!1,n.pickedAssets.includes(e.id)){if(n.pickedAssets.includes(this.id))return;for(let a=0;a<n.pickedAssets.length;a++)try{const o=n.pickedAssets[a];if(!s.assets[o])continue;r.moveAsset(o,this.id)}catch(o){_(o instanceof Error?o.message:String(o))}}else try{r.moveAsset(e.id,this.id)}catch(a){_(a instanceof Error?a.message:String(a))}}};h([C],u.prototype,"childrenId",2);h([z],u.prototype,"children",1);h([O],u.prototype,"_onDrop",1);u=h([U({type:"Folder",label:R("asset.folder.title"),dragLayer:E.Folder,importMenuConfig:{type:S.Add}})],u);const d=class d extends p{constructor(){super(...arguments);c(this,"isTemplate",!0);c(this,"_clonedEntities",[]);c(this,"_instances",new Map);c(this,"_rootKey","");c(this,"_tempSize",0)}_buildInstanceLink(){const e=this.getMetaConfig().type;if(e!=="Prefab"&&e!=="glTF")return null;const s=e;return{assetId:this.id,bindingId:"",assetKind:s,role:"root",...this._rootKey&&{sourceEntityId:this._rootKey}}}instantiateEngineObject(){const e=this._instantiateEngineObject();this._clonedEntities.push(e);const s=this._clonedEntities;return e.addComponent(class extends L{onDestroy(){const n=s.indexOf(this.entity);n>=0&&s.splice(n,1)}}),e}addInstance(e,s){var m;const n=e.instanceAssetId;if(n){const f=this.root.assetStore.assets[n];f.isTemplate&&f.removeInstance(e)}const a=e.root.domainStore.getNormalizedState().entities[e.id],o=this._buildInstanceLink();a&&o?(m=a.instance)!=null&&m.bindingId||e.root.entityFacade.updateEntity(e.id,{instance:o}):o&&(e.pendingInstance=o),this._instances.set(e.id,e.entityManager),e.on("delete",()=>{this.removeInstance(e)})}removeInstance(e){var n;((n=e.root.domainStore.getNormalizedState().entities[e.id])==null?void 0:n.instance)!==void 0?e.root.entityFacade.updateEntity(e.id,{instance:null}):e.pendingInstance=null,this._instances.delete(e.id)}get instanceCount(){return this._instances.size}static resolveInstanceEntityIds(e,s){const n=new Set;for(let r=0;r<e.length;r++){const a=e[r],o=s[a];o&&n.add(o.parentId===null?a:o.parentId)}return Array.from(n)}getInstanceEntityIds(){return d.resolveInstanceEntityIds(Array.from(this._instances.keys()),this.root.domainStore.state.entities)}unpackAllInstances(){this._instances.forEach((e,s)=>{var r;const n=e.entities.get(s);n&&(((r=n.root.domainStore.getNormalizedState().entities[n.id])==null?void 0:r.instance)!==void 0?n.root.entityFacade.updateEntity(n.id,{instance:null}):n.pendingInstance=null)}),this._instances.clear()}afterDelete(){this.unpackAllInstances(),this.root.sceneStore.selectEntity(null),this._clonedEntities.forEach(s=>s.destroy());const e=this.getDragTempEntity();e&&(e.destroy(),this.setDragTempEntity(null))}_updateDragTempEntity(){try{const e=this.instantiateEngineObject();this.setDragTempEntity(e),this._tempSize=this._getSize(e)}catch(e){console.warn(`[InstanceEditorAsset] Failed to create drag temp entity for asset ${this.id}:`,e)}}_destroyInstances(){this._instances.forEach((e,s)=>{const n=e.entities.get(s);n==null||n.destroy()}),this._instances.clear()}async updateThumbnail(){this._tempSize?super.updateThumbnail():super.updateThumbnail(!0)}_getSize(e){M(e,d._tempBoundingBox),d._tempBoundingBox.getExtent(d._tempExtend);const s=d._tempExtend.length();return s===1/0?0:s}};c(d,"_tempExtend",new P),c(d,"_tempBoundingBox",new k);let I=d;export{S as A,u as F,I,U as a,q as b,$ as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aR as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";var x=Object.defineProperty,O=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?O(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var c=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{L as g}from"./module-6406b050.js";import{E as b,p as l,C as a,s}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as P}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var d=Object.defineProperty,L=Object.getOwnPropertyDescriptor,n=(o,e,t,m)=>{for(var i=m>1?void 0:m?L(e,t):e,y=o.length-1,u;y>=0;y--)(u=o[y])&&(i=(m?u(e,t,i):u(i))||i);return m&&i&&d(e,t,i),i};let r=class extends b{constructor(e,t){super(e,t);p(this,"resource",null);p(this,"autoPlay",!0);p(this,"isLooping",!0);p(this,"speed",1);p(this,"priority",0)}};n([l({label:"lottie.resource.label",info:"lottie.resource.info",type:a.AssetPicker,assetType:"Lottie",bindPath:"resource"}),s()],r.prototype,"resource",2);n([l({label:"lottie.auto-play.label",info:"lottie.auto-play.info",type:a.Toggle,bindPath:"autoPlay",onChange(o,e,t){t||o.engineObject.pause()}}),s()],r.prototype,"autoPlay",2);n([l({label:"lottie.is-looping.label",info:"lottie.is-looping.info",type:a.Toggle,bindPath:"isLooping"}),s()],r.prototype,"isLooping",2);n([l({label:"lottie.speed.label",info:"lottie.speed.info",type:a.Number,dragStep:.01,bindPath:"speed"}),s()],r.prototype,"speed",2);n([l({label:"lottie.priority.label",info:"lottie.priority.info",type:a.Number,bindPath:"priority"}),s()],r.prototype,"priority",2);r=n([P({type:"LottieAnimation",external:!0,componentsMenu:{group:"2D",label:"component.lottie-animation.title"}})],r);b.registerCustomEngineComponent("LottieAnimation",g);export{r as LottieAnimationComponent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Q=Object.defineProperty;var X=(a,s,t)=>s in a?Q(a,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[s]=t;var c=(a,s,t)=>(X(a,typeof s!="symbol"?s+"":s,t),t);import{j as E,aH as Y,aU as q,aD as x,e1 as D,e2 as Z,aT as k,aJ as $,aV as tt,aK as et,aI as st,aL as it,ce as L,o as at,S as ot,u as P,J as W,an as B,a0 as M,e as m,_ as rt,cb as V,p as v,C as _,b0 as I,n as nt,cd as F}from"./index-0a8702e2.js";import{L as J}from"./module-6406b050.js";import{a as H,u as lt,A as pt}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{c as ct}from"./SpriteAsset-9a31ec24.js";import{n as R}from"./index-be6bc38a.js";import{A as mt}from"./AssetViewer-bc198e16.js";import{c as G,S as ut}from"./SpriteAtlasAsset-a862db46.js";import{c as dt}from"./TextureAsset-28fedf2a.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";import"./meshopt_simplifier.module-cd99529d.js";import"./bundlers-9b0d37fc.js";import"./FormItemArray-66be8701.js";import"./Accordion-4897319b.js";import"./utilities-e09052e3.js";import"./enum-58295f88.js";import"./encode-ac4bb64e.js";import"./Tooltip-33f770ba.js";import"./ktx2-encoder-1e63c1eb.js";import"./TaskQueue-05c94a4d.js";import"./ktx-parse.modern-6c9f771f.js";var ht=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,yt=(a,s,t,e)=>{for(var i=e>1?void 0:e?ft(s,t):s,o=a.length-1,r;o>=0;o--)(r=a[o])&&(i=(e?r(s,t,i):r(i))||i);return e&&i&&ht(s,t,i),i};let z=class extends E{initByMain(a,s){return Promise.resolve()}};z=yt([H({type:"LottieAnimation",async bundle(a){const s=JSON.parse(await a.content.text());return{content:new Blob([JSON.stringify(s)])}}})],z);const gt=Y("div",{display:"grid",columnGap:"$1",gridColumn:2/-1,gridTemplateColumns:"minmax(0, 4fr) repeat(1, 2fr) repeat(1, auto) repeat(1, 2fr) repeat(1, auto)",marginBottom:"$1"}),wt=function({clip:a,removeClip:s,onClipChange:t}){const{t:e}=q();return x.jsxs(gt,{children:[x.jsx(D,{size:"sm",value:a.name??"",placeholder:e("lottie.clip.name"),onChange:i=>{t({name:i.currentTarget.value})}}),x.jsx(D,{size:"sm",value:a.start??"",placeholder:e("lottie.clip.start"),onChange:i=>{t({start:+i.currentTarget.value})}}),x.jsx(Z,{width:12,onClick:s}),x.jsx(D,{size:"sm",value:a.end??"",placeholder:e("lottie.clip.end"),onChange:i=>{t({end:+i.currentTarget.value})}})]})},bt=k(function(a){const s=a.model,t=s.getViewer(),{inspectorFacade:e}=lt(),{t:i}=q(),[o,r]=$.useState(()=>Array.isArray(s.clips)?[...s.clips]:[]);$.useEffect(()=>{r(Array.isArray(s.clips)?[...s.clips]:[])},[s,s.clips]),$.useEffect(()=>{t==null||t.setClips(o)},[o,t]);const p=n=>{r(n),e.assetChange(s.id,"clips",n,"asset-meta")},l=()=>{p([...o,{}])},d=n=>{n<0||n>=o.length||p(o.filter((u,y)=>y!==n))},h=(n,u)=>{if(n<0||n>=o.length)return;const y={...o[n],...u},C=o.map((A,b)=>b===n?y:A);p(C)};return x.jsxs(tt,{title:i("lottie.clips.title"),defaultOpen:!0,collapsible:!0,children:[o.map((n,u)=>x.jsx(wt,{clip:n,removeClip:()=>d(u),onClipChange:y=>h(u,y)},`${s.id}-${u}`)),x.jsx(et,{align:"h",css:{margin:"0 auto",padding:"$1 0 0 0"},children:x.jsx(st,{size:"sm",variant:"soft",startSlot:x.jsx(it,{size:"14px"}),onClick:l,children:i("lottie.clips.add")})})]})});async function vt(a,s,t={}){try{const e=JSON.parse(a),{assets:i}=e,o=[];for(let p=0,l=i.length;p<l;p++){const d=i[p],{p:h}=d;h&&o.push({name:d.id,src:h})}const r=await ct(o,{width:2048,height:2048,...t});return r.code!==0?(console.log("Atlas Error:",r.msg),r):(e.assets=i.filter(p=>!p.p),r.info.jsonFile=JSON.stringify(e),r)}catch{return{code:11,msg:"Parse lottie file error"}}}async function xt(a){const s={uploadFiles:[],errors:[]};for(const t in a){const e=a[t],i=e.name;if(i.endsWith(".json"))try{const o=await e.text(),r=JSON.parse(o);_t(r)&&s.uploadFiles.push({main:e})}catch(o){s.errors.push(K(i,o))}}return s}async function Mt(a,s,t){const e=a.main,i=await e.text();let o;try{o=JSON.parse(i)}catch(l){return console.error(l),R.error(K(e.name,l)),e}const{nm:r}=o,p=await vt(i);if(p.code===0)try{const{imageFiles:l,atlasFile:d,jsonFile:h}=p.info,n=JSON.parse(d),{atlasItems:u}=n,y=u.length,C=Ct(),A=St(r,e.name),b=[];for(let g=0;g<y;++g)l[g]&&b.push(L.uploadBlob(`${A}-${C}-${g}.png`,new Blob([l[g]])));const U=await Promise.all(b);for(let g=0;g<y;++g)u[g].img=U[g].url;const[S,T]=await Promise.all([L.uploadBlob(`${A}-${C}.atlas`,new Blob([JSON.stringify(n)])),L.uploadBlob(`${A}-${C}.json`,new Blob([h]))]),N={jsonUrl:T.url,atlasUrl:S.url};return new File([JSON.stringify(N)],e.name)}catch(l){console.error(l),R.error(`parse lottie file fail ${l}`)}else console.error(p.msg),R.error(p.msg);return e}function _t(a){return a.nm&&a.w&&a.h&&a.assets&&a.assets.length>0&&a.layers&&a.layers.length>0}function Ct(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2,10)}function St(a,s){const t=s.replace(/\.[^.]+$/,"")||"lottie";return(typeof a=="string"&&a.length>0?a:t).trim().replace(/[^\w.-]+/g,"_")||"lottie"}function K(a,s){const t=s instanceof Error?s.message:String(s);return`Failed to parse JSON file "${a}": ${t}`}var jt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,O=(a,s,t,e)=>{for(var i=e>1?void 0:e?At(s,t):s,o=a.length-1,r;o>=0;o--)(r=a[o])&&(i=(e?r(s,t,i):r(i))||i);return e&&i&&jt(s,t,i),i};class j extends mt{constructor(){super();c(this,"lottie");c(this,"_updateComponent");c(this,"_lottieAsset");c(this,"playing",!1);c(this,"frameTime",0);c(this,"animationNames",[]);c(this,"animationIndex",0);c(this,"_hasClips",!1);at(this)}get duration(){const{_lottieAsset:t}=this;return this._hasClips&&t.clips[this.animationIndex]?t.clips[this.animationIndex].end-t.clips[this.animationIndex].start:this._lottieAsset.duration}_setAnimationNames(t){this.animationNames=this._hasClips?t==null?void 0:t.map(e=>e.name):[this._lottieAsset.engineObject.name]}setViewAsset(t,e){const i=t.engineObject,o=e.createChild("lottie_entity"),r=o.addComponent(J);this._entity=o,this.lottie=r,r.resource=i,this._lottieAsset=t,this._hasClips=t.clips&&t.clips.length>0,this._setAnimationNames(t.clips),this.animationIndex=0;const p=this;this._updateComponent=this._entity.addComponent(class extends ot{onUpdate(l){p._onUpdate()}}),this.frameTime=0}getSize(){var t;if((t=this.lottie)!=null&&t.resource){const{width:e,height:i}=this.lottie.resource;return{width:e/100,height:i/100}}return{width:0,height:0}}stopViewAsset(){var t;super.stopViewAsset(),this.lottie=null,(t=this._updateComponent)==null||t.destroy(),this.animationNames=null}setClips(t){this.lottie.resource.setClips(t),this._setAnimationNames(t)}play(t){this.lottie.isLooping=!0,this.lottie.play(t),this.playing=!0}pauseAnimation(){this.lottie.pause(),this.playing=!1}selectAnimation(t){this.animationIndex=t;const e=this._lottieAsset.clips[t];this.play(e==null?void 0:e.name)}playAnimation(){const t=this._lottieAsset.clips[this.animationIndex];this.play(t==null?void 0:t.name)}setFrameTime(t){}_onUpdate(){this.playing&&(this.frameTime=this.lottie.frame)}}O([P],j.prototype,"playing",2);O([P],j.prototype,"frameTime",2);O([P],j.prototype,"animationNames",2);O([P],j.prototype,"animationIndex",2);O([W],j.prototype,"play",1);O([W],j.prototype,"pauseAnimation",1);O([W],j.prototype,"_onUpdate",1);var It=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,w=(a,s,t,e)=>{for(var i=e>1?void 0:e?Ot(s,t):s,o=a.length-1,r;o>=0;o--)(r=a[o])&&(i=(e?r(s,t,i):r(i))||i);return e&&i&&It(s,t,i),i};let f=class extends E{constructor(s){super(s);c(this,"textureSet",new Set);c(this,"width",0);c(this,"height",0);c(this,"duration",0);c(this,"inPoint",0);c(this,"outPoint",0);c(this,"clips",[]);c(this,"mipmap",!1);c(this,"colorDilate",!1);c(this,"filterMode",B.Bilinear);c(this,"wrapModeU",M.Repeat);c(this,"wrapModeV",M.Repeat);c(this,"runtimeOptions",{overwrite:!1,textureType:"ktx2",mode:"ETC1S",quality:150,isNormal:!1});this.formSchema.addGroup(m("lottie.asset.atlas-export"),["filterMode","wrapModeU","wrapModeV","mipmap","colorDilate"])}destroy(){super.destroy(),this.textureSet.clear(),this.textureSet=null}async initByUploadFile(s){return await this._initByUrl(this.engine,s),this}async initByMain(s){const{engine:t,meta:e}=this;e.runtimeOptions&&(this.runtimeOptions=e.runtimeOptions),this.clips=e.clips||[],this.filterMode=e.filterMode??this.filterMode,this.wrapModeU=e.wrapModeU??this.wrapModeU,this.wrapModeV=e.wrapModeV??this.wrapModeV,this.mipmap=e.mipmap??this.mipmap,this.colorDilate=e.colorDilate??this.colorDilate,await this._initByUrl(t,s);const i=new rt(this.engine),o=i.addComponent(J);o.resource=this.engineObject,this.setDragTempEntity(i)}instantiate(){const s=this.root.sceneStore.createEntity(),t=this.getDragTempEntity(),{position:e,rotation:i}=t.transform,o={components:[{class:"LottieAnimation",id:V(),props:{resource:this.getCurrentRef(),priority:0,defaultState:{}}}],id:s.id,isActive:!0,isClone:!1,name:this.name?this.name:"lottie",transform:{class:"Transform",props:{position:{x:e.x,y:e.y,z:e.z},rotation:{x:i.x,y:i.y,z:i.z},scale:{x:1,y:1,z:1}}}};return s.initByFile(o),s}async _createLottieResource(s,t,e){return(await s.resourceManager.load({urls:[t,e],type:"lottie"})).getComponent(J).resource}async _initByUrl(s,t){const e=JSON.parse(await t.text()),{jsonUrl:i,atlasUrl:o}=e,r=await this._createLottieResource(s,i,o);this.bindEngineObject(r);const{sprites:p}=r.atlas,{textureSet:l}=this;for(let d=0,h=p.length;d<h;++d){const n=p[d].texture;l.has(n)||(l.add(n),n.filterMode=this.filterMode,n.wrapModeU=this.wrapModeU,n.wrapModeV=this.wrapModeV)}return this.width=r.width,this.height=r.height,this.duration=r.duration,this.inPoint=r.inPoint,this.outPoint=r.outPoint,this}};w([v({type:_.Input,disabled:!0,label:m("lottie.asset.width")})],f.prototype,"width",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.height")})],f.prototype,"height",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.duration")})],f.prototype,"duration",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.in-point")})],f.prototype,"inPoint",2);w([v({type:_.Input,disabled:!0,label:m("lottie.asset.out-point")})],f.prototype,"outPoint",2);w([v({disabled:!0,customComponent:bt}),I()],f.prototype,"clips",2);w([v({label:m("lottie.asset.mipmap"),type:_.Toggle}),I()],f.prototype,"mipmap",2);w([v({label:m("lottie.asset.color-dilate"),type:_.Toggle}),I()],f.prototype,"colorDilate",2);w([v({label:m("lottie.asset.filter-mode.title"),type:_.Select,value:B.Bilinear,options:[{label:m("lottie.asset.filter-mode.point"),value:B.Point},{label:m("lottie.asset.filter-mode.bilinear"),value:B.Bilinear},{label:m("lottie.asset.filter-mode.trilinear"),value:B.Trilinear}],onChange(a,s,t){const{textureSet:e}=a;e.forEach(i=>{i.filterMode=t})}}),I()],f.prototype,"filterMode",2);w([v({label:m("lottie.asset.wrap-mode.u"),type:_.Select,value:M.Repeat,options:[{label:m("lottie.asset.wrap-mode.clamp"),value:M.Clamp},{label:m("lottie.asset.wrap-mode.repeat"),value:M.Repeat},{label:m("lottie.asset.wrap-mode.mirror"),value:M.Mirror}],onChange(a,s,t){const{textureSet:e}=a;e.forEach(i=>{i.wrapModeU=t})}}),I()],f.prototype,"wrapModeU",2);w([v({label:m("lottie.asset.wrap-mode.v"),type:_.Select,value:M.Repeat,options:[{label:m("lottie.asset.wrap-mode.clamp"),value:M.Clamp},{label:m("lottie.asset.wrap-mode.repeat"),value:M.Repeat},{label:m("lottie.asset.wrap-mode.mirror"),value:M.Mirror}],onChange(a,s,t){const{textureSet:e}=a;e.forEach(i=>{i.wrapModeV=t})}}),I()],f.prototype,"wrapModeV",2);w([P,I()],f.prototype,"runtimeOptions",2);f=w([H({type:"Lottie",label:m("asset.lottie.title"),loaderType:"EditorLottie",importMenuConfig:{type:pt.Upload,accept:".json"},viewer:j,filterUploadFiles:xt,preUpload:Mt,dragLayer:nt.Lottie,customInspector:dt,async bundle(a,s,t){var N,g;const e=JSON.parse(await a.content.text()),i=a.meta,{jsonUrl:o,atlasUrl:r}=e,p=F(a.name).split(".")[0],l=a.dependencies||(a.dependencies=[]),d=t.vfs,h=((N=l[0])==null?void 0:N.ref.refId)??V();let n;l[0]||(l[0]={key:"atlasUrl",ref:{refId:h}});let u=d.getFileById(h);u?n=u.meta:(n=G(h,E.getRegisteredAssetMeta(ut).type,s,{ignorePack:!0}),t.addFile({name:p+"_atlas.atlas",assetId:h,url:null,parentId:a.parentId,main:null,meta:n}),u=d.getFileById(h),u.ignoreBundle=!0),n.colorDilate=i.colorDilate,n.filterMode=i.filterMode,n.wrapModeU=i.wrapModeU,n.wrapModeV=i.wrapModeV,n.mipmap=i.mipmap;const y=a.meta.runtimeOptions;let C=s.assetOptions.textureOptions;y!=null&&y.overwrite&&(C=Object.assign({},C,y)),n.runtimeOptions=C;const A=await(await fetch(r)).json();t.updateFile(h,{main:new Blob([JSON.stringify(A)]),meta:n}),await t.bundleSingleFile(u,s),e.atlasUrl="./"+F(u.exportPath);const b=((g=l[1])==null?void 0:g.ref.refId)??V();let U;l[1]||(l[1]={key:"jsonUrl",ref:{refId:b}});let S=d.getFileById(b);S?U=S.meta:(U=G(b,E.getRegisteredAssetMeta(z).type,s),t.addFile({name:p+"_clip.json",assetId:b,url:null,parentId:a.parentId,main:null,meta:U}),S=d.getFileById(b),S.ignoreBundle=!0);const T=await(await fetch(o)).json();return T.lolitaAnimations=i.clips,t.updateFile(b,{main:new Blob([JSON.stringify(T)])}),await t.bundleSingleFile(S,s),e.jsonUrl="./"+F(S.exportPath),{content:new Blob([JSON.stringify(e)])}}})],f);export{f as LottieAsset};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var l=Object.defineProperty;var c=(e,t,o)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>(c(e,typeof t!="symbol"?t+"":t,o),o);import{j as u,o as d,q as b,u as f,e as h}from"./index-0a8702e2.js";import{a as w,A as y}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var v=Object.defineProperty,D=Object.getOwnPropertyDescriptor,m=(e,t,o,n)=>{for(var r=n>1?void 0:n?D(t,o):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(r=(n?i(t,o,r):i(r))||r);return n&&r&&v(t,o,r),r};let a=class extends u{constructor(t){super(t);p(this,"content","");d(this),this.onDoubleClick=this.onDoubleClick.bind(this)}async initByMain(t){this.content=await t.text()}async initByCreation(){return""}getMainData(){return this.content}onDoubleClick(){b(this.root.projectStore.id,this.id)}};m([f],a.prototype,"content",2);a=m([w({type:"Markdown",label:h("asset.markdown.title"),defaultName:"Document.md",extname:"md",importMenuConfig:{type:y.Add},bundle({content:e}){return{content:new Blob([e],{type:"text/markdown; charset=utf-8"})}}})],a);export{a as MarkdownAsset};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var G=Object.defineProperty;var K=(p,e,t)=>e in p?G(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t;var l=(p,e,t)=>(K(p,typeof e!="symbol"?e+"":e,t),t);import{O as V,b$ as k,cQ as L,cR as U,I as Q,H as z,V as H,x as W,cS as f,j as J,n as $,cT as v,F as M,o as q,cU as x,G as I,ab as b,ac as O,cK as Y,C as P,cV as E,cW as X,w as S,cO as Z,e as w,bU as ee,_ as te,ao as ae,ap as re,B,a8 as se,Q as ne,u as N,J as m}from"./index-0a8702e2.js";import{a as ie,A as oe}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{M as he}from"./MaterialInspector-aec1248b.js";import{A as pe}from"./AssetViewer-bc198e16.js";import{E as y,s as F,b as C}from"./ProxyConfigs-4de3304c.js";async function de(p){var e;if(p.shaderRef)try{const t=await p.assetStore.getAssetByRef(p.shaderRef);if(!t||t===p.nextShaderAsset)return;(e=t.removeReferencedMaterial)==null||e.call(t,p.material)}catch{}}class ce extends pe{constructor(){super(...arguments);l(this,"_sphereRenderer",null);l(this,"_particleRenderer",null);l(this,"_asset",null);l(this,"_shaderReactionDisposer",null);l(this,"onShaderChange",()=>{const{_asset:t}=this;t.engineObject.shader.name==="particle-shader"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(t.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(t.engineObject))})}setViewAsset(t,a){if(!(t instanceof u))return;const n=a.createChild("material");this._asset=t;const r=this._sphereRenderer=n.createChild("mat").addComponent(V);r.mesh=k.createSphere(a.engine,1,32,!0);const o=this._particleRenderer=n.createChild("pat").addComponent(L);o.generator.main.duration=1e3,o.generator.main.startSpeed.constant=0,this._entity=n,a.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=U(()=>{var i,d;return(d=(i=this._asset)==null?void 0:i.shaderRef)==null?void 0:d.refId},()=>{this.onShaderChange()})}stopViewAsset(){var t;super.stopViewAsset(),(t=this._shaderReactionDisposer)==null||t.call(this),this._shaderReactionDisposer=null,this._asset=null}}class D{static update(e,t){if(!(t instanceof u))return;const a=t.engineObject;if(!a||!a.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(e),a.shader.name==="particle-shader"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(a),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(a))}static clear(){var e,t;(e=this.sphereRenderer)!=null&&e.entity&&(this.sphereRenderer.entity.isActive=!1),(t=this.particleRenderer)!=null&&t.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(e){const t=this.entity=e.createChild("material"),a=this.sphereRenderer=t.createChild("mat").addComponent(V);a.mesh=k.createSphere(e.engine,2,64,!0),this.particleRenderer=t.createChild("pat").addComponent(L),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}l(D,"entity",null),l(D,"sphereRenderer",null),l(D,"particleRenderer",null);function j(p){return p instanceof Q?{x:p.x,y:p.y}:p instanceof z?{x:p.x,y:p.y,z:p.z}:p instanceof H?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof W?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function le(p){switch(p){case f.Color:return"Color";case f.Float:return"Float";case f.Int:return"Integer";case f.Matrix:return"Matrix";case f.Texture:return"Texture";case f.TextureArray:return"TextureArray";case f.Vector2:return"Vector2";case f.Vector3:return"Vector3";case f.Vector4:return"Vector4"}}var ue=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,g=(p,e,t,a)=>{for(var n=a>1?void 0:a?fe(e,t):e,r=p.length-1,o;r>=0;r--)(o=p[r])&&(n=(a?o(e,t,n):o(n))||n);return a&&n&&ue(e,t,n),n};let u=class extends J{constructor(e){super(e);l(this,"acceptDragLayer",$.Texture);l(this,"shaderRef",{refId:null});l(this,"shaderDataKeys",new Set);l(this,"formConfig",null);l(this,"_autoSaveSuppressed",!1);q(this),x(this,{proxyConfigs:[]})}static initBuiltinMaterial(e,t){e.shader=t;const a=e.shaderData;switch(a.disableMacro("MATERIAL_NEED_WORLD_POS"),a.disableMacro("MATERIAL_OMIT_NORMAL"),a.disableMacro("MATERIAL_NEED_TILING_OFFSET"),a.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.depthState.compareFunction=v.Less,t.name){case"unlit":a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"pbr-specular":case"pbr":case"bake-pbr":case"blinn-phong":a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"skybox":e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"SkyProcedural":a.enableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.renderState.rasterState.cullMode=M.Off,e.renderState.depthState.compareFunction=v.LessEqual;break;case"particle-shader":a.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(e){this._autoSaveSuppressed=e}setRenderQueueType(e){this.engineObject.renderState.renderQueueType=e}setBlendStateEnabled(e){this.engineObject.renderState.blendState.targetBlendState.enabled=e}setDepthWriteEnabled(e){this.engineObject.renderState.depthState.writeEnabled=e}setCullMode(e){this.engineObject.renderState.rasterState.cullMode=e}setBlendMode(e){const t=this.engineObject.renderState.blendState.targetBlendState;switch(e){case I.Normal:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.OneMinusSourceAlpha,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break;case I.Additive:t.sourceColorBlendFactor=b.SourceAlpha,t.destinationColorBlendFactor=b.One,t.sourceAlphaBlendFactor=b.One,t.destinationAlphaBlendFactor=b.OneMinusSourceAlpha,t.colorBlendOperation=O.Add,t.alphaBlendOperation=O.Add;break}}bindShaderAsset(e,t){for(const a of this.shaderDataKeys)this.removePropertyChangeListener(a);return this.shaderDataKeys.clear(),e.onReady().then(async()=>{var n;if(e.shaderScriptRefId){const r=this.root.assetStore.assets[e.shaderScriptRefId.refId];this.isInitCompleted&&(r==null||r.onShaderChange(this._engineObject),t=this._getMainData())}const a=e.properties?Y(e.properties):[];e.isBuiltinShader()&&u.initBuiltinMaterial(this.engineObject,e.engineObject),t=t||this._getMainData(),await this._proxyShaderProps(a,t,this.isInitCompleted),this.refreshFormConfig(a,t),this.refreshAnimatableProperties(a),de({assetStore:this.root.assetStore,shaderRef:this.shaderRef,nextShaderAsset:e,material:this}),e.addReferencedMaterial(this),this.shaderRef={refId:e.id},await this.applyBoundPathChange("shader",P.AssetPicker,this.shaderRef),(n=this.updateThumbnail)==null||n.call(this)})}async _proxyShaderProps(e,t,a=!0){var o;this.proxyConfigs=e;const n=(o=this.extraData)==null?void 0:o.disabledMacros,r=e.map(async i=>{var d;if(this.proxySetter(i),this._virualShaderProps(e),i.bundleType==="macro"){const s=i.macroInfo,h=t.macros.find(c=>c.name===i.prop);if(!E(this,i.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):n!=null&&n.includes(i.prop)?(c=void 0,s&&(s.checked=!1)):c=i.defaultValue,x(this,{[i.prop]:c})}if(a)if(h){const c=h.value??i.defaultValue;c==null?s==null||s.onSwitch(!0,this):await i.onChange(this,i.prop,c)}else!(n!=null&&n.includes(i.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=t.shaderData[i.prop];let h=s?s.value:this[i.prop]??i.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((d=i.uiInfo)==null?void 0:d.type)===y.Color)if(i.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;E(this,i.prop)||x(this,{[i.prop]:h}),a&&this.notifyPropertyChange(i.prop,!1)}});await Promise.all(r)}proxySetter(e){const{prop:t,onChange:a,bundleType:n}=e,r=async(o,i)=>{var s;const d=this._engineObject.shaderData;n==="macro"?d.enableMacro(t,o):await F(this,t,o,e.engineType??((s=e.uiInfo)==null?void 0:s.type)),await a(this,t,o),i!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(t,r),this.shaderDataKeys.add(t)}_virualShaderProps(e){const t=this;e.forEach(a=>{X(t,a.prop)})}refreshFormConfig(e,t){var n,r,o,i,d;const a={root:[],groups:{}};if(t){for(const s of e)if(!((n=s.uiInfo)!=null&&n.hide)){if((r=s.uiInfo)!=null&&r.group){if((o=s.uiInfo)!=null&&o.group){let h=a.groups[s.uiInfo.group];h||(h={type:P.Group,property:s.uiInfo.group,children:[]},a.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),a.root.push(h)}s.bundleType==="macro"?this[s.prop]=((i=t.macros.find(h=>h.name===s.prop))==null?void 0:i.value)??s.defaultValue:this[s.prop]=((d=t.shaderData[s.prop])==null?void 0:d.value)??s.defaultValue}}this.formConfig=a}refreshAnimatableProperties(e){var t,a,n;this._additionAnimatableProperties.length=0;for(const r of e){if(!r.uiInfo||r.uiInfo.hide||r.bundleType==="macro")continue;let o={};if((r.setPath||r.getPath||r.valueType||r.interpolationType)&&(o={setPath:r.setPath,getPath:r.getPath,valueType:r.valueType,interpolationType:r.interpolationType}),!o.setPath&&!o.getPath&&r.engineType&&(r.bundleType==="shaderData"||!r.bundleType))switch(r.engineType){case y.Float:o={setPath:`shaderData.setFloat('${r.prop}', $value)`,getPath:`shaderData.getFloat('${r.prop}')`,valueType:S.Float};break;case y.Integer:o={setPath:`shaderData.setInt('${r.prop}', $value)`,getPath:`shaderData.getInt('${r.prop}')`,valueType:S.Float,interpolationType:Z.Step};break;case y.Vector2:o={setPath:`shaderData.getVector2('${r.prop}')`,getPath:`shaderData.getVector2('${r.prop}')`,valueType:S.Vector2};break;case y.Vector3:o={setPath:`shaderData.getVector3('${r.prop}')`,getPath:`shaderData.getVector3('${r.prop}')`,valueType:S.Vector3};break;case y.Vector4:o={setPath:`shaderData.getVector4('${r.prop}')`,getPath:`shaderData.getVector4('${r.prop}')`,valueType:S.Vector4};break;case y.Color:o={setPath:`shaderData.getColor('${r.prop}')`,getPath:`shaderData.getColor('${r.prop}')`,valueType:S.Color};break;case y.Boolean:o={setPath:`shaderData.setBoolean('${r.prop}', $value)`,getPath:`shaderData.getBoolean('${r.prop}')`,valueType:S.Boolean};break;case y.Texture:o={setPath:`shaderData.setTexture('${r.prop}', $value)`,getPath:`shaderData.getTexture('${r.prop}')`,valueType:S.ReferResource};break}if(!o.setPath&&!o.getPath){if(r.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:r.prop,label:(t=r.uiInfo)!=null&&t.label?w(r.uiInfo.label):r.prop,type:(a=r.uiInfo)==null?void 0:a.type,propertyProxyConfig:o}),(n=r.uiInfo)!=null&&n.label&&(o.label=w(r.uiInfo.label)),ee(this,r.prop,o)}}async initByMain(e){var c;const t=JSON.parse(await e.text());this.shaderRef=t.shaderRef;const a=t.shaderData,n=t.macros,r=t.renderState;if(!t.shaderRef)throw"invalid material";const o=new te(this.engine);this.setDragTempEntity(o);const i=await this.root.assetStore.getAssetByRef(t.shaderRef),d=i.engineObject??ae.find("unlit"),s=new re(this.engine,d);this.bindEngineObject(s);const h=s.shaderData;if(n)for(const R of n)h.enableMacro(R.name,R.value);if(a)for(const R in a){const _=a[R];let A=_.value;if(_.type===y.Color){A={..._.value};const T=_.value.intensity??1;T!==0&&(A.r/=T,A.g/=T,A.b/=T)}F(this,R,A,_.type)}r&&this._parseProperty(s,"renderState",r),await this.bindShaderAsset(i,t),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",P.Input,this.name),this._checkSchemaOnInit(t,i)}_checkSchemaOnInit(e,t){e.shader!==t.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(e){const t=this;this.bindEngineObject(e),t.shader=e.shader.name,t._name=e.name??"";const n=Object.values(this.root.assetStore.assets).filter(d=>d.meta.type==="Shader"&&!!d.meta.builtinShaderName).find(d=>d.meta.builtinShaderName===e.shader.name);switch(this.shaderRef={refId:n.id},t.isTransparent=e.renderState.blendState.targetBlendState.enabled,t.alphaCutoff=e.shaderData.getFloat("material_AlphaCutoff"),e.renderState.rasterState.cullMode){case M.Back:t.renderFace=B.Front;break;case M.Front:t.renderFace=B.Back;break;case M.Off:t.renderFace=B.Double;break}t.blendMode=e.renderState.blendState.targetBlendState.destinationColorBlendFactor===b.One?I.Additive:I.Normal;const r=e.shaderData;r.getProperties().forEach(d=>{const s=r.getPropertyValue(d);if(s instanceof se){const h=this.root.assetStore.engineObjectToAssetMap.get(s);this[d.name]=h==null?void 0:h.getCurrentRef()}else this[d.name]=j(s)});const i=this._getMainData();this._proxyShaderProps(C,i,!1),this.bindShaderAsset(n,i)}afterDelete(){var e;(e=this.engineObject)==null||e.destroy(!0)}rename(e){return this.root.assetFacade.persistAssetMain(this.id),super.rename(e)}_getMainData(e){var i,d;const t=[],a=(e??this.engineObject).shaderData;a.getMacros(t);const n=t.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h}),r=[],o={};a.getProperties(r);for(const s of r){let h;if(s.type===f.Texture||s.type===f.TextureArray)h=this[s.name];else{const c=a.getPropertyValue(s);h=j(c),((i=this[s.name])==null?void 0:i.intensity)!=null&&(h.intensity=(d=this[s.name])==null?void 0:d.intensity)}h!=null&&(o[s.name]={type:le(s.type),value:h})}return{name:this.name,shader:this.engineObject.shader.name,macros:n,renderState:this.engineObject.renderState,shaderData:o,shaderRef:this.shaderRef}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var o;const e=new ne(this.engine),t=[];e.shaderData.getMacros(t);const a=t.map(({name:i,value:d})=>d===void 0?{name:i}:{name:i,value:d});this.bindEngineObject(e);const n={};for(const i of C)i.defaultValue&&(n[i.prop]={value:i.defaultValue,type:i.engineType??((o=i.uiInfo)==null?void 0:o.type)});const r={shaderData:n,shaderRef:{refId:"0000501"},name:this.name,shader:e.shader.name,macros:a,renderState:e.renderState};return this._proxyShaderProps(C,r,!1),r}async onSubAssetEdit(){var n;const e=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(e.engineObject),await e.applyBoundPathChange("name",P.Input,e.name),e.initByEngineObject(e.engineObject),e.updateThumbnail(),await this.root.assetFacade.persistAssetMain(e.id);const t=await this.root.assetStore.getAssetByRef({refId:this.mainId}),a=((n=t.engineObject.materials)==null?void 0:n.indexOf(this._engineObject))??-1;a>=0&&await t.replaceMaterial(a,e.getCurrentRef()),this.root.assetStore.selectAsset(e.id)}saveMainImmediately(){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately().then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}_parseProperty(e,t,a){if(typeof a=="object")for(const n in a)this._parseProperty(e[t],n,a[n]);else e[t]=a}async _onDrop(e,t){const a="material_BaseTexture";if(a in this){const n=t.getCurrentRef();this[a]=n;const r=C.find(o=>o.prop===a);r&&await r.onChange(this,a,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:e,sceneUIStore:t}=this.root,a=t.hoveredEntityId;if(a){const n=e.entities.get(a);if(n){const r=n.getComponentByTypeName("MeshRenderer"),o=n.getComponentByTypeName("SkinnedMeshRenderer"),i=r||o;i&&this.root.componentFacade.updateComponent(n.id,i.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};g([N],u.prototype,"shaderRef",2);g([N.ref],u.prototype,"formConfig",2);g([m],u.prototype,"bindShaderAsset",1);g([m],u.prototype,"_proxyShaderProps",1);g([m],u.prototype,"proxySetter",1);g([m],u.prototype,"_virualShaderProps",1);g([m],u.prototype,"refreshAnimatableProperties",1);g([m],u.prototype,"_onDrop",1);u=g([ie({type:"Material",label:w("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:oe.Add},customInspector:he,viewer:ce,thumbnail:D,dragLayer:$.Material})],u);const Ae=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return u}},Symbol.toStringTag,{value:"Module"}));export{u as M,ce as a,Ae as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var A=Object.defineProperty;var L=(d,e,t)=>e in d?A(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var j=(d,e,t)=>(L(d,typeof e!="symbol"?e+"":e,t),t);import{aH as x,aI as N,aT as S,aJ as $,aD as s,aK as M,C as n,bx as V,aE as F,by as B,aY as f,aU as E,bz as T,e as z}from"./index-0a8702e2.js";import{u as W}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{I as O}from"./IconPointFilled-a304fd34.js";const U=x(O,{marginRight:"-$1",variants:{checked:{true:{color:"$green10"}}}}),H=x(N,{width:"100%",border:"none",position:"relative",whiteSpace:"pre-wrap",boxShadow:"$2","& > svg":{marginRight:"$1"}});function b(d){return S(function(t){const{inspectorConfig:r,macroConfig:c,...p}=t,{model:i}=p;let{models:g}=p;const{checked:u,onSwitch:h}=c,{type:m,...a}=r,[o,l]=$.useState(u);$.useEffect(()=>{l(u)},[u]),g=g||[i];const y=()=>{const I=!o;if(h)for(const k of g)h(I,k);l(I)},v=r.label;return s.jsxs(M,{direction:"column",fullWidth:!0,children:[m!==n.Null&&o&&V.createElement(d,{...p,inspectorConfig:{...a,type:m}}),s.jsx(F,{label:o?"":v,children:s.jsx(H,{size:"sm",variant:"subtle",startSlot:s.jsx(U,{size:"12px",checked:o}),onClick:y,children:o?"Enabled ":"Disabled"})})]})})}const J=x(M),K=x(B,{backgroundColor:"$gray1",height:"2px !important"});function Y(d){const{inspectorConfig:e,models:t,onModelChange:r,model:c,macroConfig:p}=d,{type:i,property:g,info:u}=e,{t:h}=E(),m=!c&&t&&t.length>1;if(m&&!t.find(R=>e.when?e.when(R):!0)||e.when&&!e.when(c))return null;const a=p?w.getRegisteredMacroComponent(i):w.getRegisteredComponent(i);if(!a)return console.warn(`缺少${i}类型的组件`),null;let o=e.disabled;!m&&c.getEditable&&(o=c.getEditable(e.property)===!1);const l=typeof e.label=="string"?h(e.label):e.label;let y=e.options;y&&(y=y.map(R=>({label:typeof R.label=="string"?h(R.label):R.label,value:R.value})));const v={...e,label:l,info:u,options:y,disabled:o},{triggerAfterInit:I,customComponent:k,...P}=v;return s.jsx(a,{inspectorConfig:P,macroConfig:p,models:t,model:c,onModelChange:r},g)}const C=class C{static registerComponent(e,t){this.components[e]=t}static getRegisteredComponent(e){return C.components[e]}static getRegisteredMacroComponent(e){return C.macroComponents[e]}};j(C,"components",f.getRegisteredComponents()),j(C,"macroComponents",{[n.Color]:b(f.getRegisteredComponent(n.Color)),[n.Vector4]:b(f.getRegisteredComponent(n.Vector4)),[n.Vector3]:b(f.getRegisteredComponent(n.Vector3)),[n.Vector2]:b(f.getRegisteredComponent(n.Vector2)),[n.Number]:b(f.getRegisteredComponent(n.Number)),[n.AssetPicker]:b(f.getRegisteredComponent(n.AssetPicker)),[n.Boolean]:b(f.getRegisteredComponent(n.Boolean)),[n.Null]:b(f.getRegisteredComponent(n.Null))}),j(C,"Item",S(Y)),j(C,"List",S(function(t){const{configs:r,models:c,css:p,onModelChange:i,model:g,children:u,fullWidth:h=!1,withSeparator:m}=t;return r!=null&&r.length&&r.sort((a,o)=>{const l=a.priority??0;return(o.priority??0)-l}),r?s.jsxs(J,{css:p,className:"shader-inspector-form",fullWidth:h,children:[r.map(a=>s.jsxs($.Fragment,{children:[s.jsx(C.Item,{inspectorConfig:a,macroConfig:a.macroConfig,model:g,models:c,onModelChange:i},a.property),m&&s.jsx(K,{})]},a.property)),u]}):null}));let w=C;const q=x("div",{backgroundColor:"$appBg",width:"100%"}),D=x("div",{backgroundColor:"$panelBg",borderRadius:"0 0 $2 $2",overflow:"hidden",paddingBottom:"$1"}),G=x("div",{width:"100%",backgroundColor:"$gray3",paddingBottom:"$0_5"}),Q=x(B,{backgroundColor:"$appBg",height:"2px !important"}),X=d=>{var a;const{asset:e}=d,t=e.formConfig,{assetStore:r,inspectorFacade:c}=W(),{i18n:p}=E(),i=r.assets[e.shaderRef.refId],g=i==null?void 0:i.name,u=Object.values(r.assets).filter(o=>o.meta.type==="Shader"&&o.meta.utility!=="error"),h=()=>{r.selectAsset(e.shaderRef.refId)},m=(o,l)=>{c.assetChange(e.id,o,l)};if(t.root)for(const o of t.root){const l=o.comments;l&&(o.info=l[p.language]??l.default??void 0)}return s.jsxs(q,{children:[s.jsx(G,{children:s.jsx(T,{label:z("asset.shader.title"),assets:u,disabled:!!(i!=null&&i.isSubAsset)||e.isSubAsset||!e.getEditable(),value:g,dropLayer:0,onSelect:async o=>{await e.bindShaderAsset(o,e._getMainData()),await c.assetChanges(e.id,{shaderRef:e.shaderRef,shader:e.shader})},onLocate:h})}),((a=t.root)==null?void 0:a.length)>0&&s.jsx(D,{children:s.jsx(w.List,{model:e,onModelChange:m,configs:t.root,withSeparator:!1})}),s.jsx(Q,{}),s.jsx(w.List,{model:e,onModelChange:m,configs:Object.values(t.groups)})]})},ne=S(X);export{ne as M};
|