@motion-core/motion-gpu 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/dist/core/compute-bindgroup-cache.d.ts +13 -0
- package/dist/core/compute-bindgroup-cache.d.ts.map +1 -0
- package/dist/core/compute-bindgroup-cache.js +45 -0
- package/dist/core/compute-bindgroup-cache.js.map +1 -0
- package/dist/core/compute-shader.d.ts +48 -0
- package/dist/core/compute-shader.d.ts.map +1 -1
- package/dist/core/compute-shader.js +34 -1
- package/dist/core/compute-shader.js.map +1 -1
- package/dist/core/error-diagnostics.d.ts +8 -1
- package/dist/core/error-diagnostics.d.ts.map +1 -1
- package/dist/core/error-diagnostics.js +7 -3
- package/dist/core/error-diagnostics.js.map +1 -1
- package/dist/core/error-report.d.ts.map +1 -1
- package/dist/core/error-report.js +19 -1
- package/dist/core/error-report.js.map +1 -1
- package/dist/core/material.d.ts.map +1 -1
- package/dist/core/material.js +2 -1
- package/dist/core/material.js.map +1 -1
- package/dist/core/pointer.d.ts +96 -0
- package/dist/core/pointer.d.ts.map +1 -0
- package/dist/core/pointer.js +71 -0
- package/dist/core/pointer.js.map +1 -0
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/renderer.js +150 -85
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/runtime-loop.d.ts.map +1 -1
- package/dist/core/runtime-loop.js +26 -14
- package/dist/core/runtime-loop.js.map +1 -1
- package/dist/core/shader.d.ts +7 -2
- package/dist/core/shader.d.ts.map +1 -1
- package/dist/core/shader.js +1 -0
- package/dist/core/shader.js.map +1 -1
- package/dist/core/textures.d.ts +4 -0
- package/dist/core/textures.d.ts.map +1 -1
- package/dist/core/textures.js +2 -1
- package/dist/core/textures.js.map +1 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/react/advanced.js +2 -1
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -1
- package/dist/react/use-pointer.d.ts +94 -0
- package/dist/react/use-pointer.d.ts.map +1 -0
- package/dist/react/use-pointer.js +285 -0
- package/dist/react/use-pointer.js.map +1 -0
- package/dist/svelte/advanced.js +2 -1
- package/dist/svelte/index.d.ts +2 -0
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +2 -1
- package/dist/svelte/use-pointer.d.ts +94 -0
- package/dist/svelte/use-pointer.d.ts.map +1 -0
- package/dist/svelte/use-pointer.js +292 -0
- package/dist/svelte/use-pointer.js.map +1 -0
- package/package.json +1 -1
- package/src/lib/core/compute-bindgroup-cache.ts +73 -0
- package/src/lib/core/compute-shader.ts +86 -0
- package/src/lib/core/error-diagnostics.ts +29 -4
- package/src/lib/core/error-report.ts +26 -1
- package/src/lib/core/material.ts +2 -1
- package/src/lib/core/pointer.ts +177 -0
- package/src/lib/core/renderer.ts +198 -92
- package/src/lib/core/runtime-loop.ts +37 -16
- package/src/lib/core/shader.ts +13 -2
- package/src/lib/core/textures.ts +6 -1
- package/src/lib/core/types.ts +1 -1
- package/src/lib/react/index.ts +10 -0
- package/src/lib/react/use-pointer.ts +515 -0
- package/src/lib/svelte/index.ts +10 -0
- package/src/lib/svelte/use-pointer.ts +507 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-loop.js","names":[],"sources":["../../src/lib/core/runtime-loop.ts"],"sourcesContent":["import type { CurrentReadable, CurrentWritable } from './current-value.js';\nimport { resolveMaterial, type FragMaterial, type ResolvedMaterial } from './material.js';\nimport {\n\ttoMotionGPUErrorReport,\n\ttype MotionGPUErrorPhase,\n\ttype MotionGPUErrorReport\n} from './error-report.js';\nimport { createRenderer } from './renderer.js';\nimport { buildRendererPipelineSignature } from './recompile-policy.js';\nimport { assertUniformValueForType } from './uniforms.js';\nimport type { FrameRegistry } from './frame-registry.js';\nimport type {\n\tAnyPass,\n\tFrameInvalidationToken,\n\tOutputColorSpace,\n\tPendingStorageWrite,\n\tRenderer,\n\tRenderTargetDefinitionMap,\n\tStorageBufferDefinitionMap,\n\tTextureMap,\n\tTextureValue,\n\tUniformType,\n\tUniformValue\n} from './types.js';\n\nexport interface MotionGPURuntimeLoopOptions {\n\tcanvas: HTMLCanvasElement;\n\tregistry: FrameRegistry;\n\tsize: CurrentWritable<{ width: number; height: number }>;\n\tdpr: CurrentReadable<number>;\n\tmaxDelta: CurrentReadable<number>;\n\tgetMaterial: () => FragMaterial;\n\tgetRenderTargets: () => RenderTargetDefinitionMap;\n\tgetPasses: () => AnyPass[];\n\tgetClearColor: () => [number, number, number, number];\n\tgetOutputColorSpace: () => OutputColorSpace;\n\tgetAdapterOptions: () => GPURequestAdapterOptions | undefined;\n\tgetDeviceDescriptor: () => GPUDeviceDescriptor | undefined;\n\tgetOnError: () => ((report: MotionGPUErrorReport) => void) | undefined;\n\treportError: (report: MotionGPUErrorReport | null) => void;\n\tgetErrorHistoryLimit?: () => number | undefined;\n\tgetOnErrorHistory?: () => ((history: MotionGPUErrorReport[]) => void) | undefined;\n\treportErrorHistory?: (history: MotionGPUErrorReport[]) => void;\n}\n\nexport interface MotionGPURuntimeLoop {\n\trequestFrame: () => void;\n\tinvalidate: (token?: FrameInvalidationToken) => void;\n\tadvance: () => void;\n\tdestroy: () => void;\n}\n\nfunction getRendererRetryDelayMs(attempt: number): number {\n\treturn Math.min(8000, 250 * 2 ** Math.max(0, attempt - 1));\n}\n\nexport function createMotionGPURuntimeLoop(\n\toptions: MotionGPURuntimeLoopOptions\n): MotionGPURuntimeLoop {\n\tconst { canvas: canvasElement, registry, size } = options;\n\tlet frameId: number | null = null;\n\tlet renderer: Renderer | null = null;\n\tlet isDisposed = false;\n\tlet previousTime = performance.now() / 1000;\n\tlet activeRendererSignature = '';\n\tlet failedRendererSignature: string | null = null;\n\tlet failedRendererAttempts = 0;\n\tlet nextRendererRetryAt = 0;\n\tlet rendererRebuildPromise: Promise<void> | null = null;\n\n\tconst runtimeUniforms: Record<string, UniformValue> = {};\n\tconst runtimeTextures: TextureMap = {};\n\tlet activeUniforms: Record<string, UniformValue> = {};\n\tlet activeTextures: Record<string, { source?: TextureValue }> = {};\n\tlet uniformKeys: string[] = [];\n\tlet uniformKeySet = new Set<string>();\n\tlet uniformTypes = new Map<string, UniformType>();\n\tlet textureKeys: string[] = [];\n\tlet textureKeySet = new Set<string>();\n\tlet activeMaterialSignature = '';\n\tlet currentCssWidth = -1;\n\tlet currentCssHeight = -1;\n\tconst renderUniforms: Record<string, UniformValue> = {};\n\tconst renderTextures: TextureMap = {};\n\tconst canvasSize = { width: 0, height: 0 };\n\tlet storageBufferKeys: string[] = [];\n\tlet storageBufferKeySet = new Set<string>();\n\tlet storageBufferDefinitions: StorageBufferDefinitionMap = {};\n\tconst pendingStorageWrites: PendingStorageWrite[] = [];\n\tlet shouldContinueAfterFrame = false;\n\tlet activeErrorKey: string | null = null;\n\tlet errorHistory: MotionGPUErrorReport[] = [];\n\n\tconst getHistoryLimit = (): number => {\n\t\tconst value = options.getErrorHistoryLimit?.() ?? 0;\n\t\tif (!Number.isFinite(value) || value <= 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn Math.floor(value);\n\t};\n\n\tconst publishErrorHistory = (): void => {\n\t\toptions.reportErrorHistory?.(errorHistory);\n\t\tconst onErrorHistory = options.getOnErrorHistory?.();\n\t\tif (!onErrorHistory) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonErrorHistory(errorHistory);\n\t\t} catch {\n\t\t\t// User-provided error history handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst syncErrorHistory = (): void => {\n\t\tconst limit = getHistoryLimit();\n\t\tif (limit <= 0) {\n\t\t\tif (errorHistory.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\terrorHistory = [];\n\t\t\tpublishErrorHistory();\n\t\t\treturn;\n\t\t}\n\n\t\tif (errorHistory.length <= limit) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorHistory = errorHistory.slice(errorHistory.length - limit);\n\t\tpublishErrorHistory();\n\t};\n\n\tconst setError = (error: unknown, phase: MotionGPUErrorPhase): void => {\n\t\tconst report = toMotionGPUErrorReport(error, phase);\n\t\tconst reportKey = JSON.stringify({\n\t\t\tphase: report.phase,\n\t\t\ttitle: report.title,\n\t\t\tmessage: report.message,\n\t\t\trawMessage: report.rawMessage\n\t\t});\n\t\tif (activeErrorKey === reportKey) {\n\t\t\treturn;\n\t\t}\n\t\tactiveErrorKey = reportKey;\n\t\tconst historyLimit = getHistoryLimit();\n\t\tif (historyLimit > 0) {\n\t\t\terrorHistory = [...errorHistory, report];\n\t\t\tif (errorHistory.length > historyLimit) {\n\t\t\t\terrorHistory = errorHistory.slice(errorHistory.length - historyLimit);\n\t\t\t}\n\t\t\tpublishErrorHistory();\n\t\t}\n\t\toptions.reportError(report);\n\t\tconst onError = options.getOnError();\n\t\tif (!onError) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonError(report);\n\t\t} catch {\n\t\t\t// User-provided error handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst clearError = (): void => {\n\t\tif (activeErrorKey === null) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveErrorKey = null;\n\t\toptions.reportError(null);\n\t};\n\n\tconst scheduleFrame = (): void => {\n\t\tif (isDisposed || frameId !== null) {\n\t\t\treturn;\n\t\t}\n\n\t\tframeId = requestAnimationFrame(renderFrame);\n\t};\n\n\tconst requestFrame = (): void => {\n\t\tscheduleFrame();\n\t};\n\n\tconst invalidate = (token?: FrameInvalidationToken): void => {\n\t\tregistry.invalidate(token);\n\t\trequestFrame();\n\t};\n\n\tconst advance = (): void => {\n\t\tregistry.advance();\n\t\trequestFrame();\n\t};\n\n\tconst resetRuntimeMaps = (): void => {\n\t\tfor (const key of Object.keys(runtimeUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(runtimeUniforms, key);\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(runtimeTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(runtimeTextures, key);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst resetRenderPayloadMaps = (): void => {\n\t\tfor (const key of Object.keys(renderUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(renderUniforms, key);\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(renderTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tReflect.deleteProperty(renderTextures, key);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst syncMaterialRuntimeState = (materialState: ResolvedMaterial): void => {\n\t\tconst signatureChanged = activeMaterialSignature !== materialState.signature;\n\t\tconst defaultsChanged =\n\t\t\tactiveUniforms !== materialState.uniforms || activeTextures !== materialState.textures;\n\n\t\tif (!signatureChanged && !defaultsChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveUniforms = materialState.uniforms;\n\t\tactiveTextures = materialState.textures;\n\t\tif (!signatureChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tuniformKeys = materialState.uniformLayout.entries.map((entry) => entry.name);\n\t\tuniformTypes = new Map(\n\t\t\tmaterialState.uniformLayout.entries.map((entry) => [entry.name, entry.type])\n\t\t);\n\t\ttextureKeys = materialState.textureKeys;\n\t\tuniformKeySet = new Set(uniformKeys);\n\t\ttextureKeySet = new Set(textureKeys);\n\t\tstorageBufferKeys = materialState.storageBufferKeys;\n\t\tstorageBufferKeySet = new Set(storageBufferKeys);\n\t\tstorageBufferDefinitions = (options.getMaterial().storageBuffers ??\n\t\t\t{}) as StorageBufferDefinitionMap;\n\t\tresetRuntimeMaps();\n\t\tresetRenderPayloadMaps();\n\t\tactiveMaterialSignature = materialState.signature;\n\t};\n\n\tconst resolveActiveMaterial = (): ResolvedMaterial => {\n\t\treturn resolveMaterial(options.getMaterial());\n\t};\n\n\tconst setUniform = (name: string, value: UniformValue): void => {\n\t\tif (!uniformKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown uniform \"${name}\". Declare it in material.uniforms first.`);\n\t\t}\n\t\tconst expectedType = uniformTypes.get(name);\n\t\tif (!expectedType) {\n\t\t\tthrow new Error(`Unknown uniform type for \"${name}\"`);\n\t\t}\n\t\tassertUniformValueForType(expectedType, value);\n\t\truntimeUniforms[name] = value;\n\t};\n\n\tconst setTexture = (name: string, value: TextureValue): void => {\n\t\tif (!textureKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown texture \"${name}\". Declare it in material.textures first.`);\n\t\t}\n\t\truntimeTextures[name] = value;\n\t};\n\n\tconst writeStorageBuffer = (\n\t\tname: string,\n\t\tdata: ArrayBufferView,\n\t\twriteOptions?: { offset?: number }\n\t): void => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\tthrow new Error(`Missing definition for storage buffer \"${name}\".`);\n\t\t}\n\t\tconst offset = writeOptions?.offset ?? 0;\n\t\tif (offset < 0 || offset + data.byteLength > definition.size) {\n\t\t\tthrow new Error(\n\t\t\t\t`Storage buffer \"${name}\" write out of bounds: offset=${offset}, dataSize=${data.byteLength}, bufferSize=${definition.size}.`\n\t\t\t);\n\t\t}\n\t\tpendingStorageWrites.push({ name, data, offset });\n\t};\n\n\tconst readStorageBuffer = (name: string): Promise<ArrayBuffer> => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tif (!renderer) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew Error(`Cannot read storage buffer \"${name}\": renderer not initialized.`)\n\t\t\t);\n\t\t}\n\t\tconst gpuBuffer = renderer.getStorageBuffer?.(name);\n\t\tif (!gpuBuffer) {\n\t\t\treturn Promise.reject(new Error(`Storage buffer \"${name}\" not allocated on GPU.`));\n\t\t}\n\t\tconst device = renderer.getDevice?.();\n\t\tif (!device) {\n\t\t\treturn Promise.reject(new Error('Cannot read storage buffer: GPU device unavailable.'));\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\treturn Promise.reject(new Error(`Missing definition for storage buffer \"${name}\".`));\n\t\t}\n\t\tconst stagingBuffer = device.createBuffer({\n\t\t\tsize: definition.size,\n\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t});\n\t\tconst commandEncoder = device.createCommandEncoder();\n\t\tcommandEncoder.copyBufferToBuffer(gpuBuffer, 0, stagingBuffer, 0, definition.size);\n\t\tdevice.queue.submit([commandEncoder.finish()]);\n\t\treturn stagingBuffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tconst result = stagingBuffer.getMappedRange().slice(0);\n\t\t\tstagingBuffer.unmap();\n\t\t\tstagingBuffer.destroy();\n\t\t\treturn result;\n\t\t});\n\t};\n\n\tconst renderFrame = (timestamp: number): void => {\n\t\tframeId = null;\n\t\tif (isDisposed) {\n\t\t\treturn;\n\t\t}\n\t\tsyncErrorHistory();\n\n\t\tlet materialState: ResolvedMaterial;\n\t\ttry {\n\t\t\tmaterialState = resolveActiveMaterial();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization');\n\t\t\tscheduleFrame();\n\t\t\treturn;\n\t\t}\n\n\t\tshouldContinueAfterFrame = false;\n\n\t\tconst outputColorSpace = options.getOutputColorSpace();\n\t\tconst rendererSignature = buildRendererPipelineSignature({\n\t\t\tmaterialSignature: materialState.signature,\n\t\t\toutputColorSpace\n\t\t});\n\t\tsyncMaterialRuntimeState(materialState);\n\n\t\tif (failedRendererSignature && failedRendererSignature !== rendererSignature) {\n\t\t\tfailedRendererSignature = null;\n\t\t\tfailedRendererAttempts = 0;\n\t\t\tnextRendererRetryAt = 0;\n\t\t}\n\n\t\tif (!renderer || activeRendererSignature !== rendererSignature) {\n\t\t\tif (\n\t\t\t\tfailedRendererSignature === rendererSignature &&\n\t\t\t\tperformance.now() < nextRendererRetryAt\n\t\t\t) {\n\t\t\t\tscheduleFrame();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!rendererRebuildPromise) {\n\t\t\t\trendererRebuildPromise = (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst nextRenderer = await createRenderer({\n\t\t\t\t\t\t\tcanvas: canvasElement,\n\t\t\t\t\t\t\tfragmentWgsl: materialState.fragmentWgsl,\n\t\t\t\t\t\t\tfragmentLineMap: materialState.fragmentLineMap,\n\t\t\t\t\t\t\tfragmentSource: materialState.fragmentSource,\n\t\t\t\t\t\t\tincludeSources: materialState.includeSources,\n\t\t\t\t\t\t\tdefineBlockSource: materialState.defineBlockSource,\n\t\t\t\t\t\t\tmaterialSource: materialState.source,\n\t\t\t\t\t\t\tmaterialSignature: materialState.signature,\n\t\t\t\t\t\t\tuniformLayout: materialState.uniformLayout,\n\t\t\t\t\t\t\ttextureKeys: materialState.textureKeys,\n\t\t\t\t\t\t\ttextureDefinitions: materialState.textures,\n\t\t\t\t\t\t\tstorageBufferKeys: materialState.storageBufferKeys,\n\t\t\t\t\t\t\tstorageBufferDefinitions,\n\t\t\t\t\t\t\tstorageTextureKeys: materialState.storageTextureKeys,\n\t\t\t\t\t\t\tgetRenderTargets: options.getRenderTargets,\n\t\t\t\t\t\t\tgetPasses: options.getPasses,\n\t\t\t\t\t\t\toutputColorSpace,\n\t\t\t\t\t\t\tgetClearColor: options.getClearColor,\n\t\t\t\t\t\t\tgetDpr: () => options.dpr.current,\n\t\t\t\t\t\t\tadapterOptions: options.getAdapterOptions(),\n\t\t\t\t\t\t\tdeviceDescriptor: options.getDeviceDescriptor()\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (isDisposed) {\n\t\t\t\t\t\t\tnextRenderer.destroy();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trenderer?.destroy();\n\t\t\t\t\t\trenderer = nextRenderer;\n\t\t\t\t\t\tactiveRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererSignature = null;\n\t\t\t\t\t\tfailedRendererAttempts = 0;\n\t\t\t\t\t\tnextRendererRetryAt = 0;\n\t\t\t\t\t\tclearError();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailedRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererAttempts += 1;\n\t\t\t\t\t\tconst retryDelayMs = getRendererRetryDelayMs(failedRendererAttempts);\n\t\t\t\t\t\tnextRendererRetryAt = performance.now() + retryDelayMs;\n\t\t\t\t\t\tsetError(error, 'initialization');\n\t\t\t\t\t} finally {\n\t\t\t\t\t\trendererRebuildPromise = null;\n\t\t\t\t\t\tscheduleFrame();\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst time = timestamp / 1000;\n\t\tconst rawDelta = Math.max(0, time - previousTime);\n\t\tconst delta = Math.min(rawDelta, options.maxDelta.current);\n\t\tpreviousTime = time;\n\t\tconst rect = canvasElement.getBoundingClientRect();\n\t\tconst width = Math.max(0, Math.floor(rect.width));\n\t\tconst height = Math.max(0, Math.floor(rect.height));\n\t\tif (width !== currentCssWidth || height !== currentCssHeight) {\n\t\t\tcurrentCssWidth = width;\n\t\t\tcurrentCssHeight = height;\n\t\t\tsize.set({ width, height });\n\t\t}\n\n\t\ttry {\n\t\t\tregistry.run({\n\t\t\t\ttime,\n\t\t\t\tdelta,\n\t\t\t\tsetUniform,\n\t\t\t\tsetTexture,\n\t\t\t\twriteStorageBuffer,\n\t\t\t\treadStorageBuffer,\n\t\t\t\tinvalidate,\n\t\t\t\tadvance,\n\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\tautoRender: registry.getAutoRender(),\n\t\t\t\tcanvas: canvasElement\n\t\t\t});\n\n\t\t\tconst shouldRenderFrame = registry.shouldRender();\n\t\t\tshouldContinueAfterFrame =\n\t\t\t\tregistry.getRenderMode() === 'always' ||\n\t\t\t\t(registry.getRenderMode() === 'on-demand' && shouldRenderFrame);\n\n\t\t\tif (shouldRenderFrame) {\n\t\t\t\tfor (const key of uniformKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeUniforms[key];\n\t\t\t\t\trenderUniforms[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeUniforms[key] as UniformValue) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tfor (const key of textureKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeTextures[key];\n\t\t\t\t\trenderTextures[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeTextures[key]?.source ?? null) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tcanvasSize.width = width;\n\t\t\t\tcanvasSize.height = height;\n\t\t\t\trenderer.render({\n\t\t\t\t\ttime,\n\t\t\t\t\tdelta,\n\t\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\t\tuniforms: renderUniforms,\n\t\t\t\t\ttextures: renderTextures,\n\t\t\t\t\tcanvasSize,\n\t\t\t\t\t...(pendingStorageWrites.length > 0\n\t\t\t\t\t\t? { pendingStorageWrites: pendingStorageWrites.splice(0) }\n\t\t\t\t\t\t: {})\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tclearError();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'render');\n\t\t} finally {\n\t\t\tregistry.endFrame();\n\t\t}\n\n\t\tif (shouldContinueAfterFrame) {\n\t\t\tscheduleFrame();\n\t\t}\n\t};\n\n\t(async () => {\n\t\ttry {\n\t\t\tconst initialMaterial = resolveActiveMaterial();\n\t\t\tsyncMaterialRuntimeState(initialMaterial);\n\t\t\tactiveRendererSignature = '';\n\t\t\tscheduleFrame();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization');\n\t\t\tscheduleFrame();\n\t\t}\n\t})();\n\n\treturn {\n\t\trequestFrame,\n\t\tinvalidate,\n\t\tadvance,\n\t\tdestroy: () => {\n\t\t\tisDisposed = true;\n\t\t\tif (frameId !== null) {\n\t\t\t\tcancelAnimationFrame(frameId);\n\t\t\t\tframeId = null;\n\t\t\t}\n\t\t\trenderer?.destroy();\n\t\t\tregistry.clear();\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;AAoDA,SAAS,wBAAwB,SAAyB;AACzD,QAAO,KAAK,IAAI,KAAM,MAAM,KAAK,KAAK,IAAI,GAAG,UAAU,EAAE,CAAC;;AAG3D,SAAgB,2BACf,SACuB;CACvB,MAAM,EAAE,QAAQ,eAAe,UAAU,SAAS;CAClD,IAAI,UAAyB;CAC7B,IAAI,WAA4B;CAChC,IAAI,aAAa;CACjB,IAAI,eAAe,YAAY,KAAK,GAAG;CACvC,IAAI,0BAA0B;CAC9B,IAAI,0BAAyC;CAC7C,IAAI,yBAAyB;CAC7B,IAAI,sBAAsB;CAC1B,IAAI,yBAA+C;CAEnD,MAAM,kBAAgD,EAAE;CACxD,MAAM,kBAA8B,EAAE;CACtC,IAAI,iBAA+C,EAAE;CACrD,IAAI,iBAA4D,EAAE;CAClE,IAAI,cAAwB,EAAE;CAC9B,IAAI,gCAAgB,IAAI,KAAa;CACrC,IAAI,+BAAe,IAAI,KAA0B;CACjD,IAAI,cAAwB,EAAE;CAC9B,IAAI,gCAAgB,IAAI,KAAa;CACrC,IAAI,0BAA0B;CAC9B,IAAI,kBAAkB;CACtB,IAAI,mBAAmB;CACvB,MAAM,iBAA+C,EAAE;CACvD,MAAM,iBAA6B,EAAE;CACrC,MAAM,aAAa;EAAE,OAAO;EAAG,QAAQ;EAAG;CAC1C,IAAI,oBAA8B,EAAE;CACpC,IAAI,sCAAsB,IAAI,KAAa;CAC3C,IAAI,2BAAuD,EAAE;CAC7D,MAAM,uBAA8C,EAAE;CACtD,IAAI,2BAA2B;CAC/B,IAAI,iBAAgC;CACpC,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AS,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,YAAY,SAAS,eAAe;IACpC,YAAY,SAAS,eAAe;IACpC,QAAQ;IACR,CAAC;GAEF,MAAM,oBAAoB,SAAS,cAAc;AACjD,8BACC,SAAS,eAAe,KAAK,YAC5B,SAAS,eAAe,KAAK,eAAe;AAE9C,OAAI,mBAAmB;AACtB,SAAK,MAAM,OAAO,aAAa;KAC9B,MAAM,eAAe,gBAAgB;AACrC,oBAAe,OACd,iBAAiB,SAAa,eAAe,OAAwB;;AAGvE,SAAK,MAAM,OAAO,aAAa;KAC9B,MAAM,eAAe,gBAAgB;AACrC,oBAAe,OACd,iBAAiB,SAAa,eAAe,MAAM,UAAU,OAAQ;;AAGvE,eAAW,QAAQ;AACnB,eAAW,SAAS;AACpB,aAAS,OAAO;KACf;KACA;KACA,YAAY,SAAS,eAAe;KACpC,UAAU;KACV,UAAU;KACV;KACA,GAAI,qBAAqB,SAAS,IAC/B,EAAE,sBAAsB,qBAAqB,OAAO,EAAE,EAAE,GACxD,EAAE;KACL,CAAC;;AAGH,eAAY;WACJ,OAAO;AACf,YAAS,OAAO,SAAS;YAChB;AACT,YAAS,UAAU;;AAGpB,MAAI,yBACH,gBAAe;;AAIjB,EAAC,YAAY;AACZ,MAAI;AAEH,4BADwB,uBAAuB,CACN;AACzC,6BAA0B;AAC1B,kBAAe;WACP,OAAO;AACf,YAAS,OAAO,iBAAiB;AACjC,kBAAe;;KAEb;AAEJ,QAAO;EACN;EACA;EACA;EACA,eAAe;AACd,gBAAa;AACb,OAAI,YAAY,MAAM;AACrB,yBAAqB,QAAQ;AAC7B,cAAU;;AAEX,aAAU,SAAS;AACnB,YAAS,OAAO;;EAEjB"}
|
|
1
|
+
{"version":3,"file":"runtime-loop.js","names":[],"sources":["../../src/lib/core/runtime-loop.ts"],"sourcesContent":["import type { CurrentReadable, CurrentWritable } from './current-value.js';\nimport { resolveMaterial, type FragMaterial, type ResolvedMaterial } from './material.js';\nimport {\n\ttoMotionGPUErrorReport,\n\ttype MotionGPUErrorPhase,\n\ttype MotionGPUErrorReport\n} from './error-report.js';\nimport { createRenderer } from './renderer.js';\nimport { buildRendererPipelineSignature } from './recompile-policy.js';\nimport { assertUniformValueForType } from './uniforms.js';\nimport type { FrameRegistry } from './frame-registry.js';\nimport type {\n\tAnyPass,\n\tFrameInvalidationToken,\n\tOutputColorSpace,\n\tPendingStorageWrite,\n\tRenderer,\n\tRenderTargetDefinitionMap,\n\tStorageBufferDefinitionMap,\n\tTextureMap,\n\tTextureValue,\n\tUniformType,\n\tUniformValue\n} from './types.js';\n\nexport interface MotionGPURuntimeLoopOptions {\n\tcanvas: HTMLCanvasElement;\n\tregistry: FrameRegistry;\n\tsize: CurrentWritable<{ width: number; height: number }>;\n\tdpr: CurrentReadable<number>;\n\tmaxDelta: CurrentReadable<number>;\n\tgetMaterial: () => FragMaterial;\n\tgetRenderTargets: () => RenderTargetDefinitionMap;\n\tgetPasses: () => AnyPass[];\n\tgetClearColor: () => [number, number, number, number];\n\tgetOutputColorSpace: () => OutputColorSpace;\n\tgetAdapterOptions: () => GPURequestAdapterOptions | undefined;\n\tgetDeviceDescriptor: () => GPUDeviceDescriptor | undefined;\n\tgetOnError: () => ((report: MotionGPUErrorReport) => void) | undefined;\n\treportError: (report: MotionGPUErrorReport | null) => void;\n\tgetErrorHistoryLimit?: () => number | undefined;\n\tgetOnErrorHistory?: () => ((history: MotionGPUErrorReport[]) => void) | undefined;\n\treportErrorHistory?: (history: MotionGPUErrorReport[]) => void;\n}\n\nexport interface MotionGPURuntimeLoop {\n\trequestFrame: () => void;\n\tinvalidate: (token?: FrameInvalidationToken) => void;\n\tadvance: () => void;\n\tdestroy: () => void;\n}\n\nfunction getRendererRetryDelayMs(attempt: number): number {\n\treturn Math.min(8000, 250 * 2 ** Math.max(0, attempt - 1));\n}\n\nconst ERROR_CLEAR_GRACE_MS = 750;\n\nexport function createMotionGPURuntimeLoop(\n\toptions: MotionGPURuntimeLoopOptions\n): MotionGPURuntimeLoop {\n\tconst { canvas: canvasElement, registry, size } = options;\n\tlet frameId: number | null = null;\n\tlet renderer: Renderer | null = null;\n\tlet isDisposed = false;\n\tlet previousTime = performance.now() / 1000;\n\tlet activeRendererSignature = '';\n\tlet failedRendererSignature: string | null = null;\n\tlet failedRendererAttempts = 0;\n\tlet nextRendererRetryAt = 0;\n\tlet rendererRebuildPromise: Promise<void> | null = null;\n\n\tconst runtimeUniforms: Record<string, UniformValue> = {};\n\tconst runtimeTextures: TextureMap = {};\n\tlet activeUniforms: Record<string, UniformValue> = {};\n\tlet activeTextures: Record<string, { source?: TextureValue }> = {};\n\tlet uniformKeys: string[] = [];\n\tlet uniformKeySet = new Set<string>();\n\tlet uniformTypes = new Map<string, UniformType>();\n\tlet textureKeys: string[] = [];\n\tlet textureKeySet = new Set<string>();\n\tlet activeMaterialSignature = '';\n\tlet currentCssWidth = -1;\n\tlet currentCssHeight = -1;\n\tconst renderUniforms: Record<string, UniformValue> = {};\n\tconst renderTextures: TextureMap = {};\n\tconst canvasSize = { width: 0, height: 0 };\n\tlet storageBufferKeys: string[] = [];\n\tlet storageBufferKeySet = new Set<string>();\n\tlet storageBufferDefinitions: StorageBufferDefinitionMap = {};\n\tconst pendingStorageWrites: PendingStorageWrite[] = [];\n\tlet shouldContinueAfterFrame = false;\n\tlet activeErrorKey: string | null = null;\n\tlet errorHistory: MotionGPUErrorReport[] = [];\n\tlet errorClearReadyAtMs = 0;\n\tlet lastFrameTimestampMs = performance.now();\n\n\tconst resolveNowMs = (nowMs?: number): number => {\n\t\tif (typeof nowMs === 'number' && Number.isFinite(nowMs)) {\n\t\t\treturn nowMs;\n\t\t}\n\n\t\treturn lastFrameTimestampMs;\n\t};\n\n\tconst getHistoryLimit = (): number => {\n\t\tconst value = options.getErrorHistoryLimit?.() ?? 0;\n\t\tif (!Number.isFinite(value) || value <= 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn Math.floor(value);\n\t};\n\n\tconst publishErrorHistory = (): void => {\n\t\toptions.reportErrorHistory?.(errorHistory);\n\t\tconst onErrorHistory = options.getOnErrorHistory?.();\n\t\tif (!onErrorHistory) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonErrorHistory(errorHistory);\n\t\t} catch {\n\t\t\t// User-provided error history handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst syncErrorHistory = (): void => {\n\t\tconst limit = getHistoryLimit();\n\t\tif (limit <= 0) {\n\t\t\tif (errorHistory.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\terrorHistory = [];\n\t\t\tpublishErrorHistory();\n\t\t\treturn;\n\t\t}\n\n\t\tif (errorHistory.length <= limit) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorHistory.splice(0, errorHistory.length - limit);\n\t\tpublishErrorHistory();\n\t};\n\n\tconst setError = (error: unknown, phase: MotionGPUErrorPhase, nowMs?: number): void => {\n\t\tconst report = toMotionGPUErrorReport(error, phase);\n\t\terrorClearReadyAtMs = resolveNowMs(nowMs) + ERROR_CLEAR_GRACE_MS;\n\t\tconst reportKey = JSON.stringify({\n\t\t\tphase: report.phase,\n\t\t\ttitle: report.title,\n\t\t\tmessage: report.message,\n\t\t\trawMessage: report.rawMessage\n\t\t});\n\t\tif (activeErrorKey === reportKey) {\n\t\t\treturn;\n\t\t}\n\t\tactiveErrorKey = reportKey;\n\t\tconst historyLimit = getHistoryLimit();\n\t\tif (historyLimit > 0) {\n\t\t\terrorHistory.push(report);\n\t\t\tif (errorHistory.length > historyLimit) {\n\t\t\t\terrorHistory.splice(0, errorHistory.length - historyLimit);\n\t\t\t}\n\t\t\tpublishErrorHistory();\n\t\t}\n\t\toptions.reportError(report);\n\t\tconst onError = options.getOnError();\n\t\tif (!onError) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tonError(report);\n\t\t} catch {\n\t\t\t// User-provided error handlers must not break runtime error recovery.\n\t\t}\n\t};\n\n\tconst maybeClearError = (nowMs?: number): void => {\n\t\tif (activeErrorKey === null) {\n\t\t\treturn;\n\t\t}\n\t\tif (resolveNowMs(nowMs) < errorClearReadyAtMs) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveErrorKey = null;\n\t\terrorClearReadyAtMs = 0;\n\t\toptions.reportError(null);\n\t};\n\n\tconst scheduleFrame = (): void => {\n\t\tif (isDisposed || frameId !== null) {\n\t\t\treturn;\n\t\t}\n\n\t\tframeId = requestAnimationFrame(renderFrame);\n\t};\n\n\tconst requestFrame = (): void => {\n\t\tscheduleFrame();\n\t};\n\n\tconst invalidate = (token?: FrameInvalidationToken): void => {\n\t\tregistry.invalidate(token);\n\t\trequestFrame();\n\t};\n\n\tconst advance = (): void => {\n\t\tregistry.advance();\n\t\trequestFrame();\n\t};\n\n\tconst resetRuntimeMaps = (): void => {\n\t\tfor (const key of Object.keys(runtimeUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tdelete runtimeUniforms[key];\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(runtimeTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tdelete runtimeTextures[key];\n\t\t\t}\n\t\t}\n\t};\n\n\tconst resetRenderPayloadMaps = (): void => {\n\t\tfor (const key of Object.keys(renderUniforms)) {\n\t\t\tif (!uniformKeySet.has(key)) {\n\t\t\t\tdelete renderUniforms[key];\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of Object.keys(renderTextures)) {\n\t\t\tif (!textureKeySet.has(key)) {\n\t\t\t\tdelete renderTextures[key];\n\t\t\t}\n\t\t}\n\t};\n\n\tconst syncMaterialRuntimeState = (materialState: ResolvedMaterial): void => {\n\t\tconst signatureChanged = activeMaterialSignature !== materialState.signature;\n\t\tconst defaultsChanged =\n\t\t\tactiveUniforms !== materialState.uniforms || activeTextures !== materialState.textures;\n\n\t\tif (!signatureChanged && !defaultsChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tactiveUniforms = materialState.uniforms;\n\t\tactiveTextures = materialState.textures;\n\t\tif (!signatureChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tuniformKeys = materialState.uniformLayout.entries.map((entry) => entry.name);\n\t\tuniformTypes = new Map(\n\t\t\tmaterialState.uniformLayout.entries.map((entry) => [entry.name, entry.type])\n\t\t);\n\t\ttextureKeys = materialState.textureKeys;\n\t\tuniformKeySet = new Set(uniformKeys);\n\t\ttextureKeySet = new Set(textureKeys);\n\t\tstorageBufferKeys = materialState.storageBufferKeys;\n\t\tstorageBufferKeySet = new Set(storageBufferKeys);\n\t\tstorageBufferDefinitions = (options.getMaterial().storageBuffers ??\n\t\t\t{}) as StorageBufferDefinitionMap;\n\t\tresetRuntimeMaps();\n\t\tresetRenderPayloadMaps();\n\t\tactiveMaterialSignature = materialState.signature;\n\t};\n\n\tconst resolveActiveMaterial = (): ResolvedMaterial => {\n\t\treturn resolveMaterial(options.getMaterial());\n\t};\n\n\tconst setUniform = (name: string, value: UniformValue): void => {\n\t\tif (!uniformKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown uniform \"${name}\". Declare it in material.uniforms first.`);\n\t\t}\n\t\tconst expectedType = uniformTypes.get(name);\n\t\tif (!expectedType) {\n\t\t\tthrow new Error(`Unknown uniform type for \"${name}\"`);\n\t\t}\n\t\tassertUniformValueForType(expectedType, value);\n\t\truntimeUniforms[name] = value;\n\t};\n\n\tconst setTexture = (name: string, value: TextureValue): void => {\n\t\tif (!textureKeySet.has(name)) {\n\t\t\tthrow new Error(`Unknown texture \"${name}\". Declare it in material.textures first.`);\n\t\t}\n\t\truntimeTextures[name] = value;\n\t};\n\n\tconst writeStorageBuffer = (\n\t\tname: string,\n\t\tdata: ArrayBufferView,\n\t\twriteOptions?: { offset?: number }\n\t): void => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\tthrow new Error(`Missing definition for storage buffer \"${name}\".`);\n\t\t}\n\t\tconst offset = writeOptions?.offset ?? 0;\n\t\tif (offset < 0 || offset + data.byteLength > definition.size) {\n\t\t\tthrow new Error(\n\t\t\t\t`Storage buffer \"${name}\" write out of bounds: offset=${offset}, dataSize=${data.byteLength}, bufferSize=${definition.size}.`\n\t\t\t);\n\t\t}\n\t\tpendingStorageWrites.push({ name, data, offset });\n\t};\n\n\tconst readStorageBuffer = (name: string): Promise<ArrayBuffer> => {\n\t\tif (!storageBufferKeySet.has(name)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown storage buffer \"${name}\". Declare it in material.storageBuffers first.`\n\t\t\t);\n\t\t}\n\t\tif (!renderer) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew Error(`Cannot read storage buffer \"${name}\": renderer not initialized.`)\n\t\t\t);\n\t\t}\n\t\tconst gpuBuffer = renderer.getStorageBuffer?.(name);\n\t\tif (!gpuBuffer) {\n\t\t\treturn Promise.reject(new Error(`Storage buffer \"${name}\" not allocated on GPU.`));\n\t\t}\n\t\tconst device = renderer.getDevice?.();\n\t\tif (!device) {\n\t\t\treturn Promise.reject(new Error('Cannot read storage buffer: GPU device unavailable.'));\n\t\t}\n\t\tconst definition = storageBufferDefinitions[name];\n\t\tif (!definition) {\n\t\t\treturn Promise.reject(new Error(`Missing definition for storage buffer \"${name}\".`));\n\t\t}\n\t\tconst stagingBuffer = device.createBuffer({\n\t\t\tsize: definition.size,\n\t\t\tusage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST\n\t\t});\n\t\tconst commandEncoder = device.createCommandEncoder();\n\t\tcommandEncoder.copyBufferToBuffer(gpuBuffer, 0, stagingBuffer, 0, definition.size);\n\t\tdevice.queue.submit([commandEncoder.finish()]);\n\t\treturn stagingBuffer.mapAsync(GPUMapMode.READ).then(() => {\n\t\t\tconst result = stagingBuffer.getMappedRange().slice(0);\n\t\t\tstagingBuffer.unmap();\n\t\t\tstagingBuffer.destroy();\n\t\t\treturn result;\n\t\t});\n\t};\n\n\tconst renderFrame = (timestamp: number): void => {\n\t\tframeId = null;\n\t\tif (isDisposed) {\n\t\t\treturn;\n\t\t}\n\t\tlastFrameTimestampMs = timestamp;\n\t\tsyncErrorHistory();\n\n\t\tlet materialState: ResolvedMaterial;\n\t\ttry {\n\t\t\tmaterialState = resolveActiveMaterial();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization', timestamp);\n\t\t\tscheduleFrame();\n\t\t\treturn;\n\t\t}\n\n\t\tshouldContinueAfterFrame = false;\n\n\t\tconst outputColorSpace = options.getOutputColorSpace();\n\t\tconst rendererSignature = buildRendererPipelineSignature({\n\t\t\tmaterialSignature: materialState.signature,\n\t\t\toutputColorSpace\n\t\t});\n\t\tsyncMaterialRuntimeState(materialState);\n\n\t\tif (failedRendererSignature && failedRendererSignature !== rendererSignature) {\n\t\t\tfailedRendererSignature = null;\n\t\t\tfailedRendererAttempts = 0;\n\t\t\tnextRendererRetryAt = 0;\n\t\t}\n\n\t\tif (!renderer || activeRendererSignature !== rendererSignature) {\n\t\t\tif (\n\t\t\t\tfailedRendererSignature === rendererSignature &&\n\t\t\t\tperformance.now() < nextRendererRetryAt\n\t\t\t) {\n\t\t\t\tscheduleFrame();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!rendererRebuildPromise) {\n\t\t\t\trendererRebuildPromise = (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst nextRenderer = await createRenderer({\n\t\t\t\t\t\t\tcanvas: canvasElement,\n\t\t\t\t\t\t\tfragmentWgsl: materialState.fragmentWgsl,\n\t\t\t\t\t\t\tfragmentLineMap: materialState.fragmentLineMap,\n\t\t\t\t\t\t\tfragmentSource: materialState.fragmentSource,\n\t\t\t\t\t\t\tincludeSources: materialState.includeSources,\n\t\t\t\t\t\t\tdefineBlockSource: materialState.defineBlockSource,\n\t\t\t\t\t\t\tmaterialSource: materialState.source,\n\t\t\t\t\t\t\tmaterialSignature: materialState.signature,\n\t\t\t\t\t\t\tuniformLayout: materialState.uniformLayout,\n\t\t\t\t\t\t\ttextureKeys: materialState.textureKeys,\n\t\t\t\t\t\t\ttextureDefinitions: materialState.textures,\n\t\t\t\t\t\t\tstorageBufferKeys: materialState.storageBufferKeys,\n\t\t\t\t\t\t\tstorageBufferDefinitions,\n\t\t\t\t\t\t\tstorageTextureKeys: materialState.storageTextureKeys,\n\t\t\t\t\t\t\tgetRenderTargets: options.getRenderTargets,\n\t\t\t\t\t\t\tgetPasses: options.getPasses,\n\t\t\t\t\t\t\toutputColorSpace,\n\t\t\t\t\t\t\tgetClearColor: options.getClearColor,\n\t\t\t\t\t\t\tgetDpr: () => options.dpr.current,\n\t\t\t\t\t\t\tadapterOptions: options.getAdapterOptions(),\n\t\t\t\t\t\t\tdeviceDescriptor: options.getDeviceDescriptor()\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (isDisposed) {\n\t\t\t\t\t\t\tnextRenderer.destroy();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trenderer?.destroy();\n\t\t\t\t\t\trenderer = nextRenderer;\n\t\t\t\t\t\tactiveRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererSignature = null;\n\t\t\t\t\t\tfailedRendererAttempts = 0;\n\t\t\t\t\t\tnextRendererRetryAt = 0;\n\t\t\t\t\t\tmaybeClearError(performance.now());\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tfailedRendererSignature = rendererSignature;\n\t\t\t\t\t\tfailedRendererAttempts += 1;\n\t\t\t\t\t\tconst retryDelayMs = getRendererRetryDelayMs(failedRendererAttempts);\n\t\t\t\t\t\tnextRendererRetryAt = performance.now() + retryDelayMs;\n\t\t\t\t\t\tsetError(error, 'initialization');\n\t\t\t\t\t} finally {\n\t\t\t\t\t\trendererRebuildPromise = null;\n\t\t\t\t\t\tscheduleFrame();\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst time = timestamp / 1000;\n\t\tconst rawDelta = Math.max(0, time - previousTime);\n\t\tconst delta = Math.min(rawDelta, options.maxDelta.current);\n\t\tpreviousTime = time;\n\t\tconst rect = canvasElement.getBoundingClientRect();\n\t\tconst width = Math.max(0, Math.floor(rect.width));\n\t\tconst height = Math.max(0, Math.floor(rect.height));\n\t\tif (width !== currentCssWidth || height !== currentCssHeight) {\n\t\t\tcurrentCssWidth = width;\n\t\t\tcurrentCssHeight = height;\n\t\t\tsize.set({ width, height });\n\t\t}\n\n\t\ttry {\n\t\t\tregistry.run({\n\t\t\t\ttime,\n\t\t\t\tdelta,\n\t\t\t\tsetUniform,\n\t\t\t\tsetTexture,\n\t\t\t\twriteStorageBuffer,\n\t\t\t\treadStorageBuffer,\n\t\t\t\tinvalidate,\n\t\t\t\tadvance,\n\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\tautoRender: registry.getAutoRender(),\n\t\t\t\tcanvas: canvasElement\n\t\t\t});\n\n\t\t\tconst shouldRenderFrame = registry.shouldRender();\n\t\t\tshouldContinueAfterFrame =\n\t\t\t\tregistry.getRenderMode() === 'always' ||\n\t\t\t\t(registry.getRenderMode() === 'on-demand' && shouldRenderFrame);\n\n\t\t\tif (shouldRenderFrame) {\n\t\t\t\tfor (const key of uniformKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeUniforms[key];\n\t\t\t\t\trenderUniforms[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeUniforms[key] as UniformValue) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tfor (const key of textureKeys) {\n\t\t\t\t\tconst runtimeValue = runtimeTextures[key];\n\t\t\t\t\trenderTextures[key] =\n\t\t\t\t\t\truntimeValue === undefined ? (activeTextures[key]?.source ?? null) : runtimeValue;\n\t\t\t\t}\n\n\t\t\t\tcanvasSize.width = width;\n\t\t\t\tcanvasSize.height = height;\n\t\t\t\trenderer.render({\n\t\t\t\t\ttime,\n\t\t\t\t\tdelta,\n\t\t\t\t\trenderMode: registry.getRenderMode(),\n\t\t\t\t\tuniforms: renderUniforms,\n\t\t\t\t\ttextures: renderTextures,\n\t\t\t\t\tcanvasSize,\n\t\t\t\t\tpendingStorageWrites: pendingStorageWrites.length > 0 ? pendingStorageWrites : undefined\n\t\t\t\t});\n\t\t\t\t// Clear in-place after synchronous render() completes — avoids\n\t\t\t\t// the splice(0) copy and eliminates the conditional spread object.\n\t\t\t\tif (pendingStorageWrites.length > 0) {\n\t\t\t\t\tpendingStorageWrites.length = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmaybeClearError(timestamp);\n\t\t} catch (error) {\n\t\t\tsetError(error, 'render', timestamp);\n\t\t} finally {\n\t\t\tregistry.endFrame();\n\t\t}\n\n\t\tif (shouldContinueAfterFrame) {\n\t\t\tscheduleFrame();\n\t\t}\n\t};\n\n\t(async () => {\n\t\ttry {\n\t\t\tconst initialMaterial = resolveActiveMaterial();\n\t\t\tsyncMaterialRuntimeState(initialMaterial);\n\t\t\tactiveRendererSignature = '';\n\t\t\tscheduleFrame();\n\t\t} catch (error) {\n\t\t\tsetError(error, 'initialization');\n\t\t\tscheduleFrame();\n\t\t}\n\t})();\n\n\treturn {\n\t\trequestFrame,\n\t\tinvalidate,\n\t\tadvance,\n\t\tdestroy: () => {\n\t\t\tisDisposed = true;\n\t\t\tif (frameId !== null) {\n\t\t\t\tcancelAnimationFrame(frameId);\n\t\t\t\tframeId = null;\n\t\t\t}\n\t\t\trenderer?.destroy();\n\t\t\tregistry.clear();\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;AAoDA,SAAS,wBAAwB,SAAyB;AACzD,QAAO,KAAK,IAAI,KAAM,MAAM,KAAK,KAAK,IAAI,GAAG,UAAU,EAAE,CAAC;;AAG3D,IAAM,uBAAuB;AAE7B,SAAgB,2BACf,SACuB;CACvB,MAAM,EAAE,QAAQ,eAAe,UAAU,SAAS;CA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I,mBAAmB;AACtB,SAAK,MAAM,OAAO,aAAa;KAC9B,MAAM,eAAe,gBAAgB;AACrC,oBAAe,OACd,iBAAiB,SAAa,eAAe,OAAwB;;AAGvE,SAAK,MAAM,OAAO,aAAa;KAC9B,MAAM,eAAe,gBAAgB;AACrC,oBAAe,OACd,iBAAiB,SAAa,eAAe,MAAM,UAAU,OAAQ;;AAGvE,eAAW,QAAQ;AACnB,eAAW,SAAS;AACpB,aAAS,OAAO;KACf;KACA;KACA,YAAY,SAAS,eAAe;KACpC,UAAU;KACV,UAAU;KACV;KACA,sBAAsB,qBAAqB,SAAS,IAAI,uBAAuB;KAC/E,CAAC;AAGF,QAAI,qBAAqB,SAAS,EACjC,sBAAqB,SAAS;;AAIhC,mBAAgB,UAAU;WAClB,OAAO;AACf,YAAS,OAAO,UAAU,UAAU;YAC3B;AACT,YAAS,UAAU;;AAGpB,MAAI,yBACH,gBAAe;;AAIjB,EAAC,YAAY;AACZ,MAAI;AAEH,4BADwB,uBAAuB,CACN;AACzC,6BAA0B;AAC1B,kBAAe;WACP,OAAO;AACf,YAAS,OAAO,iBAAiB;AACjC,kBAAe;;KAEb;AAEJ,QAAO;EACN;EACA;EACA;EACA,eAAe;AACd,gBAAa;AACb,OAAI,YAAY,MAAM;AACrB,yBAAqB,QAAQ;AAC7B,cAAU;;AAEX,aAAU,SAAS;AACnB,YAAS,OAAO;;EAEjB"}
|
package/dist/core/shader.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';
|
|
2
2
|
import type { StorageBufferType, UniformLayout } from './types.js';
|
|
3
|
+
type ComputeShaderSourceLocation = {
|
|
4
|
+
kind: 'compute';
|
|
5
|
+
line: number;
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* 1-based map from generated WGSL lines to original material source lines.
|
|
5
9
|
*/
|
|
6
|
-
export type ShaderLineMap = Array<MaterialSourceLocation | null>;
|
|
10
|
+
export type ShaderLineMap = Array<(MaterialSourceLocation | ComputeShaderSourceLocation) | null>;
|
|
7
11
|
/**
|
|
8
12
|
* Result of shader source generation with line mapping metadata.
|
|
9
13
|
*/
|
|
@@ -47,5 +51,6 @@ export declare function buildShaderSourceWithMap(fragmentWgsl: string, uniformLa
|
|
|
47
51
|
/**
|
|
48
52
|
* Converts source location metadata to user-facing diagnostics label.
|
|
49
53
|
*/
|
|
50
|
-
export declare function formatShaderSourceLocation(location: MaterialSourceLocation | null): string | null;
|
|
54
|
+
export declare function formatShaderSourceLocation(location: (MaterialSourceLocation | ComputeShaderSourceLocation) | null): string | null;
|
|
55
|
+
export {};
|
|
51
56
|
//# sourceMappingURL=shader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../src/lib/core/shader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+
|
|
1
|
+
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../src/lib/core/shader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE,KAAK,2BAA2B,GAAG;IAClC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AA+IF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,sBAAsB,GAAG,2BAA2B,CAAC,GAAG,IAAI,CAAC,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,EAC5B,WAAW,GAAE,MAAM,EAAO,EAC1B,OAAO,CAAC,EAAE;IACT,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAC;CACvE,GACC,MAAM,CAwDR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,EAC5B,WAAW,GAAE,MAAM,EAAO,EAC1B,OAAO,CAAC,EAAE;IACT,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAC;CACvE,GACC,iBAAiB,CA4BnB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACzC,QAAQ,EAAE,CAAC,sBAAsB,GAAG,2BAA2B,CAAC,GAAG,IAAI,GACrE,MAAM,GAAG,IAAI,CAkBf"}
|
package/dist/core/shader.js
CHANGED
|
@@ -182,6 +182,7 @@ function formatShaderSourceLocation(location) {
|
|
|
182
182
|
if (!location) return null;
|
|
183
183
|
if (location.kind === "fragment") return `fragment line ${location.line}`;
|
|
184
184
|
if (location.kind === "include") return `include <${location.include}> line ${location.line}`;
|
|
185
|
+
if (location.kind === "compute") return `compute line ${location.line}`;
|
|
185
186
|
return `define "${location.define}" line ${location.line}`;
|
|
186
187
|
}
|
|
187
188
|
//#endregion
|
package/dist/core/shader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.js","names":[],"sources":["../../src/lib/core/shader.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';\nimport type { StorageBufferType, UniformLayout } from './types.js';\n\n/**\n * Fallback uniform field used when no custom uniforms are provided.\n */\nconst DEFAULT_UNIFORM_FIELD = 'motiongpu_unused: vec4f,';\n\n/**\n * Builds WGSL struct fields for user uniforms.\n */\nfunction buildUniformStruct(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn DEFAULT_UNIFORM_FIELD;\n\t}\n\n\treturn layout.entries\n\t\t.map((entry) => {\n\t\t\tassertUniformName(entry.name);\n\t\t\treturn `${entry.name}: ${entry.type},`;\n\t\t})\n\t\t.join('\\n\\t');\n}\n\n/**\n * Builds a numeric expression that references one uniform value to keep bindings alive.\n */\nfunction getKeepAliveExpression(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tconst [firstEntry] = layout.entries;\n\tif (!firstEntry) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tif (firstEntry.type === 'f32') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}`;\n\t}\n\n\tif (firstEntry.type === 'mat4x4f') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}[0].x`;\n\t}\n\n\treturn `motiongpuUniforms.${firstEntry.name}.x`;\n}\n\n/**\n * Builds texture sampler/texture binding declarations.\n */\nfunction buildTextureBindings(textureKeys: string[]): string {\n\tif (textureKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < textureKeys.length; index += 1) {\n\t\tconst key = textureKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tassertUniformName(key);\n\t\tconst binding = 2 + index * 2;\n\t\tdeclarations.push(`@group(0) @binding(${binding}) var ${key}Sampler: sampler;`);\n\t\tdeclarations.push(`@group(0) @binding(${binding + 1}) var ${key}: texture_2d<f32>;`);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Builds read-only storage buffer bindings for fragment shader.\n */\nfunction buildFragmentStorageBufferBindings(\n\tstorageBufferKeys: string[],\n\tdefinitions: Record<string, { type: StorageBufferType }>\n): string {\n\tif (storageBufferKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < storageBufferKeys.length; index += 1) {\n\t\tconst key = storageBufferKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst definition = definitions[key];\n\t\tif (!definition) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tdeclarations.push(\n\t\t\t`@group(1) @binding(${index}) var<storage, read> ${key}: ${definition.type};`\n\t\t);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Optionally returns helper WGSL for linear-to-sRGB conversion.\n */\nfunction buildColorTransformHelpers(enableSrgbTransform: boolean): string {\n\tif (!enableSrgbTransform) {\n\t\treturn '';\n\t}\n\n\treturn `\nfn motiongpuLinearToSrgb(linearColor: vec3f) -> vec3f {\n\tlet cutoff = vec3f(0.0031308);\n\tlet lower = linearColor * 12.92;\n\tlet higher = vec3f(1.055) * pow(linearColor, vec3f(1.0 / 2.4)) - vec3f(0.055);\n\treturn select(lower, higher, linearColor > cutoff);\n}\n`;\n}\n\n/**\n * Builds fragment output code with optional color-space conversion.\n */\nfunction buildFragmentOutput(keepAliveExpression: string, enableSrgbTransform: boolean): string {\n\tif (enableSrgbTransform) {\n\t\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\tlet motiongpuLinear = vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n\tlet motiongpuSrgb = motiongpuLinearToSrgb(max(motiongpuLinear.rgb, vec3f(0.0)));\n\treturn vec4f(motiongpuSrgb, motiongpuLinear.a);\n`;\n\t}\n\n\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\treturn vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n`;\n}\n\n/**\n * 1-based map from generated WGSL lines to original material source lines.\n */\nexport type ShaderLineMap = Array<MaterialSourceLocation | null>;\n\n/**\n * Result of shader source generation with line mapping metadata.\n */\nexport interface BuiltShaderSource {\n\t/**\n\t * Full WGSL source code.\n\t */\n\tcode: string;\n\t/**\n\t * 1-based generated-line map to material source locations.\n\t */\n\tlineMap: ShaderLineMap;\n}\n\n/**\n * Assembles complete WGSL shader source used by the fullscreen renderer pipeline.\n *\n * @param fragmentWgsl - User fragment shader code containing `frag(uv: vec2f) -> vec4f`.\n * @param uniformLayout - Resolved uniform layout.\n * @param textureKeys - Sorted texture keys.\n * @param options - Shader build options.\n * @returns Complete WGSL source for vertex + fragment stages.\n */\nexport function buildShaderSource(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): string {\n\tconst uniformFields = buildUniformStruct(uniformLayout);\n\tconst keepAliveExpression = getKeepAliveExpression(uniformLayout);\n\tconst textureBindings = buildTextureBindings(textureKeys);\n\tconst enableSrgbTransform = options?.convertLinearToSrgb ?? false;\n\tconst colorTransformHelpers = buildColorTransformHelpers(enableSrgbTransform);\n\tconst fragmentOutput = buildFragmentOutput(keepAliveExpression, enableSrgbTransform);\n\tconst storageBufferBindings = buildFragmentStorageBufferBindings(\n\t\toptions?.storageBufferKeys ?? [],\n\t\toptions?.storageBufferDefinitions ?? {}\n\t);\n\n\treturn `\nstruct MotionGPUFrame {\n\ttime: f32,\n\tdelta: f32,\n\tresolution: vec2f,\n};\n\nstruct MotionGPUUniforms {\n\t${uniformFields}\n};\n\n@group(0) @binding(0) var<uniform> motiongpuFrame: MotionGPUFrame;\n@group(0) @binding(1) var<uniform> motiongpuUniforms: MotionGPUUniforms;\n${textureBindings}\n${storageBufferBindings ? '\\n' + storageBufferBindings : ''}\n${colorTransformHelpers}\n\nstruct MotionGPUVertexOut {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n};\n\n@vertex\nfn motiongpuVertex(@builtin(vertex_index) index: u32) -> MotionGPUVertexOut {\n\tvar positions = array<vec2f, 3>(\n\t\tvec2f(-1.0, -3.0),\n\t\tvec2f(-1.0, 1.0),\n\t\tvec2f(3.0, 1.0)\n\t);\n\n\tlet position = positions[index];\n\tvar out: MotionGPUVertexOut;\n\tout.position = vec4f(position, 0.0, 1.0);\n\tout.uv = (position + vec2f(1.0, 1.0)) * 0.5;\n\treturn out;\n}\n\n${fragmentWgsl}\n\n@fragment\nfn motiongpuFragment(in: MotionGPUVertexOut) -> @location(0) vec4f {\n\t${fragmentOutput}\n}\n`;\n}\n\n/**\n * Assembles complete WGSL shader source with material-source line mapping metadata.\n */\nexport function buildShaderSourceWithMap(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tfragmentLineMap?: MaterialLineMap;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): BuiltShaderSource {\n\tconst code = buildShaderSource(fragmentWgsl, uniformLayout, textureKeys, options);\n\tconst fragmentStartIndex = code.indexOf(fragmentWgsl);\n\tconst lineCount = code.split('\\n').length;\n\tconst lineMap: ShaderLineMap = new Array(lineCount + 1).fill(null);\n\n\tif (fragmentStartIndex === -1) {\n\t\treturn {\n\t\t\tcode,\n\t\t\tlineMap\n\t\t};\n\t}\n\n\tconst fragmentStartLine = code.slice(0, fragmentStartIndex).split('\\n').length;\n\tconst fragmentLineCount = fragmentWgsl.split('\\n').length;\n\n\tfor (let line = 0; line < fragmentLineCount; line += 1) {\n\t\tconst generatedLine = fragmentStartLine + line;\n\t\tlineMap[generatedLine] = options?.fragmentLineMap?.[line + 1] ?? {\n\t\t\tkind: 'fragment',\n\t\t\tline: line + 1\n\t\t};\n\t}\n\n\treturn {\n\t\tcode,\n\t\tlineMap\n\t};\n}\n\n/**\n * Converts source location metadata to user-facing diagnostics label.\n */\nexport function formatShaderSourceLocation(location: MaterialSourceLocation | null): string | null {\n\tif (!location) {\n\t\treturn null;\n\t}\n\n\tif (location.kind === 'fragment') {\n\t\treturn `fragment line ${location.line}`;\n\t}\n\n\tif (location.kind === 'include') {\n\t\treturn `include <${location.include}> line ${location.line}`;\n\t}\n\n\treturn `define \"${location.define}\" line ${location.line}`;\n}\n"],"mappings":";;;;;AAOA,IAAM,wBAAwB;;;;AAK9B,SAAS,mBAAmB,QAA+B;AAC1D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;AAGR,QAAO,OAAO,QACZ,KAAK,UAAU;AACf,oBAAkB,MAAM,KAAK;AAC7B,SAAO,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK;GACnC,CACD,KAAK,MAAO;;;;;AAMf,SAAS,uBAAuB,QAA+B;AAC9D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;CAGR,MAAM,CAAC,cAAc,OAAO;AAC5B,KAAI,CAAC,WACJ,QAAO;AAGR,KAAI,WAAW,SAAS,MACvB,QAAO,qBAAqB,WAAW;AAGxC,KAAI,WAAW,SAAS,UACvB,QAAO,qBAAqB,WAAW,KAAK;AAG7C,QAAO,qBAAqB,WAAW,KAAK;;;;;AAM7C,SAAS,qBAAqB,aAA+B;AAC5D,KAAI,YAAY,WAAW,EAC1B,QAAO;CAGR,MAAM,eAAyB,EAAE;AAEjC,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,QAAQ,SAAS,GAAG;EAC3D,MAAM,MAAM,YAAY;AACxB,MAAI,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,OAAO,wBAAwB,GAAG;EAC1D,sBAAsB;;;;;;;;;;;;;;;;;;;;;;EAsBtB,aAAa;;;;GAIZ,eAAe;;;;;;;AAQlB,SAAgB,yBACf,cACA,eACA,cAAwB,EAAE,EAC1B,SAMoB;CACpB,MAAM,OAAO,kBAAkB,cAAc,eAAe,aAAa,QAAQ;CACjF,MAAM,qBAAqB,KAAK,QAAQ,aAAa;CACrD,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC;CACnC,MAAM,UAAyB,IAAI,MAAM,YAAY,EAAE,CAAC,KAAK,KAAK;AAElE,KAAI,uBAAuB,GAC1B,QAAO;EACN;EACA;EACA;CAGF,MAAM,oBAAoB,KAAK,MAAM,GAAG,mBAAmB,CAAC,MAAM,KAAK,CAAC;CACxE,MAAM,oBAAoB,aAAa,MAAM,KAAK,CAAC;AAEnD,MAAK,IAAI,OAAO,GAAG,OAAO,mBAAmB,QAAQ,GAAG;EACvD,MAAM,gBAAgB,oBAAoB;AAC1C,UAAQ,iBAAiB,SAAS,kBAAkB,OAAO,MAAM;GAChE,MAAM;GACN,MAAM,OAAO;GACb;;AAGF,QAAO;EACN;EACA;EACA;;;;;AAMF,SAAgB,2BAA2B,UAAwD;AAClG,KAAI,CAAC,SACJ,QAAO;AAGR,KAAI,SAAS,SAAS,WACrB,QAAO,iBAAiB,SAAS;AAGlC,KAAI,SAAS,SAAS,UACrB,QAAO,YAAY,SAAS,QAAQ,SAAS,SAAS;AAGvD,QAAO,WAAW,SAAS,OAAO,SAAS,SAAS"}
|
|
1
|
+
{"version":3,"file":"shader.js","names":[],"sources":["../../src/lib/core/shader.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';\nimport type { StorageBufferType, UniformLayout } from './types.js';\n\ntype ComputeShaderSourceLocation = {\n\tkind: 'compute';\n\tline: number;\n};\n\n/**\n * Fallback uniform field used when no custom uniforms are provided.\n */\nconst DEFAULT_UNIFORM_FIELD = 'motiongpu_unused: vec4f,';\n\n/**\n * Builds WGSL struct fields for user uniforms.\n */\nfunction buildUniformStruct(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn DEFAULT_UNIFORM_FIELD;\n\t}\n\n\treturn layout.entries\n\t\t.map((entry) => {\n\t\t\tassertUniformName(entry.name);\n\t\t\treturn `${entry.name}: ${entry.type},`;\n\t\t})\n\t\t.join('\\n\\t');\n}\n\n/**\n * Builds a numeric expression that references one uniform value to keep bindings alive.\n */\nfunction getKeepAliveExpression(layout: UniformLayout): string {\n\tif (layout.entries.length === 0) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tconst [firstEntry] = layout.entries;\n\tif (!firstEntry) {\n\t\treturn 'motiongpuUniforms.motiongpu_unused.x';\n\t}\n\n\tif (firstEntry.type === 'f32') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}`;\n\t}\n\n\tif (firstEntry.type === 'mat4x4f') {\n\t\treturn `motiongpuUniforms.${firstEntry.name}[0].x`;\n\t}\n\n\treturn `motiongpuUniforms.${firstEntry.name}.x`;\n}\n\n/**\n * Builds texture sampler/texture binding declarations.\n */\nfunction buildTextureBindings(textureKeys: string[]): string {\n\tif (textureKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < textureKeys.length; index += 1) {\n\t\tconst key = textureKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tassertUniformName(key);\n\t\tconst binding = 2 + index * 2;\n\t\tdeclarations.push(`@group(0) @binding(${binding}) var ${key}Sampler: sampler;`);\n\t\tdeclarations.push(`@group(0) @binding(${binding + 1}) var ${key}: texture_2d<f32>;`);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Builds read-only storage buffer bindings for fragment shader.\n */\nfunction buildFragmentStorageBufferBindings(\n\tstorageBufferKeys: string[],\n\tdefinitions: Record<string, { type: StorageBufferType }>\n): string {\n\tif (storageBufferKeys.length === 0) {\n\t\treturn '';\n\t}\n\n\tconst declarations: string[] = [];\n\n\tfor (let index = 0; index < storageBufferKeys.length; index += 1) {\n\t\tconst key = storageBufferKeys[index];\n\t\tif (key === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst definition = definitions[key];\n\t\tif (!definition) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tdeclarations.push(\n\t\t\t`@group(1) @binding(${index}) var<storage, read> ${key}: ${definition.type};`\n\t\t);\n\t}\n\n\treturn declarations.join('\\n');\n}\n\n/**\n * Optionally returns helper WGSL for linear-to-sRGB conversion.\n */\nfunction buildColorTransformHelpers(enableSrgbTransform: boolean): string {\n\tif (!enableSrgbTransform) {\n\t\treturn '';\n\t}\n\n\treturn `\nfn motiongpuLinearToSrgb(linearColor: vec3f) -> vec3f {\n\tlet cutoff = vec3f(0.0031308);\n\tlet lower = linearColor * 12.92;\n\tlet higher = vec3f(1.055) * pow(linearColor, vec3f(1.0 / 2.4)) - vec3f(0.055);\n\treturn select(lower, higher, linearColor > cutoff);\n}\n`;\n}\n\n/**\n * Builds fragment output code with optional color-space conversion.\n */\nfunction buildFragmentOutput(keepAliveExpression: string, enableSrgbTransform: boolean): string {\n\tif (enableSrgbTransform) {\n\t\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\tlet motiongpuLinear = vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n\tlet motiongpuSrgb = motiongpuLinearToSrgb(max(motiongpuLinear.rgb, vec3f(0.0)));\n\treturn vec4f(motiongpuSrgb, motiongpuLinear.a);\n`;\n\t}\n\n\treturn `\n\tlet fragColor = frag(in.uv);\n\tlet motiongpuKeepAlive = ${keepAliveExpression};\n\treturn vec4f(fragColor.rgb + motiongpuKeepAlive * 0.0, fragColor.a);\n`;\n}\n\n/**\n * 1-based map from generated WGSL lines to original material source lines.\n */\nexport type ShaderLineMap = Array<(MaterialSourceLocation | ComputeShaderSourceLocation) | null>;\n\n/**\n * Result of shader source generation with line mapping metadata.\n */\nexport interface BuiltShaderSource {\n\t/**\n\t * Full WGSL source code.\n\t */\n\tcode: string;\n\t/**\n\t * 1-based generated-line map to material source locations.\n\t */\n\tlineMap: ShaderLineMap;\n}\n\n/**\n * Assembles complete WGSL shader source used by the fullscreen renderer pipeline.\n *\n * @param fragmentWgsl - User fragment shader code containing `frag(uv: vec2f) -> vec4f`.\n * @param uniformLayout - Resolved uniform layout.\n * @param textureKeys - Sorted texture keys.\n * @param options - Shader build options.\n * @returns Complete WGSL source for vertex + fragment stages.\n */\nexport function buildShaderSource(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): string {\n\tconst uniformFields = buildUniformStruct(uniformLayout);\n\tconst keepAliveExpression = getKeepAliveExpression(uniformLayout);\n\tconst textureBindings = buildTextureBindings(textureKeys);\n\tconst enableSrgbTransform = options?.convertLinearToSrgb ?? false;\n\tconst colorTransformHelpers = buildColorTransformHelpers(enableSrgbTransform);\n\tconst fragmentOutput = buildFragmentOutput(keepAliveExpression, enableSrgbTransform);\n\tconst storageBufferBindings = buildFragmentStorageBufferBindings(\n\t\toptions?.storageBufferKeys ?? [],\n\t\toptions?.storageBufferDefinitions ?? {}\n\t);\n\n\treturn `\nstruct MotionGPUFrame {\n\ttime: f32,\n\tdelta: f32,\n\tresolution: vec2f,\n};\n\nstruct MotionGPUUniforms {\n\t${uniformFields}\n};\n\n@group(0) @binding(0) var<uniform> motiongpuFrame: MotionGPUFrame;\n@group(0) @binding(1) var<uniform> motiongpuUniforms: MotionGPUUniforms;\n${textureBindings}\n${storageBufferBindings ? '\\n' + storageBufferBindings : ''}\n${colorTransformHelpers}\n\nstruct MotionGPUVertexOut {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n};\n\n@vertex\nfn motiongpuVertex(@builtin(vertex_index) index: u32) -> MotionGPUVertexOut {\n\tvar positions = array<vec2f, 3>(\n\t\tvec2f(-1.0, -3.0),\n\t\tvec2f(-1.0, 1.0),\n\t\tvec2f(3.0, 1.0)\n\t);\n\n\tlet position = positions[index];\n\tvar out: MotionGPUVertexOut;\n\tout.position = vec4f(position, 0.0, 1.0);\n\tout.uv = (position + vec2f(1.0, 1.0)) * 0.5;\n\treturn out;\n}\n\n${fragmentWgsl}\n\n@fragment\nfn motiongpuFragment(in: MotionGPUVertexOut) -> @location(0) vec4f {\n\t${fragmentOutput}\n}\n`;\n}\n\n/**\n * Assembles complete WGSL shader source with material-source line mapping metadata.\n */\nexport function buildShaderSourceWithMap(\n\tfragmentWgsl: string,\n\tuniformLayout: UniformLayout,\n\ttextureKeys: string[] = [],\n\toptions?: {\n\t\tconvertLinearToSrgb?: boolean;\n\t\tfragmentLineMap?: MaterialLineMap;\n\t\tstorageBufferKeys?: string[];\n\t\tstorageBufferDefinitions?: Record<string, { type: StorageBufferType }>;\n\t}\n): BuiltShaderSource {\n\tconst code = buildShaderSource(fragmentWgsl, uniformLayout, textureKeys, options);\n\tconst fragmentStartIndex = code.indexOf(fragmentWgsl);\n\tconst lineCount = code.split('\\n').length;\n\tconst lineMap: ShaderLineMap = new Array(lineCount + 1).fill(null);\n\n\tif (fragmentStartIndex === -1) {\n\t\treturn {\n\t\t\tcode,\n\t\t\tlineMap\n\t\t};\n\t}\n\n\tconst fragmentStartLine = code.slice(0, fragmentStartIndex).split('\\n').length;\n\tconst fragmentLineCount = fragmentWgsl.split('\\n').length;\n\n\tfor (let line = 0; line < fragmentLineCount; line += 1) {\n\t\tconst generatedLine = fragmentStartLine + line;\n\t\tlineMap[generatedLine] = options?.fragmentLineMap?.[line + 1] ?? {\n\t\t\tkind: 'fragment',\n\t\t\tline: line + 1\n\t\t};\n\t}\n\n\treturn {\n\t\tcode,\n\t\tlineMap\n\t};\n}\n\n/**\n * Converts source location metadata to user-facing diagnostics label.\n */\nexport function formatShaderSourceLocation(\n\tlocation: (MaterialSourceLocation | ComputeShaderSourceLocation) | null\n): string | null {\n\tif (!location) {\n\t\treturn null;\n\t}\n\n\tif (location.kind === 'fragment') {\n\t\treturn `fragment line ${location.line}`;\n\t}\n\n\tif (location.kind === 'include') {\n\t\treturn `include <${location.include}> line ${location.line}`;\n\t}\n\n\tif (location.kind === 'compute') {\n\t\treturn `compute line ${location.line}`;\n\t}\n\n\treturn `define \"${location.define}\" line ${location.line}`;\n}\n"],"mappings":";;;;;AAYA,IAAM,wBAAwB;;;;AAK9B,SAAS,mBAAmB,QAA+B;AAC1D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;AAGR,QAAO,OAAO,QACZ,KAAK,UAAU;AACf,oBAAkB,MAAM,KAAK;AAC7B,SAAO,GAAG,MAAM,KAAK,IAAI,MAAM,KAAK;GACnC,CACD,KAAK,MAAO;;;;;AAMf,SAAS,uBAAuB,QAA+B;AAC9D,KAAI,OAAO,QAAQ,WAAW,EAC7B,QAAO;CAGR,MAAM,CAAC,cAAc,OAAO;AAC5B,KAAI,CAAC,WACJ,QAAO;AAGR,KAAI,WAAW,SAAS,MACvB,QAAO,qBAAqB,WAAW;AAGxC,KAAI,WAAW,SAAS,UACvB,QAAO,qBAAqB,WAAW,KAAK;AAG7C,QAAO,qBAAqB,WAAW,KAAK;;;;;AAM7C,SAAS,qBAAqB,aAA+B;AAC5D,KAAI,YAAY,WAAW,EAC1B,QAAO;CAGR,MAAM,eAAyB,EAAE;AAEjC,MAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,QAAQ,SAAS,GAAG;EAC3D,MAAM,MAAM,YAAY;AACxB,MAAI,QAAQ,OACX;AAGD,oBAAkB,IAAI;EACtB,MAAM,UAAU,IAAI,QAAQ;AAC5B,eAAa,KAAK,sBAAsB,QAAQ,QAAQ,IAAI,mBAAmB;AAC/E,eAAa,KAAK,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AAE,EAC1B,SAMoB;CACpB,MAAM,OAAO,kBAAkB,cAAc,eAAe,aAAa,QAAQ;CACjF,MAAM,qBAAqB,KAAK,QAAQ,aAAa;CACrD,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC;CACnC,MAAM,UAAyB,IAAI,MAAM,YAAY,EAAE,CAAC,KAAK,KAAK;AAElE,KAAI,uBAAuB,GAC1B,QAAO;EACN;EACA;EACA;CAGF,MAAM,oBAAoB,KAAK,MAAM,GAAG,mBAAmB,CAAC,MAAM,KAAK,CAAC;CACxE,MAAM,oBAAoB,aAAa,MAAM,KAAK,CAAC;AAEnD,MAAK,IAAI,OAAO,GAAG,OAAO,mBAAmB,QAAQ,GAAG;EACvD,MAAM,gBAAgB,oBAAoB;AAC1C,UAAQ,iBAAiB,SAAS,kBAAkB,OAAO,MAAM;GAChE,MAAM;GACN,MAAM,OAAO;GACb;;AAGF,QAAO;EACN;EACA;EACA;;;;;AAMF,SAAgB,2BACf,UACgB;AAChB,KAAI,CAAC,SACJ,QAAO;AAGR,KAAI,SAAS,SAAS,WACrB,QAAO,iBAAiB,SAAS;AAGlC,KAAI,SAAS,SAAS,UACrB,QAAO,YAAY,SAAS,QAAQ,SAAS,SAAS;AAGvD,KAAI,SAAS,SAAS,UACrB,QAAO,gBAAgB,SAAS;AAGjC,QAAO,WAAW,SAAS,OAAO,SAAS,SAAS"}
|
package/dist/core/textures.d.ts
CHANGED
|
@@ -52,6 +52,10 @@ export interface NormalizedTextureDefinition {
|
|
|
52
52
|
* Whether this texture is a storage texture (writable by compute).
|
|
53
53
|
*/
|
|
54
54
|
storage: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether this texture should be exposed as a fragment-stage sampled binding.
|
|
57
|
+
*/
|
|
58
|
+
fragmentVisible: boolean;
|
|
55
59
|
/**
|
|
56
60
|
* Explicit width for storage textures. Undefined when derived from source.
|
|
57
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textures.d.ts","sourceRoot":"","sources":["../../src/lib/core/textures.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACX,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IACrB;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IACzB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;IAC7B;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;IAC7B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAYD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAM3E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,UAAU,EAAE,iBAAiB,GAAG,SAAS,GACvC,2BAA2B,
|
|
1
|
+
{"version":3,"file":"textures.d.ts","sourceRoot":"","sources":["../../src/lib/core/textures.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACX,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,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wBAAwB,CAAC,KAAK,EAAE;IAC/C,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,WAAW,CAAC,EAAE,iBAAiB,CAAC;CAChC,GAAG,iBAAiB,CAcpB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAkBA;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAY7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,gBAAgB,CAE9F"}
|
package/dist/core/textures.js
CHANGED
|
@@ -39,7 +39,8 @@ function normalizeTextureDefinition(definition) {
|
|
|
39
39
|
filter: definition?.filter ?? DEFAULT_TEXTURE_FILTER,
|
|
40
40
|
addressModeU: definition?.addressModeU ?? DEFAULT_TEXTURE_ADDRESS_MODE,
|
|
41
41
|
addressModeV: definition?.addressModeV ?? DEFAULT_TEXTURE_ADDRESS_MODE,
|
|
42
|
-
storage: isStorage
|
|
42
|
+
storage: isStorage,
|
|
43
|
+
fragmentVisible: definition?.fragmentVisible ?? true
|
|
43
44
|
};
|
|
44
45
|
if (definition?.width !== void 0) normalized.width = definition.width;
|
|
45
46
|
if (definition?.height !== void 0) normalized.height = definition.height;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textures.js","names":[],"sources":["../../src/lib/core/textures.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type {\n\tTextureData,\n\tTextureDefinition,\n\tTextureDefinitionMap,\n\tTextureUpdateMode,\n\tTextureValue\n} from './types.js';\n\n/**\n * Texture definition with defaults and normalized numeric limits applied.\n */\nexport interface NormalizedTextureDefinition {\n\t/**\n\t * Normalized source value.\n\t */\n\tsource: TextureValue;\n\t/**\n\t * Effective color space.\n\t */\n\tcolorSpace: 'srgb' | 'linear';\n\t/**\n\t * Effective texture format.\n\t */\n\tformat: GPUTextureFormat;\n\t/**\n\t * Effective flip-y flag.\n\t */\n\tflipY: boolean;\n\t/**\n\t * Effective mipmap toggle.\n\t */\n\tgenerateMipmaps: boolean;\n\t/**\n\t * Effective premultiplied-alpha flag.\n\t */\n\tpremultipliedAlpha: boolean;\n\t/**\n\t * Effective dynamic update strategy.\n\t */\n\tupdate?: TextureUpdateMode;\n\t/**\n\t * Effective anisotropy level.\n\t */\n\tanisotropy: number;\n\t/**\n\t * Effective filter mode.\n\t */\n\tfilter: GPUFilterMode;\n\t/**\n\t * Effective U address mode.\n\t */\n\taddressModeU: GPUAddressMode;\n\t/**\n\t * Effective V address mode.\n\t */\n\taddressModeV: GPUAddressMode;\n\t/**\n\t * Whether this texture is a storage texture (writable by compute).\n\t */\n\tstorage: boolean;\n\t/**\n\t * Explicit width for storage textures. Undefined when derived from source.\n\t */\n\twidth?: number;\n\t/**\n\t * Explicit height for storage textures. Undefined when derived from source.\n\t */\n\theight?: number;\n}\n\n/**\n * Default sampling filter for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_FILTER: GPUFilterMode = 'linear';\n\n/**\n * Default addressing mode for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_ADDRESS_MODE: GPUAddressMode = 'clamp-to-edge';\n\n/**\n * Validates and returns sorted texture keys.\n *\n * @param textures - Texture definition map.\n * @returns Lexicographically sorted texture keys.\n */\nexport function resolveTextureKeys(textures: TextureDefinitionMap): string[] {\n\tconst keys = Object.keys(textures).sort();\n\tfor (const key of keys) {\n\t\tassertUniformName(key);\n\t}\n\treturn keys;\n}\n\n/**\n * Applies defaults and clamps to a single texture definition.\n *\n * @param definition - Optional texture definition.\n * @returns Normalized definition with deterministic defaults.\n */\nexport function normalizeTextureDefinition(\n\tdefinition: TextureDefinition | undefined\n): NormalizedTextureDefinition {\n\tconst isStorage = definition?.storage === true;\n\tconst defaultFormat = definition?.colorSpace === 'linear' ? 'rgba8unorm' : 'rgba8unorm-srgb';\n\tconst normalized: NormalizedTextureDefinition = {\n\t\tsource: definition?.source ?? null,\n\t\tcolorSpace: definition?.colorSpace ?? 'srgb',\n\t\tformat: definition?.format ?? defaultFormat,\n\t\tflipY: definition?.flipY ?? true,\n\t\tgenerateMipmaps: definition?.generateMipmaps ?? false,\n\t\tpremultipliedAlpha: definition?.premultipliedAlpha ?? false,\n\t\tanisotropy: Math.max(1, Math.min(16, Math.floor(definition?.anisotropy ?? 1))),\n\t\tfilter: definition?.filter ?? DEFAULT_TEXTURE_FILTER,\n\t\taddressModeU: definition?.addressModeU ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\taddressModeV: definition?.addressModeV ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\tstorage: isStorage\n\t};\n\n\tif (definition?.width !== undefined) {\n\t\tnormalized.width = definition.width;\n\t}\n\tif (definition?.height !== undefined) {\n\t\tnormalized.height = definition.height;\n\t}\n\n\tif (definition?.update !== undefined) {\n\t\tnormalized.update = definition.update;\n\t}\n\n\treturn normalized;\n}\n\n/**\n * Normalizes all texture definitions for already-resolved texture keys.\n *\n * @param textures - Source texture definitions.\n * @param textureKeys - Texture keys to normalize.\n * @returns Normalized map keyed by `textureKeys`.\n */\nexport function normalizeTextureDefinitions(\n\ttextures: TextureDefinitionMap,\n\ttextureKeys: string[]\n): Record<string, NormalizedTextureDefinition> {\n\tconst out: Record<string, NormalizedTextureDefinition> = {};\n\tfor (const key of textureKeys) {\n\t\tout[key] = normalizeTextureDefinition(textures[key]);\n\t}\n\treturn out;\n}\n\n/**\n * Checks whether a texture value is a structured `{ source, width?, height? }` object.\n */\nexport function isTextureData(value: TextureValue): value is TextureData {\n\treturn typeof value === 'object' && value !== null && 'source' in value;\n}\n\n/**\n * Converts supported texture input variants to normalized `TextureData`.\n *\n * @param value - Texture value input.\n * @returns Structured texture data or `null`.\n */\nexport function toTextureData(value: TextureValue): TextureData | null {\n\tif (value === null) {\n\t\treturn null;\n\t}\n\n\tif (isTextureData(value)) {\n\t\treturn value;\n\t}\n\n\treturn { source: value };\n}\n\n/**\n * Resolves effective runtime texture update strategy.\n */\nexport function resolveTextureUpdateMode(input: {\n\tsource: TextureData['source'];\n\toverride?: TextureUpdateMode;\n\tdefaultMode?: TextureUpdateMode;\n}): TextureUpdateMode {\n\tif (input.override) {\n\t\treturn input.override;\n\t}\n\n\tif (input.defaultMode) {\n\t\treturn input.defaultMode;\n\t}\n\n\tif (isVideoTextureSource(input.source)) {\n\t\treturn 'perFrame';\n\t}\n\n\treturn 'once';\n}\n\n/**\n * Resolves texture dimensions from explicit values or source metadata.\n *\n * @param data - Texture payload.\n * @returns Positive integer width/height.\n * @throws {Error} When dimensions cannot be resolved to positive values.\n */\nexport function resolveTextureSize(data: TextureData): {\n\twidth: number;\n\theight: number;\n} {\n\tconst source = data.source as {\n\t\twidth?: number;\n\t\theight?: number;\n\t\tnaturalWidth?: number;\n\t\tnaturalHeight?: number;\n\t\tvideoWidth?: number;\n\t\tvideoHeight?: number;\n\t};\n\n\tconst width = data.width ?? source.naturalWidth ?? source.videoWidth ?? source.width ?? 0;\n\tconst height = data.height ?? source.naturalHeight ?? source.videoHeight ?? source.height ?? 0;\n\n\tif (width <= 0 || height <= 0) {\n\t\tthrow new Error('Texture source must have positive width and height');\n\t}\n\n\treturn { width, height };\n}\n\n/**\n * Computes the number of mipmap levels for a base texture size.\n *\n * @param width - Base width.\n * @param height - Base height.\n * @returns Total mip level count (minimum `1`).\n */\nexport function getTextureMipLevelCount(width: number, height: number): number {\n\tlet levels = 1;\n\tlet currentWidth = Math.max(1, width);\n\tlet currentHeight = Math.max(1, height);\n\n\twhile (currentWidth > 1 || currentHeight > 1) {\n\t\tcurrentWidth = Math.max(1, Math.floor(currentWidth / 2));\n\t\tcurrentHeight = Math.max(1, Math.floor(currentHeight / 2));\n\t\tlevels += 1;\n\t}\n\n\treturn levels;\n}\n\n/**\n * Checks whether the source is an `HTMLVideoElement`.\n */\nexport function isVideoTextureSource(source: TextureData['source']): source is HTMLVideoElement {\n\treturn typeof HTMLVideoElement !== 'undefined' && source instanceof HTMLVideoElement;\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"textures.js","names":[],"sources":["../../src/lib/core/textures.ts"],"sourcesContent":["import { assertUniformName } from './uniforms.js';\nimport type {\n\tTextureData,\n\tTextureDefinition,\n\tTextureDefinitionMap,\n\tTextureUpdateMode,\n\tTextureValue\n} from './types.js';\n\n/**\n * Texture definition with defaults and normalized numeric limits applied.\n */\nexport interface NormalizedTextureDefinition {\n\t/**\n\t * Normalized source value.\n\t */\n\tsource: TextureValue;\n\t/**\n\t * Effective color space.\n\t */\n\tcolorSpace: 'srgb' | 'linear';\n\t/**\n\t * Effective texture format.\n\t */\n\tformat: GPUTextureFormat;\n\t/**\n\t * Effective flip-y flag.\n\t */\n\tflipY: boolean;\n\t/**\n\t * Effective mipmap toggle.\n\t */\n\tgenerateMipmaps: boolean;\n\t/**\n\t * Effective premultiplied-alpha flag.\n\t */\n\tpremultipliedAlpha: boolean;\n\t/**\n\t * Effective dynamic update strategy.\n\t */\n\tupdate?: TextureUpdateMode;\n\t/**\n\t * Effective anisotropy level.\n\t */\n\tanisotropy: number;\n\t/**\n\t * Effective filter mode.\n\t */\n\tfilter: GPUFilterMode;\n\t/**\n\t * Effective U address mode.\n\t */\n\taddressModeU: GPUAddressMode;\n\t/**\n\t * Effective V address mode.\n\t */\n\taddressModeV: GPUAddressMode;\n\t/**\n\t * Whether this texture is a storage texture (writable by compute).\n\t */\n\tstorage: boolean;\n\t/**\n\t * Whether this texture should be exposed as a fragment-stage sampled binding.\n\t */\n\tfragmentVisible: boolean;\n\t/**\n\t * Explicit width for storage textures. Undefined when derived from source.\n\t */\n\twidth?: number;\n\t/**\n\t * Explicit height for storage textures. Undefined when derived from source.\n\t */\n\theight?: number;\n}\n\n/**\n * Default sampling filter for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_FILTER: GPUFilterMode = 'linear';\n\n/**\n * Default addressing mode for textures when no explicit value is provided.\n */\nconst DEFAULT_TEXTURE_ADDRESS_MODE: GPUAddressMode = 'clamp-to-edge';\n\n/**\n * Validates and returns sorted texture keys.\n *\n * @param textures - Texture definition map.\n * @returns Lexicographically sorted texture keys.\n */\nexport function resolveTextureKeys(textures: TextureDefinitionMap): string[] {\n\tconst keys = Object.keys(textures).sort();\n\tfor (const key of keys) {\n\t\tassertUniformName(key);\n\t}\n\treturn keys;\n}\n\n/**\n * Applies defaults and clamps to a single texture definition.\n *\n * @param definition - Optional texture definition.\n * @returns Normalized definition with deterministic defaults.\n */\nexport function normalizeTextureDefinition(\n\tdefinition: TextureDefinition | undefined\n): NormalizedTextureDefinition {\n\tconst isStorage = definition?.storage === true;\n\tconst defaultFormat = definition?.colorSpace === 'linear' ? 'rgba8unorm' : 'rgba8unorm-srgb';\n\tconst normalized: NormalizedTextureDefinition = {\n\t\tsource: definition?.source ?? null,\n\t\tcolorSpace: definition?.colorSpace ?? 'srgb',\n\t\tformat: definition?.format ?? defaultFormat,\n\t\tflipY: definition?.flipY ?? true,\n\t\tgenerateMipmaps: definition?.generateMipmaps ?? false,\n\t\tpremultipliedAlpha: definition?.premultipliedAlpha ?? false,\n\t\tanisotropy: Math.max(1, Math.min(16, Math.floor(definition?.anisotropy ?? 1))),\n\t\tfilter: definition?.filter ?? DEFAULT_TEXTURE_FILTER,\n\t\taddressModeU: definition?.addressModeU ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\taddressModeV: definition?.addressModeV ?? DEFAULT_TEXTURE_ADDRESS_MODE,\n\t\tstorage: isStorage,\n\t\tfragmentVisible: definition?.fragmentVisible ?? true\n\t};\n\n\tif (definition?.width !== undefined) {\n\t\tnormalized.width = definition.width;\n\t}\n\tif (definition?.height !== undefined) {\n\t\tnormalized.height = definition.height;\n\t}\n\n\tif (definition?.update !== undefined) {\n\t\tnormalized.update = definition.update;\n\t}\n\n\treturn normalized;\n}\n\n/**\n * Normalizes all texture definitions for already-resolved texture keys.\n *\n * @param textures - Source texture definitions.\n * @param textureKeys - Texture keys to normalize.\n * @returns Normalized map keyed by `textureKeys`.\n */\nexport function normalizeTextureDefinitions(\n\ttextures: TextureDefinitionMap,\n\ttextureKeys: string[]\n): Record<string, NormalizedTextureDefinition> {\n\tconst out: Record<string, NormalizedTextureDefinition> = {};\n\tfor (const key of textureKeys) {\n\t\tout[key] = normalizeTextureDefinition(textures[key]);\n\t}\n\treturn out;\n}\n\n/**\n * Checks whether a texture value is a structured `{ source, width?, height? }` object.\n */\nexport function isTextureData(value: TextureValue): value is TextureData {\n\treturn typeof value === 'object' && value !== null && 'source' in value;\n}\n\n/**\n * Converts supported texture input variants to normalized `TextureData`.\n *\n * @param value - Texture value input.\n * @returns Structured texture data or `null`.\n */\nexport function toTextureData(value: TextureValue): TextureData | null {\n\tif (value === null) {\n\t\treturn null;\n\t}\n\n\tif (isTextureData(value)) {\n\t\treturn value;\n\t}\n\n\treturn { source: value };\n}\n\n/**\n * Resolves effective runtime texture update strategy.\n */\nexport function resolveTextureUpdateMode(input: {\n\tsource: TextureData['source'];\n\toverride?: TextureUpdateMode;\n\tdefaultMode?: TextureUpdateMode;\n}): TextureUpdateMode {\n\tif (input.override) {\n\t\treturn input.override;\n\t}\n\n\tif (input.defaultMode) {\n\t\treturn input.defaultMode;\n\t}\n\n\tif (isVideoTextureSource(input.source)) {\n\t\treturn 'perFrame';\n\t}\n\n\treturn 'once';\n}\n\n/**\n * Resolves texture dimensions from explicit values or source metadata.\n *\n * @param data - Texture payload.\n * @returns Positive integer width/height.\n * @throws {Error} When dimensions cannot be resolved to positive values.\n */\nexport function resolveTextureSize(data: TextureData): {\n\twidth: number;\n\theight: number;\n} {\n\tconst source = data.source as {\n\t\twidth?: number;\n\t\theight?: number;\n\t\tnaturalWidth?: number;\n\t\tnaturalHeight?: number;\n\t\tvideoWidth?: number;\n\t\tvideoHeight?: number;\n\t};\n\n\tconst width = data.width ?? source.naturalWidth ?? source.videoWidth ?? source.width ?? 0;\n\tconst height = data.height ?? source.naturalHeight ?? source.videoHeight ?? source.height ?? 0;\n\n\tif (width <= 0 || height <= 0) {\n\t\tthrow new Error('Texture source must have positive width and height');\n\t}\n\n\treturn { width, height };\n}\n\n/**\n * Computes the number of mipmap levels for a base texture size.\n *\n * @param width - Base width.\n * @param height - Base height.\n * @returns Total mip level count (minimum `1`).\n */\nexport function getTextureMipLevelCount(width: number, height: number): number {\n\tlet levels = 1;\n\tlet currentWidth = Math.max(1, width);\n\tlet currentHeight = Math.max(1, height);\n\n\twhile (currentWidth > 1 || currentHeight > 1) {\n\t\tcurrentWidth = Math.max(1, Math.floor(currentWidth / 2));\n\t\tcurrentHeight = Math.max(1, Math.floor(currentHeight / 2));\n\t\tlevels += 1;\n\t}\n\n\treturn levels;\n}\n\n/**\n * Checks whether the source is an `HTMLVideoElement`.\n */\nexport function isVideoTextureSource(source: TextureData['source']): source is HTMLVideoElement {\n\treturn typeof HTMLVideoElement !== 'undefined' && source instanceof HTMLVideoElement;\n}\n"],"mappings":";;;;;AA8EA,IAAM,yBAAwC;;;;AAK9C,IAAM,+BAA+C;;;;;;;AAQrD,SAAgB,mBAAmB,UAA0C;CAC5E,MAAM,OAAO,OAAO,KAAK,SAAS,CAAC,MAAM;AACzC,MAAK,MAAM,OAAO,KACjB,mBAAkB,IAAI;AAEvB,QAAO;;;;;;;;AASR,SAAgB,2BACf,YAC8B;CAC9B,MAAM,YAAY,YAAY,YAAY;CAC1C,MAAM,gBAAgB,YAAY,eAAe,WAAW,eAAe;CAC3E,MAAM,aAA0C;EAC/C,QAAQ,YAAY,UAAU;EAC9B,YAAY,YAAY,cAAc;EACtC,QAAQ,YAAY,UAAU;EAC9B,OAAO,YAAY,SAAS;EAC5B,iBAAiB,YAAY,mBAAmB;EAChD,oBAAoB,Y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BAAwB,OAAe,QAAwB;CAC9E,IAAI,SAAS;CACb,IAAI,eAAe,KAAK,IAAI,GAAG,MAAM;CACrC,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO;AAEvC,QAAO,eAAe,KAAK,gBAAgB,GAAG;AAC7C,iBAAe,KAAK,IAAI,GAAG,KAAK,MAAM,eAAe,EAAE,CAAC;AACxD,kBAAgB,KAAK,IAAI,GAAG,KAAK,MAAM,gBAAgB,EAAE,CAAC;AAC1D,YAAU;;AAGX,QAAO;;;;;AAMR,SAAgB,qBAAqB,QAA2D;AAC/F,QAAO,OAAO,qBAAqB,eAAe,kBAAkB"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -663,7 +663,7 @@ export interface Renderer {
|
|
|
663
663
|
width: number;
|
|
664
664
|
height: number;
|
|
665
665
|
};
|
|
666
|
-
pendingStorageWrites?: PendingStorageWrite[];
|
|
666
|
+
pendingStorageWrites?: PendingStorageWrite[] | undefined;
|
|
667
667
|
}) => void;
|
|
668
668
|
/**
|
|
669
669
|
* Returns the GPU buffer for a named storage buffer, if allocated.
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/core/types.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AAE1E;;;;;GAKG;AACH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,MAAM,EAAE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AE,MAAM,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB"}
|
package/dist/react/advanced.js
CHANGED
|
@@ -8,7 +8,8 @@ import { applySchedulerPreset, captureSchedulerDebugSnapshot } from "../core/sch
|
|
|
8
8
|
import { useMotionGPU } from "./motiongpu-context.js";
|
|
9
9
|
import { useFrame } from "./frame-context.js";
|
|
10
10
|
import { FragCanvas } from "./FragCanvas.js";
|
|
11
|
+
import { usePointer } from "./use-pointer.js";
|
|
11
12
|
import { useTexture } from "./use-texture.js";
|
|
12
13
|
import "./index.js";
|
|
13
14
|
import { setMotionGPUUserContext, useMotionGPUUserContext, useSetMotionGPUUserContext } from "./use-motiongpu-user-context.js";
|
|
14
|
-
export { BlitPass, ComputePass, CopyPass, FragCanvas, PingPongComputePass, ShaderPass, applySchedulerPreset, captureSchedulerDebugSnapshot, defineMaterial, setMotionGPUUserContext, useFrame, useMotionGPU, useMotionGPUUserContext, useSetMotionGPUUserContext, useTexture };
|
|
15
|
+
export { BlitPass, ComputePass, CopyPass, FragCanvas, PingPongComputePass, ShaderPass, applySchedulerPreset, captureSchedulerDebugSnapshot, defineMaterial, setMotionGPUUserContext, useFrame, useMotionGPU, useMotionGPUUserContext, usePointer, useSetMotionGPUUserContext, useTexture };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -6,12 +6,14 @@ export { defineMaterial } from '../core/material.js';
|
|
|
6
6
|
export { BlitPass, CopyPass, ShaderPass, ComputePass, PingPongComputePass } from '../passes/index.js';
|
|
7
7
|
export { useMotionGPU } from './motiongpu-context.js';
|
|
8
8
|
export { useFrame } from './frame-context.js';
|
|
9
|
+
export { usePointer } from './use-pointer.js';
|
|
9
10
|
export { useTexture } from './use-texture.js';
|
|
10
11
|
export type { FrameInvalidationToken, FrameState, OutputColorSpace, AnyPass, ComputePassLike, RenderPass, RenderPassContext, RenderPassFlags, RenderPassInputSlot, RenderPassOutputSlot, RenderMode, RenderTarget, RenderTargetDefinition, RenderTargetDefinitionMap, TextureData, TextureDefinition, TextureDefinitionMap, TextureUpdateMode, TextureMap, TextureSource, TextureValue, TypedUniform, UniformMat4Value, UniformMap, UniformType, UniformValue } from '../core/types.js';
|
|
11
12
|
export type { LoadedTexture, TextureDecodeOptions, TextureLoadOptions } from '../core/texture-loader.js';
|
|
12
13
|
export type { FragMaterial, FragMaterialInput, MaterialIncludes, MaterialDefineValue, MaterialDefines, TypedMaterialDefineValue } from '../core/material.js';
|
|
13
14
|
export type { MotionGPUContext } from './motiongpu-context.js';
|
|
14
15
|
export type { UseFrameOptions, UseFrameResult } from './frame-context.js';
|
|
16
|
+
export type { PointerClick, PointerFrameRequestMode, PointerKind, PointerPoint, PointerState, UsePointerOptions, UsePointerResult } from './use-pointer.js';
|
|
15
17
|
export type { TextureUrlInput, UseTextureResult } from './use-texture.js';
|
|
16
18
|
export type { StorageBufferAccess, StorageBufferDefinition, StorageBufferDefinitionMap, StorageBufferType, ComputePassContext } from '../core/types.js';
|
|
17
19
|
export type { ComputePassOptions, ComputeDispatchContext } from '../passes/ComputePass.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/react/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EACX,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,eAAe,EACf,UAAU,EACV,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BAA0B,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -8,5 +8,6 @@ import "../passes/index.js";
|
|
|
8
8
|
import { useMotionGPU } from "./motiongpu-context.js";
|
|
9
9
|
import { useFrame } from "./frame-context.js";
|
|
10
10
|
import { FragCanvas } from "./FragCanvas.js";
|
|
11
|
+
import { usePointer } from "./use-pointer.js";
|
|
11
12
|
import { useTexture } from "./use-texture.js";
|
|
12
|
-
export { BlitPass, ComputePass, CopyPass, FragCanvas, PingPongComputePass, ShaderPass, defineMaterial, useFrame, useMotionGPU, useTexture };
|
|
13
|
+
export { BlitPass, ComputePass, CopyPass, FragCanvas, PingPongComputePass, ShaderPass, defineMaterial, useFrame, useMotionGPU, usePointer, useTexture };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type CurrentReadable } from '../core/current-value.js';
|
|
2
|
+
import { type PointerClick, type PointerFrameRequestMode, type PointerState } from '../core/pointer.js';
|
|
3
|
+
export type { PointerClick, PointerFrameRequestMode, PointerKind, PointerPoint, PointerState } from '../core/pointer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for pointer input handling in `usePointer`.
|
|
6
|
+
*/
|
|
7
|
+
export interface UsePointerOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Enables pointer listeners.
|
|
10
|
+
*
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Frame wake-up strategy for pointer-driven state changes.
|
|
16
|
+
*
|
|
17
|
+
* @default 'auto'
|
|
18
|
+
*/
|
|
19
|
+
requestFrame?: PointerFrameRequestMode;
|
|
20
|
+
/**
|
|
21
|
+
* Requests pointer capture on pointer down.
|
|
22
|
+
*
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
capturePointer?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Tracks pointer move/up outside canvas while pointer is pressed.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
trackWhilePressedOutsideCanvas?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Enables click/tap synthesis on pointer up.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
clickEnabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum press duration to consider pointer up a click (milliseconds).
|
|
40
|
+
*
|
|
41
|
+
* @default 350
|
|
42
|
+
*/
|
|
43
|
+
clickMaxDurationMs?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum pointer travel from down to up to consider pointer up a click (pixels).
|
|
46
|
+
*
|
|
47
|
+
* @default 8
|
|
48
|
+
*/
|
|
49
|
+
clickMaxMovePx?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Allowed pointer buttons for click synthesis.
|
|
52
|
+
*
|
|
53
|
+
* @default [0]
|
|
54
|
+
*/
|
|
55
|
+
clickButtons?: number[];
|
|
56
|
+
/**
|
|
57
|
+
* Called after pointer move state update.
|
|
58
|
+
*/
|
|
59
|
+
onMove?: (state: PointerState, event: PointerEvent) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Called after pointer down state update.
|
|
62
|
+
*/
|
|
63
|
+
onDown?: (state: PointerState, event: PointerEvent) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Called after pointer up/cancel state update.
|
|
66
|
+
*/
|
|
67
|
+
onUp?: (state: PointerState, event: PointerEvent) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Called when click/tap is synthesized.
|
|
70
|
+
*/
|
|
71
|
+
onClick?: (click: PointerClick, state: PointerState, event: PointerEvent) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reactive state returned by `usePointer`.
|
|
75
|
+
*/
|
|
76
|
+
export interface UsePointerResult {
|
|
77
|
+
/**
|
|
78
|
+
* Current pointer state.
|
|
79
|
+
*/
|
|
80
|
+
state: CurrentReadable<PointerState>;
|
|
81
|
+
/**
|
|
82
|
+
* Last synthesized click/tap event.
|
|
83
|
+
*/
|
|
84
|
+
lastClick: CurrentReadable<PointerClick | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Clears last click snapshot.
|
|
87
|
+
*/
|
|
88
|
+
resetClick: () => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Tracks normalized pointer coordinates and click/tap snapshots for the active `FragCanvas`.
|
|
92
|
+
*/
|
|
93
|
+
export declare function usePointer(options?: UsePointerOptions): UsePointerResult;
|
|
94
|
+
//# sourceMappingURL=use-pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pointer.d.ts","sourceRoot":"","sources":["../../src/lib/react/use-pointer.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAMN,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAEjB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACX,YAAY,EACZ,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,YAAY,CAAC,EAAE,uBAAuB,CAAC;IACvC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,YAA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