Bladeren bron

Allow setDirty in plugin enable/disable, other minor fixes.

master
Palash Bansal 1 jaar geleden
bovenliggende
commit
04a32b1c87
No account linked to committer's email address

+ 2
- 2
src/core/object/iObjectCommons.ts Bestand weergeven

iMaterialCommons.upgradeMaterial.call(mat) iMaterialCommons.upgradeMaterial.call(mat)
} }
materials.push(mat) materials.push(mat)
if (mat) {
if (mat && mat.appliedMeshes) {
mat.appliedMeshes.add(this) mat.appliedMeshes.add(this)
} }
} }
if (geometry) { if (geometry) {
this.updateMorphTargets() this.updateMorphTargets()
this._onGeometryUpdate && geometry.addEventListener('geometryUpdate', this._onGeometryUpdate) this._onGeometryUpdate && geometry.addEventListener('geometryUpdate', this._onGeometryUpdate)
geometry.appliedMeshes.add(this)
if (geometry.appliedMeshes) geometry.appliedMeshes.add(this)
} }
this.dispatchEvent({type: 'geometryChanged', geometry: geometry ?? null, oldGeometry: geom, bubbleToParent: true, object: this}) this.dispatchEvent({type: 'geometryChanged', geometry: geometry ?? null, oldGeometry: geom, bubbleToParent: true, object: this})
this.refreshUi() this.refreshUi()

+ 2
- 1
src/plugins/extras/Object3DGeneratorPlugin.ts Bestand weergeven

protected _selectedType = '' protected _selectedType = ''


@uiButton('Generate', {sendArgs: false}) @uiButton('Generate', {sendArgs: false})
generate(type?: string, params?: any, addToScene = true) {
generate(type?: string, params?: any, addToScene = true, select = true) {
if (!this._viewer) throw new Error('No viewer') if (!this._viewer) throw new Error('No viewer')
const obj = this.generators[type ?? this._selectedType]?.(params) const obj = this.generators[type ?? this._selectedType]?.(params)
addToScene && obj && this._viewer.scene.addObject(obj) addToScene && obj && this._viewer.scene.addObject(obj)
select && obj.dispatchEvent({type: 'select', value: obj, object: obj, ui: true})
return obj return obj
} }



+ 4
- 4
src/viewer/AViewerPlugin.ts Bestand weergeven

} }


private _disabledBy = new Set<any>() private _disabledBy = new Set<any>()
disable = (key: any) => {
disable = (key: any, setDirty = true) => {
const size = this._disabledBy.size const size = this._disabledBy.size
this._disabledBy.add(key) this._disabledBy.add(key)
if (this.setDirty && size !== this._disabledBy.size) this.setDirty()
if (setDirty && this.setDirty && size !== this._disabledBy.size) this.setDirty()
} }
enable = (key: any) => {
enable = (key: any, setDirty = true) => {
const size = this._disabledBy.size const size = this._disabledBy.size
this._disabledBy.delete(key) this._disabledBy.delete(key)
if (this.setDirty && size !== this._disabledBy.size) this.setDirty()
if (setDirty && this.setDirty && size !== this._disabledBy.size) this.setDirty()
} }
isDisabled = () => { isDisabled = () => {
return this._disabledBy.size > 0 || !this.enabled return this._disabledBy.size > 0 || !this.enabled

+ 2
- 3
src/viewer/ThreeViewer.ts Bestand weergeven

this._container = container this._container = container
this.setDirty = this.setDirty.bind(this) this.setDirty = this.setDirty.bind(this)
this._animationLoop = this._animationLoop.bind(this) this._animationLoop = this._animationLoop.bind(this)
this._setActiveCameraView = this._setActiveCameraView.bind(this)


this.renderStats = new GLStatsJS(this._container) this.renderStats = new GLStatsJS(this._container)
if (debug) this.renderStats.show() if (debug) this.renderStats.show()
} }
this.plugins[type] = p this.plugins[type] = p
const oldType = p.constructor.OldPluginType const oldType = p.constructor.OldPluginType
if (oldType && this.plugins[oldType]) this.console.error('ThreeViewer: Plugin type mismatch')
if (oldType && this.plugins[oldType]) this.console.error(`ThreeViewer: Plugin type mismatch ${oldType}`)
if (oldType) this.plugins[oldType] = p if (oldType) this.plugins[oldType] = p


await p.onAdded(this) await p.onAdded(this)
try { try {
this.plugins[type] = p this.plugins[type] = p
const oldType = p.constructor.OldPluginType const oldType = p.constructor.OldPluginType
if (oldType && this.plugins[oldType]) this.console.error('ThreeViewer: Plugin type mismatch')
if (oldType && this.plugins[oldType]) this.console.error(`ThreeViewer: Plugin type mismatch ${oldType}`)
if (oldType) this.plugins[oldType] = p if (oldType) this.plugins[oldType] = p
p.onAdded(this) p.onAdded(this)
} catch (e) { } catch (e) {

Laden…
Annuleren
Opslaan