Просмотр исходного кода

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

master
Palash Bansal 1 год назад
Родитель
Сommit
04a32b1c87
Аккаунт пользователя с таким Email не найден

+ 2
- 2
src/core/object/iObjectCommons.ts Просмотреть файл

@@ -250,7 +250,7 @@ export const iObjectCommons = {
iMaterialCommons.upgradeMaterial.call(mat)
}
materials.push(mat)
if (mat) {
if (mat && mat.appliedMeshes) {
mat.appliedMeshes.add(this)
}
}
@@ -314,7 +314,7 @@ export const iObjectCommons = {
if (geometry) {
this.updateMorphTargets()
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.refreshUi()

+ 2
- 1
src/plugins/extras/Object3DGeneratorPlugin.ts Просмотреть файл

@@ -28,10 +28,11 @@ export class Object3DGeneratorPlugin extends AViewerPluginSync {
protected _selectedType = ''

@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')
const obj = this.generators[type ?? this._selectedType]?.(params)
addToScene && obj && this._viewer.scene.addObject(obj)
select && obj.dispatchEvent({type: 'select', value: obj, object: obj, ui: true})
return obj
}


+ 4
- 4
src/viewer/AViewerPlugin.ts Просмотреть файл

@@ -72,15 +72,15 @@ export abstract class AViewerPlugin<TE extends AViewerPluginEventMap = AViewerPl
}

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

+ 2
- 3
src/viewer/ThreeViewer.ts Просмотреть файл

@@ -367,7 +367,6 @@ export class ThreeViewer extends EventDispatcher<Record<IViewerEventTypes, IView
this._container = container
this.setDirty = this.setDirty.bind(this)
this._animationLoop = this._animationLoop.bind(this)
this._setActiveCameraView = this._setActiveCameraView.bind(this)

this.renderStats = new GLStatsJS(this._container)
if (debug) this.renderStats.show()
@@ -785,7 +784,7 @@ export class ThreeViewer extends EventDispatcher<Record<IViewerEventTypes, IView
}
this.plugins[type] = p
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

await p.onAdded(this)
@@ -819,7 +818,7 @@ export class ThreeViewer extends EventDispatcher<Record<IViewerEventTypes, IView
try {
this.plugins[type] = p
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
p.onAdded(this)
} catch (e) {

Загрузка…
Отмена
Сохранить