@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.2
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/LICENSE +3 -1
- package/dist/animation/key-frames.d.ts +1 -1
- package/dist/animation/key-frames.d.ts.map +1 -1
- package/dist/animation/key-frames.js +6 -27
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/timeline.d.ts +8 -8
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +18 -49
- package/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop-template.d.ts +23 -0
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
- package/dist/animation-loop/animation-loop-template.js +7 -0
- package/dist/animation-loop/animation-loop-template.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.d.ts +30 -22
- package/dist/animation-loop/animation-loop.d.ts.map +1 -0
- package/dist/{lib → animation-loop}/animation-loop.js +77 -192
- package/dist/animation-loop/animation-loop.js.map +1 -0
- package/dist/{lib → animation-loop}/animation-props.d.ts +2 -3
- package/dist/animation-loop/animation-props.d.ts.map +1 -0
- package/dist/animation-loop/animation-props.js.map +1 -0
- package/dist/animation-loop/make-animation-loop.d.ts +6 -0
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
- package/dist/animation-loop/make-animation-loop.js +28 -0
- package/dist/animation-loop/make-animation-loop.js.map +1 -0
- package/dist/debug/copy-texture-to-image.d.ts +26 -0
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
- package/dist/debug/copy-texture-to-image.js +46 -0
- package/dist/debug/copy-texture-to-image.js.map +1 -0
- package/dist/debug/debug-framebuffer.d.ts +11 -0
- package/dist/debug/debug-framebuffer.d.ts.map +1 -0
- package/dist/debug/debug-framebuffer.js +43 -0
- package/dist/debug/debug-framebuffer.js.map +1 -0
- package/dist/debug/debug-shader-layout.d.ts +9 -0
- package/dist/debug/debug-shader-layout.d.ts.map +1 -0
- package/dist/debug/debug-shader-layout.js +28 -0
- package/dist/debug/debug-shader-layout.js.map +1 -0
- package/dist/debug/pixel-data-utils.d.ts +24 -0
- package/dist/debug/pixel-data-utils.d.ts.map +1 -0
- package/dist/debug/pixel-data-utils.js +41 -0
- package/dist/debug/pixel-data-utils.js.map +1 -0
- package/dist/dist.dev.js +10073 -0
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +6 -5
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.d.ts +2 -2
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +16 -10
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +6 -5
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +10 -19
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometries/plane-geometry.d.ts +2 -2
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +14 -23
- package/dist/geometries/plane-geometry.js.map +1 -1
- package/dist/geometries/sphere-geometry.d.ts +2 -2
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +9 -13
- package/dist/geometries/sphere-geometry.js.map +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +9 -25
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +2 -2
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +0 -9
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.d.ts +43 -43
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +20 -86
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +37 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +110 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +3120 -0
- package/dist/index.d.ts +24 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/clip-space.d.ts +8 -0
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +47 -0
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +12 -46
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +36 -179
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model.d.ts +206 -0
- package/dist/model/model.d.ts.map +1 -0
- package/dist/model/model.js +440 -0
- package/dist/model/model.js.map +1 -0
- package/dist/scenegraph/group-node.d.ts +21 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -0
- package/dist/scenegraph/group-node.js +94 -0
- package/dist/scenegraph/group-node.js.map +1 -0
- package/dist/scenegraph/model-node.d.ts +18 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -0
- package/dist/scenegraph/model-node.js +28 -0
- package/dist/scenegraph/model-node.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.d.ts +56 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-node.js +141 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -0
- package/dist/shader-inputs.d.ts +63 -0
- package/dist/shader-inputs.d.ts.map +1 -0
- package/dist/shader-inputs.js +66 -0
- package/dist/shader-inputs.js.map +1 -0
- package/dist/transform/buffer-transform.d.ts +35 -0
- package/dist/transform/buffer-transform.d.ts.map +1 -0
- package/dist/transform/buffer-transform.js +62 -0
- package/dist/transform/buffer-transform.js.map +1 -0
- package/dist/transform/texture-transform.d.ts +57 -0
- package/dist/transform/texture-transform.d.ts.map +1 -0
- package/dist/transform/texture-transform.js +122 -0
- package/dist/transform/texture-transform.js.map +1 -0
- package/dist.min.js +293 -0
- package/package.json +21 -12
- package/src/animation/timeline.ts +15 -14
- package/src/animation-loop/animation-loop-template.ts +23 -0
- package/src/{lib → animation-loop}/animation-loop.ts +99 -88
- package/src/{lib → animation-loop}/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +44 -0
- package/src/debug/copy-texture-to-image.ts +72 -0
- package/src/debug/debug-framebuffer.ts +57 -0
- package/src/debug/debug-shader-layout.ts +38 -0
- package/src/debug/pixel-data-utils.ts +57 -0
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +47 -45
- package/src/geometries/cylinder-geometry.ts +2 -2
- package/src/geometries/ico-sphere-geometry.ts +6 -5
- package/src/geometries/plane-geometry.ts +5 -4
- package/src/geometries/sphere-geometry.ts +4 -3
- package/src/geometries/truncated-cone-geometry.ts +4 -13
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +19 -3
- package/src/geometry/geometry.ts +65 -110
- package/src/geometry/gpu-geometry.ts +125 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/index.ts +34 -10
- package/src/lib/clip-space.ts +22 -21
- package/src/lib/pipeline-factory.ts +48 -179
- package/src/model/model.ts +733 -0
- package/src/scenegraph/group-node.ts +103 -0
- package/src/scenegraph/model-node.ts +50 -0
- package/src/scenegraph/scenegraph-node.ts +204 -0
- package/src/shader-inputs.ts +150 -0
- package/src/transform/buffer-transform.ts +94 -0
- package/src/transform/texture-transform.ts +169 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/dist/lib/animation-loop.d.ts.map +0 -1
- package/dist/lib/animation-loop.js.map +0 -1
- package/dist/lib/animation-props.d.ts.map +0 -1
- package/dist/lib/animation-props.js.map +0 -1
- package/dist/lib/model-utils.d.ts +0 -5
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js +0 -45
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts +0 -41
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js +0 -182
- package/dist/lib/model.js.map +0 -1
- package/dist/lib/render-loop.d.ts +0 -14
- package/dist/lib/render-loop.d.ts.map +0 -1
- package/dist/lib/render-loop.js +0 -49
- package/dist/lib/render-loop.js.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/geometry/primitive-utils.ts +0 -30
- package/src/lib/model-utils.ts +0 -124
- package/src/lib/model.ts +0 -183
- package/src/lib/render-loop.ts +0 -58
- /package/dist/{lib → animation-loop}/animation-props.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","names":["Buffer","RenderPipeline","UniformStore","getTypedArrayFromDataType","log","uid","deepEqual","splitUniformsAndBindings","isNumberArray","getAttributeInfosFromLayouts","ShaderAssembler","getShaderLayoutFromWGSL","ShaderInputs","makeGPUGeometry","PipelineFactory","getDebugTableForShaderLayout","debugFramebuffer","LOG_DRAW_PRIORITY","LOG_DRAW_TIMEOUT","Model","constructor","device","props","_this$props$modules","_this$props$modules2","_this$shaderInputs","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","vertexArray","transformFeedback","pipeline","shaderInputs","_uniformStore","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","_lastLogTime","_logOpen","_drawCount","defaultProps","Object","assign","moduleMap","fromEntries","modules","map","module","name","setShaderInputs","isWebGPU","info","type","source","_this$props","shaderLayout","_this$props2","wgsl","platformInfo","getPlatformInfo","length","getModules","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","warn","updateModuleSettings","seal","destroy","release","predraw","updateShaderInputs","draw","renderPass","_logDrawCallStart","indexCount","byteLength","indexType","undefined","_logDrawCallEnd","_logFramebuffer","gpuGeometry","setTopology","mergeBufferLayouts","attributeName","entries","find","layout","_setPipelineNeedsUpdate","setBufferLayout","setParameters","moduleName","keys","uniformBuffer","getManagedUniformBuffer","setShaderModuleProps","filter","k","uniform","getUniformValues","setTransformFeedback","buffers","_option","bufferName","buffer","getAttributeNames","includes","attributeNames","set","attributeInfo","setBuffer","location","value","setConstant","reason","createShader","stage","createRenderPipeline","logDrawTimeout","level","Date","now","group","collapsed","shaderLayoutTable","table","uniformTable","getDebugTable","attributeTable","_getAttributeDebugTable","groupEnd","debugFramebuffers","get","framebuffer","minimap","shaderType","values","_getBufferOrConstantValues","bufferDataType","Uint32Array","debugData","Uint16Array","toString","attribute","dataType","TypedArrayConstructor","typedArray","handle","defines","varyings","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push","shaderLanguage","shadingLanguage","shaderLanguageVersion","shadingLanguageVersion","gpu","features","_bufferLayout$attribu"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, RenderPipelineProps, RenderPipelineParameters} from '@luma.gl/core';\nimport type {BufferLayout, VertexArray, TransformFeedback} from '@luma.gl/core';\nimport type {AttributeInfo, Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {\n Device,\n Buffer,\n RenderPipeline,\n RenderPass,\n UniformStore,\n getTypedArrayFromDataType\n} from '@luma.gl/core';\nimport {log, uid, deepEqual, splitUniformsAndBindings, isNumberArray} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';\nimport {ShaderAssembler, getShaderLayoutFromWGSL} from '@luma.gl/shadertools';\nimport {ShaderInputs} from '../shader-inputs';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\nimport {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';\nimport {debugFramebuffer} from '../debug/debug-framebuffer';\n\nconst LOG_DRAW_PRIORITY = 2;\nconst LOG_DRAW_TIMEOUT = 10000;\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n source?: string;\n vs: {glsl?: string; wgsl?: string} | string | null;\n fs: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n // TODO - injections, hooks etc?\n\n /** Shader inputs, used to generated uniform buffers and bindings */\n shaderInputs?: ShaderInputs;\n /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** @internal For use with {@link TransformFeedback}, WebGL 2 only. */\n varyings?: string[];\n\n transformFeedback?: TransformFeedback;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n source: null,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: undefined!,\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n varyings: [],\n\n shaderInputs: undefined!,\n pipelineFactory: undefined!,\n transformFeedback: undefined,\n shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()\n };\n\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string;\n readonly pipelineFactory: PipelineFactory;\n userData: {[key: string]: any} = {};\n\n // Fixed properties (change can trigger pipeline rebuild)\n\n /** The render pipeline GPU parameters, depth testing etc */\n parameters: RenderPipelineParameters;\n\n /** The primitive topology */\n topology: PrimitiveTopology;\n /** Buffer layout */\n bufferLayout: BufferLayout[];\n\n // Dynamic properties\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\n\n /** Index buffer */\n indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n /** TransformFeedback, WebGL 2 only. */\n transformFeedback: TransformFeedback | null = null;\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /** ShaderInputs instance */\n shaderInputs: ShaderInputs;\n\n _uniformStore: UniformStore;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n // Setup shader module inputs\n const moduleMap = Object.fromEntries(\n this.props.modules?.map(module => [module.name, module]) || []\n );\n this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));\n\n const isWebGPU = this.device.info.type === 'webgpu';\n // TODO - hack to support unified WGSL shader\n // TODO - this is wrong, compile a single shader\n if (this.props.source) {\n if (isWebGPU) {\n this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.source);\n }\n this.props.fs = this.props.source;\n this.props.vs = this.props.source;\n }\n\n // Support WGSL shader layout introspection\n if (isWebGPU && typeof this.props.vs !== 'string') {\n this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.vs.wgsl);\n }\n\n // Setup shader assembler\n const platformInfo = getPlatformInfo(device);\n\n // Extract modules from shader inputs if not supplied\n const modules =\n (this.props.modules?.length > 0 ? this.props.modules : this.shaderInputs?.getModules()) || [];\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders({\n platformInfo,\n ...this.props,\n modules\n });\n\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer');\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n log.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()')();\n this.updateModuleSettings(props.moduleSettings);\n }\n if (props.transformFeedback) {\n this.transformFeedback = props.transformFeedback;\n }\n\n // WebGL1?\n // this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Catch any access to non-standard props\n Object.seal(this);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n this._uniformStore.destroy();\n }\n\n // Draw call\n\n predraw() {\n // Update uniform buffers if needed\n this.updateShaderInputs();\n }\n\n draw(renderPass: RenderPass): void {\n this.predraw();\n\n try {\n this._logDrawCallStart();\n\n // Check if the pipeline is invalidated\n // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?\n this.pipeline = this._updatePipeline();\n\n // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw\n // Any caching needs to be done inside the pipeline functions\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n const {indexBuffer} = this.vertexArray;\n const indexCount = indexBuffer ? indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2) : undefined;\n \n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount,\n indexCount,\n transformFeedback: this.transformFeedback\n });\n } finally {\n this._logDrawCallEnd();\n }\n this._logFramebuffer(renderPass);\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(gpuGeometry.bufferLayout, this.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // Filter geometry attribute so that we don't issue warnings for unused attributes\n const attributes = {...gpuGeometry.attributes};\n for (const [attributeName] of Object.entries(attributes)) {\n if (\n !this.pipeline.shaderLayout.attributes.find(layout => layout.name === attributeName) &&\n attributeName !== 'positions'\n ) {\n delete attributes[attributeName];\n }\n }\n\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setIndexBuffer(gpuGeometry.indices);\n this.setAttributes(gpuGeometry.attributes, 'ignore-unknown');\n this.setAttributes(attributes);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n\n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n setShaderInputs(shaderInputs: ShaderInputs): void {\n this.shaderInputs = shaderInputs;\n this._uniformStore = new UniformStore(this.shaderInputs.modules);\n // Create uniform buffer bindings for all modules\n for (const moduleName of Object.keys(this.shaderInputs.modules)) {\n const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);\n this.bindings[`${moduleName}Uniforms`] = uniformBuffer;\n }\n }\n\n /**\n * Updates shader module settings (which results in uniforms being set)\n */\n setShaderModuleProps(props: Record<string, any>): void {\n const uniforms = this._getModuleUniforms(props);\n\n // Extract textures & framebuffers set by the modules\n // TODO better way to extract bindings\n const keys = Object.keys(uniforms).filter(k => {\n const uniform = uniforms[k];\n return !isNumberArray(uniform) && typeof uniform !== 'number' && typeof uniform !== 'boolean';\n });\n const bindings: Record<string, Binding> = {};\n for (const k of keys) {\n bindings[k] = uniforms[k];\n delete uniforms[k];\n }\n }\n\n updateShaderInputs(): void {\n this._uniformStore.setUniforms(this.shaderInputs.getUniformValues());\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n log.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()')();\n const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));\n Object.assign(this.bindings, bindings);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Updates optional transform feedback. WebGL 2 only.\n */\n setTransformFeedback(transformFeedback: TransformFeedback | null): void {\n this.transformFeedback = transformFeedback;\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>, _option?: 'ignore-unknown'): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n )();\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => getAttributeNames(layout).includes(bufferName));\n if (!bufferLayout) {\n log.warn(`Model(${this.id}): Missing layout for buffer \"${bufferName}\".`)();\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = getAttributeNames(bufferLayout);\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set && _option !== 'ignore-unknown') {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(\n `Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`\n )();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(\n 1,\n `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`\n )();\n }\n \n this._pipelineNeedsUpdate = false;\n\n const vs = this.device.createShader({\n id: `${this.id}-vertex`,\n stage: 'vertex',\n source: this.vs\n });\n\n const fs = this.fs\n ? this.device.createShader({\n id: `${this.id}-fragment`,\n stage: 'fragment',\n source: this.fs\n })\n : null;\n\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs,\n fs\n });\n\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n\n /** Throttle draw call logging */\n _lastLogTime = 0;\n _logOpen = false;\n\n _logDrawCallStart(): void {\n // IF level is 4 or higher, log every frame.\n const logDrawTimeout = log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;\n if (log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {\n return;\n }\n\n this._lastLogTime = Date.now();\n this._logOpen = true;\n\n log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, {collapsed: log.level <= 2})();\n }\n\n _logDrawCallEnd(): void {\n if (this._logOpen) {\n const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);\n\n // log.table(logLevel, attributeTable)();\n // log.table(logLevel, uniformTable)();\n log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();\n\n const uniformTable = this.shaderInputs.getDebugTable();\n // Add any global uniforms\n for (const [name, value] of Object.entries(this.uniforms)) {\n uniformTable[name] = {value};\n }\n log.table(LOG_DRAW_PRIORITY, uniformTable)();\n\n const attributeTable = this._getAttributeDebugTable();\n log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();\n log.table(LOG_DRAW_PRIORITY, attributeTable)();\n\n log.groupEnd(LOG_DRAW_PRIORITY)();\n this._logOpen = false;\n }\n }\n\n protected _drawCount = 0;\n _logFramebuffer(renderPass: RenderPass): void {\n const debugFramebuffers = log.get('framebuffer');\n this._drawCount++;\n // Update first 3 frames and then every 60 frames\n if (!debugFramebuffers || ((this._drawCount++ > 3) && (this._drawCount % 60))) {\n return;\n }\n // TODO - display framebuffer output in debug window\n const framebuffer = renderPass.props.framebuffer;\n if (framebuffer) {\n debugFramebuffer(framebuffer, {id: framebuffer.id, minimap: true});\n // log.image({logLevel: LOG_DRAW_PRIORITY, message: `${framebuffer.id} %c sup?`, image})();\n }\n }\n\n _getAttributeDebugTable(): Record<string, Record<string, unknown>> {\n const table: Record<string, Record<string, unknown>> = {};\n for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {\n table[attributeInfo.location] = {\n name,\n type: attributeInfo.shaderType,\n values: this._getBufferOrConstantValues(\n this.vertexArray.attributes[attributeInfo.location],\n attributeInfo.bufferDataType\n )\n };\n }\n if (this.vertexArray.indexBuffer) {\n const {indexBuffer} = this.vertexArray;\n const values =\n indexBuffer.indexType === 'uint32'\n ? new Uint32Array(indexBuffer.debugData)\n : new Uint16Array(indexBuffer.debugData);\n table.indices = {\n name: 'indices',\n type: indexBuffer.indexType,\n values: values.toString()\n };\n }\n return table;\n }\n\n // TODO - fix typing of luma data types\n _getBufferOrConstantValues(attribute: Buffer | TypedArray, dataType: any): string {\n const TypedArrayConstructor = getTypedArrayFromDataType(dataType);\n const typedArray =\n attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;\n return typedArray.toString();\n }\n}\n\n// HELPERS\n\n/** TODO - move to core, document add tests */\nfunction mergeBufferLayouts(layouts1: BufferLayout[], layouts2: BufferLayout[]): BufferLayout[] {\n const layouts = [...layouts1];\n for (const attribute of layouts2) {\n const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n\n/** Create a shadertools platform info from the Device */\nexport function getPlatformInfo(device: Device): PlatformInfo {\n return {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguage,\n shaderLanguageVersion: device.info.shadingLanguageVersion as 100 | 300,\n gpu: device.info.gpu,\n features: device.features\n };\n}\n\n/** Get attribute names from a BufferLayout */\nfunction getAttributeNames(bufferLayout: BufferLayout): string[] {\n return bufferLayout.attributes\n ? b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ix4 } from '@math.gl/core';
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from './scenegraph-node';
|
|
3
|
+
export type GroupNodeProps = ScenegraphNodeProps & {
|
|
4
|
+
children?: ScenegraphNode[];
|
|
5
|
+
};
|
|
6
|
+
export declare class GroupNode extends ScenegraphNode {
|
|
7
|
+
children: ScenegraphNode[];
|
|
8
|
+
constructor(children: ScenegraphNode[]);
|
|
9
|
+
constructor(props?: GroupNodeProps);
|
|
10
|
+
getBounds(): [number[], number[]] | null;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
add(...children: (ScenegraphNode | ScenegraphNode[])[]): this;
|
|
13
|
+
remove(child: ScenegraphNode): this;
|
|
14
|
+
removeAll(): this;
|
|
15
|
+
traverse(visitor: (node: ScenegraphNode, context: {
|
|
16
|
+
worldMatrix: Matrix4;
|
|
17
|
+
}) => void, { worldMatrix }?: {
|
|
18
|
+
worldMatrix?: Matrix4;
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=group-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/group-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtE,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B,CAAA;AAED,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,EAAE,cAAc,EAAE,CAAC;gBAEf,QAAQ,EAAE,cAAc,EAAE;gBAC1B,KAAK,CAAC,EAAE,cAAc;IAazB,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAkCxC,OAAO,IAAI,IAAI;IAOxB,GAAG,CAAC,GAAG,QAAQ,EAAE,CAAC,cAAc,GAAG,cAAc,EAAE,CAAC,EAAE,GAAG,IAAI;IAW7D,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IASnC,SAAS,IAAI,IAAI;IAKjB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE;QAAC,WAAW,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,EAAE,EAAC,WAA2B,EAAC;;KAAK;CAWtH"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
2
|
+
import { log } from '@luma.gl/core';
|
|
3
|
+
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
4
|
+
export class GroupNode extends ScenegraphNode {
|
|
5
|
+
constructor() {
|
|
6
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
7
|
+
props = Array.isArray(props) ? {
|
|
8
|
+
children: props
|
|
9
|
+
} : props;
|
|
10
|
+
const {
|
|
11
|
+
children = []
|
|
12
|
+
} = props;
|
|
13
|
+
log.assert(children.every(child => child instanceof ScenegraphNode), 'every child must an instance of ScenegraphNode');
|
|
14
|
+
super(props);
|
|
15
|
+
this.children = void 0;
|
|
16
|
+
this.children = children;
|
|
17
|
+
}
|
|
18
|
+
getBounds() {
|
|
19
|
+
const result = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
|
|
20
|
+
this.traverse((node, _ref) => {
|
|
21
|
+
let {
|
|
22
|
+
worldMatrix
|
|
23
|
+
} = _ref;
|
|
24
|
+
const bounds = node.getBounds();
|
|
25
|
+
if (!bounds) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const [min, max] = bounds;
|
|
29
|
+
const center = new Vector3(min).add(max).divide([2, 2, 2]);
|
|
30
|
+
worldMatrix.transformAsPoint(center, center);
|
|
31
|
+
const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
32
|
+
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
33
|
+
for (let v = 0; v < 8; v++) {
|
|
34
|
+
const position = new Vector3(v & 0b001 ? -1 : 1, v & 0b010 ? -1 : 1, v & 0b100 ? -1 : 1).multiply(halfSize).add(center);
|
|
35
|
+
for (let i = 0; i < 3; i++) {
|
|
36
|
+
result[0][i] = Math.min(result[0][i], position[i]);
|
|
37
|
+
result[1][i] = Math.max(result[1][i], position[i]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (!Number.isFinite(result[0][0])) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.children.forEach(child => child.destroy());
|
|
48
|
+
this.removeAll();
|
|
49
|
+
super.destroy();
|
|
50
|
+
}
|
|
51
|
+
add() {
|
|
52
|
+
for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
+
children[_key] = arguments[_key];
|
|
54
|
+
}
|
|
55
|
+
for (const child of children) {
|
|
56
|
+
if (Array.isArray(child)) {
|
|
57
|
+
this.add(...child);
|
|
58
|
+
} else {
|
|
59
|
+
this.children.push(child);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
remove(child) {
|
|
65
|
+
const children = this.children;
|
|
66
|
+
const indexOf = children.indexOf(child);
|
|
67
|
+
if (indexOf > -1) {
|
|
68
|
+
children.splice(indexOf, 1);
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
removeAll() {
|
|
73
|
+
this.children = [];
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
traverse(visitor) {
|
|
77
|
+
let {
|
|
78
|
+
worldMatrix = new Matrix4()
|
|
79
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
80
|
+
const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
81
|
+
for (const child of this.children) {
|
|
82
|
+
if (child instanceof GroupNode) {
|
|
83
|
+
child.traverse(visitor, {
|
|
84
|
+
worldMatrix: modelMatrix
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
visitor(child, {
|
|
88
|
+
worldMatrix: modelMatrix
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=group-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-node.js","names":["Matrix4","Vector3","log","ScenegraphNode","GroupNode","constructor","props","arguments","length","undefined","Array","isArray","children","assert","every","child","getBounds","result","Infinity","traverse","node","_ref","worldMatrix","bounds","min","max","center","add","divide","transformAsPoint","halfSize","subtract","transformAsVector","v","position","multiply","i","Math","Number","isFinite","destroy","forEach","removeAll","_len","_key","push","remove","indexOf","splice","visitor","modelMatrix","multiplyRight","matrix"],"sources":["../../src/scenegraph/group-node.ts"],"sourcesContent":["import {Matrix4, Vector3} from '@math.gl/core';\nimport {log} from '@luma.gl/core';\nimport {ScenegraphNode, ScenegraphNodeProps} from './scenegraph-node';\n\nexport type GroupNodeProps = ScenegraphNodeProps & {\n children?: ScenegraphNode[];\n}\n\nexport class GroupNode extends ScenegraphNode {\n children: ScenegraphNode[];\n\n constructor(children: ScenegraphNode[]);\n constructor(props?: GroupNodeProps);\n\n constructor(props: ScenegraphNode[] | GroupNodeProps = {}) {\n props = Array.isArray(props) ? {children: props} : props;\n const {children = []} = props;\n log.assert(\n children.every((child) => child instanceof ScenegraphNode),\n 'every child must an instance of ScenegraphNode'\n );\n super(props);\n this.children = children;\n }\n\n override getBounds(): [number[], number[]] | null {\n const result: [number[], number[]] = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];\n\n this.traverse((node, {worldMatrix}) => {\n const bounds = node.getBounds();\n if (!bounds) {\n return;\n }\n const [min, max] = bounds;\n const center = new Vector3(min).add(max).divide([2, 2, 2]);\n worldMatrix.transformAsPoint(center, center);\n const halfSize = new Vector3(max).subtract(min).divide([2, 2, 2]);\n worldMatrix.transformAsVector(halfSize, halfSize);\n\n for (let v = 0; v < 8; v++) {\n // Test all 8 corners of the box\n const position = new Vector3(\n v & 0b001 ? -1 : 1,\n v & 0b010 ? -1 : 1,\n v & 0b100 ? -1 : 1\n ).multiply(halfSize).add(center);\n\n for (let i = 0; i < 3; i++) {\n result[0][i] = Math.min(result[0][i], position[i]);\n result[1][i] = Math.max(result[1][i], position[i]);\n }\n }\n });\n if (!Number.isFinite(result[0][0])) {\n return null;\n }\n return result;\n }\n\n override destroy(): void {\n this.children.forEach((child) => child.destroy());\n this.removeAll();\n super.destroy();\n }\n\n // Unpacks arrays and nested arrays of children\n add(...children: (ScenegraphNode | ScenegraphNode[])[]): this {\n for (const child of children) {\n if (Array.isArray(child)) {\n this.add(...child);\n } else {\n this.children.push(child);\n }\n }\n return this;\n }\n\n remove(child: ScenegraphNode): this {\n const children = this.children;\n const indexOf = children.indexOf(child);\n if (indexOf > -1) {\n children.splice(indexOf, 1);\n }\n return this;\n }\n\n removeAll(): this {\n this.children = [];\n return this;\n }\n\n traverse(visitor: (node: ScenegraphNode, context: {worldMatrix: Matrix4}) => void, {worldMatrix = new Matrix4()} = {}) {\n const modelMatrix = new Matrix4(worldMatrix).multiplyRight(this.matrix);\n\n for (const child of this.children) {\n if (child instanceof GroupNode) {\n child.traverse(visitor, {worldMatrix: modelMatrix});\n } else {\n visitor(child, {worldMatrix: modelMatrix});\n }\n }\n }\n}\n"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,GAAG,QAAO,eAAe;AAAC,SAC1BC,cAAc;AAMtB,OAAO,MAAMC,SAAS,SAASD,cAAc,CAAC;EAM5CE,WAAWA,CAAA,EAAgD;IAAA,IAA/CC,KAAwC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,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jC,IAAIG,KAAK,YAAYX,SAAS,EAAE;QAC9BW,KAAK,CAACI,QAAQ,CAAC8B,OAAO,EAAE;UAAC3B,WAAW,EAAE4B;QAAW,CAAC,CAAC;MACrD,CAAC,MAAM;QACLD,OAAO,CAAClC,KAAK,EAAE;UAACO,WAAW,EAAE4B;QAAW,CAAC,CAAC;MAC5C;IACF;EACF;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RenderPass } from '@luma.gl/core';
|
|
2
|
+
import { ScenegraphNode, ScenegraphNodeProps } from './scenegraph-node';
|
|
3
|
+
import { Model } from '../model/model';
|
|
4
|
+
export type ModelNodeProps = ScenegraphNodeProps & {
|
|
5
|
+
model: Model;
|
|
6
|
+
managedResources?: any[];
|
|
7
|
+
bounds?: [number[], number[]];
|
|
8
|
+
};
|
|
9
|
+
export declare class ModelNode extends ScenegraphNode {
|
|
10
|
+
readonly model: Model;
|
|
11
|
+
bounds: [number[], number[]] | null;
|
|
12
|
+
managedResources: any[];
|
|
13
|
+
constructor(props: ModelNodeProps);
|
|
14
|
+
getBounds(): [number[], number[]] | null;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
draw(renderPass?: RenderPass): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=model-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/model-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG;IACjD,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAC/B,CAAA;AAED,qBAAa,SAAU,SAAQ,cAAc;IAC3C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAQ;IAC3C,gBAAgB,EAAE,GAAG,EAAE,CAAC;gBAOZ,KAAK,EAAE,cAAc;IAUxB,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAIxC,OAAO,IAAI,IAAI;IAWxB,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU;CAI7B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ScenegraphNode } from "./scenegraph-node.js";
|
|
2
|
+
export class ModelNode extends ScenegraphNode {
|
|
3
|
+
constructor(props) {
|
|
4
|
+
super(props);
|
|
5
|
+
this.model = void 0;
|
|
6
|
+
this.bounds = null;
|
|
7
|
+
this.managedResources = void 0;
|
|
8
|
+
this.model = props.model;
|
|
9
|
+
this.managedResources = props.managedResources || [];
|
|
10
|
+
this.bounds = props.bounds || null;
|
|
11
|
+
this.setProps(props);
|
|
12
|
+
}
|
|
13
|
+
getBounds() {
|
|
14
|
+
return this.bounds;
|
|
15
|
+
}
|
|
16
|
+
destroy() {
|
|
17
|
+
if (this.model) {
|
|
18
|
+
this.model.destroy();
|
|
19
|
+
this.model = null;
|
|
20
|
+
}
|
|
21
|
+
this.managedResources.forEach(resource => resource.destroy());
|
|
22
|
+
this.managedResources = [];
|
|
23
|
+
}
|
|
24
|
+
draw(renderPass) {
|
|
25
|
+
return this.model.draw(renderPass);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=model-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-node.js","names":["ScenegraphNode","ModelNode","constructor","props","model","bounds","managedResources","setProps","getBounds","destroy","forEach","resource","draw","renderPass"],"sources":["../../src/scenegraph/model-node.ts"],"sourcesContent":["import {RenderPass} from '@luma.gl/core';\nimport {ScenegraphNode, ScenegraphNodeProps} from './scenegraph-node';\nimport {Model} from '../model/model';\n\nexport type ModelNodeProps = ScenegraphNodeProps & {\n model: Model;\n managedResources?: any[];\n bounds?: [number[], number[]];\n}\n\nexport class ModelNode extends ScenegraphNode {\n readonly model: Model;\n bounds: [number[], number[]] | null = null;\n managedResources: any[];\n\n // TODO - is this used? override callbacks to make sure we call them with this\n // onBeforeRender = null;\n // onAfterRender = null;\n // AfterRender = null;\n\n constructor(props: ModelNodeProps) {\n super(props);\n\n // Create new Model or used supplied Model\n this.model = props.model;\n this.managedResources = props.managedResources || [];\n this.bounds = props.bounds || null;\n this.setProps(props);\n }\n\n override getBounds(): [number[], number[]] | null {\n return this.bounds;\n }\n\n override destroy(): void {\n if (this.model) {\n this.model.destroy();\n // @ts-expect-error\n this.model = null;\n }\n this.managedResources.forEach((resource) => resource.destroy());\n this.managedResources = [];\n }\n\n // Expose model methods\n draw(renderPass?: RenderPass) {\n // Return value indicates if something was actually drawn\n return this.model.draw(renderPass);\n }\n}\n"],"mappings":"SACQA,cAAc;AAStB,OAAO,MAAMC,SAAS,SAASD,cAAc,CAAC;EAU5CE,WAAWA,CAACC,KAAqB,EAAE;IACjC,KAAK,CAACA,KAAK,CAAC;IAAC,KAVNC,KAAK;IAAA,KACdC,MAAM,GAAgC,IAAI;IAAA,KAC1CC,gBAAgB;IAWd,IAAI,CAACF,KAAK,GAAGD,KAAK,CAACC,KAAK;IACxB,IAAI,CAACE,gBAAgB,GAAGH,KAAK,CAACG,gBAAgB,IAAI,EAAE;IACpD,IAAI,CAACD,MAAM,GAAGF,KAAK,CAACE,MAAM,IAAI,IAAI;IAClC,IAAI,CAACE,QAAQ,CAACJ,KAAK,CAAC;EACtB;EAESK,SAASA,CAAA,EAAgC;IAChD,OAAO,IAAI,CAACH,MAAM;EACpB;EAESI,OAAOA,CAAA,EAAS;IACvB,IAAI,IAAI,CAACL,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACK,OAAO,CAAC,CAAC;MAEpB,IAAI,CAACL,KAAK,GAAG,IAAI;IACnB;IACA,IAAI,CAACE,gBAAgB,CAACI,OAAO,CAAEC,QAAQ,IAAKA,QAAQ,CAACF,OAAO,CAAC,CAAC,CAAC;IAC/D,IAAI,CAACH,gBAAgB,GAAG,EAAE;EAC5B;EAGAM,IAAIA,CAACC,UAAuB,EAAE;IAE5B,OAAO,IAAI,CAACT,KAAK,CAACQ,IAAI,CAACC,UAAU,CAAC;EACpC;AACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NumberArray } from '@luma.gl/core';
|
|
2
|
+
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
3
|
+
/** Properties for creating a new Scenegraph */
|
|
4
|
+
export type ScenegraphNodeProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
/** whether to display the object at all */
|
|
7
|
+
display?: boolean;
|
|
8
|
+
matrix?: NumberArray;
|
|
9
|
+
position?: NumberArray;
|
|
10
|
+
rotation?: NumberArray;
|
|
11
|
+
scale?: NumberArray;
|
|
12
|
+
update?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class ScenegraphNode {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
matrix: Matrix4;
|
|
17
|
+
display: boolean;
|
|
18
|
+
position: Vector3;
|
|
19
|
+
rotation: Vector3;
|
|
20
|
+
scale: Vector3;
|
|
21
|
+
userData: Record<string, unknown>;
|
|
22
|
+
props: ScenegraphNodeProps;
|
|
23
|
+
constructor(props?: ScenegraphNodeProps);
|
|
24
|
+
getBounds(): [number[], number[]] | null;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
/** @deprecated use .destroy() */
|
|
27
|
+
delete(): void;
|
|
28
|
+
setProps(props: ScenegraphNodeProps): this;
|
|
29
|
+
toString(): string;
|
|
30
|
+
setPosition(position: any): this;
|
|
31
|
+
setRotation(rotation: any): this;
|
|
32
|
+
setScale(scale: any): this;
|
|
33
|
+
setMatrix(matrix: any, copyMatrix?: boolean): void;
|
|
34
|
+
setMatrixComponents(components: {
|
|
35
|
+
position?: any;
|
|
36
|
+
rotation?: any;
|
|
37
|
+
scale?: any;
|
|
38
|
+
update?: boolean;
|
|
39
|
+
}): this;
|
|
40
|
+
updateMatrix(): this;
|
|
41
|
+
update(options?: {
|
|
42
|
+
position?: any;
|
|
43
|
+
rotation?: any;
|
|
44
|
+
scale?: any;
|
|
45
|
+
}): this;
|
|
46
|
+
getCoordinateUniforms(viewMatrix: any, modelMatrix?: any): {
|
|
47
|
+
viewMatrix: any;
|
|
48
|
+
modelMatrix: any;
|
|
49
|
+
objectMatrix: any;
|
|
50
|
+
worldMatrix: any;
|
|
51
|
+
worldInverseMatrix: any;
|
|
52
|
+
worldInverseTransposeMatrix: any;
|
|
53
|
+
};
|
|
54
|
+
_setScenegraphNodeProps(props: ScenegraphNodeProps): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=scenegraph-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenegraph-node.d.ts","sourceRoot":"","sources":["../../src/scenegraph/scenegraph-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,WAAW,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AAEF,qBAAa,cAAc;IACzB,QA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,YAAY,EAAE,GAAG,CAAC;QAClB,WAAW,EAAE,GAAG,CAAC;QACjB,kBAAkB,EAAE,GAAG,CAAC;QACxB,2BAA2B,EAAE,GAAG,CAAC;KAClC;IA0CD,uBAAuB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAsB1D"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { assert, uid } from '@luma.gl/core';
|
|
2
|
+
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
3
|
+
export class ScenegraphNode {
|
|
4
|
+
constructor() {
|
|
5
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6
|
+
this.id = void 0;
|
|
7
|
+
this.matrix = new Matrix4();
|
|
8
|
+
this.display = true;
|
|
9
|
+
this.position = new Vector3();
|
|
10
|
+
this.rotation = new Vector3();
|
|
11
|
+
this.scale = new Vector3(1, 1, 1);
|
|
12
|
+
this.userData = {};
|
|
13
|
+
this.props = {};
|
|
14
|
+
const {
|
|
15
|
+
id
|
|
16
|
+
} = props;
|
|
17
|
+
this.id = id || uid(this.constructor.name);
|
|
18
|
+
this._setScenegraphNodeProps(props);
|
|
19
|
+
}
|
|
20
|
+
getBounds() {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
destroy() {}
|
|
24
|
+
delete() {
|
|
25
|
+
this.destroy();
|
|
26
|
+
}
|
|
27
|
+
setProps(props) {
|
|
28
|
+
this._setScenegraphNodeProps(props);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
toString() {
|
|
32
|
+
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
33
|
+
}
|
|
34
|
+
setPosition(position) {
|
|
35
|
+
assert(position.length === 3, 'setPosition requires vector argument');
|
|
36
|
+
this.position = position;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
setRotation(rotation) {
|
|
40
|
+
assert(rotation.length === 3, 'setRotation requires vector argument');
|
|
41
|
+
this.rotation = rotation;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
setScale(scale) {
|
|
45
|
+
assert(scale.length === 3, 'setScale requires vector argument');
|
|
46
|
+
this.scale = scale;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
setMatrix(matrix) {
|
|
50
|
+
let copyMatrix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
51
|
+
if (copyMatrix) {
|
|
52
|
+
this.matrix.copy(matrix);
|
|
53
|
+
} else {
|
|
54
|
+
this.matrix = matrix;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
setMatrixComponents(components) {
|
|
58
|
+
const {
|
|
59
|
+
position,
|
|
60
|
+
rotation,
|
|
61
|
+
scale,
|
|
62
|
+
update = true
|
|
63
|
+
} = components;
|
|
64
|
+
if (position) {
|
|
65
|
+
this.setPosition(position);
|
|
66
|
+
}
|
|
67
|
+
if (rotation) {
|
|
68
|
+
this.setRotation(rotation);
|
|
69
|
+
}
|
|
70
|
+
if (scale) {
|
|
71
|
+
this.setScale(scale);
|
|
72
|
+
}
|
|
73
|
+
if (update) {
|
|
74
|
+
this.updateMatrix();
|
|
75
|
+
}
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
updateMatrix() {
|
|
79
|
+
const pos = this.position;
|
|
80
|
+
const rot = this.rotation;
|
|
81
|
+
const scale = this.scale;
|
|
82
|
+
this.matrix.identity();
|
|
83
|
+
this.matrix.translate(pos);
|
|
84
|
+
this.matrix.rotateXYZ(rot);
|
|
85
|
+
this.matrix.scale(scale);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
update() {
|
|
89
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
90
|
+
const {
|
|
91
|
+
position,
|
|
92
|
+
rotation,
|
|
93
|
+
scale
|
|
94
|
+
} = options;
|
|
95
|
+
if (position) {
|
|
96
|
+
this.setPosition(position);
|
|
97
|
+
}
|
|
98
|
+
if (rotation) {
|
|
99
|
+
this.setRotation(rotation);
|
|
100
|
+
}
|
|
101
|
+
if (scale) {
|
|
102
|
+
this.setScale(scale);
|
|
103
|
+
}
|
|
104
|
+
this.updateMatrix();
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
108
|
+
assert(viewMatrix);
|
|
109
|
+
modelMatrix = modelMatrix || this.matrix;
|
|
110
|
+
const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
111
|
+
const worldInverse = worldMatrix.invert();
|
|
112
|
+
const worldInverseTranspose = worldInverse.transpose();
|
|
113
|
+
return {
|
|
114
|
+
viewMatrix,
|
|
115
|
+
modelMatrix,
|
|
116
|
+
objectMatrix: modelMatrix,
|
|
117
|
+
worldMatrix,
|
|
118
|
+
worldInverseMatrix: worldInverse,
|
|
119
|
+
worldInverseTransposeMatrix: worldInverseTranspose
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
_setScenegraphNodeProps(props) {
|
|
123
|
+
if ('display' in props) {
|
|
124
|
+
this.display = props.display;
|
|
125
|
+
}
|
|
126
|
+
if ('position' in props) {
|
|
127
|
+
this.setPosition(props.position);
|
|
128
|
+
}
|
|
129
|
+
if ('rotation' in props) {
|
|
130
|
+
this.setRotation(props.rotation);
|
|
131
|
+
}
|
|
132
|
+
if ('scale' in props) {
|
|
133
|
+
this.setScale(props.scale);
|
|
134
|
+
}
|
|
135
|
+
if ('matrix' in props) {
|
|
136
|
+
this.setMatrix(props.matrix);
|
|
137
|
+
}
|
|
138
|
+
Object.assign(this.props, props);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=scenegraph-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenegraph-node.js","names":["assert","uid","Vector3","Matrix4","ScenegraphNode","constructor","props","arguments","length","undefined","id","matrix","display","position","rotation","scale","userData","name","_setScenegraphNodeProps","getBounds","destroy","delete","setProps","toString","setPosition","setRotation","setScale","setMatrix","copyMatrix","copy","setMatrixComponents","components","update","updateMatrix","pos","rot","identity","translate","rotateXYZ","options","getCoordinateUniforms","viewMatrix","modelMatrix","worldMatrix","multiplyRight","worldInverse","invert","worldInverseTranspose","transpose","objectMatrix","worldInverseMatrix","worldInverseTransposeMatrix","Object","assign"],"sources":["../../src/scenegraph/scenegraph-node.ts"],"sourcesContent":["import {assert, uid, NumberArray} from '@luma.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\n\n/** Properties for creating a new Scenegraph */\nexport type ScenegraphNodeProps = {\n id?: string;\n /** whether to display the object at all */\n display?: boolean;\n matrix?: NumberArray;\n position?: NumberArray;\n rotation?: NumberArray;\n scale?: NumberArray;\n update?: boolean\n};\n\nexport class ScenegraphNode {\n readonly id: string;\n matrix: Matrix4 = new Matrix4();\n\n display = true; \n position = new Vector3();\n rotation = new Vector3();\n scale = new Vector3(1, 1, 1);\n userData: Record<string, unknown> = {};\n\n props: ScenegraphNodeProps = {};\n\n constructor(props: ScenegraphNodeProps = {}) {\n const {id} = props;\n\n this.id = id || uid(this.constructor.name);\n\n this._setScenegraphNodeProps(props);\n }\n\n getBounds(): [number[], number[]] | null {\n return null;\n }\n\n destroy(): void {}\n\n /** @deprecated use .destroy() */\n delete(): void {\n this.destroy();\n }\n setProps(props: ScenegraphNodeProps): this {\n this._setScenegraphNodeProps(props);\n return this;\n }\n\n toString(): string {\n return `{type: ScenegraphNode, id: ${this.id})}`;\n }\n\n setPosition(position: any): this {\n assert(position.length === 3, 'setPosition requires vector argument');\n this.position = position;\n return this;\n }\n\n setRotation(rotation: any): this {\n assert(rotation.length === 3, 'setRotation requires vector argument');\n this.rotation = rotation;\n return this;\n }\n\n setScale(scale: any): this {\n assert(scale.length === 3, 'setScale requires vector argument');\n this.scale = scale;\n return this;\n }\n\n setMatrix(matrix: any, copyMatrix: boolean = true): void {\n if (copyMatrix) {\n this.matrix.copy(matrix);\n } else {\n this.matrix = matrix;\n }\n }\n\n setMatrixComponents(components: {\n position?: any;\n rotation?: any;\n scale?: any;\n update?: boolean;\n }): this {\n const {position, rotation, scale, update = true} = components;\n if (position) {\n this.setPosition(position);\n }\n if (rotation) {\n this.setRotation(rotation);\n }\n if (scale) {\n this.setScale(scale);\n }\n if (update) {\n this.updateMatrix();\n }\n return this;\n }\n\n updateMatrix(): this {\n const pos = this.position;\n const rot = this.rotation;\n const scale = this.scale;\n\n this.matrix.identity();\n this.matrix.translate(pos);\n this.matrix.rotateXYZ(rot);\n this.matrix.scale(scale);\n return this;\n }\n\n update(options: {position?: any; rotation?: any; scale?: any} = {}): this {\n const {position, rotation, scale} = options;\n if (position) {\n this.setPosition(position);\n }\n if (rotation) {\n this.setRotation(rotation);\n }\n if (scale) {\n this.setScale(scale);\n }\n this.updateMatrix();\n return this;\n }\n\n getCoordinateUniforms(\n viewMatrix: any,\n modelMatrix?: any\n ): {\n viewMatrix: any;\n modelMatrix: any;\n objectMatrix: any;\n worldMatrix: any;\n worldInverseMatrix: any;\n worldInverseTransposeMatrix: any;\n } {\n // TODO - solve multiple class problem\n // assert(viewMatrix instanceof Matrix4);\n assert(viewMatrix);\n modelMatrix = modelMatrix || this.matrix;\n const worldMatrix = new Matrix4(viewMatrix).multiplyRight(modelMatrix);\n const worldInverse = worldMatrix.invert();\n const worldInverseTranspose = worldInverse.transpose();\n\n return {\n viewMatrix,\n modelMatrix,\n objectMatrix: modelMatrix,\n worldMatrix,\n worldInverseMatrix: worldInverse,\n worldInverseTransposeMatrix: worldInverseTranspose\n };\n }\n\n // TODO - copied code, not yet vetted\n /*\n transform() {\n if (!this.parent) {\n this.endPosition.set(this.position);\n this.endRotation.set(this.rotation);\n this.endScale.set(this.scale);\n } else {\n const parent = this.parent;\n this.endPosition.set(this.position.add(parent.endPosition));\n this.endRotation.set(this.rotation.add(parent.endRotation));\n this.endScale.set(this.scale.add(parent.endScale));\n }\n\n const ch = this.children;\n for (let i = 0; i < ch.length; ++i) {\n ch[i].transform();\n }\n\n return this;\n }\n */\n\n _setScenegraphNodeProps(props: ScenegraphNodeProps): void {\n if ('display' in props) {\n this.display = props.display;\n }\n\n if ('position' in props) {\n this.setPosition(props.position);\n }\n if ('rotation' in props) {\n this.setRotation(props.rotation);\n }\n if ('scale' in props) {\n this.setScale(props.scale);\n }\n\n // Matrix overwrites other props\n if ('matrix' in props) {\n this.setMatrix(props.matrix);\n }\n\n Object.assign(this.props, props);\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAM,EAAEC,GAAG,QAAoB,eAAe;AACtD,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAc9C,OAAO,MAAMC,cAAc,CAAC;EAY1BC,WAAWA,CAAA,EAAkC;IAAA,IAAjCC,KAA0B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KAXlCG,EAAE;IAAA,KACXC,MAAM,GAAY,IAAIR,OAAO,CAAC,CAAC;IAAA,KAE/BS,OAAO,GAAG,IAAI;IAAA,KACdC,QAAQ,GAAG,IAAIX,OAAO,CAAC,CAAC;IAAA,KACxBY,QAAQ,GAAG,IAAIZ,OAAO,CAAC,CAAC;IAAA,KACxBa,KAAK,GAAG,IAAIb,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAAA,KAC5Bc,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCV,KAAK,GAAwB,CAAC,CAAC;IAG7B,MAAM;MAACI;IAAE,CAAC,GAAGJ,KAAK;IAElB,IAAI,CAACI,EAAE,GAAGA,EAAE,IAAIT,GAAG,CAAC,IAAI,CAACI,WAAW,CAACY,IAAI,CAAC;IAE1C,IAAI,CAACC,uBAAuB,CAACZ,KAAK,CAAC;EACrC;EAEAa,SAASA,CAAA,EAAgC;IACvC,OAAO,IAAI;EACb;EAEAC,OAAOA,CAAA,EAAS,CAAC;EAGjBC,MAAMA,CAAA,EAAS;IACb,IAAI,CAACD,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,IAAI,IAAI,CAAC/B,MAAM;IACxC,MAAMgC,WAAW,GAAG,IAAIxC,OAAO,CAACsC,UAAU,CAAC,CAACG,aAAa,CAACF,WAAW,CAAC;IACtE,MAAMG,YAAY,GAAGF,WAAW,CAACG,MAAM,CAAC,CAAC;IACzC,MAAMC,qBAAqB,GAAGF,YAAY,CAACG,SAAS,CAAC,CAAC;IAEtD,OAAO;MACLP,UAAU;MACVC,WAAW;MACXO,YAAY,EAAEP,WAAW;MACzBC,WAAW;MACXO,kBAAkB,EAAEL,YAAY;MAChCM,2BAA2B,EAAEJ;IAC/B,CAAC;EACH;EAyBA7B,uBAAuBA,CAACZ,KAA0B,EAAQ;IACxD,IAAI,SAAS,IAAIA,KAAK,EAAE;MACtB,IAAI,CAACM,OAAO,GAAGN,KAAK,CAACM,OAAO;IAC9B;IAEA,IAAI,UAAU,IAAIN,KAAK,EAAE;MACvB,IAAI,CAACkB,WAAW,CAAClB,KAAK,CAACO,QAAQ,CAAC;IAClC;IACA,IAAI,UAAU,IAAIP,KAAK,EAAE;MACvB,IAAI,CAACmB,WAAW,CAACnB,KAAK,CAACQ,QAAQ,CAAC;IAClC;IACA,IAAI,OAAO,IAAIR,KAAK,EAAE;MACpB,IAAI,CAACoB,QAAQ,CAACpB,KAAK,CAACS,KAAK,CAAC;IAC5B;IAGA,IAAI,QAAQ,IAAIT,KAAK,EAAE;MACrB,IAAI,CAACqB,SAAS,CAACrB,KAAK,CAACK,MAAM,CAAC;IAC9B;IAEAyC,MAAM,CAACC,MAAM,CAAC,IAAI,CAAC/C,KAAK,EAAEA,KAAK,CAAC;EAClC;AACF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { UniformValue, Texture, Sampler } from '@luma.gl/core';
|
|
2
|
+
import { ShaderModuleInstance } from '@luma.gl/shadertools';
|
|
3
|
+
/** Minimal ShaderModule subset, we don't need shader code etc */
|
|
4
|
+
export type ShaderModuleInputs<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string, Texture | Sampler> = Record<string, Texture | Sampler>> = {
|
|
5
|
+
defaultUniforms?: UniformsT;
|
|
6
|
+
getUniforms?: (settings: Partial<PropsT>, prevUniforms?: UniformsT) => UniformsT;
|
|
7
|
+
/** Not used. Used to access props type */
|
|
8
|
+
props?: PropsT;
|
|
9
|
+
bindings?: Record<keyof BindingsT, {
|
|
10
|
+
location: number;
|
|
11
|
+
type: 'texture' | 'sampler' | 'uniforms';
|
|
12
|
+
}>;
|
|
13
|
+
uniformTypes?: any;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* ShaderInputs holds uniform and binding values for one or more shader modules,
|
|
17
|
+
* - It can generate binary data for any uniform buffer
|
|
18
|
+
* - It can manage a uniform buffer for each block
|
|
19
|
+
* - It can update managed uniform buffers with a single call
|
|
20
|
+
* - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ShaderInputs<ShaderPropsT extends Partial<Record<string, Record<string, unknown>>> = Partial<Record<string, Record<string, unknown>>>> {
|
|
23
|
+
/**
|
|
24
|
+
* The map of modules
|
|
25
|
+
* @todo should should this include the resolved dependencies?
|
|
26
|
+
*/
|
|
27
|
+
modules: Readonly<{
|
|
28
|
+
[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>;
|
|
29
|
+
}>;
|
|
30
|
+
/** Stores the uniform values for each module */
|
|
31
|
+
moduleUniforms: Record<keyof ShaderPropsT, Record<string, UniformValue>>;
|
|
32
|
+
/** Stores the uniform bindings for each module */
|
|
33
|
+
moduleBindings: Record<keyof ShaderPropsT, Record<string, Texture | Sampler>>;
|
|
34
|
+
/** Tracks if uniforms have changed */
|
|
35
|
+
moduleUniformsChanged: Record<keyof ShaderPropsT, false | string>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new UniformStore instance
|
|
38
|
+
* @param modules
|
|
39
|
+
*/
|
|
40
|
+
constructor(modules: {
|
|
41
|
+
[P in keyof ShaderPropsT]: ShaderModuleInputs<ShaderPropsT[P]>;
|
|
42
|
+
});
|
|
43
|
+
/** Destroy */
|
|
44
|
+
destroy(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Set module props
|
|
47
|
+
*/
|
|
48
|
+
setProps(props: Partial<{
|
|
49
|
+
[P in keyof ShaderPropsT]?: Partial<ShaderPropsT[P]>;
|
|
50
|
+
}>): void;
|
|
51
|
+
/** Merges all bindings for the shader (from the various modules) */
|
|
52
|
+
/**
|
|
53
|
+
* Return the map of modules
|
|
54
|
+
* @todo should should this include the resolved dependencies?
|
|
55
|
+
*/
|
|
56
|
+
getModules(): ShaderModuleInstance[];
|
|
57
|
+
/** Get all uniform values for all modules */
|
|
58
|
+
getUniformValues(): Record<keyof ShaderPropsT, Record<string, UniformValue>>;
|
|
59
|
+
/** Merges all bindings for the shader (from the various modules) */
|
|
60
|
+
getBindings(): Record<string, Texture | Sampler>;
|
|
61
|
+
getDebugTable(): Record<string, Record<string, unknown>>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=shader-inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-inputs.d.ts","sourceRoot":"","sources":["../src/shader-inputs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAkB,oBAAoB,EAAC,MAAM,sBAAsB,CAAA;AAG1E,iEAAiE;AACjE,MAAM,MAAM,kBAAkB,CAC5B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC7E,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,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