@zephyr3d/editor 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-ySiLtSxz.js → index-BZ1L8ggE.js} +43 -3
- package/dist/assistant/zephyr-types-index.json +13230 -9488
- package/dist/images/icon1024.png +0 -0
- package/dist/index.html +1 -1
- package/dist/modules/zephyr3d_backend-webgl.js +2 -0
- package/dist/modules/zephyr3d_backend-webgl.js.map +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js +457 -16
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_device.js +27 -0
- package/dist/modules/zephyr3d_device.js.map +1 -1
- package/dist/modules/zephyr3d_loaders.js +208 -1
- package/dist/modules/zephyr3d_loaders.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +774 -80
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgl/dist/capabilities_webgl.js +2 -0
- package/dist/vendor/zephyr3d/backend-webgl/dist/capabilities_webgl.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js +2 -0
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js +55 -10
- package/dist/vendor/zephyr3d/backend-webgpu/dist/commandqueue.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/computepass_webgpu.js +4 -0
- package/dist/vendor/zephyr3d/backend-webgpu/dist/computepass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/device.js +44 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +58 -5
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/timestamp_query.js +297 -0
- package/dist/vendor/zephyr3d/backend-webgpu/dist/timestamp_query.js.map +1 -0
- package/dist/vendor/zephyr3d/device/dist/base_types.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/device.js +27 -0
- package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/index.d.ts +81 -1
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js +208 -1
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js.map +1 -1
- package/dist/vendor/zephyr3d/loaders/dist/index.d.ts +8 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +334 -63
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/morphtargetgrouptrack.js +66 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/morphtargetgrouptrack.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js +9 -0
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/index.d.ts +260 -4
- package/dist/vendor/zephyr3d/scene/dist/index.js +7 -0
- package/dist/vendor/zephyr3d/scene/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/sao.js +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/sao.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/executor.js +270 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js +19 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/types.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/scene.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/scene.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +2 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js +70 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/package.json +6 -6
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\r\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\r\n * used to declare dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\r\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n\r\n /**\r\n * Resolve a framebuffer handle to the actual backend framebuffer object.\r\n *\r\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\r\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\r\n *\r\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\r\n * @returns The resolved framebuffer object (type depends on the allocator).\r\n */\r\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer managed by the graph executor.\r\n *\r\n * The framebuffer is released automatically when graph execution finishes or\r\n * aborts. Attachments may be actual backend resources or texture formats,\r\n * depending on the allocator implementation. If an attachment is an\r\n * {@link RGHandle}, the current pass must declare it with\r\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object (type depends on the allocator).\r\n */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Register a cleanup callback to run when graph execution finishes or aborts.\r\n *\r\n * Callbacks run in reverse registration order. Use this for temporary objects\r\n * created inside pass execution that are not graph resources, such as pooled\r\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\r\n * executor still runs cleanup callbacks and preserves the original pass error\r\n * ahead of cleanup errors.\r\n *\r\n * @param callback - Cleanup function to invoke after execution.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Ordered execution step inside a render graph pass.\r\n *\r\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\r\n * and access validation. They are intended to make multi-step pass bodies\r\n * explicit without splitting graph-level resource dependencies.\r\n *\r\n * @public\r\n */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Passes that must complete before this pass due to non-resource hazards. */\r\n readonly dependencies: RGPass[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes a new version of an existing resource.\r\n *\r\n * The returned handle represents the post-write version. Use it for subsequent\r\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\r\n * an older version of the same resource to `compile()` is rejected because it\r\n * usually means the caller ignored the handle returned by `write()`. If the pass\r\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\r\n * before writing.\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n * @returns A handle referencing the newly written version.\r\n */\r\n write(handle: RGHandle): RGHandle;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Create a logical dependency token produced by this pass.\r\n *\r\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\r\n * They are useful for ordering passes whose dependencies are side effects rather\r\n * than texture reads/writes.\r\n *\r\n * @param name - Debug label for this token.\r\n * @returns A handle referencing the newly created token.\r\n */\r\n createToken(name?: string): RGHandle;\r\n\r\n /**\r\n * Create a graph-managed framebuffer view.\r\n *\r\n * The graph compiler infers dependencies from any attachment handles in the\r\n * descriptor. The executor creates and releases the framebuffer automatically.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns A handle referencing the framebuffer view.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Add an ordered logical subpass to this pass.\r\n *\r\n * Subpasses execute in registration order and share the parent pass's declared\r\n * reads, writes, framebuffer views, and user data. A pass may use either\r\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\r\n *\r\n * @param name - Debug label for the subpass.\r\n * @param fn - Callback invoked when this subpass executes.\r\n */\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\r\n *\r\n * This is intentionally backend-agnostic: graph-managed descriptors may use\r\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\r\n * resources or texture formats understood by the allocator.\r\n *\r\n * @public\r\n */\r\nexport interface RGFramebufferDesc {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: unknown | unknown[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: unknown | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls `allocate()` before a resource's first use and\r\n * `release()` after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Retain a texture allocated by this allocator so it can outlive the graph pass\r\n * that produced it.\r\n *\r\n * This is used when a graph-produced transient texture must be handed off to\r\n * an external owner, such as a cross-frame history resource. Executors still\r\n * release the graph's own reference at the resource's last use; the external\r\n * owner must later call {@link RGTextureAllocator.release} for the retained\r\n * reference.\r\n *\r\n * Allocators that cannot retain transient textures should leave this undefined.\r\n */\r\n retain?(texture: TTexture): void;\r\n\r\n /**\r\n * Allocate a temporary framebuffer matching the given descriptor.\r\n *\r\n * Implementations should not auto-release this framebuffer; the graph executor\r\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object.\r\n */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Release a previously allocated temporary framebuffer.\r\n *\r\n * @param framebuffer - The framebuffer to release.\r\n */\r\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA+C;mFAExD,UAA4B;2FAE5BC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;IAEjC,WACER,CAAAA,EAAU,EACVC,IAAY,EACZI,IAAoB,EACpBC,IAA8C,EAC9CG,UAAaT,GAAAA,EAAE,CACf;QACA,IAAI,CAACA,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACG,UAAU,GAAGA,UAAAA;AACpB;AACF;AA4EA;;;;;;;;AAQC,IACM,MAAMC,SAAAA,CAAAA;IACFT,IAAa;IACbU,SAA0B;IAEnC,WAAYV,CAAAA,IAAY,EAAEU,SAAyB,CAAE;QACnD,IAAI,CAACV,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACU,SAAS,GAAGA,SAAAA;AACnB;AACF;AAEA;;;AAGC,IACM,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdZ,IAAa;AACtB,qDACSa,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC,mFACSC,YAAyB,GAAA,EAAE;sEAEpCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBP,YAAmC,IAAK;AACxC,+EACSQ,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;IAEb,WAAYP,CAAAA,KAAa,EAAEZ,IAAY,CAAE;QACvC,IAAI,CAACY,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACZ,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { AbstractDevice, TextureFormat, TimestampQueryStatus } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RGPassBuilder.createFramebuffer},\r\n * {@link RenderGraph.importTexture}, or {@link RGPassBuilder.write}. They are lightweight identifiers\r\n * used to declare dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @public\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}. The handle must be declared\r\n * by the current pass with {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n\r\n /**\r\n * Resolve a framebuffer handle to the actual backend framebuffer object.\r\n *\r\n * The handle must be declared by the current pass with {@link RGPassBuilder.read}\r\n * or created by the same pass with {@link RGPassBuilder.createFramebuffer}.\r\n *\r\n * @param handle - Handle returned from {@link RGPassBuilder.createFramebuffer}.\r\n * @returns The resolved framebuffer object (type depends on the allocator).\r\n */\r\n getFramebuffer<TFramebuffer = unknown>(handle: RGHandle): TFramebuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer managed by the graph executor.\r\n *\r\n * The framebuffer is released automatically when graph execution finishes or\r\n * aborts. Attachments may be actual backend resources or texture formats,\r\n * depending on the allocator implementation. If an attachment is an\r\n * {@link RGHandle}, the current pass must declare it with\r\n * {@link RGPassBuilder.read} or {@link RGPassBuilder.write}.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object (type depends on the allocator).\r\n */\r\n createFramebuffer<TFramebuffer = unknown>(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Register a cleanup callback to run when graph execution finishes or aborts.\r\n *\r\n * Callbacks run in reverse registration order. Use this for temporary objects\r\n * created inside pass execution that are not graph resources, such as pooled\r\n * framebuffers wrapping graph-managed textures. If pass execution throws, the\r\n * executor still runs cleanup callbacks and preserves the original pass error\r\n * ahead of cleanup errors.\r\n *\r\n * @param callback - Cleanup function to invoke after execution.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Ordered execution step inside a render graph pass.\r\n *\r\n * Subpasses share the parent pass's resource declarations, lifetime, culling,\r\n * and access validation. They are intended to make multi-step pass bodies\r\n * explicit without splitting graph-level resource dependencies.\r\n *\r\n * @public\r\n */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @public\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Passes that must complete before this pass due to non-resource hazards. */\r\n readonly dependencies: RGPass[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes a new version of an existing resource.\r\n *\r\n * The returned handle represents the post-write version. Use it for subsequent\r\n * reads and as the graph output passed to {@link RenderGraph.compile}. Passing\r\n * an older version of the same resource to `compile()` is rejected because it\r\n * usually means the caller ignored the handle returned by `write()`. If the pass\r\n * needs the previous contents, call {@link RGPassBuilder.read} on the input handle explicitly\r\n * before writing.\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n * @returns A handle referencing the newly written version.\r\n */\r\n write(handle: RGHandle): RGHandle;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Create a logical dependency token produced by this pass.\r\n *\r\n * Tokens do not resolve to GPU resources and are not allocated by the executor.\r\n * They are useful for ordering passes whose dependencies are side effects rather\r\n * than texture reads/writes.\r\n *\r\n * @param name - Debug label for this token.\r\n * @returns A handle referencing the newly created token.\r\n */\r\n createToken(name?: string): RGHandle;\r\n\r\n /**\r\n * Create a graph-managed framebuffer view.\r\n *\r\n * The graph compiler infers dependencies from any attachment handles in the\r\n * descriptor. The executor creates and releases the framebuffer automatically.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns A handle referencing the framebuffer view.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Add an ordered logical subpass to this pass.\r\n *\r\n * Subpasses execute in registration order and share the parent pass's declared\r\n * reads, writes, framebuffer views, and user data. A pass may use either\r\n * subpasses or {@link RGPassBuilder.setExecute}, but not both.\r\n *\r\n * @param name - Debug label for the subpass.\r\n * @param fn - Callback invoked when this subpass executes.\r\n */\r\n addSubpass<D>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * A pass may use either this method or {@link RGPassBuilder.addSubpass}, but not both.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n/**\r\n * Profiling scope type in a render graph timing tree.\r\n * @public\r\n */\r\nexport type RGProfileScopeType = 'graph' | 'pass' | 'subpass';\r\n\r\n/**\r\n * Render graph GPU timestamp profiling options.\r\n * @public\r\n */\r\nexport interface RGProfilingOptions {\r\n /** Enable render graph timestamp profiling. Default true when an options object is provided. */\r\n enabled?: boolean;\r\n /** Measure the whole graph execution. Default true. */\r\n graph?: boolean;\r\n /** Measure every render graph pass. Default true. */\r\n pass?: boolean;\r\n /** Measure every subpass and expose it as a child scope. Default true. */\r\n subpass?: boolean;\r\n /** Include pending upload/copy commands at timestamp boundaries. Default true. */\r\n includePendingUploads?: boolean;\r\n /** Allow graph profile scopes to remain open across frame boundaries. Default false. */\r\n allowCrossFrame?: boolean;\r\n /** Maximum unresolved profile frames kept by the executor. Default 3. */\r\n maxPendingFrames?: number;\r\n /** Root graph profile label. Default 'RenderGraph'. */\r\n label?: string;\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n}\r\n\r\n/**\r\n * Render graph executor construction options.\r\n * @public\r\n */\r\nexport interface RenderGraphExecutorOptions {\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n /** Render graph timestamp profiling options. Default false. */\r\n profiling?: boolean | RGProfilingOptions;\r\n}\r\n\r\n/**\r\n * Resolved GPU timing for one graph/pass/subpass scope.\r\n * @public\r\n */\r\nexport interface RGProfileScopeResult {\r\n /** Scope label. */\r\n name: string;\r\n /** Scope type. */\r\n type: RGProfileScopeType;\r\n /** Timestamp query id used by the device, or 0 for synthetic/unsupported scopes. */\r\n queryId: number;\r\n /** GPU duration in milliseconds. */\r\n durationMs: number;\r\n /** Timestamp result status. */\r\n status: TimestampQueryStatus;\r\n /** Child scopes. */\r\n children: RGProfileScopeResult[];\r\n /** Optional diagnostic message. */\r\n message?: string;\r\n}\r\n\r\n/**\r\n * Resolved GPU timing tree for one render graph execution.\r\n * @public\r\n */\r\nexport interface RGProfileResult {\r\n /** Render frame id when profiling began. */\r\n frameId: number;\r\n /** Aggregate profile status. */\r\n status: TimestampQueryStatus;\r\n /** Root graph scope. */\r\n graph: RGProfileScopeResult;\r\n /** Top-level pass scopes. Same objects as graph.children. */\r\n passes: RGProfileScopeResult[];\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Descriptor for a framebuffer view managed by the graph or created temporarily during pass execution.\r\n *\r\n * This is intentionally backend-agnostic: graph-managed descriptors may use\r\n * {@link RGHandle} attachments, and executor-created descriptors use resolved\r\n * resources or texture formats understood by the allocator.\r\n *\r\n * @public\r\n */\r\nexport interface RGFramebufferDesc {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: unknown | unknown[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: unknown | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls `allocate()` before a resource's first use and\r\n * `release()` after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown, TFramebuffer = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Retain a texture allocated by this allocator so it can outlive the graph pass\r\n * that produced it.\r\n *\r\n * This is used when a graph-produced transient texture must be handed off to\r\n * an external owner, such as a cross-frame history resource. Executors still\r\n * release the graph's own reference at the resource's last use; the external\r\n * owner must later call {@link RGTextureAllocator.release} for the retained\r\n * reference.\r\n *\r\n * Allocators that cannot retain transient textures should leave this undefined.\r\n */\r\n retain?(texture: TTexture): void;\r\n\r\n /**\r\n * Allocate a temporary framebuffer matching the given descriptor.\r\n *\r\n * Implementations should not auto-release this framebuffer; the graph executor\r\n * calls {@link RGTextureAllocator.releaseFramebuffer} when execution completes or aborts.\r\n *\r\n * @param desc - Framebuffer descriptor.\r\n * @returns The allocated framebuffer object.\r\n */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): TFramebuffer;\r\n\r\n /**\r\n * Release a previously allocated temporary framebuffer.\r\n *\r\n * @param framebuffer - The framebuffer to release.\r\n */\r\n releaseFramebuffer?(framebuffer: TFramebuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","physicalId","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","hasSideEffect","data","subpasses","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA+C;mFAExD,UAA4B;2FAE5BC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;IAEjC,WACER,CAAAA,EAAU,EACVC,IAAY,EACZI,IAAoB,EACpBC,IAA8C,EAC9CG,UAAaT,GAAAA,EAAE,CACf;QACA,IAAI,CAACA,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACG,UAAU,GAAGA,UAAAA;AACpB;AACF;AA4EA;;;;;;;;AAQC,IACM,MAAMC,SAAAA,CAAAA;IACFT,IAAa;IACbU,SAA0B;IAEnC,WAAYV,CAAAA,IAAY,EAAEU,SAAyB,CAAE;QACnD,IAAI,CAACV,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACU,SAAS,GAAGA,SAAAA;AACnB;AACF;AAEA;;;AAGC,IACM,MAAMC,MAAAA,CAAAA;IACFC,KAAc;IACdZ,IAAa;AACtB,qDACSa,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;AAClC,mFACSC,YAAyB,GAAA,EAAE;sEAEpCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBP,YAAmC,IAAK;AACxC,+EACSQ,SAA4B,GAAA,EAAE;gEAEvCC,QAAQ,IAAK;IAEb,WAAYP,CAAAA,KAAa,EAAEZ,IAAY,CAAE;QACvC,IAAI,CAACY,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACZ,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
@@ -29,6 +29,7 @@ import '../material/sprite.js';
|
|
|
29
29
|
import '../material/sprite_std.js';
|
|
30
30
|
import '../utility/blueprint/material/texture.js';
|
|
31
31
|
import '../shaders/atmosphere.js';
|
|
32
|
+
import '../render/rendergraph/forward_plus_builder.js';
|
|
32
33
|
import { ScriptAttachment, normalizeScriptAttachmentConfig, normalizeScriptAttachments } from './script_attachment.js';
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene.js","sources":["../../src/scene/scene.ts"],"sourcesContent":["import type { Matrix4x4, Nullable } from '@zephyr3d/base';\r\nimport { Vector3, Vector4, Ray, DRef, DWeakRef, makeObservable, Disposable } from '@zephyr3d/base';\r\nimport { SceneNode } from './scene_node';\r\nimport { Octree } from './octree';\r\nimport { RaycastVisitor } from './raycast_visitor';\r\nimport { Environment } from './environment';\r\nimport type { GraphNode } from './graph_node';\r\nimport type { Camera } from '../camera/camera';\r\nimport type { Drawable } from '../render';\r\nimport { SceneRenderer } from '../render';\r\nimport type { Compositor } from '../posteffect';\r\nimport type { Metadata } from 'draco3d';\r\nimport { getDevice } from '../app/api';\r\nimport type { IRenderable } from '../app';\r\nimport {\r\n normalizeScriptAttachmentConfig,\r\n normalizeScriptAttachments,\r\n ScriptAttachment\r\n} from './script_attachment';\r\n\r\n/**\r\n * Represents a renderable world that manages scene graph, spatial indexing, and environment.\r\n *\r\n * Core responsibilities:\r\n * - Owns the root {@link SceneNode} and maintains a spatial {@link Octree} for culling/raycasting.\r\n * - Manages environment/lighting via {@link Environment}.\r\n * - Provides per-frame update queues (global and per-camera) for scene nodes.\r\n * - Offers utilities like ray construction and raycasting.\r\n * - Emits observable events: `update`, `startrender`, `endrender`.\r\n *\r\n * Performance notes:\r\n * - Octree placement is lazily synchronized on demand before reads (e.g., `octree`, `boundingBox`)\r\n * and during per-frame updates.\r\n * - Update queues use weak references to avoid retaining disposed nodes.\r\n *\r\n * @public\r\n */\r\nexport class Scene\r\n extends makeObservable(Disposable)<{\r\n /** Dispatched once per frame before render-related work. */\r\n update: [Scene];\r\n /** Dispatched immediately before rendering begins for a camera. */\r\n startrender: [Scene, Camera, Compositor];\r\n /** Dispatched immediately after rendering finishes for a camera. */\r\n endrender: [Scene, Camera, Compositor];\r\n }>()\r\n implements IRenderable\r\n{\r\n /** @internal */\r\n private static _nextId = 0;\r\n /** @internal Scene name. */\r\n protected _name: string;\r\n /** @internal Root node reference. */\r\n protected _rootNode: DRef<SceneNode>;\r\n /** @internal Spatial index for placement/culling. */\r\n protected _octree: Octree;\r\n /**\r\n * @internal Pending nodes whose placement in the octree must be updated.\r\n * Populated by {@link Scene.invalidateNodePlacement} and drained by {@link Scene.updateNodePlacement}.\r\n */\r\n protected _nodePlaceList: Set<GraphNode>;\r\n /** @internal Environment data (sky/light/IBL). */\r\n protected _env: Environment;\r\n /** @internal Frame counter that last updated this scene. */\r\n protected _updateFrame: number;\r\n /** @internal Unique scene ID. */\r\n protected _id: number;\r\n /** @internal One-shot per-frame update queue (runs before render). */\r\n protected _nodeUpdateQueue: DWeakRef<SceneNode>[];\r\n /** @internal */\r\n protected _drawableUpdateQueue: Drawable[];\r\n /** @internal One-shot per-frame-per-camera update queue. */\r\n protected _perCameraUpdateQueue: DWeakRef<SceneNode>[];\r\n /** @internal Main camera reference. */\r\n protected _mainCamera: DRef<Camera>;\r\n /** @internal Arbitrary metadata loaded with the scene (optional). */\r\n protected _metaData: Nullable<Metadata>;\r\n /** @internal User-attached script entries (engine-defined). */\r\n private _scripts: ScriptAttachment[];\r\n /**\r\n * Creates an instance of Scene.\r\n *\r\n * Initializes:\r\n * - Unique ID\r\n * - Empty environment\r\n * - Octree with default depth/leaf capacities\r\n * - Root scene node named \"Root\"\r\n *\r\n * @param name - Optional scene name for diagnostics/UI.\r\n */\r\n constructor(name?: string) {\r\n super();\r\n this._id = ++Scene._nextId;\r\n this._name = name ?? '';\r\n this._octree = new Octree(this, 8, 8);\r\n this._nodePlaceList = new Set();\r\n this._nodeUpdateQueue = [];\r\n this._drawableUpdateQueue = [];\r\n this._perCameraUpdateQueue = [];\r\n this._env = new Environment();\r\n this._updateFrame = -1;\r\n this._rootNode = new DRef();\r\n this._rootNode.set(new SceneNode(this));\r\n this._rootNode.get()!.name = 'Root';\r\n this._metaData = null;\r\n this._scripts = [];\r\n this._mainCamera = new DRef();\r\n }\r\n /**\r\n * Gets the unique identifier of the scene.\r\n */\r\n get id() {\r\n return this._id;\r\n }\r\n /**\r\n * Name of the scene\r\n */\r\n get name() {\r\n return this._name;\r\n }\r\n set name(val: string) {\r\n this._name = val ?? '';\r\n }\r\n /**\r\n * Main camera used to render the scene by default.\r\n */\r\n get mainCamera() {\r\n return this._mainCamera.get();\r\n }\r\n set mainCamera(camera) {\r\n this._mainCamera.set(camera);\r\n }\r\n /**\r\n * Gets the root scene node of the scene\r\n */\r\n get rootNode() {\r\n return this._rootNode.get()!;\r\n }\r\n /**\r\n * Gets the octree used for spatial organization and queries.\r\n *\r\n * Ensures pending node placements are synchronized before returning.\r\n */\r\n get octree() {\r\n // Make sure the octree state is up to date\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n return this._octree;\r\n }\r\n /**\r\n * Gets the world-axis-aligned bounding box of the scene.\r\n *\r\n * Ensures pending node placements are synchronized before computing.\r\n */\r\n get boundingBox() {\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n // this._syncBVChangedList();\r\n return this._octree.getRootNode().getBoxLoosed();\r\n }\r\n /**\r\n * The environment (sky, lights, IBL) of the scene.\r\n */\r\n get env() {\r\n return this._env;\r\n }\r\n /**\r\n * Arbitrary metadata associated with the scene (e.g., imported asset info).\r\n */\r\n get metaData() {\r\n return this._metaData;\r\n }\r\n set metaData(val) {\r\n this._metaData = val;\r\n }\r\n /**\r\n * Attached script filename or identifier (engine-specific).\r\n *\r\n * @remarks\r\n * Integrates with the engine’s scripting system if available.\r\n */\r\n get script() {\r\n return this._scripts[0]?.script ?? '';\r\n }\r\n set script(fileName: string) {\r\n const script = fileName ?? '';\r\n if (!script) {\r\n this._scripts.splice(0, 1);\r\n } else if (this._scripts[0]) {\r\n this._scripts[0].script = script;\r\n } else {\r\n this._scripts.unshift(new ScriptAttachment(script));\r\n }\r\n }\r\n /**\r\n * Script component configuration payload used by editor/runtime script components.\r\n */\r\n get scriptConfig() {\r\n return this._scripts[0]?.config ?? null;\r\n }\r\n set scriptConfig(value: Nullable<object | unknown[]>) {\r\n const normalized = normalizeScriptAttachmentConfig(value);\r\n if (this._scripts[0]) {\r\n this._scripts[0].config = normalized;\r\n } else if (normalized != null) {\r\n this._scripts.unshift(new ScriptAttachment('', normalized));\r\n }\r\n if (this._scripts[0] && !this._scripts[0].script && this._scripts[0].config == null) {\r\n this._scripts.splice(0, 1);\r\n }\r\n }\r\n /**\r\n * All script attachments on this scene.\r\n */\r\n get scripts() {\r\n return this._scripts;\r\n }\r\n set scripts(value: ScriptAttachment[]) {\r\n this._scripts = normalizeScriptAttachments(value);\r\n }\r\n /**\r\n * Script configs for all script attachments.\r\n */\r\n get scriptConfigs() {\r\n return this._scripts.map((item) => item.config);\r\n }\r\n set scriptConfigs(value: unknown[]) {\r\n const next = Array.isArray(value) ? value : [];\r\n for (let i = 0; i < Math.max(this._scripts.length, next.length); i++) {\r\n const config = normalizeScriptAttachmentConfig(next[i]);\r\n if (this._scripts[i]) {\r\n this._scripts[i].config = config;\r\n } else if (config != null) {\r\n this._scripts.push(new ScriptAttachment('', config));\r\n }\r\n }\r\n this._scripts = this._scripts.filter((item) => item.script || item.config != null);\r\n }\r\n /**\r\n * Finds a scene node by its persistent ID.\r\n *\r\n * @typeParam T - Expected node type.\r\n * @param id - Persistent identifier to match against `SceneNode.persistentId`.\r\n * @returns The first matching node, or `null` if not found.\r\n */\r\n findNodeById<T extends SceneNode>(id: string) {\r\n return this._rootNode.get()!.findNodeById<T>(id);\r\n }\r\n /**\r\n * Finds a scene node by name.\r\n *\r\n * If multiple nodes share the same name, returns the first match encountered\r\n * during traversal.\r\n *\r\n * @typeParam T - Expected node type.\r\n * @param name - Node name to match.\r\n * @returns The first matching node, or `null` if not found.\r\n *\r\n * @remarks\r\n * Names are not guaranteed unique. Prefer IDs for stable references.\r\n */\r\n findNodeByName<T extends SceneNode>(name: string) {\r\n return this._rootNode.get()!.findNodeByName<T>(name);\r\n }\r\n /**\r\n * Casts a ray into the scene and returns the closest intersection, if any.\r\n *\r\n * @param ray - The ray in world space.\r\n * @param length - Maximum ray length. Defaults to `Infinity`.\r\n * @returns Intersection info `{ target, dist, point }`, or `null` if no hit.\r\n *\r\n */\r\n raycast(ray: Ray, length = Infinity) {\r\n const raycastVisitor = new RaycastVisitor(ray, length);\r\n this.octree.getRootNode().traverse(raycastVisitor);\r\n return raycastVisitor.intersected\r\n ? {\r\n target: raycastVisitor.intersected,\r\n dist: raycastVisitor.intersectedDist,\r\n point: raycastVisitor.intersectedPoint\r\n }\r\n : null;\r\n }\r\n /**\r\n * Constructs a world-space ray from a camera and a screen position.\r\n *\r\n * @param camera - Camera whose projection/view defines the ray.\r\n * @param viewportWidth - Current viewport width in pixels.\r\n * @param viewportHeight - Current viewport height in pixels.\r\n * @param screenX - Screen-space x (pixels).\r\n * @param screenY - Screen-space y (pixels).\r\n * @param invModelMatrix - Optional inverse model matrix to transform the ray into local space.\r\n * @returns The constructed Ray.\r\n *\r\n * @remarks\r\n * Computes NDC from screen coordinates, unprojects using `invViewProjectionMatrix`,\r\n * then forms a ray from the camera world position to the unprojected point.\r\n * If `invModelMatrix` is provided, both origin and direction are transformed.\r\n */\r\n constructRay(\r\n camera: Camera,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n screenX: number,\r\n screenY: number,\r\n invModelMatrix?: Matrix4x4\r\n ) {\r\n const vClip = new Vector4((2 * screenX) / viewportWidth - 1, 1 - (2 * screenY) / viewportHeight, 1, 1);\r\n const vWorld = camera.invViewProjectionMatrix.transform(vClip);\r\n vWorld.scaleBy(1 / vWorld.w);\r\n let vEye = camera.getWorldPosition();\r\n let vDir = Vector3.sub(vWorld.xyz(), vEye).inplaceNormalize();\r\n if (invModelMatrix) {\r\n vEye = invModelMatrix.transformPointAffine(vEye);\r\n vDir = invModelMatrix.transformVectorAffine(vDir);\r\n }\r\n return new Ray(vEye, vDir);\r\n }\r\n /**\r\n * Queues a node for a one-shot update before the next render.\r\n *\r\n * The node's `update(frame, elapsedSeconds, deltaSeconds)` will be called\r\n * during Scene.frameUpdate and then the node is removed from the queue.\r\n *\r\n * @param node - Node to schedule.\r\n *\r\n * @remarks\r\n * - To update continuously each frame, call `queueUpdateNode(this)` from within the node's `update` method.\r\n * - Duplicate scheduling within the same frame is prevented.\r\n */\r\n queueUpdateNode(node: SceneNode) {\r\n if (node && this._nodeUpdateQueue.findIndex((val) => val.get() === node) < 0) {\r\n this._nodeUpdateQueue.push(new DWeakRef(node));\r\n }\r\n }\r\n /**\r\n * Queues a drawable for a one-shot state update before the next render.\r\n *\r\n * The drawable's `updateState()` will be called during Scene.frameUpdate and then the drawable is removed from the queue.\r\n * @param drawable - Drawable to schedule.\r\n *\r\n * @remarks\r\n * - To update continuously each frame, call `queueUpdateDrawable(this)` from within the drawable's `updateState` method.\r\n * - Duplicate scheduling within the same frame is prevented.\r\n */\r\n queueUpdateDrawable(drawable: Drawable) {\r\n if (drawable && this._drawableUpdateQueue.indexOf(drawable) < 0) {\r\n this._drawableUpdateQueue.push(drawable);\r\n }\r\n }\r\n /**\r\n * Queues a node for a one-shot per-camera update before render.\r\n *\r\n * The node's `updatePerCamera(camera, elapsedSeconds, deltaSeconds)` will be\r\n * called once for each camera during {@link Scene.frameUpdatePerCamera}, then removed.\r\n *\r\n * @param node - Node to schedule.\r\n *\r\n * @remarks\r\n * - To run per-camera work continuously, re-queue from `updatePerCamera`.\r\n * - Duplicate scheduling within the same frame is prevented.\r\n */\r\n queuePerCameraUpdateNode(node: SceneNode) {\r\n if (node && this._perCameraUpdateQueue.findIndex((val) => val.get() === node) < 0) {\r\n this._perCameraUpdateQueue.push(new DWeakRef(node));\r\n }\r\n }\r\n /**\r\n * Renders this scene using the `mainCamera`, if present.\r\n *\r\n * Equivalent to `mainCamera.render(this)` when `mainCamera` is set.\r\n */\r\n render() {\r\n if (this.mainCamera) {\r\n this.mainCamera.render(this);\r\n }\r\n }\r\n /**\r\n * Marks a graph node as needing placement update in the octree.\r\n *\r\n * Called by nodes when their transform/visibility/attachment changes in a way\r\n * that affects spatial placement.\r\n *\r\n * @internal\r\n */\r\n invalidateNodePlacement(node: GraphNode) {\r\n this._nodePlaceList.add(node);\r\n }\r\n /**\r\n * Synchronizes environment light maps (IBL, SH/FB) with the sky as needed.\r\n *\r\n * Uses device capabilities to decide between Spherical Harmonics floating-point blending (SHFB)\r\n * and classic SH textures, and lazily fills missing environment fields from the sky.\r\n *\r\n * @internal\r\n */\r\n private updateEnvLight() {\r\n if (this.env.light.type === 'ibl') {\r\n this.env.light.radianceMap = this.env.sky.radianceMap;\r\n this.env.light.sheenRadianceMap = this.env.sky.sheenRadianceMap;\r\n this.env.light.irradianceWindow = this.env.sky.shWindowWeights;\r\n this.env.light.irradianceSHFB = this.env.sky.irradianceSHFB;\r\n this.env.light.irradianceSH = null;\r\n }\r\n }\r\n /**\r\n * Returns the renderer class used to render the scene.\r\n *\r\n * Override in subclasses to supply a custom renderer.\r\n *\r\n * @internal\r\n */\r\n getRenderer() {\r\n return SceneRenderer;\r\n }\r\n /**\r\n * Performs per-frame scene updates, once per device frame.\r\n *\r\n * Steps:\r\n * - Ensure this runs only once per frame (via `frameInfo.frameCounter`).\r\n * - Update environment light synchronization.\r\n * - Dispatch `update` event.\r\n * - Drain the one-shot node update queue and call `node.update(...)`.\r\n * - Apply pending octree placement updates.\r\n *\r\n */\r\n frameUpdate() {\r\n const frameInfo = getDevice().frameInfo;\r\n if (frameInfo.frameCounter !== this._updateFrame) {\r\n this._updateFrame = frameInfo.frameCounter;\r\n this.updateEnvLight();\r\n this.dispatchEvent('update', this);\r\n this.mainCamera?.updateController();\r\n if (this._nodeUpdateQueue.length > 0) {\r\n const elapsedInSeconds = frameInfo.elapsedOverall * 0.001;\r\n const deltaInSeconds = frameInfo.elapsedFrame * 0.001;\r\n const queue = this._nodeUpdateQueue;\r\n this._nodeUpdateQueue = [];\r\n while (queue.length > 0) {\r\n const ref = queue.shift()!;\r\n const node = ref.get();\r\n if (node?.attached) {\r\n node.update(frameInfo.frameCounter, elapsedInSeconds, deltaInSeconds);\r\n }\r\n ref.dispose();\r\n }\r\n }\r\n if (this._drawableUpdateQueue.length > 0) {\r\n for (const drawable of this._drawableUpdateQueue) {\r\n drawable.updateState();\r\n }\r\n this._drawableUpdateQueue = [];\r\n }\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n }\r\n }\r\n /**\r\n * Performs per-camera scene updates for the current frame.\r\n *\r\n * Steps:\r\n * - Drain the per-camera update queue and call `node.updatePerCamera(camera, ...)`.\r\n * - Apply pending octree placement updates.\r\n *\r\n * @param camera - The camera being updated for.\r\n */\r\n frameUpdatePerCamera(camera: Camera) {\r\n if (this._perCameraUpdateQueue.length > 0) {\r\n const frameInfo = getDevice().frameInfo;\r\n const elapsedInSeconds = frameInfo.elapsedOverall * 0.001;\r\n const deltaInSeconds = frameInfo.elapsedFrame * 0.001;\r\n const queue = this._perCameraUpdateQueue;\r\n this._perCameraUpdateQueue = [];\r\n while (queue.length > 0) {\r\n const ref = queue.shift()!;\r\n ref.get()?.updatePerCamera(camera, elapsedInSeconds, deltaInSeconds);\r\n ref.dispose();\r\n }\r\n }\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n }\r\n /**\r\n * Applies placement changes for nodes in `list` to the given `octree`.\r\n *\r\n * Rules:\r\n * - If node is not disposed, attached, not hidden, and `placeToOctree` is true,\r\n * it is placed; otherwise removed.\r\n * - Drains `list` until empty.\r\n *\r\n * @param octree - Target spatial index.\r\n * @param list - Set of nodes awaiting placement evaluation.\r\n */\r\n updateNodePlacement(octree: Octree, list: Set<GraphNode>) {\r\n function placeNode(node: GraphNode) {\r\n if (!node.disposed && node.attached && !node.hidden && node.placeToOctree) {\r\n octree.placeNode(node);\r\n } else {\r\n octree.removeNode(node);\r\n }\r\n list.delete(node);\r\n }\r\n if (list.size > 0) {\r\n while (list.size > 0) {\r\n const node = list.keys().next().value!;\r\n if (octree) {\r\n placeNode(node);\r\n } else {\r\n list.delete(node);\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * Disposes the scene and its owned resources.\r\n *\r\n * Disposes:\r\n * - Environment\r\n * - Root node (and, by extension, its hierarchy)\r\n * - Main camera reference wrapper\r\n *\r\n */\r\n protected onDispose() {\r\n this._env.dispose();\r\n this._rootNode.dispose();\r\n this._mainCamera.dispose();\r\n }\r\n}\r\n"],"names":["Scene","makeObservable","Disposable","_nextId","name","_id","_name","_octree","Octree","_nodePlaceList","Set","_nodeUpdateQueue","_drawableUpdateQueue","_perCameraUpdateQueue","_env","Environment","_updateFrame","_rootNode","DRef","set","SceneNode","get","_metaData","_scripts","_mainCamera","id","val","mainCamera","camera","rootNode","octree","updateNodePlacement","boundingBox","getRootNode","getBoxLoosed","env","metaData","script","fileName","splice","unshift","ScriptAttachment","scriptConfig","config","value","normalized","normalizeScriptAttachmentConfig","scripts","normalizeScriptAttachments","scriptConfigs","map","item","next","Array","isArray","i","Math","max","length","push","filter","findNodeById","findNodeByName","raycast","ray","Infinity","raycastVisitor","RaycastVisitor","traverse","intersected","target","dist","intersectedDist","point","intersectedPoint","constructRay","viewportWidth","viewportHeight","screenX","screenY","invModelMatrix","vClip","Vector4","vWorld","invViewProjectionMatrix","transform","scaleBy","w","vEye","getWorldPosition","vDir","Vector3","sub","xyz","inplaceNormalize","transformPointAffine","transformVectorAffine","Ray","queueUpdateNode","node","findIndex","DWeakRef","queueUpdateDrawable","drawable","indexOf","queuePerCameraUpdateNode","render","invalidateNodePlacement","add","light","type","radianceMap","sky","sheenRadianceMap","irradianceWindow","shWindowWeights","irradianceSHFB","irradianceSH","getRenderer","SceneRenderer","frameUpdate","frameInfo","getDevice","frameCounter","updateEnvLight","dispatchEvent","updateController","elapsedInSeconds","elapsedOverall","deltaInSeconds","elapsedFrame","queue","ref","shift","attached","update","dispose","updateState","frameUpdatePerCamera","updatePerCamera","list","placeNode","disposed","hidden","placeToOctree","removeNode","delete","size","keys"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;;;IAiBO,MAAMA,KAAAA,SACHC,cAAeC,CAAAA,UAAAA,CAAAA,EAAAA,CAAAA;qBAWvB,OAAeC,OAAAA,GAAU,CAAE;iCAE3B,KAAwB;0CAExB,SAAqC;0DAErC,OAA0B;AAC1B;;;AAGC,MACD,cAAyC;uDAEzC,IAA4B;iEAE5B,YAA+B;sCAE/B,GAAsB;2EAEtB,gBAAkD;qBAElD,oBAA2C;iEAE3C,qBAAuD;4CAEvD,WAAoC;0EAEpC,SAAwC;oEAExC,QAAqC;AACrC;;;;;;;;;;MAWA,WAAA,CAAYC,IAAa,CAAE;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F;QACA,IAAI,CAACzG,mBAAmB,CAAC,IAAI,CAACxB,OAAO,EAAE,IAAI,CAACE,cAAc,CAAA;AAC5D;AACA;;;;;;;;;;AAUC,MACDsB,mBAAoBD,CAAAA,MAAc,EAAE8G,IAAoB,EAAE;AACxD,QAAA,SAASC,UAAU1C,IAAe,EAAA;AAChC,YAAA,IAAI,CAACA,IAAAA,CAAK2C,QAAQ,IAAI3C,IAAKmC,CAAAA,QAAQ,IAAI,CAACnC,IAAK4C,CAAAA,MAAM,IAAI5C,IAAAA,CAAK6C,aAAa,EAAE;AACzElH,gBAAAA,MAAAA,CAAO+G,SAAS,CAAC1C,IAAAA,CAAAA;aACZ,MAAA;AACLrE,gBAAAA,MAAAA,CAAOmH,UAAU,CAAC9C,IAAAA,CAAAA;AACpB;AACAyC,YAAAA,IAAAA,CAAKM,MAAM,CAAC/C,IAAAA,CAAAA;AACd;QACA,IAAIyC,IAAAA,CAAKO,IAAI,GAAG,CAAG,EAAA;YACjB,MAAOP,IAAAA,CAAKO,IAAI,GAAG,CAAG,CAAA;AACpB,gBAAA,MAAMhD,OAAOyC,IAAKQ,CAAAA,IAAI,EAAGhG,CAAAA,IAAI,GAAGR,KAAK;AACrC,gBAAA,IAAId,MAAQ,EAAA;oBACV+G,SAAU1C,CAAAA,IAAAA,CAAAA;iBACL,MAAA;AACLyC,oBAAAA,IAAAA,CAAKM,MAAM,CAAC/C,IAAAA,CAAAA;AACd;AACF;AACF;AACF;AACA;;;;;;;;AAQC,MACD,SAAsB,GAAA;QACpB,IAAI,CAACrF,IAAI,CAAC0H,OAAO,EAAA;QACjB,IAAI,CAACvH,SAAS,CAACuH,OAAO,EAAA;QACtB,IAAI,CAAChH,WAAW,CAACgH,OAAO,EAAA;AAC1B;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"scene.js","sources":["../../src/scene/scene.ts"],"sourcesContent":["import type { Matrix4x4, Nullable } from '@zephyr3d/base';\r\nimport { Vector3, Vector4, Ray, DRef, DWeakRef, makeObservable, Disposable } from '@zephyr3d/base';\r\nimport { SceneNode } from './scene_node';\r\nimport { Octree } from './octree';\r\nimport { RaycastVisitor } from './raycast_visitor';\r\nimport { Environment } from './environment';\r\nimport type { GraphNode } from './graph_node';\r\nimport type { Camera } from '../camera/camera';\r\nimport type { Drawable } from '../render';\r\nimport { SceneRenderer } from '../render';\r\nimport type { Compositor } from '../posteffect';\r\nimport type { Metadata } from 'draco3d';\r\nimport { getDevice } from '../app/api';\r\nimport type { IRenderable } from '../app';\r\nimport {\r\n normalizeScriptAttachmentConfig,\r\n normalizeScriptAttachments,\r\n ScriptAttachment\r\n} from './script_attachment';\r\n\r\n/**\r\n * Represents a renderable world that manages scene graph, spatial indexing, and environment.\r\n *\r\n * Core responsibilities:\r\n * - Owns the root {@link SceneNode} and maintains a spatial {@link Octree} for culling/raycasting.\r\n * - Manages environment/lighting via {@link Environment}.\r\n * - Provides per-frame update queues (global and per-camera) for scene nodes.\r\n * - Offers utilities like ray construction and raycasting.\r\n * - Emits observable events: `update`, `startrender`, `endrender`.\r\n *\r\n * Performance notes:\r\n * - Octree placement is lazily synchronized on demand before reads (e.g., `octree`, `boundingBox`)\r\n * and during per-frame updates.\r\n * - Update queues use weak references to avoid retaining disposed nodes.\r\n *\r\n * @public\r\n */\r\nexport class Scene\r\n extends makeObservable(Disposable)<{\r\n /** Dispatched once per frame before render-related work. */\r\n update: [Scene];\r\n /** Dispatched immediately before rendering begins for a camera. */\r\n startrender: [Scene, Camera, Compositor];\r\n /** Dispatched immediately after rendering finishes for a camera. */\r\n endrender: [Scene, Camera, Compositor];\r\n }>()\r\n implements IRenderable\r\n{\r\n /** @internal */\r\n private static _nextId = 0;\r\n /** @internal Scene name. */\r\n protected _name: string;\r\n /** @internal Root node reference. */\r\n protected _rootNode: DRef<SceneNode>;\r\n /** @internal Spatial index for placement/culling. */\r\n protected _octree: Octree;\r\n /**\r\n * @internal Pending nodes whose placement in the octree must be updated.\r\n * Populated by {@link Scene.invalidateNodePlacement} and drained by {@link Scene.updateNodePlacement}.\r\n */\r\n protected _nodePlaceList: Set<GraphNode>;\r\n /** @internal Environment data (sky/light/IBL). */\r\n protected _env: Environment;\r\n /** @internal Frame counter that last updated this scene. */\r\n protected _updateFrame: number;\r\n /** @internal Unique scene ID. */\r\n protected _id: number;\r\n /** @internal One-shot per-frame update queue (runs before render). */\r\n protected _nodeUpdateQueue: DWeakRef<SceneNode>[];\r\n /** @internal */\r\n protected _drawableUpdateQueue: Drawable[];\r\n /** @internal One-shot per-frame-per-camera update queue. */\r\n protected _perCameraUpdateQueue: DWeakRef<SceneNode>[];\r\n /** @internal Main camera reference. */\r\n protected _mainCamera: DRef<Camera>;\r\n /** @internal Arbitrary metadata loaded with the scene (optional). */\r\n protected _metaData: Nullable<Metadata>;\r\n /** @internal User-attached script entries (engine-defined). */\r\n private _scripts: ScriptAttachment[];\r\n /**\r\n * Creates an instance of Scene.\r\n *\r\n * Initializes:\r\n * - Unique ID\r\n * - Empty environment\r\n * - Octree with default depth/leaf capacities\r\n * - Root scene node named \"Root\"\r\n *\r\n * @param name - Optional scene name for diagnostics/UI.\r\n */\r\n constructor(name?: string) {\r\n super();\r\n this._id = ++Scene._nextId;\r\n this._name = name ?? '';\r\n this._octree = new Octree(this, 8, 8);\r\n this._nodePlaceList = new Set();\r\n this._nodeUpdateQueue = [];\r\n this._drawableUpdateQueue = [];\r\n this._perCameraUpdateQueue = [];\r\n this._env = new Environment();\r\n this._updateFrame = -1;\r\n this._rootNode = new DRef();\r\n this._rootNode.set(new SceneNode(this));\r\n this._rootNode.get()!.name = 'Root';\r\n this._metaData = null;\r\n this._scripts = [];\r\n this._mainCamera = new DRef();\r\n }\r\n /**\r\n * Gets the unique identifier of the scene.\r\n */\r\n get id() {\r\n return this._id;\r\n }\r\n /**\r\n * Name of the scene\r\n */\r\n get name() {\r\n return this._name;\r\n }\r\n set name(val: string) {\r\n this._name = val ?? '';\r\n }\r\n /**\r\n * Main camera used to render the scene by default.\r\n */\r\n get mainCamera() {\r\n return this._mainCamera.get();\r\n }\r\n set mainCamera(camera) {\r\n this._mainCamera.set(camera);\r\n }\r\n /**\r\n * Gets the root scene node of the scene\r\n */\r\n get rootNode() {\r\n return this._rootNode.get()!;\r\n }\r\n /**\r\n * Gets the octree used for spatial organization and queries.\r\n *\r\n * Ensures pending node placements are synchronized before returning.\r\n */\r\n get octree() {\r\n // Make sure the octree state is up to date\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n return this._octree;\r\n }\r\n /**\r\n * Gets the world-axis-aligned bounding box of the scene.\r\n *\r\n * Ensures pending node placements are synchronized before computing.\r\n */\r\n get boundingBox() {\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n // this._syncBVChangedList();\r\n return this._octree.getRootNode().getBoxLoosed();\r\n }\r\n /**\r\n * The environment (sky, lights, IBL) of the scene.\r\n */\r\n get env() {\r\n return this._env;\r\n }\r\n /**\r\n * Arbitrary metadata associated with the scene (e.g., imported asset info).\r\n */\r\n get metaData() {\r\n return this._metaData;\r\n }\r\n set metaData(val) {\r\n this._metaData = val;\r\n }\r\n /**\r\n * Attached script filename or identifier (engine-specific).\r\n *\r\n * @remarks\r\n * Integrates with the engine’s scripting system if available.\r\n */\r\n get script() {\r\n return this._scripts[0]?.script ?? '';\r\n }\r\n set script(fileName: string) {\r\n const script = fileName ?? '';\r\n if (!script) {\r\n this._scripts.splice(0, 1);\r\n } else if (this._scripts[0]) {\r\n this._scripts[0].script = script;\r\n } else {\r\n this._scripts.unshift(new ScriptAttachment(script));\r\n }\r\n }\r\n /**\r\n * Script component configuration payload used by editor/runtime script components.\r\n */\r\n get scriptConfig() {\r\n return this._scripts[0]?.config ?? null;\r\n }\r\n set scriptConfig(value: Nullable<object | unknown[]>) {\r\n const normalized = normalizeScriptAttachmentConfig(value);\r\n if (this._scripts[0]) {\r\n this._scripts[0].config = normalized;\r\n } else if (normalized != null) {\r\n this._scripts.unshift(new ScriptAttachment('', normalized));\r\n }\r\n if (this._scripts[0] && !this._scripts[0].script && this._scripts[0].config == null) {\r\n this._scripts.splice(0, 1);\r\n }\r\n }\r\n /**\r\n * All script attachments on this scene.\r\n */\r\n get scripts() {\r\n return this._scripts;\r\n }\r\n set scripts(value: ScriptAttachment[]) {\r\n this._scripts = normalizeScriptAttachments(value);\r\n }\r\n /**\r\n * Script configs for all script attachments.\r\n */\r\n get scriptConfigs() {\r\n return this._scripts.map((item) => item.config);\r\n }\r\n set scriptConfigs(value: unknown[]) {\r\n const next = Array.isArray(value) ? value : [];\r\n for (let i = 0; i < Math.max(this._scripts.length, next.length); i++) {\r\n const config = normalizeScriptAttachmentConfig(next[i]);\r\n if (this._scripts[i]) {\r\n this._scripts[i].config = config;\r\n } else if (config != null) {\r\n this._scripts.push(new ScriptAttachment('', config));\r\n }\r\n }\r\n this._scripts = this._scripts.filter((item) => item.script || item.config != null);\r\n }\r\n /**\r\n * Finds a scene node by its persistent ID.\r\n *\r\n * @typeParam T - Expected node type.\r\n * @param id - Persistent identifier to match against `SceneNode.persistentId`.\r\n * @returns The first matching node, or `null` if not found.\r\n */\r\n findNodeById<T extends SceneNode>(id: string) {\r\n return this._rootNode.get()!.findNodeById<T>(id);\r\n }\r\n /**\r\n * Finds a scene node by name.\r\n *\r\n * If multiple nodes share the same name, returns the first match encountered\r\n * during traversal.\r\n *\r\n * @typeParam T - Expected node type.\r\n * @param name - Node name to match.\r\n * @returns The first matching node, or `null` if not found.\r\n *\r\n * @remarks\r\n * Names are not guaranteed unique. Prefer IDs for stable references.\r\n */\r\n findNodeByName<T extends SceneNode>(name: string) {\r\n return this._rootNode.get()!.findNodeByName<T>(name);\r\n }\r\n /**\r\n * Casts a ray into the scene and returns the closest intersection, if any.\r\n *\r\n * @param ray - The ray in world space.\r\n * @param length - Maximum ray length. Defaults to `Infinity`.\r\n * @returns Intersection info `{ target, dist, point }`, or `null` if no hit.\r\n *\r\n */\r\n raycast(ray: Ray, length = Infinity) {\r\n const raycastVisitor = new RaycastVisitor(ray, length);\r\n this.octree.getRootNode().traverse(raycastVisitor);\r\n return raycastVisitor.intersected\r\n ? {\r\n target: raycastVisitor.intersected,\r\n dist: raycastVisitor.intersectedDist,\r\n point: raycastVisitor.intersectedPoint\r\n }\r\n : null;\r\n }\r\n /**\r\n * Constructs a world-space ray from a camera and a screen position.\r\n *\r\n * @param camera - Camera whose projection/view defines the ray.\r\n * @param viewportWidth - Current viewport width in pixels.\r\n * @param viewportHeight - Current viewport height in pixels.\r\n * @param screenX - Screen-space x (pixels).\r\n * @param screenY - Screen-space y (pixels).\r\n * @param invModelMatrix - Optional inverse model matrix to transform the ray into local space.\r\n * @returns The constructed Ray.\r\n *\r\n * @remarks\r\n * Computes NDC from screen coordinates, unprojects using `invViewProjectionMatrix`,\r\n * then forms a ray from the camera world position to the unprojected point.\r\n * If `invModelMatrix` is provided, both origin and direction are transformed.\r\n */\r\n constructRay(\r\n camera: Camera,\r\n viewportWidth: number,\r\n viewportHeight: number,\r\n screenX: number,\r\n screenY: number,\r\n invModelMatrix?: Matrix4x4\r\n ) {\r\n const vClip = new Vector4((2 * screenX) / viewportWidth - 1, 1 - (2 * screenY) / viewportHeight, 1, 1);\r\n const vWorld = camera.invViewProjectionMatrix.transform(vClip);\r\n vWorld.scaleBy(1 / vWorld.w);\r\n let vEye = camera.getWorldPosition();\r\n let vDir = Vector3.sub(vWorld.xyz(), vEye).inplaceNormalize();\r\n if (invModelMatrix) {\r\n vEye = invModelMatrix.transformPointAffine(vEye);\r\n vDir = invModelMatrix.transformVectorAffine(vDir);\r\n }\r\n return new Ray(vEye, vDir);\r\n }\r\n /**\r\n * Queues a node for a one-shot update before the next render.\r\n *\r\n * The node's `update(frame, elapsedSeconds, deltaSeconds)` will be called\r\n * during Scene.frameUpdate and then the node is removed from the queue.\r\n *\r\n * @param node - Node to schedule.\r\n *\r\n * @remarks\r\n * - To update continuously each frame, call `queueUpdateNode(this)` from within the node's `update` method.\r\n * - Duplicate scheduling within the same frame is prevented.\r\n */\r\n queueUpdateNode(node: SceneNode) {\r\n if (node && this._nodeUpdateQueue.findIndex((val) => val.get() === node) < 0) {\r\n this._nodeUpdateQueue.push(new DWeakRef(node));\r\n }\r\n }\r\n /**\r\n * Queues a drawable for a one-shot state update before the next render.\r\n *\r\n * The drawable's `updateState()` will be called during Scene.frameUpdate and then the drawable is removed from the queue.\r\n * @param drawable - Drawable to schedule.\r\n *\r\n * @remarks\r\n * - To update continuously each frame, call `queueUpdateDrawable(this)` from within the drawable's `updateState` method.\r\n * - Duplicate scheduling within the same frame is prevented.\r\n */\r\n queueUpdateDrawable(drawable: Drawable) {\r\n if (drawable && this._drawableUpdateQueue.indexOf(drawable) < 0) {\r\n this._drawableUpdateQueue.push(drawable);\r\n }\r\n }\r\n /**\r\n * Queues a node for a one-shot per-camera update before render.\r\n *\r\n * The node's `updatePerCamera(camera, elapsedSeconds, deltaSeconds)` will be\r\n * called once for each camera during {@link Scene.frameUpdatePerCamera}, then removed.\r\n *\r\n * @param node - Node to schedule.\r\n *\r\n * @remarks\r\n * - To run per-camera work continuously, re-queue from `updatePerCamera`.\r\n * - Duplicate scheduling within the same frame is prevented.\r\n */\r\n queuePerCameraUpdateNode(node: SceneNode) {\r\n if (node && this._perCameraUpdateQueue.findIndex((val) => val.get() === node) < 0) {\r\n this._perCameraUpdateQueue.push(new DWeakRef(node));\r\n }\r\n }\r\n /**\r\n * Renders this scene using the `mainCamera`, if present.\r\n *\r\n * Equivalent to `mainCamera.render(this)` when `mainCamera` is set.\r\n */\r\n render() {\r\n if (this.mainCamera) {\r\n this.mainCamera.render(this);\r\n }\r\n }\r\n /**\r\n * Marks a graph node as needing placement update in the octree.\r\n *\r\n * Called by nodes when their transform/visibility/attachment changes in a way\r\n * that affects spatial placement.\r\n *\r\n * @internal\r\n */\r\n invalidateNodePlacement(node: GraphNode) {\r\n this._nodePlaceList.add(node);\r\n }\r\n /**\r\n * Synchronizes environment light maps (IBL, SH/FB) with the sky as needed.\r\n *\r\n * Uses device capabilities to decide between Spherical Harmonics floating-point blending (SHFB)\r\n * and classic SH textures, and lazily fills missing environment fields from the sky.\r\n *\r\n * @internal\r\n */\r\n private updateEnvLight() {\r\n if (this.env.light.type === 'ibl') {\r\n this.env.light.radianceMap = this.env.sky.radianceMap;\r\n this.env.light.sheenRadianceMap = this.env.sky.sheenRadianceMap;\r\n this.env.light.irradianceWindow = this.env.sky.shWindowWeights;\r\n this.env.light.irradianceSHFB = this.env.sky.irradianceSHFB;\r\n this.env.light.irradianceSH = null;\r\n }\r\n }\r\n /**\r\n * Returns the renderer class used to render the scene.\r\n *\r\n * Override in subclasses to supply a custom renderer.\r\n *\r\n * @internal\r\n */\r\n getRenderer() {\r\n return SceneRenderer;\r\n }\r\n /**\r\n * Performs per-frame scene updates, once per device frame.\r\n *\r\n * Steps:\r\n * - Ensure this runs only once per frame (via `frameInfo.frameCounter`).\r\n * - Update environment light synchronization.\r\n * - Dispatch `update` event.\r\n * - Drain the one-shot node update queue and call `node.update(...)`.\r\n * - Apply pending octree placement updates.\r\n *\r\n */\r\n frameUpdate() {\r\n const frameInfo = getDevice().frameInfo;\r\n if (frameInfo.frameCounter !== this._updateFrame) {\r\n this._updateFrame = frameInfo.frameCounter;\r\n this.updateEnvLight();\r\n this.dispatchEvent('update', this);\r\n this.mainCamera?.updateController();\r\n if (this._nodeUpdateQueue.length > 0) {\r\n const elapsedInSeconds = frameInfo.elapsedOverall * 0.001;\r\n const deltaInSeconds = frameInfo.elapsedFrame * 0.001;\r\n const queue = this._nodeUpdateQueue;\r\n this._nodeUpdateQueue = [];\r\n while (queue.length > 0) {\r\n const ref = queue.shift()!;\r\n const node = ref.get();\r\n if (node?.attached) {\r\n node.update(frameInfo.frameCounter, elapsedInSeconds, deltaInSeconds);\r\n }\r\n ref.dispose();\r\n }\r\n }\r\n if (this._drawableUpdateQueue.length > 0) {\r\n for (const drawable of this._drawableUpdateQueue) {\r\n drawable.updateState();\r\n }\r\n this._drawableUpdateQueue = [];\r\n }\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n }\r\n }\r\n /**\r\n * Performs per-camera scene updates for the current frame.\r\n *\r\n * Steps:\r\n * - Drain the per-camera update queue and call `node.updatePerCamera(camera, ...)`.\r\n * - Apply pending octree placement updates.\r\n *\r\n * @param camera - The camera being updated for.\r\n */\r\n frameUpdatePerCamera(camera: Camera) {\r\n if (this._perCameraUpdateQueue.length > 0) {\r\n const frameInfo = getDevice().frameInfo;\r\n const elapsedInSeconds = frameInfo.elapsedOverall * 0.001;\r\n const deltaInSeconds = frameInfo.elapsedFrame * 0.001;\r\n const queue = this._perCameraUpdateQueue;\r\n this._perCameraUpdateQueue = [];\r\n while (queue.length > 0) {\r\n const ref = queue.shift()!;\r\n ref.get()?.updatePerCamera(camera, elapsedInSeconds, deltaInSeconds);\r\n ref.dispose();\r\n }\r\n }\r\n this.updateNodePlacement(this._octree, this._nodePlaceList);\r\n }\r\n /**\r\n * Applies placement changes for nodes in `list` to the given `octree`.\r\n *\r\n * Rules:\r\n * - If node is not disposed, attached, not hidden, and `placeToOctree` is true,\r\n * it is placed; otherwise removed.\r\n * - Drains `list` until empty.\r\n *\r\n * @param octree - Target spatial index.\r\n * @param list - Set of nodes awaiting placement evaluation.\r\n */\r\n updateNodePlacement(octree: Octree, list: Set<GraphNode>) {\r\n function placeNode(node: GraphNode) {\r\n if (!node.disposed && node.attached && !node.hidden && node.placeToOctree) {\r\n octree.placeNode(node);\r\n } else {\r\n octree.removeNode(node);\r\n }\r\n list.delete(node);\r\n }\r\n if (list.size > 0) {\r\n while (list.size > 0) {\r\n const node = list.keys().next().value!;\r\n if (octree) {\r\n placeNode(node);\r\n } else {\r\n list.delete(node);\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * Disposes the scene and its owned resources.\r\n *\r\n * Disposes:\r\n * - Environment\r\n * - Root node (and, by extension, its hierarchy)\r\n * - Main camera reference wrapper\r\n *\r\n */\r\n protected onDispose() {\r\n this._env.dispose();\r\n this._rootNode.dispose();\r\n this._mainCamera.dispose();\r\n }\r\n}\r\n"],"names":["Scene","makeObservable","Disposable","_nextId","name","_id","_name","_octree","Octree","_nodePlaceList","Set","_nodeUpdateQueue","_drawableUpdateQueue","_perCameraUpdateQueue","_env","Environment","_updateFrame","_rootNode","DRef","set","SceneNode","get","_metaData","_scripts","_mainCamera","id","val","mainCamera","camera","rootNode","octree","updateNodePlacement","boundingBox","getRootNode","getBoxLoosed","env","metaData","script","fileName","splice","unshift","ScriptAttachment","scriptConfig","config","value","normalized","normalizeScriptAttachmentConfig","scripts","normalizeScriptAttachments","scriptConfigs","map","item","next","Array","isArray","i","Math","max","length","push","filter","findNodeById","findNodeByName","raycast","ray","Infinity","raycastVisitor","RaycastVisitor","traverse","intersected","target","dist","intersectedDist","point","intersectedPoint","constructRay","viewportWidth","viewportHeight","screenX","screenY","invModelMatrix","vClip","Vector4","vWorld","invViewProjectionMatrix","transform","scaleBy","w","vEye","getWorldPosition","vDir","Vector3","sub","xyz","inplaceNormalize","transformPointAffine","transformVectorAffine","Ray","queueUpdateNode","node","findIndex","DWeakRef","queueUpdateDrawable","drawable","indexOf","queuePerCameraUpdateNode","render","invalidateNodePlacement","add","light","type","radianceMap","sky","sheenRadianceMap","irradianceWindow","shWindowWeights","irradianceSHFB","irradianceSH","getRenderer","SceneRenderer","frameUpdate","frameInfo","getDevice","frameCounter","updateEnvLight","dispatchEvent","updateController","elapsedInSeconds","elapsedOverall","deltaInSeconds","elapsedFrame","queue","ref","shift","attached","update","dispose","updateState","frameUpdatePerCamera","updatePerCamera","list","placeNode","disposed","hidden","placeToOctree","removeNode","delete","size","keys"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;;;IAiBO,MAAMA,KAAAA,SACHC,cAAeC,CAAAA,UAAAA,CAAAA,EAAAA,CAAAA;qBAWvB,OAAeC,OAAAA,GAAU,CAAE;iCAE3B,KAAwB;0CAExB,SAAqC;0DAErC,OAA0B;AAC1B;;;AAGC,MACD,cAAyC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AI,CAAChH,WAAW,CAACgH,OAAO,EAAA;AAC1B;AACF;;;;"}
|
|
@@ -12,7 +12,7 @@ import { getSceneClass } from './scene/scene.js';
|
|
|
12
12
|
import { getTerrainClass } from './scene/terrain.js';
|
|
13
13
|
import { getWaterClass, getFFTWaveGeneratorClass, getFBMWaveGeneratorClass } from './scene/water.js';
|
|
14
14
|
import { getTextSpriteClass, getMSDFTextSpriteClass, getMSDFTextClass } from './scene/text.js';
|
|
15
|
-
import { getInterpolatorClass, getSkeletonClass, getSkeletonRigClass, getSkinBindingClass, getJointDynamicsModifierClass, getAnimationClass, getPropTrackClass, getNodeRotationTrackClass, getNodeScaleTrackClass, getNodeTranslationTrackClass, getNodeEulerRotationTrackClass, getFixedGeometryCacheTrackClass, getPCAGeometryCacheTrackClass, getMorphTrackClass } from './scene/animation.js';
|
|
15
|
+
import { getInterpolatorClass, getSkeletonClass, getSkeletonRigClass, getSkinBindingClass, getJointDynamicsModifierClass, getAnimationClass, getPropTrackClass, getNodeRotationTrackClass, getNodeScaleTrackClass, getNodeTranslationTrackClass, getNodeEulerRotationTrackClass, getFixedGeometryCacheTrackClass, getPCAGeometryCacheTrackClass, getMorphTrackClass, getMorphTargetGroupTrackClass } from './scene/animation.js';
|
|
16
16
|
import '../../scene/scene.js';
|
|
17
17
|
import '../../values.js';
|
|
18
18
|
import '../../render/render_queue.js';
|
|
@@ -185,6 +185,7 @@ const defaultValues = {
|
|
|
185
185
|
getFixedGeometryCacheTrackClass(),
|
|
186
186
|
getPCAGeometryCacheTrackClass(),
|
|
187
187
|
getMorphTrackClass(),
|
|
188
|
+
getMorphTargetGroupTrackClass(),
|
|
188
189
|
getSceneNodeClass(this),
|
|
189
190
|
getGraphNodeClass(),
|
|
190
191
|
getMeshClass(),
|