Przeglądaj źródła

Minor change in animation

master
Palash Bansal 1 rok temu
rodzic
commit
05682786ea
No account linked to committer's email address

+ 3188
- 3245
package-lock.json
Plik diff jest za duży
Wyświetl plik


+ 1
- 1
package.json Wyświetl plik

@@ -1,6 +1,6 @@
{
"name": "threepipe",
"version": "0.0.33",
"version": "0.0.34",
"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",
"module": "dist/index.mjs",

+ 13
- 1
src/plugins/animation/PopmotionPlugin.ts Wyświetl plik

@@ -173,11 +173,24 @@ export class PopmotionPlugin extends AViewerPluginSync<''> {
}
return true
}
// todo: test boolean
if (options.from === undefined) {
console.warn('from is undefined', options)
resolve()
return
}
const isBool = typeof options.from === 'boolean'
if (isBool) {
options.from = options.from ? 1 : 0 as any
options.to = options.to ? 1 : 0 as any
}
const opts: AnimationOptions<V> = {
driver: this.defaultDriver,
...options,
onUpdate: !isBool ? options.onUpdate : undefined,
onComplete: ()=>{
try {
if (isBool) options.onUpdate?.(options.to as any)
options.onComplete && options.onComplete()
} catch (e: any) {
if (!end2()) return
@@ -198,7 +211,6 @@ export class PopmotionPlugin extends AViewerPluginSync<''> {
resolve()
},
}
// todo: support boolean using timeout.
const anim = animate(opts)
this.animations[uuid]._stop = anim.stop
this.animations[uuid].options = opts

+ 7
- 0
src/plugins/pipeline/GBufferPlugin.ts Wyświetl plik

@@ -169,6 +169,13 @@ export class GBufferPlugin
this.target.texture[0].name = 'gbufferDepthNormal'
this.target.texture[1].name = 'gbufferFlags'
this.textures = this.target.texture

// todo flag buffer filtering?
// const flagTexture = this.flagsTexture
// flagTexture.generateMipmaps = false
// flagTexture.minFilter = NearestFilter
// flagTexture.magFilter = NearestFilter

} else {
this.target.texture.name = 'gbufferDepthNormal'
this.textures.push(this.target.texture)

+ 10
- 4
src/utils/animation.ts Wyświetl plik

@@ -68,24 +68,30 @@ export function makeSetterFor<V>(target: any, key: string, setDirty?: ()=>void)
if (typeof target?.setDirty === 'function') target.setDirty()
setDirty?.()
}
if (v && typeof v.copy === 'function')
const isBool = typeof v === 'boolean'
if (v && v.isColor)
return (a: any) => {
v.set(a)
dirty()
}
else if (v && typeof v.copy === 'function')
return (a: any) => {
v.copy(a)
dirty()
}
else
return (a: V)=>{
target[key] = a
target[key] = !isBool ? a : !!a
dirty()
}
}

export async function animateTarget<V>(target: any, key: string, options: AnimationOptions<V>, animations?: AnimateResult[]) {
export async function animateTarget<V>(target: any, key: string, options: AnimationOptions<V>, animations?: AnimateResult[], forceCurrent = false) {
if (!(key in target)) {
console.error('invalid key', key, target)
}
const setter = makeSetterFor(target, key)
const fromVal = target[key]
const fromVal = forceCurrent || options.from === undefined ? target[key] : options.from
const onUpdate = (val: V)=>{
setter(val)
options.onUpdate && options.onUpdate(val)

+ 1
- 1
src/viewer/version.ts Wyświetl plik

@@ -1 +1 @@
export const VERSION = '0.0.33'
export const VERSION = '0.0.34'

Ładowanie…
Anuluj
Zapisz