| @@ -346,7 +346,7 @@ export class AssetImporter extends EventDispatcher<IAssetImporterEvent, IAssetIm | |||
| const isData = path.startsWith('data:') || false | |||
| if (!isData) path = path.replace(/\?.*$/, '') // remove query string | |||
| const ext = isData ? undefined : file?.ext ?? parseFileExtension(file?.name ?? path)?.toLowerCase() | |||
| const ext = isData ? undefined : file?.ext ?? parseFileExtension(file?.name ?? path.trim())?.toLowerCase() | |||
| const mime = file?.mime ?? isData ? path.slice(0, path.indexOf(';')).split(':')[1] || undefined : undefined | |||
| if (file) { | |||
| @@ -533,9 +533,9 @@ export class AssetImporter extends EventDispatcher<IAssetImporterEvent, IAssetIm | |||
| // get a loader that can load a file. | |||
| private _getLoader(name?:string, ext?:string, mime?: string): ILoader | undefined { | |||
| if (!ext && !mime && name) ext = parseFileExtension(name).toLowerCase() | |||
| mime = mime?.toLowerCase() | |||
| ext = ext?.toLowerCase() | |||
| return (name ? this._loadingManager.getHandler(name) as ILoader : undefined) | |||
| mime = mime?.toLowerCase().trim() | |||
| ext = ext?.toLowerCase().trim() | |||
| return (name ? this._loadingManager.getHandler(name.trim()) as ILoader : undefined) | |||
| || this._loaderCache.find((lc)=> ext && lc.ext.includes(ext) || mime && lc.mime.includes(mime))?.loader | |||
| } | |||
| @@ -126,6 +126,7 @@ export class PhysicalMaterial extends MeshPhysicalMaterial<IMaterialEvent, Physi | |||
| expanded: true, | |||
| onChange: (ev)=>{ | |||
| if (!ev.config || ev.config.onChange) return | |||
| // todo frameFade | |||
| // todo set needsUpdate true only for properties that require it like maps. | |||
| this.setDirty({uiChangeEvent: ev, needsUpdate: !!ev.last, refreshUi: !!ev.last}) | |||
| }, | |||
| @@ -181,7 +181,7 @@ export class RootScene extends Scene<ISceneEvent, ISceneEventTypes> implements I | |||
| return imported as T&IObject3D | |||
| } | |||
| this._addObject3D(<IObject3D>imported, options) | |||
| this.dispatchEvent({type: 'addSceneObject', object: <IObject3D>imported}) | |||
| this.dispatchEvent({type: 'addSceneObject', object: <IObject3D>imported, options}) | |||
| return imported as T&IObject3D | |||
| } | |||
| @@ -41,7 +41,7 @@ export class ClearcoatTintPlugin extends AViewerPluginSync<''> { | |||
| if (tf.tintColor === undefined) tf.tintColor = '#ffffff' | |||
| if (tf.thickness === undefined) tf.thickness = 0.1 | |||
| if (tf.ior === undefined) tf.ior = 1.5 | |||
| Object.assign(tf, params) | |||
| params && Object.assign(tf, params) | |||
| if (material.setDirty) material.setDirty() | |||
| return tf | |||
| } | |||
| @@ -47,7 +47,7 @@ export class FragmentClippingExtensionPlugin extends AViewerPluginSync<''> { | |||
| if (tf.clipParams === undefined) tf.clipParams = [0, 0, 0, 0] | |||
| if (tf.clipMode === undefined !== undefined) tf.clipMode = FragmentClippingMode.Circle | |||
| if (tf.clipInvert === undefined !== undefined) tf.clipInvert = false | |||
| Object.assign(tf, params) | |||
| params && Object.assign(tf, params) | |||
| if (material.setDirty) material.setDirty() | |||
| return true | |||
| } | |||
| @@ -54,7 +54,7 @@ export class NoiseBumpMaterialPlugin extends AViewerPluginSync<''> { | |||
| if (tf.useColorFlakes === undefined) tf.useColorFlakes = false | |||
| if (tf.flakeParams === undefined) tf.flakeParams = new Vector4(0, 1, 3, 0) | |||
| if (tf.flakeFallOffParams === undefined) tf.flakeFallOffParams = new Vector3(0, 1, 0) | |||
| Object.assign(tf, params) | |||
| params && Object.assign(tf, params) | |||
| if (material.setDirty) material.setDirty() | |||
| return true | |||
| } | |||
| @@ -87,7 +87,7 @@ export abstract class AScreenPassExtensionPlugin<T extends string> extends AView | |||
| } | |||
| private _onPluginAdd = (e: IViewerEvent)=>{ | |||
| if (e.plugin?.constructor?.PluginType !== 'GBuffer') return | |||
| if (e.plugin?.constructor?.PluginType !== GBufferPlugin.PluginType) return | |||
| const gbuffer = e.plugin as GBufferPlugin | |||
| gbuffer.registerGBufferUpdater(this.constructor.PluginType, this.updateGBufferFlags.bind(this)) | |||
| this._viewer?.removeEventListener('addPlugin', this._onPluginAdd) | |||