| @@ -451,7 +451,7 @@ export class RootScene extends Scene<ISceneEvent, ISceneEventTypes> implements I | |||
| updateShaderProperties(material: {defines: Record<string, string|number|undefined>, uniforms: {[name: string]: IUniform}}): this { | |||
| if (material.uniforms.sceneBoundingRadius) material.uniforms.sceneBoundingRadius.value = this._sceneBoundingRadius | |||
| else console.warn('BaseRenderer: no uniform: sceneBoundingRadius') | |||
| else console.warn('RootScene: no uniform: sceneBoundingRadius') | |||
| return this | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| import {IMaterial, IMaterialUserData} from '../core' | |||
| import {IMaterial, IMaterialUserData, IWebGLRenderer} from '../core' | |||
| import {getOrCall, objectMap} from 'ts-browser-helpers' | |||
| import {shaderReplaceString, shaderUtils} from '../utils' | |||
| import {Object3D, Shader, ShaderChunk, WebGLRenderer} from 'three' | |||
| @@ -128,7 +128,7 @@ export function updateMaterialDefines(defines: MaterialExtension['extraDefines'] | |||
| if (flag) material.needsUpdate = true | |||
| } | |||
| function materialBeforeRender({target, object, renderer}:{object?: Object3D, renderer?: WebGLRenderer, target: IMaterial}) { | |||
| function materialBeforeRender({target, object, renderer}:{object?: Object3D, renderer?: IWebGLRenderer, target: IMaterial}) { | |||
| const material = target | |||
| if (!material || !object || !renderer) throw new Error('Invalid material, object or renderer') | |||
| if (!material.materialExtensions) return | |||
| @@ -147,7 +147,7 @@ function materialBeforeRender({target, object, renderer}:{object?: Object3D, ren | |||
| } | |||
| } | |||
| function materialAfterRender({target, object, renderer}:{object?: Object3D, renderer?: WebGLRenderer, target: IMaterial}) { | |||
| function materialAfterRender({target, object, renderer}:{object?: Object3D, renderer?: IWebGLRenderer, target: IMaterial}) { | |||
| const material = target | |||
| if (!material || !object || !renderer) throw new Error('Invalid material, object or renderer') | |||
| if (!material.materialExtensions) return | |||
| @@ -1,5 +1,5 @@ | |||
| import {IUniform, Object3D, Shader, WebGLRenderer} from 'three' | |||
| import {IMaterial} from '../core' | |||
| import {IMaterial, IWebGLRenderer} from '../core' | |||
| import {UiObjectConfig} from 'uiconfig.js' | |||
| import {ValOrFunc} from 'ts-browser-helpers' | |||
| @@ -56,7 +56,7 @@ export interface MaterialExtension{ | |||
| * @param material | |||
| * @param renderer | |||
| */ | |||
| onObjectRender?: (object: Object3D, material: IMaterial, renderer: WebGLRenderer) => void | |||
| onObjectRender?: (object: Object3D, material: IMaterial, renderer: IWebGLRenderer) => void | |||
| /** | |||
| @@ -66,7 +66,7 @@ export interface MaterialExtension{ | |||
| * @param material | |||
| * @param renderer | |||
| */ | |||
| onAfterRender?: (object: Object3D, material: IMaterial, renderer: WebGLRenderer) => void | |||
| onAfterRender?: (object: Object3D, material: IMaterial, renderer: IWebGLRenderer) => void | |||
| /** | |||
| * Function to check if this material extension is compatible with the given material. | |||
| @@ -268,8 +268,8 @@ export class BaseGroundPlugin<TEvent extends string = ''> extends AViewerPluginS | |||
| if (this._material.userData.gBufferData.tonemapEnabled !== this.tonemapGround) { | |||
| this._material.userData.gBufferData.tonemapEnabled = this.tonemapGround | |||
| } | |||
| this._material.userData.ssaoDisabled = true | |||
| this._material.userData.sscsDisabled = true | |||
| // this._material.userData.ssaoDisabled = true //todo should be in BakedGroundPlugin | |||
| // this._material.userData.sscsDisabled = true //todo should be in BakedGroundPlugin | |||
| // if (this._material.userData.__postTonemap === undefined) { | |||
| // this._material.userData.__postTonemap = this._material.userData.postTonemap | |||
| @@ -92,7 +92,7 @@ vec3 clearcoatTint(const in float dotNV, const in float dotNL, const in float cl | |||
| }, material) | |||
| }, | |||
| extraUniforms: { | |||
| ...this._uniforms, | |||
| // ...this._uniforms, // done in constructor | |||
| }, | |||
| computeCacheKey: (material1: PhysicalMaterial) => { | |||
| return (this.isDisabled() ? '0' : '1') + (material1.userData._clearcoatTint?.enableTint ? '1' : '0') + (material1.clearcoat > 0 ? '1' : '0') | |||
| @@ -100,7 +100,7 @@ vec3 clearcoatTint(const in float dotNV, const in float dotNL, const in float cl | |||
| isCompatible: (material1: PhysicalMaterial) => { | |||
| return material1.isPhysicalMaterial | |||
| }, | |||
| getUiConfig: (material: PhysicalMaterial) => { | |||
| getUiConfig: (material: PhysicalMaterial) => { // todo use uiConfigMaterialExtension | |||
| const viewer = this._viewer! | |||
| if (material.userData._clearcoatTint === undefined) material.userData._clearcoatTint = {} | |||
| const state = material.userData._clearcoatTint | |||
| @@ -169,6 +169,7 @@ vec3 clearcoatTint(const in float dotNV, const in float dotNL, const in float cl | |||
| constructor() { | |||
| super() | |||
| this._loaderCreate = this._loaderCreate.bind(this) | |||
| Object.assign(this.materialExtension.extraUniforms!, this._uniforms) | |||
| } | |||
| onAdded(v: ThreeViewer) { | |||
| @@ -119,13 +119,13 @@ export class CustomBumpMapPlugin extends AViewerPluginSync<''> { | |||
| }, material) | |||
| }, | |||
| extraUniforms: { | |||
| ...this._uniforms, | |||
| // ...this._uniforms, // done in constructor | |||
| }, | |||
| computeCacheKey: (material1: PhysicalMaterial) => { | |||
| return (this.enabled ? '1' : '0') + (material1.userData._hasCustomBump ? '1' : '0') + material1.userData?._customBumpMap?.uuid | |||
| }, | |||
| isCompatible: (material1: PhysicalMaterial) => material1.isPhysicalMaterial, | |||
| getUiConfig: material => { | |||
| getUiConfig: material => { // todo use uiConfigMaterialExtension | |||
| const viewer = this._viewer! | |||
| const enableCustomBump = this.enableCustomBump.bind(this) | |||
| const state = material.userData | |||
| @@ -193,6 +193,7 @@ export class CustomBumpMapPlugin extends AViewerPluginSync<''> { | |||
| constructor() { | |||
| super() | |||
| this._loaderCreate = this._loaderCreate.bind(this) | |||
| Object.assign(this.materialExtension.extraUniforms!, this._uniforms) | |||
| } | |||
| onAdded(v: ThreeViewer) { | |||
| @@ -107,7 +107,7 @@ export class FragmentClippingExtensionPlugin extends AViewerPluginSync<''> { | |||
| }, material) | |||
| }, | |||
| extraUniforms: { | |||
| ...this._uniforms, | |||
| // ...this._uniforms, // done in constructor | |||
| }, | |||
| computeCacheKey: (material1: PhysicalMaterial) => { | |||
| return (this.enabled ? '1' : '0') + (material1.userData._fragmentClippingExt?.clipEnabled ? '1' : '0') | |||
| @@ -115,7 +115,7 @@ export class FragmentClippingExtensionPlugin extends AViewerPluginSync<''> { | |||
| isCompatible: (material1: PhysicalMaterial) => { | |||
| return material1.isPhysicalMaterial || material1.userData.isGBufferMaterial // todo isGBufferMaterial | |||
| }, | |||
| getUiConfig: material => { | |||
| getUiConfig: material => { // todo use uiConfigMaterialExtension | |||
| const viewer = this._viewer! | |||
| if (material.userData._fragmentClippingExt === undefined) material.userData._fragmentClippingExt = {} | |||
| const state = material.userData._fragmentClippingExt | |||
| @@ -194,6 +194,7 @@ export class FragmentClippingExtensionPlugin extends AViewerPluginSync<''> { | |||
| constructor() { | |||
| super() | |||
| this._loaderCreate = this._loaderCreate.bind(this) | |||
| Object.assign(this.materialExtension.extraUniforms!, this._uniforms) | |||
| } | |||
| onAdded(v: ThreeViewer) { | |||
| @@ -92,13 +92,13 @@ export class NoiseBumpMaterialPlugin extends AViewerPluginSync<''> { | |||
| }, material) | |||
| }, | |||
| extraUniforms: { | |||
| ...this._uniforms, | |||
| // ...this._uniforms, // done in constructor | |||
| }, | |||
| computeCacheKey: (material1: PhysicalMaterial) => { | |||
| return (this.isDisabled() ? '0' : '1') + (material1.userData._noiseBumpMat?.hasBump ? '1' : '0') | |||
| }, | |||
| isCompatible: (material1: PhysicalMaterial) => material1.isPhysicalMaterial, | |||
| getUiConfig: material => { | |||
| getUiConfig: material => { // todo use uiConfigMaterialExtension | |||
| const viewer = this._viewer! | |||
| if (material.userData._noiseBumpMat === undefined) material.userData._noiseBumpMat = {} | |||
| const state = material.userData._noiseBumpMat | |||
| @@ -249,6 +249,7 @@ export class NoiseBumpMaterialPlugin extends AViewerPluginSync<''> { | |||
| constructor() { | |||
| super() | |||
| this._loaderCreate = this._loaderCreate.bind(this) | |||
| Object.assign(this.materialExtension.extraUniforms!, this._uniforms) | |||
| } | |||
| onAdded(v: ThreeViewer) { | |||