Pārlūkot izejas kodu

Add setDirty param in setInteractions, CanvasSnapshotPlugin ui param fix, add incRenderToScreen in RenderManager.

master
Palash Bansal pirms 11 mēnešiem
vecāks
revīzija
deb77a6a15
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 2
- 2
src/core/ICamera.ts Parādīt failu

position: Vector3, position: Vector3,


readonly interactionsEnabled: boolean; readonly interactionsEnabled: boolean;
setInteractions(enabled: boolean, by: string): void;
setInteractions(enabled: boolean, by: string, setDirty?: boolean): void;


/** /**
* Check whether user can interact with this camera. * Check whether user can interact with this camera.
bubbleToParent: false bubbleToParent: false
// todo // todo
} & ICameraSetDirtyOptions } & ICameraSetDirtyOptions
}
}

+ 2
- 2
src/core/camera/PerspectiveCamera2.ts Parādīt failu

return this._interactionsDisabledBy.size === 0 return this._interactionsDisabledBy.size === 0
} }


setInteractions(enabled: boolean, by: string): void {
setInteractions(enabled: boolean, by: string, setDirty = true): void {
const size = this._interactionsDisabledBy.size const size = this._interactionsDisabledBy.size
if (enabled) { if (enabled) {
this._interactionsDisabledBy.delete(by) this._interactionsDisabledBy.delete(by)
} else { } else {
this._interactionsDisabledBy.add(by) this._interactionsDisabledBy.add(by)
} }
if (size !== this._interactionsDisabledBy.size) this.refreshCameraControls(true)
if (size !== this._interactionsDisabledBy.size) this.refreshCameraControls(setDirty)
} }


get canUserInteract() { get canUserInteract() {

+ 18
- 19
src/plugins/export/CanvasSnapshotPlugin.ts Parādīt failu

import {serialize, timeout} from 'ts-browser-helpers' import {serialize, timeout} from 'ts-browser-helpers'
import {AViewerPluginSync} from '../../viewer' import {AViewerPluginSync} from '../../viewer'
import {uiButton, uiConfig, uiFolderContainer, uiInput, uiVector} from 'uiconfig.js'
import {uiButton, uiConfig, uiFolderContainer, uiInput} from 'uiconfig.js'
import {CanvasSnapshot, CanvasSnapshotOptions} from '../../utils/canvas-snapshot' import {CanvasSnapshot, CanvasSnapshotOptions} from '../../utils/canvas-snapshot'
import {ProgressivePlugin} from '../pipeline/ProgressivePlugin' import {ProgressivePlugin} from '../pipeline/ProgressivePlugin'
import {Zippable, zipSync} from 'three/examples/jsm/libs/fflate.module.js' import {Zippable, zipSync} from 'three/examples/jsm/libs/fflate.module.js'
import {Vector4} from 'three'


export interface CanvasSnapshotPluginOptions extends CanvasSnapshotOptions{ export interface CanvasSnapshotPluginOptions extends CanvasSnapshotOptions{
/** /**
tileColumns?: number tileColumns?: number
} }


@uiFolderContainer('Canvas Snapshot (Image Export)')
@uiFolderContainer('Image Export (Canvas Snapshot)')
export class CanvasSnapshotPlugin extends AViewerPluginSync { export class CanvasSnapshotPlugin extends AViewerPluginSync {
static readonly PluginType = 'CanvasSnapshotPlugin' static readonly PluginType = 'CanvasSnapshotPlugin'
enabled = true enabled = true
if (progressive && lastMaxFrames !== undefined) { if (progressive && lastMaxFrames !== undefined) {
progressive.maxFrameCount = lastMaxFrames progressive.maxFrameCount = lastMaxFrames
} }
viewer.scene.mainCamera.setInteractions(true, CanvasSnapshotPlugin.PluginType)
viewer.scene.mainCamera.setInteractions(true, CanvasSnapshotPlugin.PluginType, false)
viewer.renderManager.renderScale = dpr viewer.renderManager.renderScale = dpr


return file return file
@serialize() @serialize()
filename = 'snapshot' filename = 'snapshot'


@uiInput('Frame Count')
@serialize()
progressiveFrames = 64
@uiInput('Tile Rows')
@serialize()
tileRows = 1
@uiInput('Tile Columns')
@serialize()
tileColumns = 1
@uiVector('Crop Rect (x, y, w, h)', [0, 1], 0.001)
@serialize()
rect = new Vector4(0, 0, 1, 1)
// @uiInput('Frame Count')
// @serialize()
// progressiveFrames = 64
//
// @uiInput('Tile Rows')
// @serialize()
// tileRows = 1
//
// @uiInput('Tile Columns')
// @serialize()
// tileColumns = 1
//
// @uiVector('Crop Rect (x, y, w, h)', [0, 1], 0.001)
// @serialize()
// rect = new Vector4(0, 0, 1, 1)


private _downloading = false private _downloading = false



+ 7
- 2
src/rendering/RenderManager.ts Parādīt failu

this.dispatchEvent({type: 'postRender', scene, renderToScreen: this._composer.renderToScreen}) this.dispatchEvent({type: 'postRender', scene, renderToScreen: this._composer.renderToScreen})
this._composer.renderToScreen = true this._composer.renderToScreen = true
if (renderToScreen) { if (renderToScreen) {
this._frameCount += 1
this._totalFrameCount += 1
this.incRenderToScreen()
} }
this._dirty = false this._dirty = false
} }


// todo better name
incRenderToScreen() {
this._frameCount += 1
this._totalFrameCount += 1
}

onPostFrame = () => { onPostFrame = () => {
for (const pass of this._passes) { for (const pass of this._passes) {
if (pass.enabled && pass.onPostFrame) pass.onPostFrame?.(this) if (pass.enabled && pass.onPostFrame) pass.onPostFrame?.(this)

Notiek ielāde…
Atcelt
Saglabāt