| { | { | ||||
| "name": "threepipe", | "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.", | "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", | "main": "dist/index.js", | ||||
| "module": "dist/index.mjs", | "module": "dist/index.mjs", |
| } | } | ||||
| return true | 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> = { | const opts: AnimationOptions<V> = { | ||||
| driver: this.defaultDriver, | driver: this.defaultDriver, | ||||
| ...options, | ...options, | ||||
| onUpdate: !isBool ? options.onUpdate : undefined, | |||||
| onComplete: ()=>{ | onComplete: ()=>{ | ||||
| try { | try { | ||||
| if (isBool) options.onUpdate?.(options.to as any) | |||||
| options.onComplete && options.onComplete() | options.onComplete && options.onComplete() | ||||
| } catch (e: any) { | } catch (e: any) { | ||||
| if (!end2()) return | if (!end2()) return | ||||
| resolve() | resolve() | ||||
| }, | }, | ||||
| } | } | ||||
| // todo: support boolean using timeout. | |||||
| const anim = animate(opts) | const anim = animate(opts) | ||||
| this.animations[uuid]._stop = anim.stop | this.animations[uuid]._stop = anim.stop | ||||
| this.animations[uuid].options = opts | this.animations[uuid].options = opts |
| this.target.texture[0].name = 'gbufferDepthNormal' | this.target.texture[0].name = 'gbufferDepthNormal' | ||||
| this.target.texture[1].name = 'gbufferFlags' | this.target.texture[1].name = 'gbufferFlags' | ||||
| this.textures = this.target.texture | this.textures = this.target.texture | ||||
| // todo flag buffer filtering? | |||||
| // const flagTexture = this.flagsTexture | |||||
| // flagTexture.generateMipmaps = false | |||||
| // flagTexture.minFilter = NearestFilter | |||||
| // flagTexture.magFilter = NearestFilter | |||||
| } else { | } else { | ||||
| this.target.texture.name = 'gbufferDepthNormal' | this.target.texture.name = 'gbufferDepthNormal' | ||||
| this.textures.push(this.target.texture) | this.textures.push(this.target.texture) |
| if (typeof target?.setDirty === 'function') target.setDirty() | if (typeof target?.setDirty === 'function') target.setDirty() | ||||
| 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) => { | return (a: any) => { | ||||
| v.copy(a) | v.copy(a) | ||||
| dirty() | dirty() | ||||
| } | } | ||||
| else | else | ||||
| return (a: V)=>{ | return (a: V)=>{ | ||||
| target[key] = a | |||||
| target[key] = !isBool ? a : !!a | |||||
| dirty() | 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)) { | if (!(key in target)) { | ||||
| console.error('invalid key', key, target) | console.error('invalid key', key, target) | ||||
| } | } | ||||
| const setter = makeSetterFor(target, key) | const setter = makeSetterFor(target, key) | ||||
| const fromVal = target[key] | |||||
| const fromVal = forceCurrent || options.from === undefined ? target[key] : options.from | |||||
| const onUpdate = (val: V)=>{ | const onUpdate = (val: V)=>{ | ||||
| setter(val) | setter(val) | ||||
| options.onUpdate && options.onUpdate(val) | options.onUpdate && options.onUpdate(val) |
| export const VERSION = '0.0.33' | |||||
| export const VERSION = '0.0.34' |