| updateShaderProperties(material: {defines: Record<string, string|number|undefined>, uniforms: {[name: string]: IUniform}}): this { | updateShaderProperties(material: {defines: Record<string, string|number|undefined>, uniforms: {[name: string]: IUniform}}): this { | ||||
| if (material.uniforms.sceneBoundingRadius) material.uniforms.sceneBoundingRadius.value = this._sceneBoundingRadius | if (material.uniforms.sceneBoundingRadius) material.uniforms.sceneBoundingRadius.value = this._sceneBoundingRadius | ||||
| else console.warn('BaseRenderer: no uniform: frameCount') | |||||
| else console.warn('BaseRenderer: no uniform: sceneBoundingRadius') | |||||
| return this | return this | ||||
| } | } | ||||
| export {MaterialExtender, updateMaterialDefines} from './MaterialExtender' | |||||
| export {MaterialExtender, updateMaterialDefines, uiConfigMaterialExtension} from './MaterialExtender' | |||||
| export type {MaterialExtension, IShaderPropertiesUpdater} from './MaterialExtension' | export type {MaterialExtension, IShaderPropertiesUpdater} from './MaterialExtension' |
| import {ExtendedCopyPass} from '../../postprocessing' | import {ExtendedCopyPass} from '../../postprocessing' | ||||
| export interface RenderTargetBlock { | export interface RenderTargetBlock { | ||||
| target: ValOrFunc<IRenderTarget|{texture?: ValOrArr<ITexture>}|undefined> | |||||
| target: ValOrFunc<IRenderTarget|{texture?: ValOrArr<ITexture>}|undefined|null> | |||||
| name: string | name: string | ||||
| visible: boolean | visible: boolean | ||||
| transparent: boolean | transparent: boolean |
| if (Object.keys(dict).length < 1) break | if (Object.keys(dict).length < 1) break | ||||
| if (!updated) { | if (!updated) { | ||||
| console.error(entries, dict, pipeline) | console.error(entries, dict, pipeline) | ||||
| throw 'Not possible 2' | |||||
| throw 'Not possible 2' // when some dependency(required) doesnt exist. todo: show better error. | |||||
| break | break | ||||
| } | } | ||||
| } | } |
| } | } | ||||
| updateShaderProperties(material: {defines: Record<string, string|number|undefined>, uniforms: {[name: string]: IUniform}}): this { | updateShaderProperties(material: {defines: Record<string, string|number|undefined>, uniforms: {[name: string]: IUniform}}): this { | ||||
| // if (material.uniforms.currentFrameCount) material.uniforms.currentFrameCount.value = this.frameCount | |||||
| if (material.uniforms.currentFrameCount) material.uniforms.currentFrameCount.value = this.frameCount | |||||
| if (!this.stableNoise) { | if (!this.stableNoise) { | ||||
| if (material.uniforms.frameCount) material.uniforms.frameCount.value = this._totalFrameCount | if (material.uniforms.frameCount) material.uniforms.frameCount.value = this._totalFrameCount | ||||
| else console.warn('RenderManager: no uniform: frameCount') | else console.warn('RenderManager: no uniform: frameCount') |
| * @param propKey - uniform name | * @param propKey - uniform name | ||||
| * @param thisTarget - if `this` is the uniform (because uniforms = this wont work). It also adds _ in front of the name | * @param thisTarget - if `this` is the uniform (because uniforms = this wont work). It also adds _ in front of the name | ||||
| */ | */ | ||||
| export function uniform({uniforms, propKey, thisTarget = false}: {uniforms?: any, propKey?: string|symbol, thisTarget?:boolean} = {}): PropertyDecorator { | |||||
| export function uniform({uniforms, propKey, thisTarget = false, onChange}: {uniforms?: any, propKey?: string|symbol, thisTarget?:boolean, onChange?: (...args: any[]) => any} = {}): PropertyDecorator { | |||||
| // backing up properties as values are different when called again, no idea why. | // backing up properties as values are different when called again, no idea why. | ||||
| const cUniforms = !!uniforms | const cUniforms = !!uniforms | ||||
| const cPropKey = !!propKey | const cPropKey = !!propKey | ||||
| return getUniform(this).value | return getUniform(this).value | ||||
| }, | }, | ||||
| set(newVal: any) { | set(newVal: any) { | ||||
| getUniform(this).value = newVal | |||||
| let val = getUniform(this).value | |||||
| if (val === newVal) return | |||||
| val = newVal | |||||
| safeSetProperty(this, 'uniformsNeedUpdate', true, true) | safeSetProperty(this, 'uniformsNeedUpdate', true, true) | ||||
| onChange && callOnChange.call(this, onChange, [propertyKey, newVal]) | |||||
| }, | }, | ||||
| // configurable: true, | // configurable: true, | ||||
| // enumerable: true, | // enumerable: true, |