@eigong/effekseer-webgpu-runtime 0.1.3 → 0.1.4
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/README.md +5 -3
- package/package.json +2 -2
- package/runtime/effekseer.webgpu.js +1 -1
package/README.md
CHANGED
|
@@ -29,11 +29,10 @@ import {
|
|
|
29
29
|
effekseerWebgpuRuntimeJsUrl,
|
|
30
30
|
effekseerWebgpuRuntimeWasmUrl,
|
|
31
31
|
effekseerWebgpuBridgeUrl,
|
|
32
|
-
effekseerWebgpuDebugBridgeUrl,
|
|
33
32
|
} from '@eigong/effekseer-webgpu-runtime'
|
|
34
33
|
```
|
|
35
34
|
|
|
36
|
-
The default loader uses the client bridge:
|
|
35
|
+
The default loader uses the client bridge, which strips profiling and log-control APIs before minification:
|
|
37
36
|
|
|
38
37
|
```js
|
|
39
38
|
import { loadEffekseerWebGPURuntime } from '@eigong/effekseer-webgpu-runtime'
|
|
@@ -42,7 +41,10 @@ import { loadEffekseerWebGPURuntime } from '@eigong/effekseer-webgpu-runtime'
|
|
|
42
41
|
Use the debug/source bridge only when you explicitly want it:
|
|
43
42
|
|
|
44
43
|
```js
|
|
45
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
effekseerWebgpuDebugBridgeUrl,
|
|
46
|
+
loadEffekseerWebGPUDebugRuntime,
|
|
47
|
+
} from '@eigong/effekseer-webgpu-runtime/debug'
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
Or resolve all runtime URLs at once:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eigong/effekseer-webgpu-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Redistributable Effekseer WebGPU runtime assets with MIT license notice",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"sideEffects": false,
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "
|
|
42
|
+
"build": "node ./scripts/build-client-runtime.mjs",
|
|
43
43
|
"prepublishOnly": "npm run build"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const effekseer=(()=>{let e={},t={},r=null,n=!1,a=!1,i=null,s=null,o="",f=0,l=[];const u=e=>e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):null,d=e=>{if("string"!=typeof e||0===e.length)return"";const t=e.replace(/\\/g,"/").split("/"),r=[];for(let e=0;e<t.length;e++){const n=t[e];n&&"."!==n&&(".."!==n?r.push(n):r.length>0&&r.pop())}let n=r.join("/");for(;n.startsWith("/");)n=n.slice(1);return n.replace(/[A-Z]/g,e=>e.toLowerCase())},c="EFWGPKG2",p="__efwgpk__/main_effect_path.txt",m=new Uint8Array([69,102,107,87,103,46,87,101,98,71,80,85,46,67,84,82]);let h=0,g=null;const b=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let e=0;e<8;e++)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e})(),w=e=>{if(!(e instanceof Uint8Array))return 0;let t=4294967295;for(let r=0;r<e.length;r++){const n=255&(t^e[r]);t=t>>>8^b[n]}return~t>>>0},E=async(e,t)=>{const r=await(async()=>{if(g)return g;if(!globalThis.crypto||!globalThis.crypto.subtle||"function"!=typeof globalThis.crypto.subtle.importKey)throw new Error("Web Crypto AES-CTR is required for encrypted efkwgpk payloads");return g=globalThis.crypto.subtle.importKey("raw",m,"AES-CTR",!1,["decrypt"]),g})();return globalThis.crypto.subtle.decrypt({name:"AES-CTR",counter:t,length:128},r,e)},S=e=>String(e||"").replace(/\\/g,"/").split("?")[0].split("#")[0],v=e=>{const t=u(e);if(!t||t.byteLength<8)return"";const r=new Uint8Array(t,0,8);return String.fromCharCode(...r)},k=e=>{const t=new Map,r=e?e.byteLength:0,n=(e=>{const t=e?e.byteLength:0;if(!e||t<64)return null;const r=new DataView(e);if(v(e)!==c)return null;const n=r.getUint32(8,!0),a=r.getUint32(12,!0),i=r.getUint32(16,!0),s=r.getUint32(20,!0),o=r.getUint32(24,!0),f=r.getUint32(28,!0),l=r.getUint32(32,!0),u=r.getUint32(36,!0),d=r.getUint32(40,!0),p=r.getUint32(44,!0),m=r.getUint32(48,!0),h=r.getUint32(52,!0),g=2===i?64:3===i?80:0;if(0===g||n!==g||48!==o)return null;let b=null;if(4&a){if(i<3||t<80)return null;if(b=new Uint8Array(e.slice(56,72)),16!==b.byteLength)return null}return{headerSize:n,globalFlags:a,formatRevision:i,entryCount:s,entryStride:o,entriesOffset:f,stringPoolOffset:l,stringPoolSize:u,payloadOffset:d,payloadSize:p,tocCrc:m,payloadCrc:h,payloadNonce:b,payloadEncrypted:!!(4&a)}})(e);if(!n)return t;const a=new DataView(e),{headerSize:i,entryCount:s,entryStride:o,entriesOffset:f,stringPoolOffset:l,stringPoolSize:u,payloadOffset:p,payloadSize:m,tocCrc:h,payloadCrc:g}=n,b=BigInt(s)*BigInt(o);if(b>BigInt(r))return t;const E=Number(b);if(!x(f,E,r))return t;if(!x(l,u,r))return t;if(!x(p,m,r))return t;const S=l+u,k=p+m,G=new Uint8Array(e,0,i).slice();G.fill(0,48,56);const y=new Uint8Array(i+E+u);if(y.set(G,0),y.set(new Uint8Array(e,f,E),i),y.set(new Uint8Array(e,l,u),i+E),w(y)!==h>>>0)return t;const C=new Uint8Array(e,p,m);if(w(C)!==g>>>0)return t;const T=new TextDecoder("utf-8");for(let n=0;n<s;n++){const i=f+n*o,s=a.getUint32(i+8,!0),u=a.getUint32(i+12,!0),c=a.getUint32(i+16,!0),m=a.getUint32(i+20,!0),h=a.getUint32(i+24,!0),g=a.getUint32(i+28,!0),b=a.getUint32(i+32,!0),w=a.getUint32(i+36,!0);if(!x(s,u,r))continue;if(s<l||s+u>S)continue;if(!x(m,h,r))continue;if(m<p||m+h>k)continue;let E="";try{E=T.decode(new Uint8Array(e,s,u))}catch{continue}const v=d(E);if(!v)continue;const G={index:n,path:E,normalizedPath:v,flags:c,payloadOffset:m,packedSize:h,rawSize:g,packedCrc:b,rawCrc:w},y=t.get(v);y?y.push(G):t.set(v,[G])}return t._efwgpkMeta={payloadOffset:p,payloadSize:m,payloadEncrypted:n.payloadEncrypted,payloadNonce:n.payloadNonce,decryptedPayloadPromise:null},t},G=async e=>{const t=globalThis.fflate;if(t&&"function"==typeof t.unzlibSync){const r=t.unzlibSync(new Uint8Array(e));return u(r)}if("function"!=typeof DecompressionStream)throw new Error("No zlib inflate backend available for efkwgpk payload");const r=new DecompressionStream("deflate"),n=r.writable.getWriter();await n.write(e),await n.close();return await new Response(r.readable).arrayBuffer()},y=async(e,t,r)=>{const n=t&&t._efwgpkMeta?t._efwgpkMeta:null;if(!n||!n.payloadEncrypted)return new Uint8Array(e,r.payloadOffset,r.packedSize);if(!n.decryptedPayloadPromise){const t=new Uint8Array(e,n.payloadOffset,n.payloadSize);n.decryptedPayloadPromise=E(t,n.payloadNonce).then(e=>new Uint8Array(e))}const a=await n.decryptedPayloadPromise,i=r.payloadOffset-n.payloadOffset;return i<0||i+r.packedSize>a.byteLength?null:a.subarray(i,i+r.packedSize)},C=async(e,t,r)=>{const n=d(r);if(!n||!e||!t||0===t.size)return null;const a=t.get(n);if(!a||0===a.length)return null;for(let r=0;r<a.length;r++){const n=a[r];if(!x(n.payloadOffset,n.packedSize,e.byteLength))continue;const i=await y(e,t,n);if(i&&w(i)===n.packedCrc>>>0){if(0===n.flags&&n.packedSize===n.rawSize){const e=i.slice();if(w(e)!==n.rawCrc>>>0)continue;return e.buffer}if(1===n.flags){const e=await G(i);if(!e||e.byteLength!==n.rawSize)continue;if(w(new Uint8Array(e))!==n.rawCrc>>>0)continue;return e}}}return null},T=e=>e&&Number.isFinite(e.payloadOffset)&&Number.isFinite(e.packedSize)&&Number.isFinite(e.rawSize)&&Number.isFinite(e.flags)?`${e.flags}:${e.payloadOffset}:${e.packedSize}:${e.rawSize}`:"",P=(e,t,r)=>{const n=d(r);if(!n||!e||!t||0===t.size)return null;const a=t.get(n);if(!a||0===a.length)return null;for(let t=0;t<a.length;t++){const r=a[t];if(x(r.payloadOffset,r.packedSize,e.byteLength)){if(0===r.flags&&r.packedSize===r.rawSize)return r;if(1===r.flags)return r}}return null},x=(e,t,r)=>!!(Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(r))&&(!(e<0||t<0||r<0)&&(!(e>r)&&t<=r-e)),R=(e,t,r)=>{const n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{const a=0|n.status;a>=200&&a<300||0===a?t(n.response):r&&r("not found",e)},n.onerror=()=>{r&&r("not found",e)},n.send(null)},_=e=>{try{const t=new XMLHttpRequest;t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null);const r=0|t.status;if(r>=200&&r<300||0===r)return t.response}catch{}return null},M=e=>{"function"==typeof e&&("function"==typeof queueMicrotask?queueMicrotask(e):Promise.resolve().then(e))},D=(e,t)=>{const r=String(e||"").replace(/\\/g,"/");const n=Number(t);return`${r}::${Number.isFinite(n)?n:1}`},I=e=>{e&&e.context&&e._cacheKey&&e.context._effectCache&&e.context._effectCache.get(e._cacheKey)===e&&e.context._effectCache.delete(e._cacheKey)},U=e=>e?{id:e.id,path:e.path,scale:e.scale,enabled:e.enabled,status:e.status,effect:"loaded"===e.status?e.effect:null,errorMessage:e.errorMessage,errorPath:e.errorPath,loadPromise:e.loadPromise,activeHandles:new Set(e.activeHandles),ownedResourceAliases:e.ownedResourceAliases.slice()}:null,L=(e,t,r)=>{if(e&&("function"==typeof t&&(e.isLoaded?M(()=>t()):e._loadFailed||e._onloadListeners.push(t)),"function"==typeof r))if(e._loadFailed){const t=e._loadErrorMessage||"failed to load effect",n=e._loadErrorPath||"";M(()=>r(t,n))}else e.isLoaded||e._onerrorListeners.push(r)},A=(e,t,r="")=>{if(!e||e._loadFailed)return;e._loadFailed=!0,e._loadErrorMessage=String(t||"failed to load effect"),e._loadErrorPath=String(r||""),I(e);const n=e._onerrorListeners.slice();e._onloadListeners.length=0,e._onerrorListeners.length=0;for(let t=0;t<n.length;t++){const r=n[t];M(()=>r(e._loadErrorMessage,e._loadErrorPath))}};let F=(e,t,r)=>{R(e,t,r)};const B={ptr:0,capacity:0},O=(t,r)=>{const n=t instanceof Float32Array?t:new Float32Array(t);if(n.length<=0)return void r(0);const a=((i=n.length)<=B.capacity&&0!==B.ptr||(0!==B.ptr&&(e._free(B.ptr),B.ptr=0,B.capacity=0),B.ptr=e._malloc(4*i),B.capacity=i),B.ptr);var i;e.HEAPF32.set(n,a>>2),r(a)},z=Object.freeze({rgba8unorm:22,"rgba8unorm-srgb":23,bgra8unorm:27,"bgra8unorm-srgb":28,rgba16float:40,depth24plus:46,"depth24plus-stencil8":47,depth32float:48}),V=(Object.freeze(Object.fromEntries(Object.entries(z).map(([e,t])=>[t,e]))),e=>{if("number"==typeof e&&Number.isFinite(e))return 0|e;if("string"!=typeof e)return null;const t=e.trim().toLowerCase();return t&&Object.prototype.hasOwnProperty.call(z,t)?z[t]:null}),j=async s=>{if(n)return;if(a)return void await new Promise((e,t)=>{l.push(r=>r?e():t(new Error("Runtime initialization failed.")))});if(a=!0,"undefined"==typeof effekseer_webgpu_native)throw a=!1,new Error("effekseer_webgpu_native is not loaded.");const o={};"string"==typeof s&&s.length>0&&(o.locateFile=e=>e.endsWith(".wasm")?s:e),i&&(o.preinitializedWebGPUDevice=i);const f=effekseer_webgpu_native(o);e=f instanceof Promise?await f:f,!i&&e?.preinitializedWebGPUDevice&&(i=e.preinitializedWebGPUDevice),i&&(e.preinitializedWebGPUDevice=i),(()=>{t={InitInternal:e.cwrap("EffekseerInitInternal","number",["number","number","string","number","number"]),InitExternal:e.cwrap("EffekseerInitExternal","number",["number","number","number","number"]),Init:e.cwrap("EffekseerInit","number",["number","number","string","number","number","number"]),Terminate:e.cwrap("EffekseerTerminate","void",["number"]),Update:e.cwrap("EffekseerUpdate","void",["number","number"]),BeginUpdate:e.cwrap("EffekseerBeginUpdate","void",["number"]),EndUpdate:e.cwrap("EffekseerEndUpdate","void",["number"]),UpdateHandle:e.cwrap("EffekseerUpdateHandle","void",["number","number","number"]),Draw:e.cwrap("EffekseerDraw","void",["number"]),DrawExternal:e.cwrap("EffekseerDrawExternal","void",["number"]),BeginDraw:e.cwrap("EffekseerBeginDraw","void",["number"]),EndDraw:e.cwrap("EffekseerEndDraw","void",["number"]),DrawHandle:e.cwrap("EffekseerDrawHandle","void",["number","number"]),SetProjectionMatrix:e.cwrap("EffekseerSetProjectionMatrix","void",["number","number"]),SetProjectionPerspective:e.cwrap("EffekseerSetProjectionPerspective","void",["number","number","number","number","number"]),SetProjectionOrthographic:e.cwrap("EffekseerSetProjectionOrthographic","void",["number","number","number","number","number"]),SetCameraMatrix:e.cwrap("EffekseerSetCameraMatrix","void",["number","number"]),SetCameraLookAt:e.cwrap("EffekseerSetCameraLookAt","void",["number","number","number","number","number","number","number","number","number","number"]),LoadEffect:e.cwrap("EffekseerLoadEffect","number",["number","number","number","number"]),ReleaseEffect:e.cwrap("EffekseerReleaseEffect","void",["number","number"]),ReloadResources:e.cwrap("EffekseerReloadResources","void",["number","number","number","number"]),StopAllEffects:e.cwrap("EffekseerStopAllEffects","void",["number"]),PlayEffect:e.cwrap("EffekseerPlayEffect","number",["number","number","number","number","number"]),StopEffect:e.cwrap("EffekseerStopEffect","void",["number","number"]),StopRoot:e.cwrap("EffekseerStopRoot","void",["number","number"]),Exists:e.cwrap("EffekseerExists","number",["number","number"]),SetFrame:e.cwrap("EffekseerSetFrame","void",["number","number","number"]),SetLocation:e.cwrap("EffekseerSetLocation","void",["number","number","number","number","number"]),SetRotation:e.cwrap("EffekseerSetRotation","void",["number","number","number","number","number"]),SetScale:e.cwrap("EffekseerSetScale","void",["number","number","number","number","number"]),SetMatrix:e.cwrap("EffekseerSetMatrix","void",["number","number","number"]),SetAllColor:e.cwrap("EffekseerSetAllColor","void",["number","number","number","number","number","number"]),SetTargetLocation:e.cwrap("EffekseerSetTargetLocation","void",["number","number","number","number","number"]),GetDynamicInput:e.cwrap("EffekseerGetDynamicInput","number",["number","number","number"]),SetDynamicInput:e.cwrap("EffekseerSetDynamicInput","void",["number","number","number","number"]),SendTrigger:e.cwrap("EffekseerSendTrigger","void",["number","number","number"]),SetPaused:e.cwrap("EffekseerSetPaused","void",["number","number","number"]),SetShown:e.cwrap("EffekseerSetShown","void",["number","number","number"]),SetSpeed:e.cwrap("EffekseerSetSpeed","void",["number","number","number"]),SetRandomSeed:e.cwrap("EffekseerSetRandomSeed","void",["number","number","number"]),SetCompositeMode:e.cwrap("EffekseerSetCompositeMode","void",["number","number"]),GetRestInstancesCount:e.cwrap("EffekseerGetRestInstancesCount","number",["number"]),GetUpdateTime:e.cwrap("EffekseerGetUpdateTime","number",["number"]),GetDrawTime:e.cwrap("EffekseerGetDrawTime","number",["number"]),GetDrawFlushComputeTime:e.cwrap("EffekseerGetDrawFlushComputeTime","number",["number"]),GetDrawBeginFrameTime:e.cwrap("EffekseerGetDrawBeginFrameTime","number",["number"]),GetDrawManagerTime:e.cwrap("EffekseerGetDrawManagerTime","number",["number"]),GetDrawEndFrameTime:e.cwrap("EffekseerGetDrawEndFrameTime","number",["number"]),GetDrawTotalTime:e.cwrap("EffekseerGetDrawTotalTime","number",["number"]),GetGpuTimestampSupported:e.cwrap("EffekseerGetGpuTimestampSupported","number",["number"]),GetGpuTimestampValid:e.cwrap("EffekseerGetGpuTimestampValid","number",["number"]),GetGpuTimestampEffekseerPassTime:e.cwrap("EffekseerGetGpuTimestampEffekseerPassTime","number",["number"]),GetGpuTimestampFrameTime:e.cwrap("EffekseerGetGpuTimestampFrameTime","number",["number"]),GetGpuTimestampReadPending:e.cwrap("EffekseerGetGpuTimestampReadPending","number",["number"]),GetGpuTimestampLastMapStatus:e.cwrap("EffekseerGetGpuTimestampLastMapStatus","number",["number"]),GetGpuTimestampMapState:e.cwrap("EffekseerGetGpuTimestampMapState","number",["number"]),GetGpuTimestampMapMode:e.cwrap("EffekseerGetGpuTimestampMapMode","number",["number"]),GetGpuTimestampStallRecoveries:e.cwrap("EffekseerGetGpuTimestampStallRecoveries","number",["number"]),GetRendererProfileBindGroupTime:e.cwrap("EffekseerGetRendererProfileBindGroupTime","number",["number"]),GetRendererProfileBindGroupCacheFlushCount:e.cwrap("EffekseerGetRendererProfileBindGroupCacheFlushCount","number",["number"]),GetRendererProfileBindGroupCacheHits:e.cwrap("EffekseerGetRendererProfileBindGroupCacheHits","number",["number"]),GetRendererProfileBindGroupCacheMisses:e.cwrap("EffekseerGetRendererProfileBindGroupCacheMisses","number",["number"]),GetRendererProfileBindGroupCreates:e.cwrap("EffekseerGetRendererProfileBindGroupCreates","number",["number"]),GetRendererProfilePipelineTime:e.cwrap("EffekseerGetRendererProfilePipelineTime","number",["number"]),GetRendererProfileSetStateTime:e.cwrap("EffekseerGetRendererProfileSetStateTime","number",["number"]),GetRendererProfileIssueDrawTime:e.cwrap("EffekseerGetRendererProfileIssueDrawTime","number",["number"]),GetRendererProfileDrawTotalTime:e.cwrap("EffekseerGetRendererProfileDrawTotalTime","number",["number"]),GetRendererProfileDrawSpritesCalls:e.cwrap("EffekseerGetRendererProfileDrawSpritesCalls","number",["number"]),GetRendererProfileDrawPolygonCalls:e.cwrap("EffekseerGetRendererProfileDrawPolygonCalls","number",["number"]),GetInternalStandardRendererTextureSetupTime:e.cwrap("EffekseerGetInternalStandardRendererTextureSetupTime","number",["number"]),GetInternalStandardRendererShaderSelectTime:e.cwrap("EffekseerGetInternalStandardRendererShaderSelectTime","number",["number"]),GetInternalStandardRendererVertexPackTime:e.cwrap("EffekseerGetInternalStandardRendererVertexPackTime","number",["number"]),GetInternalStandardRendererPixelPackTime:e.cwrap("EffekseerGetInternalStandardRendererPixelPackTime","number",["number"]),GetInternalStandardRendererConstantUploadTime:e.cwrap("EffekseerGetInternalStandardRendererConstantUploadTime","number",["number"]),GetInternalStandardRendererRenderStateTime:e.cwrap("EffekseerGetInternalStandardRendererRenderStateTime","number",["number"]),GetInternalStandardRendererVertexBindTime:e.cwrap("EffekseerGetInternalStandardRendererVertexBindTime","number",["number"]),GetInternalStandardRendererIndexBindTime:e.cwrap("EffekseerGetInternalStandardRendererIndexBindTime","number",["number"]),GetInternalStandardRendererLayoutTime:e.cwrap("EffekseerGetInternalStandardRendererLayoutTime","number",["number"]),GetInternalStandardRendererDrawTime:e.cwrap("EffekseerGetInternalStandardRendererDrawTime","number",["number"]),GetManagerProfileFrustumTime:e.cwrap("EffekseerGetManagerProfileFrustumTime","number",["number"]),GetManagerProfileSortTime:e.cwrap("EffekseerGetManagerProfileSortTime","number",["number"]),GetManagerProfileCanDrawTime:e.cwrap("EffekseerGetManagerProfileCanDrawTime","number",["number"]),GetManagerProfileContainerDrawTime:e.cwrap("EffekseerGetManagerProfileContainerDrawTime","number",["number"]),GetManagerProfileGpuParticleTime:e.cwrap("EffekseerGetManagerProfileGpuParticleTime","number",["number"]),GetManagerProfileDrawSetCount:e.cwrap("EffekseerGetManagerProfileDrawSetCount","number",["number"]),GetManagerProfileVisibleDrawSetCount:e.cwrap("EffekseerGetManagerProfileVisibleDrawSetCount","number",["number"]),GetManagerProfileContainersTotal:e.cwrap("EffekseerGetManagerProfileContainersTotal","number",["number"]),GetManagerProfileContainersDrawn:e.cwrap("EffekseerGetManagerProfileContainersDrawn","number",["number"]),GetManagerProfileContainersDepthCulled:e.cwrap("EffekseerGetManagerProfileContainersDepthCulled","number",["number"]),GetDrawCallCount:e.cwrap("EffekseerGetDrawCallCount","number",["number"]),GetDrawVertexCount:e.cwrap("EffekseerGetDrawVertexCount","number",["number"]),GetTotalParticleCount:e.cwrap("EffekseerGetTotalParticleCount","number",["number"]),DrawExternalBack:e.cwrap("EffekseerDrawExternalBack","void",["number"]),DrawExternalFront:e.cwrap("EffekseerDrawExternalFront","void",["number"]),IsVertexArrayObjectSupported:e.cwrap("EffekseerIsVertexArrayObjectSupported","number",["number"]),SetRestorationOfStatesFlag:e.cwrap("EffekseerSetRestorationOfStatesFlag","void",["number","number"]),CaptureBackground:e.cwrap("EffekseerCaptureBackground","void",["number","number","number","number","number"]),ResetBackground:e.cwrap("EffekseerResetBackground","void",["number"]),SetLogEnabled:e.cwrap("EffekseerSetLogEnabled","void",["number"]),SetDepthTexture:e.cwrap("EffekseerSetDepthTexture","void",["number","number"]),SetBackgroundTexture:e.cwrap("EffekseerSetBackgroundTexture","void",["number","number"])},e.resourcesMap={},e._loadBinary=(t,n)=>{const a=r;if(!a)return null;let i=a.resources.find(e=>e.path===t);if(i)return i.isLoaded?i.buffer:null;i={path:t,isLoaded:!1,buffer:null,isRequired:!!n},a.resources.push(i);const s=e=>String(e||"").replace(/\\/g,"/"),o=e=>{const t=s(e);let r=t.startsWith("/")||/^[a-zA-Z]+:\/\//.test(t)?t:(a.baseDir||"")+t;return a.redirect&&(r=a.redirect(r)),r},f=(e=>{const t=s(e),r=[],n=new Set,a=e=>{e&&!n.has(e)&&(n.add(e),r.push(e))},i=e=>{if(!e||e.includes("/"))return;const t=e.toLowerCase();(t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".dds"))&&a(`Texture/${e}`),(t.endsWith(".efkmodel")||t.endsWith(".mqo"))&&a(`Model/${e}`)},o=t.indexOf("/");if(o>0){const e=t.slice(0,o).toLowerCase();(e.endsWith(".efk")||e.endsWith(".efkefc")||e.endsWith(".efkproj"))&&a(t.slice(o+1))}a(t),i(t);let f=t.indexOf("/");for(;f>=0;){const e=t.slice(f+1);a(e),i(e),f=t.indexOf("/",f+1)}return r})(t);if(a.syncResourceLoad){for(let r=0;r<f.length;r++){const n=f[r],a=o(n),s=e.resourcesMap[a]||e.resourcesMap[n]||e.resourcesMap[t];if(null!=s)return i.buffer=s,i.isLoaded=!0,s;const l=_(a);if(null!=l)return i.buffer=l,i.isLoaded=!0,e.resourcesMap[a]=l,e.resourcesMap[n]=l,l}return i.buffer=null,i.isLoaded=!0,null}for(let r=0;r<f.length;r++){const n=f[r],s=o(n),l=e.resourcesMap[s]||e.resourcesMap[n]||e.resourcesMap[t];if(null!=l)return i.buffer=l,i.isLoaded=!0,Promise.resolve().then(()=>a._update()),null}let l=0;const u=()=>{if(l>=f.length)return i.buffer=null,i.isLoaded=!0,void a._update();const e=f[l++],t=o(e);F(t,e=>{if(null!=e)return i.buffer=e,i.isLoaded=!0,void a._update();u()},()=>{u()})};return u(),null},n=!0,a=!1;const i=l;l=[],i.forEach(e=>e(!0))})()};class H{constructor(e){this.context=e,this.nativeptr=0,this.baseDir="",this.syncResourceLoad=!1,this.isLoaded=!1,this.scale=1,this.resources=[],this.mainBuffer=null,this.onload=null,this.onerror=null,this._onloadListeners=[],this._onerrorListeners=[],this._loadFailed=!1,this._loadErrorMessage="",this._loadErrorPath="",this._cacheKey="",this.redirect=null,this.packageOnly=!1,this._ownedResourceAliases=[],this._managedRefIds=new Set}_load(n){const a=u(n);if(!a)return void A(this,"invalid data","");r=this,this.mainBuffer=a;const i=e._malloc(a.byteLength);e.HEAPU8.set(new Uint8Array(a),i),this.nativeptr=t.LoadEffect(this.context.nativeptr,i,a.byteLength,this.scale),e._free(i),r=null,this._update()}_reload(){if(!this.mainBuffer||!this.nativeptr)return;r=this;const n=e._malloc(this.mainBuffer.byteLength);e.HEAPU8.set(new Uint8Array(this.mainBuffer),n),t.ReloadResources(this.context.nativeptr,this.nativeptr,n,this.mainBuffer.byteLength),e._free(n),r=null}_update(){let e=!1;const t=[];for(let r=0;r<this.resources.length;r++){const n=this.resources[r];if(!n.isLoaded){e=!0;break}n.isRequired&&null==n.buffer&&t.push(n.path)}if(e)return;t.length>0&&console.warn(`[EffekseerWebGPU] missing required resources ignored: ${t.join(", ")}`);const r=0!==this.nativeptr;if(!r){const e=t.length>0?`failed to load effect. missing resources: ${t.join(", ")}`:"failed to load effect";return void A(this,e,this.baseDir||"")}r&&this.resources.length>0&&this._reload(),!this.isLoaded&&r&&(this.isLoaded=!0,(e=>{if(!e)return;const t=e._onloadListeners.slice();e._onloadListeners.length=0,e._onerrorListeners.length=0;for(let e=0;e<t.length;e++){const r=t[e];M(()=>r())}})(this))}}const W=(t,r,n,a,i,s,o,f=null)=>{const l=f||new H(t);l.scale=a,l._ownedResourceAliases=[],L(l,i,s);const u=k(r);if(0===u.size)return A(l,"invalid data. expected efkwgpk package",n||""),l;const c=(()=>{if("string"!=typeof n||0===n.length)return"";const e=S(n),t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):""})(),m=c.toLowerCase(),g=`efwgpk://${++h}/`,b=new Map;return l.baseDir=c,l.syncResourceLoad=!0,l.packageOnly=!0,l.redirect=e=>{const t=S(e),r=[];m&&t.toLowerCase().startsWith(m)&&r.push(t.slice(c.length)),r.push(t);for(let e=0;e<r.length;e++){const t=d(r[e]);if(!t)continue;const n=b.get(t);if(n)return n}return e},(async()=>{try{const t=await(async(e,t)=>{const r=await C(e,t,p);if(r)try{const e=new TextDecoder("utf-8").decode(new Uint8Array(r)).replace(/\0+$/,""),t=d(e);if(t)return t}catch{}for(const[e,r]of t.entries())if(e.endsWith(".efkwg")&&r&&r.length>0)return e;return""})(r,u);if(!t)throw new Error("main effect path not found in efkwgpk package");const a=await C(r,u,t),i=String.fromCharCode(...new Uint8Array(a||new ArrayBuffer(0),0,Math.min(4,a?a.byteLength:0)));if(!a||"EFWG"!==i&&"SKFE"!==i)throw new Error("main effect inside efkwgpk is not a valid .efkwg");const s=new Map,o=new Map;for(const[n]of u.entries()){if(n===t||n===d(p))continue;const a=P(r,u,n);if(!a)continue;const i=T(a);if(!i)continue;let f=s.get(i);if(!f){let t=o.get(i);if(void 0===t&&(t=await C(r,u,n),o.set(i,t||null)),!t)continue;f=`${g}__payload/${s.size}`,e.resourcesMap[f]=t,s.set(i,f)}b.set(n,f)}l._ownedResourceAliases=Array.from(s.values()),l._load(a),l.nativeptr||A(l,"failed to load effect from efkwgpk package",n||t)}catch(e){A(l,e&&e.message?e.message:"failed to load effect from efkwgpk package",n||"")}})(),l};class N{constructor(e,t){this.context=e,this.native=t}stop(){t.StopEffect(this.context.nativeptr,this.native)}stopRoot(){t.StopRoot(this.context.nativeptr,this.native)}get exists(){return!!t.Exists(this.context.nativeptr,this.native)}setFrame(e){t.SetFrame(this.context.nativeptr,this.native,e)}setLocation(e,r,n){t.SetLocation(this.context.nativeptr,this.native,e,r,n)}setRotation(e,r,n){t.SetRotation(this.context.nativeptr,this.native,e,r,n)}setScale(e,r,n){t.SetScale(this.context.nativeptr,this.native,e,r,n)}setAllColor(e,r,n,a){t.SetAllColor(this.context.nativeptr,this.native,e,r,n,a)}setTargetLocation(e,r,n){t.SetTargetLocation(this.context.nativeptr,this.native,e,r,n)}getDynamicInput(e){return t.GetDynamicInput(this.context.nativeptr,this.native,e)}setDynamicInput(e,r){t.SetDynamicInput(this.context.nativeptr,this.native,e,r)}sendTrigger(e){t.SendTrigger(this.context.nativeptr,this.native,e)}setPaused(e){t.SetPaused(this.context.nativeptr,this.native,e?1:0)}setShown(e){t.SetShown(this.context.nativeptr,this.native,e?1:0)}setSpeed(e){t.SetSpeed(this.context.nativeptr,this.native,e)}setRandomSeed(e){t.SetRandomSeed(this.context.nativeptr,this.native,e)}setMatrix(e){O(e,e=>t.SetMatrix(this.context.nativeptr,this.native,e))}}class ${constructor(){this.nativeptr=0,this._effectCache=new Map,this._registeredEffects=new Map,this._registeredEffectStates=new Map,this.fixedUpdateStepFrames=1,this.fixedUpdateMaxSubsteps=4,this.fixedUpdateAccumulator=0,this.externalRenderPassEnabled=!1}_normalizeManagedEffectDescriptor(e,t){const r=String(e||"").trim();if(!r)throw new Error("registerEffects() requires non-empty effect ids.");let n=null;if("string"==typeof t)n={path:t};else{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(`registerEffects() entry "${r}" must be a string path or config object.`);n=t}const a=String(n.path||"").trim();if(!a)throw new Error(`registerEffects() entry "${r}" requires a non-empty path.`);const i=Number(n.scale);return{id:r,path:a,scale:Number.isFinite(i)?i:1,enabled:!1!==n.enabled}}_createManagedEffectState(e){return{id:e.id,path:e.path,scale:e.scale,enabled:e.enabled,status:"unloaded",effect:null,errorMessage:"",errorPath:"",loadPromise:null,activeHandles:new Set,ownedResourceAliases:[],_generation:0,_loadingEffect:null}}_resolveManagedEffectIds(e,t=!1){if(null==e){const e=[];for(const[r,n]of this._registeredEffectStates.entries())t&&!n.enabled||e.push(r);return e}const r=Array.isArray(e)?e:[e],n=[],a=new Set;for(let e=0;e<r.length;e++){const t=String(r[e]||"").trim();t&&!a.has(t)&&(a.add(t),n.push(t))}return n}_registerManagedEffectReference(e,t){e&&(e._managedRefIds instanceof Set||(e._managedRefIds=new Set),e._managedRefIds.add(t))}_releaseManagedEffectReference(e,t){e&&e._managedRefIds instanceof Set&&e._managedRefIds.delete(t)}_releaseManagedEffectIfUnused(r){if(!r)return;const n=r._managedRefIds instanceof Set?r._managedRefIds:null;n&&n.size>0||(I(r),(t=>{if(t&&e.resourcesMap)for(let r=0;r<t.length;r++){const n=t[r];"string"==typeof n&&0!==n.length&&delete e.resourcesMap[n]}})(r._ownedResourceAliases),r._ownedResourceAliases=[],this.nativeptr&&r.nativeptr&&(t.ReleaseEffect(this.nativeptr,r.nativeptr),r.nativeptr=0))}_stopManagedHandles(e){if(e){for(const t of e.activeHandles)try{t?.stopRoot?.()}catch{}e.activeHandles.clear()}}_cleanupManagedHandles(){for(const e of this._registeredEffectStates.values())if(e&&0!==e.activeHandles.size)for(const t of Array.from(e.activeHandles))t&&!1!==t.exists||e.activeHandles.delete(t)}_resetManagedEffectStateToUnloaded(e){e&&(e.effect=null,e.status="unloaded",e.errorMessage="",e.errorPath="",e.loadPromise=null,e.ownedResourceAliases=[],e._loadingEffect=null)}_loadRegisteredEffectState(e){if(!e||!this.nativeptr)return Promise.resolve(null);const t=this._registeredEffects.get(e.id);if(!t)return Promise.resolve(null);const r=e._generation+1;e._generation=r,e.status="loading",e.errorMessage="",e.errorPath="",e.effect=null,e.ownedResourceAliases=[],e._loadingEffect=null;const n=new Promise(n=>{let a=!1,i=null;const s=i=>{if(a)return;a=!0;return this._registeredEffectStates.get(e.id)!==e||e._generation!==r?(this._releaseManagedEffectIfUnused(i),void n(null)):(e._loadingEffect=null,e.loadPromise=null,i&&i.isLoaded?(e.effect=i,e.status="loaded",e.errorMessage="",e.errorPath="",e.ownedResourceAliases=Array.isArray(i._ownedResourceAliases)?i._ownedResourceAliases.slice():[],void n(i)):(e.status="failed",e.errorMessage="failed to load effect",e.errorPath=t.path,void n(null)))},o=(s,o="")=>{if(a)return;a=!0,i&&this._releaseManagedEffectReference(i,e.id);if(this._registeredEffectStates.get(e.id)!==e||e._generation!==r)return i&&this._releaseManagedEffectIfUnused(i),void n(null);e._loadingEffect=null,e.loadPromise=null,e.effect=null,e.status="failed",e.errorMessage=String(s||"failed to load effect"),e.errorPath=String(o||t.path||""),e.ownedResourceAliases=[],i&&this._releaseManagedEffectIfUnused(i),n(null)};try{i=this.loadEffect(t.path,t.scale,()=>s(i),(e,t)=>o(e,t))}catch(e){return void o(e&&e.message?e.message:"failed to load effect",t.path)}e._loadingEffect=i,i?(this._registerManagedEffectReference(i,e.id),i.isLoaded?s(i):i._loadFailed&&o(i._loadErrorMessage,i._loadErrorPath)):o("failed to create effect",t.path)});return e.loadPromise=n,n}_prepareInitSettings(e={},t=!1){const r=e.instanceMaxCount||4e3,n=e.squareMaxCount||1e4,a=!1!==e.linearColorSpace?1:0,i=e.compositeWithBackground?1:0;return this.externalRenderPassEnabled=t,this.fixedUpdateAccumulator=0,{instanceMaxCount:r,squareMaxCount:n,linearColorSpace:a,compositeWithBackground:i}}_finishContextInit(e={}){return this.nativeptr&&e.effects&&(this.registerEffects(e.effects),this.preloadEffects()),!!this.nativeptr}init(e,r={}){if(!0===r.externalRenderPass)return this.initExternal(r);let n="#canvas";"string"==typeof e?n=e.startsWith("#")?e:`#${e}`:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.id||(f+=1,e.id=`effekseer_webgpu_canvas_${f}`),n=`#${e.id}`);const a=this._prepareInitSettings(r,!1);return this.nativeptr=t.InitInternal(a.instanceMaxCount,a.squareMaxCount,n,a.linearColorSpace,a.compositeWithBackground),this._finishContextInit(r)}initExternal(e={}){const r=this._prepareInitSettings(e,!0);return this.nativeptr=t.InitExternal(r.instanceMaxCount,r.squareMaxCount,r.linearColorSpace,r.compositeWithBackground),this._finishContextInit(e)}update(e=1){const r=Number(e);if(!Number.isFinite(r)||r<=0)return void this._cleanupManagedHandles();this.fixedUpdateAccumulator+=r;let n=0;for(;this.fixedUpdateAccumulator>=this.fixedUpdateStepFrames&&n<this.fixedUpdateMaxSubsteps;)t.Update(this.nativeptr,this.fixedUpdateStepFrames),this.fixedUpdateAccumulator-=this.fixedUpdateStepFrames,n++;n>=this.fixedUpdateMaxSubsteps&&this.fixedUpdateAccumulator>=this.fixedUpdateStepFrames&&(this.fixedUpdateAccumulator=0),this._cleanupManagedHandles()}beginUpdate(){t.BeginUpdate(this.nativeptr)}endUpdate(){t.EndUpdate(this.nativeptr)}updateHandle(e,r=1){t.UpdateHandle(this.nativeptr,e.native,r)}draw(){this.externalRenderPassEnabled||t.Draw(this.nativeptr)}drawExternal(r,n=null,a="all"){if(!r)return;const i=V(n&&n.colorFormat),s=(()=>{const e=V(n&&n.depthFormat);return null===e?0:e})(),o=(e=>{const t=Number(e);return!Number.isFinite(t)||t<=0?1:Math.max(1,Math.floor(t))})(n&&n.sampleCount),f=(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),l=f(n,"depthTextureView")||f(n,"importDepthTextureView"),u=f(n,"backgroundTextureView")||f(n,"importBackgroundTextureView"),d=l?f(n,"depthTextureView")?n.depthTextureView:n.importDepthTextureView:null,c=u?f(n,"backgroundTextureView")?n.backgroundTextureView:n.importBackgroundTextureView:null,p=l?e.__effekseerDepthTextureView:null,m=u?e.__effekseerBackgroundTextureView:null;e.__effekseerExternalRenderPass=r,e.__effekseerExternalPassColorFormat=i,e.__effekseerExternalPassDepthFormat=s,e.__effekseerExternalPassSampleCount=o,l&&(e.__effekseerDepthTextureView=d||null),u&&(e.__effekseerBackgroundTextureView=c||null);const h="back"===a?"back":"front"===a?"front":"all";try{"back"===h?t.DrawExternalBack(this.nativeptr):"front"===h?t.DrawExternalFront(this.nativeptr):t.DrawExternal(this.nativeptr)}finally{l&&(e.__effekseerDepthTextureView=p||null),u&&(e.__effekseerBackgroundTextureView=m||null),e.__effekseerExternalRenderPass=null,e.__effekseerExternalPassColorFormat=null,e.__effekseerExternalPassDepthFormat=null,e.__effekseerExternalPassSampleCount=null}}beginDraw(){t.BeginDraw(this.nativeptr)}endDraw(){t.EndDraw(this.nativeptr)}drawHandle(e){t.DrawHandle(this.nativeptr,e.native)}setProjectionMatrix(e){O(e,e=>t.SetProjectionMatrix(this.nativeptr,e))}setProjectionPerspective(e,r,n,a){t.SetProjectionPerspective(this.nativeptr,e,r,n,a)}setProjectionOrthographic(e,r,n,a){t.SetProjectionOrthographic(this.nativeptr,e,r,n,a)}setCameraMatrix(e){O(e,e=>t.SetCameraMatrix(this.nativeptr,e))}setCameraLookAt(e,r,n,a,i,s,o,f,l){t.SetCameraLookAt(this.nativeptr,e,r,n,a,i,s,o,f,l)}setCameraLookAtFromVector(e,t,r={x:0,y:1,z:0}){this.setCameraLookAt(e.x,e.y,e.z,t.x,t.y,t.z,r.x,r.y,r.z)}setCompositeMode(e){t.SetCompositeMode(this.nativeptr,e?1:0)}loadEffect(e,t=1,r,n,a){const i="function"==typeof t?1:t,s="function"==typeof t?t:r,o="function"==typeof t?r:n,f=a;let l=null;if("string"==typeof e&&null==f){l=D(e,i);const t=this._effectCache.get(l);if(t)return L(t,s,o),t}const d=new H(this);d.scale=i,d.redirect=f,d._cacheKey=l||"",L(d,s,o),l&&this._effectCache.set(l,d);const p=(e,t="")=>(A(d,e,t),d);if("string"==typeof e)return"string"==typeof(m=e)&&0!==m.length&&m.replace(/\\/g,"/").split("?")[0].split("#")[0].toLowerCase().endsWith(".efkwg")?(R(e,t=>{const r=u(t);if(!r)return void p("failed to fetch efkwg effect",e);const n=e.replace(/\\/g,"/").split("?")[0].split("#")[0],a=n.lastIndexOf("/");d.baseDir=a>=0?n.slice(0,a+1):"",d.syncResourceLoad=!1,d._load(r),d.nativeptr||p("failed to load efkwg effect",e)},()=>{p("failed to fetch efkwg effect",e)}),d):(e=>"string"==typeof e&&0!==e.length&&S(e).toLowerCase().endsWith(".efkwgpk"))(e)?(R(e,t=>{const r=u(t);r?W(this,r,e,i,null,null,0,d):p("failed to fetch efkwgpk package",e)},()=>{p("failed to fetch efkwgpk package",e)}),d):p("unsupported effect format. expected .efkwg or .efkwgpk",e);var m;const h=u(e);if(!h)return p("invalid data. expected efkwg or efkwgpk bytes","");if(v(h)===c)return W(this,h,"",i,null,null,0,d);const g=String.fromCharCode(...new Uint8Array(h,0,Math.min(4,h.byteLength)));return"EFWG"===g||"SKFE"===g?(d._load(h),d.nativeptr?d:p("failed to load efkwg effect","")):p("invalid data. expected efkwg or efkwgpk bytes","")}loadEffectPackage(e,t,r=1,n,a){let i=r,s=n,o=a;return"function"==typeof r&&(i=1,s=r,o=n),this.loadEffect(e,i,s,o)}registerEffects(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("registerEffects() expects an object map of effect ids to paths/configs.");const t=[];for(const[r,n]of Object.entries(e)){if(this._registeredEffects.has(r))throw new Error(`registerEffects() duplicate id "${r}".`);t.push(this._normalizeManagedEffectDescriptor(r,n))}for(let e=0;e<t.length;e++){const r=t[e];if(this._registeredEffects.has(r.id))throw new Error(`registerEffects() duplicate id "${r.id}".`)}for(let e=0;e<t.length;e++){const r=t[e];this._registeredEffects.set(r.id,r),this._registeredEffectStates.set(r.id,this._createManagedEffectState(r))}if(this.nativeptr)for(let e=0;e<t.length;e++){const r=t[e];r.enabled&&this.preloadEffects([r.id])}}preloadEffects(e){const t=this._resolveManagedEffectIds(e,null==e);return Promise.all(t.map(async e=>{const t=this._registeredEffectStates.get(e);return t?"loaded"===t.status&&t.effect?.isLoaded?[e,t.effect]:"loading"===t.status&&t.loadPromise?[e,await t.loadPromise]:[e,await this._loadRegisteredEffectState(t)]:[e,null]})).then(e=>new Map(e))}reloadEffects(e){const t=this._resolveManagedEffectIds(e,null==e);return this.unloadEffects(t),this.preloadEffects(t)}unloadEffects(e){const t=this._resolveManagedEffectIds(e);for(let e=0;e<t.length;e++){const r=t[e],n=this._registeredEffectStates.get(r);if(!n)continue;n._generation+=1,this._stopManagedHandles(n);const a=n._loadingEffect;a&&(this._releaseManagedEffectReference(a,r),this._releaseManagedEffectIfUnused(a));const i=n.effect;i&&(this._releaseManagedEffectReference(i,r),this._releaseManagedEffectIfUnused(i)),this._resetManagedEffectStateToUnloaded(n)}}unregisterEffects(e){const t=this._resolveManagedEffectIds(e);this.unloadEffects(t);for(let e=0;e<t.length;e++){const r=t[e];this._registeredEffects.delete(r),this._registeredEffectStates.delete(r)}}getEffect(e){const t=this._registeredEffectStates.get(String(e||""));return"loaded"===t?.status&&t.effect?.isLoaded?t.effect:null}getEffectState(e){return U(this._registeredEffectStates.get(String(e||"")))}getEffectStates(){return Array.from(this._registeredEffectStates.values(),e=>U(e))}whenEffectsReady(e){return this.preloadEffects(e)}playEffect(e,t=0,r=0,n=0){const a=this._registeredEffectStates.get(String(e||""));if(!a||"loaded"!==a.status||!a.effect?.isLoaded)return null;const i=this.play(a.effect,t,r,n);return i&&a.activeHandles.add(i),i}releaseEffect(e){e&&e.nativeptr&&(I(e),t.ReleaseEffect(this.nativeptr,e.nativeptr),e.nativeptr=0)}play(e,r=0,n=0,a=0){if(!e||!e.isLoaded)return null;const i=t.PlayEffect(this.nativeptr,e.nativeptr,r,n,a);return i>=0?new N(this,i):null}stopAll(){t.StopAllEffects(this.nativeptr)}setResourceLoader(e){F=e}getRestInstancesCount(){return t.GetRestInstancesCount(this.nativeptr)}getUpdateTime(){return t.GetUpdateTime(this.nativeptr)}getDrawTime(){return t.GetDrawTime(this.nativeptr)}getDrawFlushComputeTime(){return t.GetDrawFlushComputeTime(this.nativeptr)}getDrawBeginFrameTime(){return t.GetDrawBeginFrameTime(this.nativeptr)}getDrawManagerTime(){return t.GetDrawManagerTime(this.nativeptr)}getDrawEndFrameTime(){return t.GetDrawEndFrameTime(this.nativeptr)}getDrawTotalTime(){return t.GetDrawTotalTime(this.nativeptr)}getGpuTimestampSupported(){return!!t.GetGpuTimestampSupported(this.nativeptr)}getGpuTimestampValid(){return!!t.GetGpuTimestampValid(this.nativeptr)}getGpuTimestampEffekseerPassTime(){return t.GetGpuTimestampEffekseerPassTime(this.nativeptr)}getGpuTimestampFrameTime(){return t.GetGpuTimestampFrameTime(this.nativeptr)}getGpuTimestampReadPending(){return!!t.GetGpuTimestampReadPending(this.nativeptr)}getGpuTimestampLastMapStatus(){return t.GetGpuTimestampLastMapStatus(this.nativeptr)}getGpuTimestampMapState(){return t.GetGpuTimestampMapState(this.nativeptr)}getGpuTimestampMapMode(){return t.GetGpuTimestampMapMode(this.nativeptr)}getGpuTimestampStallRecoveries(){return t.GetGpuTimestampStallRecoveries(this.nativeptr)}getRendererProfileBindGroupTime(){return t.GetRendererProfileBindGroupTime(this.nativeptr)}getRendererProfileBindGroupCacheFlushCount(){return t.GetRendererProfileBindGroupCacheFlushCount(this.nativeptr)}getRendererProfileBindGroupCacheHits(){return t.GetRendererProfileBindGroupCacheHits(this.nativeptr)}getRendererProfileBindGroupCacheMisses(){return t.GetRendererProfileBindGroupCacheMisses(this.nativeptr)}getRendererProfileBindGroupCreates(){return t.GetRendererProfileBindGroupCreates(this.nativeptr)}getRendererProfilePipelineTime(){return t.GetRendererProfilePipelineTime(this.nativeptr)}getRendererProfileSetStateTime(){return t.GetRendererProfileSetStateTime(this.nativeptr)}getRendererProfileIssueDrawTime(){return t.GetRendererProfileIssueDrawTime(this.nativeptr)}getRendererProfileDrawTotalTime(){return t.GetRendererProfileDrawTotalTime(this.nativeptr)}getRendererProfileDrawSpritesCalls(){return t.GetRendererProfileDrawSpritesCalls(this.nativeptr)}getRendererProfileDrawPolygonCalls(){return t.GetRendererProfileDrawPolygonCalls(this.nativeptr)}getInternalStandardRendererTextureSetupTime(){return t.GetInternalStandardRendererTextureSetupTime(this.nativeptr)}getInternalStandardRendererShaderSelectTime(){return t.GetInternalStandardRendererShaderSelectTime(this.nativeptr)}getInternalStandardRendererVertexPackTime(){return t.GetInternalStandardRendererVertexPackTime(this.nativeptr)}getInternalStandardRendererPixelPackTime(){return t.GetInternalStandardRendererPixelPackTime(this.nativeptr)}getInternalStandardRendererConstantUploadTime(){return t.GetInternalStandardRendererConstantUploadTime(this.nativeptr)}getInternalStandardRendererRenderStateTime(){return t.GetInternalStandardRendererRenderStateTime(this.nativeptr)}getInternalStandardRendererVertexBindTime(){return t.GetInternalStandardRendererVertexBindTime(this.nativeptr)}getInternalStandardRendererIndexBindTime(){return t.GetInternalStandardRendererIndexBindTime(this.nativeptr)}getInternalStandardRendererLayoutTime(){return t.GetInternalStandardRendererLayoutTime(this.nativeptr)}getInternalStandardRendererDrawTime(){return t.GetInternalStandardRendererDrawTime(this.nativeptr)}getManagerProfileFrustumTime(){return t.GetManagerProfileFrustumTime(this.nativeptr)}getManagerProfileSortTime(){return t.GetManagerProfileSortTime(this.nativeptr)}getManagerProfileCanDrawTime(){return t.GetManagerProfileCanDrawTime(this.nativeptr)}getManagerProfileContainerDrawTime(){return t.GetManagerProfileContainerDrawTime(this.nativeptr)}getManagerProfileGpuParticleTime(){return t.GetManagerProfileGpuParticleTime(this.nativeptr)}getManagerProfileDrawSetCount(){return t.GetManagerProfileDrawSetCount(this.nativeptr)}getManagerProfileVisibleDrawSetCount(){return t.GetManagerProfileVisibleDrawSetCount(this.nativeptr)}getManagerProfileContainersTotal(){return t.GetManagerProfileContainersTotal(this.nativeptr)}getManagerProfileContainersDrawn(){return t.GetManagerProfileContainersDrawn(this.nativeptr)}getManagerProfileContainersDepthCulled(){return t.GetManagerProfileContainersDepthCulled(this.nativeptr)}getDrawCallCount(){return t.GetDrawCallCount(this.nativeptr)}getDrawVertexCount(){return t.GetDrawVertexCount(this.nativeptr)}getTotalParticleCount(){return t.GetTotalParticleCount(this.nativeptr)}isVertexArrayObjectSupported(){return!!t.IsVertexArrayObjectSupported(this.nativeptr)}setRestorationOfStatesFlag(e){t.SetRestorationOfStatesFlag(this.nativeptr,e?1:0)}captureBackground(e,r,n,a){t.CaptureBackground(this.nativeptr,e,r,n,a)}resetBackground(){t.ResetBackground(this.nativeptr)}}return new class{async initRuntime(e,t,r){try{await j(e),t&&t()}catch(e){a=!1,n=!1,l=[],r?r(e):console.error(e)}}createContext(){return n?new $:null}releaseContext(e){e&&e.nativeptr&&(e.unloadEffects?.(),t.Terminate(e.nativeptr),e.nativeptr=0,e._effectCache?.clear?.(),e._registeredEffects?.clear?.(),e._registeredEffectStates?.clear?.())}setLogEnabled(e){n&&t.SetLogEnabled(e?1:0)}setImageCrossOrigin(e){o=e}setWebGPUDevice(e){if(n||a)throw new Error("setWebGPUDevice() must be called before initRuntime().");if(null==e)return s=null,void(i=null);if("object"!=typeof e||"function"!=typeof e.createCommandEncoder||!e.queue)throw new Error("setWebGPUDevice() expects a valid GPUDevice.");s=e,i=e}setRendererWorkingColorSpace(e){return((e=null)=>{const t=e;return!(!t||!t.ColorManagement)&&"workingColorSpace"in t.ColorManagement&&void 0!==t.LinearSRGBColorSpace&&(t.ColorManagement.workingColorSpace=t.LinearSRGBColorSpace,!0)})(e)}getWebGPUDevice(){return i||(e?e.preinitializedWebGPUDevice:null)||null}init(e,t){return this.defaultContext?.nativeptr&&this.releaseContext(this.defaultContext),this.defaultContext=new $,this.defaultContext.init(e,t)}update(e){this.defaultContext.update(e)}beginUpdate(){this.defaultContext.beginUpdate()}endUpdate(){this.defaultContext.endUpdate()}updateHandle(e,t){this.defaultContext.updateHandle(e,t)}draw(){this.defaultContext.draw()}drawExternal(e,t,r="all"){this.defaultContext.drawExternal(e,t,r)}beginDraw(){this.defaultContext.beginDraw()}endDraw(){this.defaultContext.endDraw()}drawHandle(e){this.defaultContext.drawHandle(e)}setProjectionMatrix(e){this.defaultContext.setProjectionMatrix(e)}setProjectionPerspective(e,t,r,n){this.defaultContext.setProjectionPerspective(e,t,r,n)}setProjectionOrthographic(e,t,r,n){this.defaultContext.setProjectionOrthographic(e,t,r,n)}setCameraMatrix(e){this.defaultContext.setCameraMatrix(e)}setCameraLookAt(e,t,r,n,a,i,s,o,f){this.defaultContext.setCameraLookAt(e,t,r,n,a,i,s,o,f)}setCameraLookAtFromVector(e,t,r){this.defaultContext.setCameraLookAtFromVector(e,t,r)}setCompositeMode(e){this.defaultContext.setCompositeMode(e)}loadEffect(e,t,r,n,a){return this.defaultContext.loadEffect(e,t,r,n,a)}loadEffectPackage(e,t,r,n,a){return this.defaultContext.loadEffectPackage(e,t,r,n,a)}registerEffects(e){this.defaultContext.registerEffects(e)}preloadEffects(e){return this.defaultContext.preloadEffects(e)}reloadEffects(e){return this.defaultContext.reloadEffects(e)}unloadEffects(e){this.defaultContext.unloadEffects(e)}unregisterEffects(e){this.defaultContext.unregisterEffects(e)}getEffect(e){return this.defaultContext.getEffect(e)}getEffectState(e){return this.defaultContext.getEffectState(e)}getEffectStates(){return this.defaultContext.getEffectStates()}whenEffectsReady(e){return this.defaultContext.whenEffectsReady(e)}playEffect(e,t,r,n){return this.defaultContext.playEffect(e,t,r,n)}releaseEffect(e){this.defaultContext.releaseEffect(e)}play(e,t,r,n){return this.defaultContext.play(e,t,r,n)}stopAll(){this.defaultContext.stopAll()}setResourceLoader(e){this.defaultContext.setResourceLoader(e)}getRestInstancesCount(){return this.defaultContext.getRestInstancesCount()}getUpdateTime(){return this.defaultContext.getUpdateTime()}getDrawTime(){return this.defaultContext.getDrawTime()}isVertexArrayObjectSupported(){return this.defaultContext.isVertexArrayObjectSupported()}}})();"undefined"!=typeof globalThis&&(globalThis.effekseer=effekseer),"undefined"!=typeof exports&&(exports=effekseer);
|
|
1
|
+
const e=(()=>{let e={},t={},r=null,n=!1,a=!1,s=null,i=null,o="",f=0,c=[];const l=e=>e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):null,u=e=>{if("string"!=typeof e||0===e.length)return"";const t=e.replace(/\\/g,"/").split("/"),r=[];for(let e=0;e<t.length;e++){const n=t[e];n&&"."!==n&&(".."!==n?r.push(n):r.length>0&&r.pop())}let n=r.join("/");for(;n.startsWith("/");)n=n.slice(1);return n.replace(/[A-Z]/g,e=>e.toLowerCase())},d="EFWGPKG2",p="__efwgpk__/main_effect_path.txt",h=new Uint8Array([69,102,107,87,103,46,87,101,98,71,80,85,46,67,84,82]);let g=0,m=null;const b=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let e=0;e<8;e++)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r>>>0}return e})(),w=e=>{if(!(e instanceof Uint8Array))return 0;let t=4294967295;for(let r=0;r<e.length;r++){const n=255&(t^e[r]);t=t>>>8^b[n]}return~t>>>0},E=async(e,t)=>{const r=await(async()=>{if(m)return m;if(!globalThis.crypto||!globalThis.crypto.subtle||"function"!=typeof globalThis.crypto.subtle.importKey)throw new Error("Web Crypto AES-CTR is required for encrypted efkwgpk payloads");return m=globalThis.crypto.subtle.importKey("raw",h,"AES-CTR",!1,["decrypt"]),m})();return globalThis.crypto.subtle.decrypt({name:"AES-CTR",counter:t,length:128},r,e)},y=e=>String(e||"").replace(/\\/g,"/").split("?")[0].split("#")[0],S=e=>{const t=l(e);if(!t||t.byteLength<8)return"";const r=new Uint8Array(t,0,8);return String.fromCharCode(...r)},v=e=>{const t=new Map,r=e?e.byteLength:0,n=(e=>{const t=e?e.byteLength:0;if(!e||t<64)return null;const r=new DataView(e);if(S(e)!==d)return null;const n=r.getUint32(8,!0),a=r.getUint32(12,!0),s=r.getUint32(16,!0),i=r.getUint32(20,!0),o=r.getUint32(24,!0),f=r.getUint32(28,!0),c=r.getUint32(32,!0),l=r.getUint32(36,!0),u=r.getUint32(40,!0),p=r.getUint32(44,!0),h=r.getUint32(48,!0),g=r.getUint32(52,!0),m=2===s?64:3===s?80:0;if(0===m||n!==m||48!==o)return null;let b=null;if(4&a){if(s<3||t<80)return null;if(b=new Uint8Array(e.slice(56,72)),16!==b.byteLength)return null}return{headerSize:n,globalFlags:a,formatRevision:s,entryCount:i,entryStride:o,entriesOffset:f,stringPoolOffset:c,stringPoolSize:l,payloadOffset:u,payloadSize:p,tocCrc:h,payloadCrc:g,payloadNonce:b,payloadEncrypted:!!(4&a)}})(e);if(!n)return t;const a=new DataView(e),{headerSize:s,entryCount:i,entryStride:o,entriesOffset:f,stringPoolOffset:c,stringPoolSize:l,payloadOffset:p,payloadSize:h,tocCrc:g,payloadCrc:m}=n,b=BigInt(i)*BigInt(o);if(b>BigInt(r))return t;const E=Number(b);if(!P(f,E,r))return t;if(!P(c,l,r))return t;if(!P(p,h,r))return t;const y=c+l,v=p+h,x=new Uint8Array(e,0,s).slice();x.fill(0,48,56);const _=new Uint8Array(s+E+l);if(_.set(x,0),_.set(new Uint8Array(e,f,E),s),_.set(new Uint8Array(e,c,l),s+E),w(_)!==g>>>0)return t;const k=new Uint8Array(e,p,h);if(w(k)!==m>>>0)return t;const C=new TextDecoder("utf-8");for(let n=0;n<i;n++){const s=f+n*o,i=a.getUint32(s+8,!0),l=a.getUint32(s+12,!0),d=a.getUint32(s+16,!0),h=a.getUint32(s+20,!0),g=a.getUint32(s+24,!0),m=a.getUint32(s+28,!0),b=a.getUint32(s+32,!0),w=a.getUint32(s+36,!0);if(!P(i,l,r))continue;if(i<c||i+l>y)continue;if(!P(h,g,r))continue;if(h<p||h+g>v)continue;let E="";try{E=C.decode(new Uint8Array(e,i,l))}catch{continue}const S=u(E);if(!S)continue;const x={index:n,path:E,normalizedPath:S,flags:d,payloadOffset:h,packedSize:g,rawSize:m,packedCrc:b,rawCrc:w},_=t.get(S);_?_.push(x):t.set(S,[x])}return t._efwgpkMeta={payloadOffset:p,payloadSize:h,payloadEncrypted:n.payloadEncrypted,payloadNonce:n.payloadNonce,decryptedPayloadPromise:null},t},x=async e=>{const t=globalThis.fflate;if(t&&"function"==typeof t.unzlibSync){const r=t.unzlibSync(new Uint8Array(e));return l(r)}if("function"!=typeof DecompressionStream)throw new Error("No zlib inflate backend available for efkwgpk payload");const r=new DecompressionStream("deflate"),n=r.writable.getWriter();await n.write(e),await n.close();return await new Response(r.readable).arrayBuffer()},_=async(e,t,r)=>{const n=t&&t._efwgpkMeta?t._efwgpkMeta:null;if(!n||!n.payloadEncrypted)return new Uint8Array(e,r.payloadOffset,r.packedSize);if(!n.decryptedPayloadPromise){const t=new Uint8Array(e,n.payloadOffset,n.payloadSize);n.decryptedPayloadPromise=E(t,n.payloadNonce).then(e=>new Uint8Array(e))}const a=await n.decryptedPayloadPromise,s=r.payloadOffset-n.payloadOffset;return s<0||s+r.packedSize>a.byteLength?null:a.subarray(s,s+r.packedSize)},k=async(e,t,r)=>{const n=u(r);if(!n||!e||!t||0===t.size)return null;const a=t.get(n);if(!a||0===a.length)return null;for(let r=0;r<a.length;r++){const n=a[r];if(!P(n.payloadOffset,n.packedSize,e.byteLength))continue;const s=await _(e,t,n);if(s&&w(s)===n.packedCrc>>>0){if(0===n.flags&&n.packedSize===n.rawSize){const e=s.slice();if(w(e)!==n.rawCrc>>>0)continue;return e.buffer}if(1===n.flags){const e=await x(s);if(!e||e.byteLength!==n.rawSize)continue;if(w(new Uint8Array(e))!==n.rawCrc>>>0)continue;return e}}}return null},C=e=>e&&Number.isFinite(e.payloadOffset)&&Number.isFinite(e.packedSize)&&Number.isFinite(e.rawSize)&&Number.isFinite(e.flags)?`${e.flags}:${e.payloadOffset}:${e.packedSize}:${e.rawSize}`:"",M=(e,t,r)=>{const n=u(r);if(!n||!e||!t||0===t.size)return null;const a=t.get(n);if(!a||0===a.length)return null;for(let t=0;t<a.length;t++){const r=a[t];if(P(r.payloadOffset,r.packedSize,e.byteLength)){if(0===r.flags&&r.packedSize===r.rawSize)return r;if(1===r.flags)return r}}return null},P=(e,t,r)=>!!(Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(r))&&(!(e<0||t<0||r<0)&&(!(e>r)&&t<=r-e)),R=(e,t,r)=>{const n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{const a=0|n.status;a>=200&&a<300||0===a?t(n.response):r&&r("not found",e)},n.onerror=()=>{r&&r("not found",e)},n.send(null)},U=e=>{try{const t=new XMLHttpRequest;t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null);const r=0|t.status;if(r>=200&&r<300||0===r)return t.response}catch{}return null},A=e=>{"function"==typeof e&&("function"==typeof queueMicrotask?queueMicrotask(e):Promise.resolve().then(e))},L=(e,t)=>{const r=String(e||"").replace(/\\/g,"/");const n=Number(t);return`${r}::${Number.isFinite(n)?n:1}`},D=e=>{e&&e.context&&e._cacheKey&&e.context._effectCache&&e.context._effectCache.get(e._cacheKey)===e&&e.context._effectCache.delete(e._cacheKey)},I=e=>e?{id:e.id,path:e.path,scale:e.scale,enabled:e.enabled,status:e.status,effect:"loaded"===e.status?e.effect:null,errorMessage:e.errorMessage,errorPath:e.errorPath,loadPromise:e.loadPromise,activeHandles:new Set(e.activeHandles),ownedResourceAliases:e.ownedResourceAliases.slice()}:null,F=(e,t,r)=>{if(e&&("function"==typeof t&&(e.isLoaded?A(()=>t()):e._loadFailed||e._onloadListeners.push(t)),"function"==typeof r))if(e._loadFailed){const t=e._loadErrorMessage||"failed to load effect",n=e._loadErrorPath||"";A(()=>r(t,n))}else e.isLoaded||e._onerrorListeners.push(r)},T=(e,t,r="")=>{if(!e||e._loadFailed)return;e._loadFailed=!0,e._loadErrorMessage=String(t||"failed to load effect"),e._loadErrorPath=String(r||""),D(e);const n=e._onerrorListeners.slice();e._onloadListeners.length=0,e._onerrorListeners.length=0;for(let t=0;t<n.length;t++){const r=n[t];A(()=>r(e._loadErrorMessage,e._loadErrorPath))}};let O=(e,t,r)=>{R(e,t,r)};const z={ptr:0,capacity:0},B=(t,r)=>{const n=t instanceof Float32Array?t:new Float32Array(t);if(n.length<=0)return void r(0);const a=((s=n.length)<=z.capacity&&0!==z.ptr||(0!==z.ptr&&(e._free(z.ptr),z.ptr=0,z.capacity=0),z.ptr=e._malloc(4*s),z.capacity=s),z.ptr);var s;e.HEAPF32.set(n,a>>2),r(a)},j=Object.freeze({rgba8unorm:22,"rgba8unorm-srgb":23,bgra8unorm:27,"bgra8unorm-srgb":28,rgba16float:40,depth24plus:46,"depth24plus-stencil8":47,depth32float:48}),W=(Object.freeze(Object.fromEntries(Object.entries(j).map(([e,t])=>[t,e]))),e=>{if("number"==typeof e&&Number.isFinite(e))return 0|e;if("string"!=typeof e)return null;const t=e.trim().toLowerCase();return t&&Object.prototype.hasOwnProperty.call(j,t)?j[t]:null}),H=async i=>{if(n)return;if(a)return void await new Promise((e,t)=>{c.push(r=>r?e():t(new Error("Runtime initialization failed.")))});if(a=!0,"undefined"==typeof effekseer_webgpu_native)throw a=!1,new Error("effekseer_webgpu_native is not loaded.");const o={};"string"==typeof i&&i.length>0&&(o.locateFile=e=>e.endsWith(".wasm")?i:e),s&&(o.preinitializedWebGPUDevice=s);const f=effekseer_webgpu_native(o);e=f instanceof Promise?await f:f,!s&&e?.preinitializedWebGPUDevice&&(s=e.preinitializedWebGPUDevice),s&&(e.preinitializedWebGPUDevice=s),(()=>{t={InitInternal:e.cwrap("EffekseerInitInternal","number",["number","number","string","number","number"]),InitExternal:e.cwrap("EffekseerInitExternal","number",["number","number","number","number"]),Init:e.cwrap("EffekseerInit","number",["number","number","string","number","number","number"]),Terminate:e.cwrap("EffekseerTerminate","void",["number"]),Update:e.cwrap("EffekseerUpdate","void",["number","number"]),BeginUpdate:e.cwrap("EffekseerBeginUpdate","void",["number"]),EndUpdate:e.cwrap("EffekseerEndUpdate","void",["number"]),UpdateHandle:e.cwrap("EffekseerUpdateHandle","void",["number","number","number"]),Draw:e.cwrap("EffekseerDraw","void",["number"]),DrawExternal:e.cwrap("EffekseerDrawExternal","void",["number"]),BeginDraw:e.cwrap("EffekseerBeginDraw","void",["number"]),EndDraw:e.cwrap("EffekseerEndDraw","void",["number"]),DrawHandle:e.cwrap("EffekseerDrawHandle","void",["number","number"]),SetProjectionMatrix:e.cwrap("EffekseerSetProjectionMatrix","void",["number","number"]),SetProjectionPerspective:e.cwrap("EffekseerSetProjectionPerspective","void",["number","number","number","number","number"]),SetProjectionOrthographic:e.cwrap("EffekseerSetProjectionOrthographic","void",["number","number","number","number","number"]),SetCameraMatrix:e.cwrap("EffekseerSetCameraMatrix","void",["number","number"]),SetCameraLookAt:e.cwrap("EffekseerSetCameraLookAt","void",["number","number","number","number","number","number","number","number","number","number"]),LoadEffect:e.cwrap("EffekseerLoadEffect","number",["number","number","number","number"]),ReleaseEffect:e.cwrap("EffekseerReleaseEffect","void",["number","number"]),ReloadResources:e.cwrap("EffekseerReloadResources","void",["number","number","number","number"]),StopAllEffects:e.cwrap("EffekseerStopAllEffects","void",["number"]),PlayEffect:e.cwrap("EffekseerPlayEffect","number",["number","number","number","number","number"]),StopEffect:e.cwrap("EffekseerStopEffect","void",["number","number"]),StopRoot:e.cwrap("EffekseerStopRoot","void",["number","number"]),Exists:e.cwrap("EffekseerExists","number",["number","number"]),SetFrame:e.cwrap("EffekseerSetFrame","void",["number","number","number"]),SetLocation:e.cwrap("EffekseerSetLocation","void",["number","number","number","number","number"]),SetRotation:e.cwrap("EffekseerSetRotation","void",["number","number","number","number","number"]),SetScale:e.cwrap("EffekseerSetScale","void",["number","number","number","number","number"]),SetMatrix:e.cwrap("EffekseerSetMatrix","void",["number","number","number"]),SetAllColor:e.cwrap("EffekseerSetAllColor","void",["number","number","number","number","number","number"]),SetTargetLocation:e.cwrap("EffekseerSetTargetLocation","void",["number","number","number","number","number"]),GetDynamicInput:e.cwrap("EffekseerGetDynamicInput","number",["number","number","number"]),SetDynamicInput:e.cwrap("EffekseerSetDynamicInput","void",["number","number","number","number"]),SendTrigger:e.cwrap("EffekseerSendTrigger","void",["number","number","number"]),SetPaused:e.cwrap("EffekseerSetPaused","void",["number","number","number"]),SetShown:e.cwrap("EffekseerSetShown","void",["number","number","number"]),SetSpeed:e.cwrap("EffekseerSetSpeed","void",["number","number","number"]),SetRandomSeed:e.cwrap("EffekseerSetRandomSeed","void",["number","number","number"]),SetCompositeMode:e.cwrap("EffekseerSetCompositeMode","void",["number","number"]),GetRestInstancesCount:e.cwrap("EffekseerGetRestInstancesCount","number",["number"]),DrawExternalBack:e.cwrap("EffekseerDrawExternalBack","void",["number"]),DrawExternalFront:e.cwrap("EffekseerDrawExternalFront","void",["number"]),IsVertexArrayObjectSupported:e.cwrap("EffekseerIsVertexArrayObjectSupported","number",["number"]),SetRestorationOfStatesFlag:e.cwrap("EffekseerSetRestorationOfStatesFlag","void",["number","number"]),CaptureBackground:e.cwrap("EffekseerCaptureBackground","void",["number","number","number","number","number"]),ResetBackground:e.cwrap("EffekseerResetBackground","void",["number"]),SetDepthTexture:e.cwrap("EffekseerSetDepthTexture","void",["number","number"]),SetBackgroundTexture:e.cwrap("EffekseerSetBackgroundTexture","void",["number","number"])},e.resourcesMap={},e._loadBinary=(t,n)=>{const a=r;if(!a)return null;let s=a.resources.find(e=>e.path===t);if(s)return s.isLoaded?s.buffer:null;s={path:t,isLoaded:!1,buffer:null,isRequired:!!n},a.resources.push(s);const i=e=>String(e||"").replace(/\\/g,"/"),o=e=>{const t=i(e);let r=t.startsWith("/")||/^[a-zA-Z]+:\/\//.test(t)?t:(a.baseDir||"")+t;return a.redirect&&(r=a.redirect(r)),r},f=(e=>{const t=i(e),r=[],n=new Set,a=e=>{e&&!n.has(e)&&(n.add(e),r.push(e))},s=e=>{if(!e||e.includes("/"))return;const t=e.toLowerCase();(t.endsWith(".png")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".dds"))&&a(`Texture/${e}`),(t.endsWith(".efkmodel")||t.endsWith(".mqo"))&&a(`Model/${e}`)},o=t.indexOf("/");if(o>0){const e=t.slice(0,o).toLowerCase();(e.endsWith(".efk")||e.endsWith(".efkefc")||e.endsWith(".efkproj"))&&a(t.slice(o+1))}a(t),s(t);let f=t.indexOf("/");for(;f>=0;){const e=t.slice(f+1);a(e),s(e),f=t.indexOf("/",f+1)}return r})(t);if(a.syncResourceLoad){for(let r=0;r<f.length;r++){const n=f[r],a=o(n),i=e.resourcesMap[a]||e.resourcesMap[n]||e.resourcesMap[t];if(null!=i)return s.buffer=i,s.isLoaded=!0,i;const c=U(a);if(null!=c)return s.buffer=c,s.isLoaded=!0,e.resourcesMap[a]=c,e.resourcesMap[n]=c,c}return s.buffer=null,s.isLoaded=!0,null}for(let r=0;r<f.length;r++){const n=f[r],i=o(n),c=e.resourcesMap[i]||e.resourcesMap[n]||e.resourcesMap[t];if(null!=c)return s.buffer=c,s.isLoaded=!0,Promise.resolve().then(()=>a._update()),null}let c=0;const l=()=>{if(c>=f.length)return s.buffer=null,s.isLoaded=!0,void a._update();const e=f[c++],t=o(e);O(t,e=>{if(null!=e)return s.buffer=e,s.isLoaded=!0,void a._update();l()},()=>{l()})};return l(),null},n=!0,a=!1;const s=c;c=[],s.forEach(e=>e(!0))})()};class V{constructor(e){this.context=e,this.nativeptr=0,this.baseDir="",this.syncResourceLoad=!1,this.isLoaded=!1,this.scale=1,this.resources=[],this.mainBuffer=null,this.onload=null,this.onerror=null,this._onloadListeners=[],this._onerrorListeners=[],this._loadFailed=!1,this._loadErrorMessage="",this._loadErrorPath="",this._cacheKey="",this.redirect=null,this.packageOnly=!1,this._ownedResourceAliases=[],this._managedRefIds=new Set}_load(n){const a=l(n);if(!a)return void T(this,"invalid data","");r=this,this.mainBuffer=a;const s=e._malloc(a.byteLength);e.HEAPU8.set(new Uint8Array(a),s),this.nativeptr=t.LoadEffect(this.context.nativeptr,s,a.byteLength,this.scale),e._free(s),r=null,this._update()}_reload(){if(!this.mainBuffer||!this.nativeptr)return;r=this;const n=e._malloc(this.mainBuffer.byteLength);e.HEAPU8.set(new Uint8Array(this.mainBuffer),n),t.ReloadResources(this.context.nativeptr,this.nativeptr,n,this.mainBuffer.byteLength),e._free(n),r=null}_update(){let e=!1;const t=[];for(let r=0;r<this.resources.length;r++){const n=this.resources[r];if(!n.isLoaded){e=!0;break}n.isRequired&&null==n.buffer&&t.push(n.path)}if(e)return;t.length>0&&console.warn(`[EffekseerWebGPU] missing required resources ignored: ${t.join(", ")}`);const r=0!==this.nativeptr;if(!r){const e=t.length>0?`failed to load effect. missing resources: ${t.join(", ")}`:"failed to load effect";return void T(this,e,this.baseDir||"")}r&&this.resources.length>0&&this._reload(),!this.isLoaded&&r&&(this.isLoaded=!0,(e=>{if(!e)return;const t=e._onloadListeners.slice();e._onloadListeners.length=0,e._onerrorListeners.length=0;for(let e=0;e<t.length;e++){const r=t[e];A(()=>r())}})(this))}}const G=(t,r,n,a,s,i,o,f=null)=>{const c=f||new V(t);c.scale=a,c._ownedResourceAliases=[],F(c,s,i);const l=v(r);if(0===l.size)return T(c,"invalid data. expected efkwgpk package",n||""),c;const d=(()=>{if("string"!=typeof n||0===n.length)return"";const e=y(n),t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):""})(),h=d.toLowerCase(),m=`efwgpk://${++g}/`,b=new Map;return c.baseDir=d,c.syncResourceLoad=!0,c.packageOnly=!0,c.redirect=e=>{const t=y(e),r=[];h&&t.toLowerCase().startsWith(h)&&r.push(t.slice(d.length)),r.push(t);for(let e=0;e<r.length;e++){const t=u(r[e]);if(!t)continue;const n=b.get(t);if(n)return n}return e},(async()=>{try{const t=await(async(e,t)=>{const r=await k(e,t,p);if(r)try{const e=new TextDecoder("utf-8").decode(new Uint8Array(r)).replace(/\0+$/,""),t=u(e);if(t)return t}catch{}for(const[e,r]of t.entries())if(e.endsWith(".efkwg")&&r&&r.length>0)return e;return""})(r,l);if(!t)throw new Error("main effect path not found in efkwgpk package");const a=await k(r,l,t),s=String.fromCharCode(...new Uint8Array(a||new ArrayBuffer(0),0,Math.min(4,a?a.byteLength:0)));if(!a||"EFWG"!==s&&"SKFE"!==s)throw new Error("main effect inside efkwgpk is not a valid .efkwg");const i=new Map,o=new Map;for(const[n]of l.entries()){if(n===t||n===u(p))continue;const a=M(r,l,n);if(!a)continue;const s=C(a);if(!s)continue;let f=i.get(s);if(!f){let t=o.get(s);if(void 0===t&&(t=await k(r,l,n),o.set(s,t||null)),!t)continue;f=`${m}__payload/${i.size}`,e.resourcesMap[f]=t,i.set(s,f)}b.set(n,f)}c._ownedResourceAliases=Array.from(i.values()),c._load(a),c.nativeptr||T(c,"failed to load effect from efkwgpk package",n||t)}catch(e){T(c,e&&e.message?e.message:"failed to load effect from efkwgpk package",n||"")}})(),c};class N{constructor(e,t){this.context=e,this.native=t}stop(){t.StopEffect(this.context.nativeptr,this.native)}stopRoot(){t.StopRoot(this.context.nativeptr,this.native)}get exists(){return!!t.Exists(this.context.nativeptr,this.native)}setFrame(e){t.SetFrame(this.context.nativeptr,this.native,e)}setLocation(e,r,n){t.SetLocation(this.context.nativeptr,this.native,e,r,n)}setRotation(e,r,n){t.SetRotation(this.context.nativeptr,this.native,e,r,n)}setScale(e,r,n){t.SetScale(this.context.nativeptr,this.native,e,r,n)}setAllColor(e,r,n,a){t.SetAllColor(this.context.nativeptr,this.native,e,r,n,a)}setTargetLocation(e,r,n){t.SetTargetLocation(this.context.nativeptr,this.native,e,r,n)}getDynamicInput(e){return t.GetDynamicInput(this.context.nativeptr,this.native,e)}setDynamicInput(e,r){t.SetDynamicInput(this.context.nativeptr,this.native,e,r)}sendTrigger(e){t.SendTrigger(this.context.nativeptr,this.native,e)}setPaused(e){t.SetPaused(this.context.nativeptr,this.native,e?1:0)}setShown(e){t.SetShown(this.context.nativeptr,this.native,e?1:0)}setSpeed(e){t.SetSpeed(this.context.nativeptr,this.native,e)}setRandomSeed(e){t.SetRandomSeed(this.context.nativeptr,this.native,e)}setMatrix(e){B(e,e=>t.SetMatrix(this.context.nativeptr,this.native,e))}}class ${constructor(){this.nativeptr=0,this._effectCache=new Map,this._registeredEffects=new Map,this._registeredEffectStates=new Map,this.fixedUpdateStepFrames=1,this.fixedUpdateMaxSubsteps=4,this.fixedUpdateAccumulator=0,this.externalRenderPassEnabled=!1}_normalizeManagedEffectDescriptor(e,t){const r=String(e||"").trim();if(!r)throw new Error("registerEffects() requires non-empty effect ids.");let n=null;if("string"==typeof t)n={path:t};else{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(`registerEffects() entry "${r}" must be a string path or config object.`);n=t}const a=String(n.path||"").trim();if(!a)throw new Error(`registerEffects() entry "${r}" requires a non-empty path.`);const s=Number(n.scale);return{id:r,path:a,scale:Number.isFinite(s)?s:1,enabled:!1!==n.enabled}}_createManagedEffectState(e){return{id:e.id,path:e.path,scale:e.scale,enabled:e.enabled,status:"unloaded",effect:null,errorMessage:"",errorPath:"",loadPromise:null,activeHandles:new Set,ownedResourceAliases:[],_generation:0,_loadingEffect:null}}_resolveManagedEffectIds(e,t=!1){if(null==e){const e=[];for(const[r,n]of this._registeredEffectStates.entries())t&&!n.enabled||e.push(r);return e}const r=Array.isArray(e)?e:[e],n=[],a=new Set;for(let e=0;e<r.length;e++){const t=String(r[e]||"").trim();t&&!a.has(t)&&(a.add(t),n.push(t))}return n}_registerManagedEffectReference(e,t){e&&(e._managedRefIds instanceof Set||(e._managedRefIds=new Set),e._managedRefIds.add(t))}_releaseManagedEffectReference(e,t){e&&e._managedRefIds instanceof Set&&e._managedRefIds.delete(t)}_releaseManagedEffectIfUnused(r){if(!r)return;const n=r._managedRefIds instanceof Set?r._managedRefIds:null;n&&n.size>0||(D(r),(t=>{if(t&&e.resourcesMap)for(let r=0;r<t.length;r++){const n=t[r];"string"==typeof n&&0!==n.length&&delete e.resourcesMap[n]}})(r._ownedResourceAliases),r._ownedResourceAliases=[],this.nativeptr&&r.nativeptr&&(t.ReleaseEffect(this.nativeptr,r.nativeptr),r.nativeptr=0))}_stopManagedHandles(e){if(e){for(const t of e.activeHandles)try{t?.stopRoot?.()}catch{}e.activeHandles.clear()}}_cleanupManagedHandles(){for(const e of this._registeredEffectStates.values())if(e&&0!==e.activeHandles.size)for(const t of Array.from(e.activeHandles))t&&!1!==t.exists||e.activeHandles.delete(t)}_resetManagedEffectStateToUnloaded(e){e&&(e.effect=null,e.status="unloaded",e.errorMessage="",e.errorPath="",e.loadPromise=null,e.ownedResourceAliases=[],e._loadingEffect=null)}_loadRegisteredEffectState(e){if(!e||!this.nativeptr)return Promise.resolve(null);const t=this._registeredEffects.get(e.id);if(!t)return Promise.resolve(null);const r=e._generation+1;e._generation=r,e.status="loading",e.errorMessage="",e.errorPath="",e.effect=null,e.ownedResourceAliases=[],e._loadingEffect=null;const n=new Promise(n=>{let a=!1,s=null;const i=s=>{if(a)return;a=!0;return this._registeredEffectStates.get(e.id)!==e||e._generation!==r?(this._releaseManagedEffectIfUnused(s),void n(null)):(e._loadingEffect=null,e.loadPromise=null,s&&s.isLoaded?(e.effect=s,e.status="loaded",e.errorMessage="",e.errorPath="",e.ownedResourceAliases=Array.isArray(s._ownedResourceAliases)?s._ownedResourceAliases.slice():[],void n(s)):(e.status="failed",e.errorMessage="failed to load effect",e.errorPath=t.path,void n(null)))},o=(i,o="")=>{if(a)return;a=!0,s&&this._releaseManagedEffectReference(s,e.id);if(this._registeredEffectStates.get(e.id)!==e||e._generation!==r)return s&&this._releaseManagedEffectIfUnused(s),void n(null);e._loadingEffect=null,e.loadPromise=null,e.effect=null,e.status="failed",e.errorMessage=String(i||"failed to load effect"),e.errorPath=String(o||t.path||""),e.ownedResourceAliases=[],s&&this._releaseManagedEffectIfUnused(s),n(null)};try{s=this.loadEffect(t.path,t.scale,()=>i(s),(e,t)=>o(e,t))}catch(e){return void o(e&&e.message?e.message:"failed to load effect",t.path)}e._loadingEffect=s,s?(this._registerManagedEffectReference(s,e.id),s.isLoaded?i(s):s._loadFailed&&o(s._loadErrorMessage,s._loadErrorPath)):o("failed to create effect",t.path)});return e.loadPromise=n,n}_prepareInitSettings(e={},t=!1){const r=e.instanceMaxCount||4e3,n=e.squareMaxCount||1e4,a=!1!==e.linearColorSpace?1:0,s=e.compositeWithBackground?1:0;return this.externalRenderPassEnabled=t,this.fixedUpdateAccumulator=0,{instanceMaxCount:r,squareMaxCount:n,linearColorSpace:a,compositeWithBackground:s}}_finishContextInit(e={}){return this.nativeptr&&e.effects&&(this.registerEffects(e.effects),this.preloadEffects()),!!this.nativeptr}init(e,r={}){if(!0===r.externalRenderPass)return this.initExternal(r);let n="#canvas";"string"==typeof e?n=e.startsWith("#")?e:`#${e}`:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.id||(f+=1,e.id=`effekseer_webgpu_canvas_${f}`),n=`#${e.id}`);const a=this._prepareInitSettings(r,!1);return this.nativeptr=t.InitInternal(a.instanceMaxCount,a.squareMaxCount,n,a.linearColorSpace,a.compositeWithBackground),this._finishContextInit(r)}initExternal(e={}){const r=this._prepareInitSettings(e,!0);return this.nativeptr=t.InitExternal(r.instanceMaxCount,r.squareMaxCount,r.linearColorSpace,r.compositeWithBackground),this._finishContextInit(e)}update(e=1){const r=Number(e);if(!Number.isFinite(r)||r<=0)return void this._cleanupManagedHandles();this.fixedUpdateAccumulator+=r;let n=0;for(;this.fixedUpdateAccumulator>=this.fixedUpdateStepFrames&&n<this.fixedUpdateMaxSubsteps;)t.Update(this.nativeptr,this.fixedUpdateStepFrames),this.fixedUpdateAccumulator-=this.fixedUpdateStepFrames,n++;n>=this.fixedUpdateMaxSubsteps&&this.fixedUpdateAccumulator>=this.fixedUpdateStepFrames&&(this.fixedUpdateAccumulator=0),this._cleanupManagedHandles()}beginUpdate(){t.BeginUpdate(this.nativeptr)}endUpdate(){t.EndUpdate(this.nativeptr)}updateHandle(e,r=1){t.UpdateHandle(this.nativeptr,e.native,r)}draw(){this.externalRenderPassEnabled||t.Draw(this.nativeptr)}drawExternal(r,n=null,a="all"){if(!r)return;const s=W(n&&n.colorFormat),i=(()=>{const e=W(n&&n.depthFormat);return null===e?0:e})(),o=(e=>{const t=Number(e);return!Number.isFinite(t)||t<=0?1:Math.max(1,Math.floor(t))})(n&&n.sampleCount),f=(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),c=f(n,"depthTextureView")||f(n,"importDepthTextureView"),l=f(n,"backgroundTextureView")||f(n,"importBackgroundTextureView"),u=c?f(n,"depthTextureView")?n.depthTextureView:n.importDepthTextureView:null,d=l?f(n,"backgroundTextureView")?n.backgroundTextureView:n.importBackgroundTextureView:null,p=c?e.__effekseerDepthTextureView:null,h=l?e.__effekseerBackgroundTextureView:null;e.__effekseerExternalRenderPass=r,e.__effekseerExternalPassColorFormat=s,e.__effekseerExternalPassDepthFormat=i,e.__effekseerExternalPassSampleCount=o,c&&(e.__effekseerDepthTextureView=u||null),l&&(e.__effekseerBackgroundTextureView=d||null);const g="back"===a?"back":"front"===a?"front":"all";try{"back"===g?t.DrawExternalBack(this.nativeptr):"front"===g?t.DrawExternalFront(this.nativeptr):t.DrawExternal(this.nativeptr)}finally{c&&(e.__effekseerDepthTextureView=p||null),l&&(e.__effekseerBackgroundTextureView=h||null),e.__effekseerExternalRenderPass=null,e.__effekseerExternalPassColorFormat=null,e.__effekseerExternalPassDepthFormat=null,e.__effekseerExternalPassSampleCount=null}}beginDraw(){t.BeginDraw(this.nativeptr)}endDraw(){t.EndDraw(this.nativeptr)}drawHandle(e){t.DrawHandle(this.nativeptr,e.native)}setProjectionMatrix(e){B(e,e=>t.SetProjectionMatrix(this.nativeptr,e))}setProjectionPerspective(e,r,n,a){t.SetProjectionPerspective(this.nativeptr,e,r,n,a)}setProjectionOrthographic(e,r,n,a){t.SetProjectionOrthographic(this.nativeptr,e,r,n,a)}setCameraMatrix(e){B(e,e=>t.SetCameraMatrix(this.nativeptr,e))}setCameraLookAt(e,r,n,a,s,i,o,f,c){t.SetCameraLookAt(this.nativeptr,e,r,n,a,s,i,o,f,c)}setCameraLookAtFromVector(e,t,r={x:0,y:1,z:0}){this.setCameraLookAt(e.x,e.y,e.z,t.x,t.y,t.z,r.x,r.y,r.z)}setCompositeMode(e){t.SetCompositeMode(this.nativeptr,e?1:0)}loadEffect(e,t=1,r,n,a){const s="function"==typeof t?1:t,i="function"==typeof t?t:r,o="function"==typeof t?r:n,f=a;let c=null;if("string"==typeof e&&null==f){c=L(e,s);const t=this._effectCache.get(c);if(t)return F(t,i,o),t}const u=new V(this);u.scale=s,u.redirect=f,u._cacheKey=c||"",F(u,i,o),c&&this._effectCache.set(c,u);const p=(e,t="")=>(T(u,e,t),u);if("string"==typeof e)return"string"==typeof(h=e)&&0!==h.length&&h.replace(/\\/g,"/").split("?")[0].split("#")[0].toLowerCase().endsWith(".efkwg")?(R(e,t=>{const r=l(t);if(!r)return void p("failed to fetch efkwg effect",e);const n=e.replace(/\\/g,"/").split("?")[0].split("#")[0],a=n.lastIndexOf("/");u.baseDir=a>=0?n.slice(0,a+1):"",u.syncResourceLoad=!1,u._load(r),u.nativeptr||p("failed to load efkwg effect",e)},()=>{p("failed to fetch efkwg effect",e)}),u):(e=>"string"==typeof e&&0!==e.length&&y(e).toLowerCase().endsWith(".efkwgpk"))(e)?(R(e,t=>{const r=l(t);r?G(this,r,e,s,null,null,0,u):p("failed to fetch efkwgpk package",e)},()=>{p("failed to fetch efkwgpk package",e)}),u):p("unsupported effect format. expected .efkwg or .efkwgpk",e);var h;const g=l(e);if(!g)return p("invalid data. expected efkwg or efkwgpk bytes","");if(S(g)===d)return G(this,g,"",s,null,null,0,u);const m=String.fromCharCode(...new Uint8Array(g,0,Math.min(4,g.byteLength)));return"EFWG"===m||"SKFE"===m?(u._load(g),u.nativeptr?u:p("failed to load efkwg effect","")):p("invalid data. expected efkwg or efkwgpk bytes","")}loadEffectPackage(e,t,r=1,n,a){let s=r,i=n,o=a;return"function"==typeof r&&(s=1,i=r,o=n),this.loadEffect(e,s,i,o)}registerEffects(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("registerEffects() expects an object map of effect ids to paths/configs.");const t=[];for(const[r,n]of Object.entries(e)){if(this._registeredEffects.has(r))throw new Error(`registerEffects() duplicate id "${r}".`);t.push(this._normalizeManagedEffectDescriptor(r,n))}for(let e=0;e<t.length;e++){const r=t[e];if(this._registeredEffects.has(r.id))throw new Error(`registerEffects() duplicate id "${r.id}".`)}for(let e=0;e<t.length;e++){const r=t[e];this._registeredEffects.set(r.id,r),this._registeredEffectStates.set(r.id,this._createManagedEffectState(r))}if(this.nativeptr)for(let e=0;e<t.length;e++){const r=t[e];r.enabled&&this.preloadEffects([r.id])}}preloadEffects(e){const t=this._resolveManagedEffectIds(e,null==e);return Promise.all(t.map(async e=>{const t=this._registeredEffectStates.get(e);return t?"loaded"===t.status&&t.effect?.isLoaded?[e,t.effect]:"loading"===t.status&&t.loadPromise?[e,await t.loadPromise]:[e,await this._loadRegisteredEffectState(t)]:[e,null]})).then(e=>new Map(e))}reloadEffects(e){const t=this._resolveManagedEffectIds(e,null==e);return this.unloadEffects(t),this.preloadEffects(t)}unloadEffects(e){const t=this._resolveManagedEffectIds(e);for(let e=0;e<t.length;e++){const r=t[e],n=this._registeredEffectStates.get(r);if(!n)continue;n._generation+=1,this._stopManagedHandles(n);const a=n._loadingEffect;a&&(this._releaseManagedEffectReference(a,r),this._releaseManagedEffectIfUnused(a));const s=n.effect;s&&(this._releaseManagedEffectReference(s,r),this._releaseManagedEffectIfUnused(s)),this._resetManagedEffectStateToUnloaded(n)}}unregisterEffects(e){const t=this._resolveManagedEffectIds(e);this.unloadEffects(t);for(let e=0;e<t.length;e++){const r=t[e];this._registeredEffects.delete(r),this._registeredEffectStates.delete(r)}}getEffect(e){const t=this._registeredEffectStates.get(String(e||""));return"loaded"===t?.status&&t.effect?.isLoaded?t.effect:null}getEffectState(e){return I(this._registeredEffectStates.get(String(e||"")))}getEffectStates(){return Array.from(this._registeredEffectStates.values(),e=>I(e))}whenEffectsReady(e){return this.preloadEffects(e)}playEffect(e,t=0,r=0,n=0){const a=this._registeredEffectStates.get(String(e||""));if(!a||"loaded"!==a.status||!a.effect?.isLoaded)return null;const s=this.play(a.effect,t,r,n);return s&&a.activeHandles.add(s),s}releaseEffect(e){e&&e.nativeptr&&(D(e),t.ReleaseEffect(this.nativeptr,e.nativeptr),e.nativeptr=0)}play(e,r=0,n=0,a=0){if(!e||!e.isLoaded)return null;const s=t.PlayEffect(this.nativeptr,e.nativeptr,r,n,a);return s>=0?new N(this,s):null}stopAll(){t.StopAllEffects(this.nativeptr)}setResourceLoader(e){O=e}getRestInstancesCount(){return t.GetRestInstancesCount(this.nativeptr)}isVertexArrayObjectSupported(){return!!t.IsVertexArrayObjectSupported(this.nativeptr)}setRestorationOfStatesFlag(e){t.SetRestorationOfStatesFlag(this.nativeptr,e?1:0)}captureBackground(e,r,n,a){t.CaptureBackground(this.nativeptr,e,r,n,a)}resetBackground(){t.ResetBackground(this.nativeptr)}}return new class{async initRuntime(e,t,r){try{await H(e),t&&t()}catch(e){a=!1,n=!1,c=[],r?r(e):console.error(e)}}createContext(){return n?new $:null}releaseContext(e){e&&e.nativeptr&&(e.unloadEffects?.(),t.Terminate(e.nativeptr),e.nativeptr=0,e._effectCache?.clear?.(),e._registeredEffects?.clear?.(),e._registeredEffectStates?.clear?.())}setImageCrossOrigin(e){o=e}setWebGPUDevice(e){if(n||a)throw new Error("setWebGPUDevice() must be called before initRuntime().");if(null==e)return i=null,void(s=null);if("object"!=typeof e||"function"!=typeof e.createCommandEncoder||!e.queue)throw new Error("setWebGPUDevice() expects a valid GPUDevice.");i=e,s=e}setRendererWorkingColorSpace(e){return((e=null)=>{const t=e;return!(!t||!t.ColorManagement)&&"workingColorSpace"in t.ColorManagement&&void 0!==t.LinearSRGBColorSpace&&(t.ColorManagement.workingColorSpace=t.LinearSRGBColorSpace,!0)})(e)}getWebGPUDevice(){return s||(e?e.preinitializedWebGPUDevice:null)||null}init(e,t){return this.defaultContext?.nativeptr&&this.releaseContext(this.defaultContext),this.defaultContext=new $,this.defaultContext.init(e,t)}update(e){this.defaultContext.update(e)}beginUpdate(){this.defaultContext.beginUpdate()}endUpdate(){this.defaultContext.endUpdate()}updateHandle(e,t){this.defaultContext.updateHandle(e,t)}draw(){this.defaultContext.draw()}drawExternal(e,t,r="all"){this.defaultContext.drawExternal(e,t,r)}beginDraw(){this.defaultContext.beginDraw()}endDraw(){this.defaultContext.endDraw()}drawHandle(e){this.defaultContext.drawHandle(e)}setProjectionMatrix(e){this.defaultContext.setProjectionMatrix(e)}setProjectionPerspective(e,t,r,n){this.defaultContext.setProjectionPerspective(e,t,r,n)}setProjectionOrthographic(e,t,r,n){this.defaultContext.setProjectionOrthographic(e,t,r,n)}setCameraMatrix(e){this.defaultContext.setCameraMatrix(e)}setCameraLookAt(e,t,r,n,a,s,i,o,f){this.defaultContext.setCameraLookAt(e,t,r,n,a,s,i,o,f)}setCameraLookAtFromVector(e,t,r){this.defaultContext.setCameraLookAtFromVector(e,t,r)}setCompositeMode(e){this.defaultContext.setCompositeMode(e)}loadEffect(e,t,r,n,a){return this.defaultContext.loadEffect(e,t,r,n,a)}loadEffectPackage(e,t,r,n,a){return this.defaultContext.loadEffectPackage(e,t,r,n,a)}registerEffects(e){this.defaultContext.registerEffects(e)}preloadEffects(e){return this.defaultContext.preloadEffects(e)}reloadEffects(e){return this.defaultContext.reloadEffects(e)}unloadEffects(e){this.defaultContext.unloadEffects(e)}unregisterEffects(e){this.defaultContext.unregisterEffects(e)}getEffect(e){return this.defaultContext.getEffect(e)}getEffectState(e){return this.defaultContext.getEffectState(e)}getEffectStates(){return this.defaultContext.getEffectStates()}whenEffectsReady(e){return this.defaultContext.whenEffectsReady(e)}playEffect(e,t,r,n){return this.defaultContext.playEffect(e,t,r,n)}releaseEffect(e){this.defaultContext.releaseEffect(e)}play(e,t,r,n){return this.defaultContext.play(e,t,r,n)}stopAll(){this.defaultContext.stopAll()}setResourceLoader(e){this.defaultContext.setResourceLoader(e)}getRestInstancesCount(){return this.defaultContext.getRestInstancesCount()}isVertexArrayObjectSupported(){return this.defaultContext.isVertexArrayObjectSupported()}}})();"undefined"!=typeof globalThis&&(globalThis.effekseer=e),"undefined"!=typeof exports&&(exports=e);
|