| @@ -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", | |||
| @@ -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 | |||
| @@ -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) | |||
| @@ -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 @@ | |||
| export const VERSION = '0.0.33' | |||
| export const VERSION = '0.0.34' | |||