| @@ -6,3 +6,5 @@ | |||
| # Datasource local storage ignored files | |||
| /dataSources/ | |||
| /dataSources.local.xml | |||
| # GitHub Copilot persisted chat sessions | |||
| /copilot/chatSessions | |||
| @@ -39,7 +39,7 @@ export type IGeometryEventTypes = 'dispose' | 'geometryUpdate' // | string | |||
| export type IGeometryEvent<T extends string = IGeometryEventTypes> = Event & { | |||
| type: T | |||
| bubbleToObject?: boolean // bubble event to parent root | |||
| geometry: IGeometry | |||
| geometry?: IGeometry | |||
| // change?: string | |||
| } | |||
| export type IGeometrySetDirtyOptions = AnyOptions & {bubbleToObject?: boolean} | |||
| @@ -43,7 +43,7 @@ export interface IMaterialUserData extends IImportResultUserData{ | |||
| renderToGBuffer?: boolean | |||
| /** | |||
| * Same as {@link renderToGBuffer} for now | |||
| * Same as {@link renderToGBuffer} but for depth only, not normal or flags etc | |||
| */ | |||
| renderToDepth?: boolean | |||
| @@ -162,6 +162,7 @@ export interface IMaterial<E extends IMaterialEvent = IMaterialEvent, ET = IMate | |||
| isRawShaderMaterial?: boolean | |||
| isPhysicalMaterial?: boolean | |||
| isUnlitMaterial?: boolean | |||
| isGBufferMaterial?: boolean | |||
| // [key: string]: any | |||
| } | |||
| @@ -400,6 +400,12 @@ export class GBufferMaterial extends ShaderMaterial2 { | |||
| ['FORCED_LINEAR_DEPTH']: material.userData.forcedLinearDepth ?? undefined, | |||
| }, material) | |||
| // todo: do the same in DepthBufferPlugin and NormalBufferPlugin | |||
| // what about the material extension settings in the userData of the source materials? | |||
| if (material.materialExtensions?.length) { | |||
| this.registerMaterialExtensions(material.materialExtensions) | |||
| } | |||
| // this.transparent = true | |||
| this.needsUpdate = true | |||
| @@ -408,6 +414,16 @@ export class GBufferMaterial extends ShaderMaterial2 { | |||
| onAfterRender(renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, object: Object3D) { | |||
| super.onAfterRender(renderer, scene, camera, geometry, object) | |||
| let material = (object as any).material as IMaterial & Partial<PhysicalMaterial> | |||
| if (Array.isArray(material)) { // todo: add support for multi materials. | |||
| material = material[0] | |||
| } | |||
| if (!material) return | |||
| if (material.materialExtensions?.length) { | |||
| this.unregisterMaterialExtensions(material.materialExtensions) | |||
| } | |||
| this.reset() | |||
| } | |||
| @@ -146,6 +146,8 @@ export class RenderManager extends RenderTargetManager<IRenderManagerEvent, IRen | |||
| preserveDrawingBuffer: true, | |||
| powerPreference: RenderManager.POWER_PREFERENCE, | |||
| }) | |||
| renderer.info.autoReset = false | |||
| renderer.useLegacyLights = false | |||
| renderer.setAnimationLoop(this._animationLoop) | |||
| renderer.onContextLost = (event: WebGLContextEvent) => { | |||
| @@ -223,6 +225,7 @@ export class RenderManager extends RenderTargetManager<IRenderManagerEvent, IRen | |||
| if (renderToScreen) { | |||
| this._frameCount += 1 | |||
| this._totalFrameCount += 1 | |||
| this._renderer.info.reset() | |||
| } | |||
| this._dirty = false | |||
| } | |||
| @@ -218,6 +218,7 @@ export {WebGLUtils} from 'three' | |||
| export * from 'three/src/constants.js' | |||
| export type {Shader} from 'three' | |||
| export type {IUniform} from 'three' | |||
| export * from 'three/examples/jsm/libs/fflate.module.js' | |||
| @@ -9,14 +9,14 @@ const warnEnabled = true | |||
| * @param prepend - prepend new string to old string | |||
| * @param append - append new string to old string | |||
| */ | |||
| export function shaderReplaceString(shader: string, str: string, newStr: string, { | |||
| export function shaderReplaceString(shader: string, str: string|RegExp, newStr: string, { | |||
| replaceAll = false, | |||
| prepend = false, | |||
| append = false, | |||
| } = {}) { | |||
| // todo: use safeReplaceString from ts-browser-helpers | |||
| if (warnEnabled /* && ThreeViewer.ViewerDebugging */) { | |||
| if (!shader.includes(str)) { | |||
| if (typeof str === 'string' ? !shader.includes(str) : !str.test(shader)) { | |||
| console.error(`${str} not found in shader`) | |||
| return shader | |||
| } | |||
| @@ -118,7 +118,8 @@ export interface ThreeViewerOptions { | |||
| */ | |||
| rgbm?: boolean | |||
| /** | |||
| * Use rendered gbuffer as depth-prepass / z-prepass. | |||
| * Use rendered gbuffer as depth-prepass / z-prepass. (Requires DepthBufferPlugin/GBufferPlugin) | |||
| * todo: It will be disabled when there are any transparent/transmissive objects with render to depth buffer enabled. | |||
| */ | |||
| zPrepass?: boolean | |||
| /** | |||
| @@ -254,6 +255,10 @@ export class ThreeViewer extends EventDispatcher<IViewerEvent, IViewerEventTypes | |||
| * @returns {HTMLElement} | |||
| */ | |||
| get container(): HTMLElement { | |||
| // todo console.warn('container is deprecated, NOTE: subscribe to events when the canvas is moved to another container') | |||
| if (this._canvas.parentElement !== this._container) { | |||
| this.console.error('ThreeViewer: Canvas is not in the container, this might cause issues with some plugins.') | |||
| } | |||
| return this._container | |||
| } | |||