| <excludeFolder url="file://$MODULE_DIR$/plugins/plugin-template-vite" /> | <excludeFolder url="file://$MODULE_DIR$/plugins/plugin-template-vite" /> | ||||
| <excludeFolder url="file://$MODULE_DIR$/plugins/svg-renderer/docs" /> | <excludeFolder url="file://$MODULE_DIR$/plugins/svg-renderer/docs" /> | ||||
| <excludeFolder url="file://$MODULE_DIR$/plugins/tweakpane-editor/docs" /> | <excludeFolder url="file://$MODULE_DIR$/plugins/tweakpane-editor/docs" /> | ||||
| <excludeFolder url="file://$MODULE_DIR$/website/.vitepress/dist" /> | |||||
| </content> | </content> | ||||
| <orderEntry type="inheritedJdk" /> | <orderEntry type="inheritedJdk" /> | ||||
| <orderEntry type="sourceFolder" forTests="false" /> | <orderEntry type="sourceFolder" forTests="false" /> |
| { | { | ||||
| "name": "threepipe", | "name": "threepipe", | ||||
| "version": "0.0.38-dev", | |||||
| "version": "0.0.38", | |||||
| "description": "A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.", | "description": "A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.", | ||||
| "main": "dist/index.js", | "main": "dist/index.js", | ||||
| "module": "dist/index.mjs", | "module": "dist/index.mjs", |
| const mat = e.target | const mat = e.target | ||||
| if (!mat || mat.assetType !== 'material') return | if (!mat || mat.assetType !== 'material') return | ||||
| mat.setDirty() | mat.setDirty() | ||||
| this._getMapsForMaterial(mat) | |||||
| .forEach(map=> | |||||
| !map.isRenderTargetTexture && map.userData.disposeOnIdle !== false && | |||||
| map.dispose && !isInScene(map) && map.dispose()) | |||||
| for (const map of this._getMapsForMaterial(mat)) { | |||||
| const dispose = !map.isRenderTargetTexture | |||||
| && map.userData.disposeOnIdle !== false | |||||
| && !isInScene(map) // todo <- is this always required? this will be very slow if doing for every map of every material dispose on scene clear | |||||
| if (dispose && typeof map.dispose === 'function') { | |||||
| // console.log('disposing texture', map) | |||||
| map.dispose() | |||||
| } | |||||
| } | |||||
| // this.unregisterMaterial(mat) // not unregistering on dispose, that has to be done explicitly. todo: make an easy way to do that. | // this.unregisterMaterial(mat) // not unregistering on dispose, that has to be done explicitly. todo: make an easy way to do that. | ||||
| } | } | ||||
| material?: IMaterial | IMaterial[] | material?: IMaterial | IMaterial[] | ||||
| /** | /** | ||||
| * Same as material but always returns an array. | * Same as material but always returns an array. | ||||
| * To set, just set `material` property | |||||
| */ | */ | ||||
| readonly materials?: IMaterial[] | readonly materials?: IMaterial[] | ||||
| // eslint-disable-next-line @typescript-eslint/naming-convention | // eslint-disable-next-line @typescript-eslint/naming-convention |
| import {ICamera} from '../ICamera' | import {ICamera} from '../ICamera' | ||||
| import {Vector3} from 'three' | import {Vector3} from 'three' | ||||
| import {ThreeViewer} from '../../viewer' | import {ThreeViewer} from '../../viewer' | ||||
| import {UnlitMaterial} from '../material/UnlitMaterial' | |||||
| import {PhysicalMaterial} from '../material/PhysicalMaterial' | |||||
| // todo move somewhere? | |||||
| const defaultMaterial = new UnlitMaterial() | |||||
| defaultMaterial.name = 'Default Unlit Material' | |||||
| defaultMaterial.uiConfig = undefined as any | |||||
| export function makeICameraCommonUiConfig(this: ICamera, config: UiObjectConfig): UiObjectConfig[] { | export function makeICameraCommonUiConfig(this: ICamera, config: UiObjectConfig): UiObjectConfig[] { | ||||
| return [ | return [ | ||||
| type: 'folder', | type: 'folder', | ||||
| children: (this.material as IUiConfigContainer[]).map((a)=>a?.uiConfig).filter(a=>a), | children: (this.material as IUiConfigContainer[]).map((a)=>a?.uiConfig).filter(a=>a), | ||||
| } : (this.material as IUiConfigContainer)?.uiConfig, | } : (this.material as IUiConfigContainer)?.uiConfig, | ||||
| { | |||||
| label: 'Remove Material(s)', | |||||
| type: 'button', | |||||
| hidden: ()=>!this.materials?.length || this.materials.length === 1 && this.materials[0] === defaultMaterial, | |||||
| value: ()=>{ | |||||
| const mat = this.materials | |||||
| this.material = [defaultMaterial] | |||||
| return ()=> this.material = mat | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: 'New Physical Material', | |||||
| type: 'button', | |||||
| hidden: ()=>!(!this.materials?.length || this.materials.length === 1 && this.materials[0] === defaultMaterial), | |||||
| value: ()=>{ | |||||
| const mat = this.materials | |||||
| this.material = [new PhysicalMaterial()] | |||||
| return ()=> this.material = mat | |||||
| }, | |||||
| }, | |||||
| { | |||||
| label: 'New Unlit Material', | |||||
| type: 'button', | |||||
| hidden: ()=>!(!this.materials?.length || this.materials.length === 1 && this.materials[0] === defaultMaterial), | |||||
| value: ()=>{ | |||||
| const mat = this.materials | |||||
| this.material = [new UnlitMaterial()] | |||||
| return ()=> this.material = mat | |||||
| }, | |||||
| }, | |||||
| ] | ] | ||||
| ;(config.children as UiObjectConfig[]).push(...ui) | ;(config.children as UiObjectConfig[]).push(...ui) | ||||
| } | } |