Преглед на файлове

plugin-tweakpane - update uiconfig.js, allow image undo, minor fix

master
Palash Bansal преди 1 година
родител
ревизия
268e96d063
No account linked to committer's email address
променени са 3 файла, в които са добавени 31 реда и са изтрити 27 реда
  1. 5
    4
      plugins/tweakpane/package-lock.json
  2. 4
    3
      plugins/tweakpane/package.json
  3. 22
    20
      plugins/tweakpane/src/tpImageInputGenerator.ts

+ 5
- 4
plugins/tweakpane/package-lock.json Целия файл

}, },
"devDependencies": { "devDependencies": {
"tweakpane-image-plugin": "https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz", "tweakpane-image-plugin": "https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz",
"uiconfig-tweakpane": "^0.0.10"
"uiconfig-tweakpane": "^0.0.10",
"uiconfig.js": "^0.1.3"
} }
}, },
"../../src": {}, "../../src": {},
} }
}, },
"node_modules/uiconfig.js": { "node_modules/uiconfig.js": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/uiconfig.js/-/uiconfig.js-0.1.1.tgz",
"integrity": "sha512-JzJyAgtFOfWVg964mmKKByULnhg4d5QpfsvXzj0T/Mncs1pK3/FACM+pAteLmT1xDeVDwwIU5s86UzlTiYwR/A==",
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/uiconfig.js/-/uiconfig.js-0.1.3.tgz",
"integrity": "sha512-Q3eXWGrwXO46lkjfCsMQX6fsMKLmg4u4rrvZMkRJlQiDmsQyCaDdIJy7CMKrBWWfL9e6f4w+66SHAb+u4rOL2g==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
} }

+ 4
- 3
plugins/tweakpane/package.json Целия файл

{ {
"name": "@threepipe/plugin-tweakpane", "name": "@threepipe/plugin-tweakpane",
"description": "Tweakpane UI Plugin for ThreePipe", "description": "Tweakpane UI Plugin for ThreePipe",
"version": "0.5.1",
"version": "0.5.2",
"devDependencies": { "devDependencies": {
"tweakpane-image-plugin": "https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz", "tweakpane-image-plugin": "https://github.com/repalash/tweakpane-image-plugin/releases/download/v1.1.404/package.tgz",
"uiconfig-tweakpane": "^0.0.10"
"uiconfig-tweakpane": "^0.0.10",
"uiconfig.js": "^0.1.3"
}, },
"dependencies": { "dependencies": {
"threepipe": "file:./../../src/" "threepipe": "file:./../../src/"
"uiconfig-tweakpane": "^0.0.10" "uiconfig-tweakpane": "^0.0.10"
}, },
"peerDependencies": { "peerDependencies": {
"threepipe": "^0.0.34"
"threepipe": "^0.0.35"
} }
} }
}, },

+ 22
- 20
plugins/tweakpane/src/tpImageInputGenerator.ts Целия файл



function proxyGetValue(cc: any, viewer: ThreeViewer, config: UiObjectConfig) { function proxyGetValue(cc: any, viewer: ThreeViewer, config: UiObjectConfig) {
if (cc?.get) cc = cc.get() if (cc?.get) cc = cc.get()
let ret: any = undefined
if (!cc) return staticData.placeholderVal
let ret = staticData.placeholderVal
if (!cc) return ret
if (cc.isCompressedTexture && !cc.image.tp_src) { if (cc.isCompressedTexture && !cc.image.tp_src) {
cc.image.tp_src = staticData.compressedTexImage cc.image.tp_src = staticData.compressedTexImage
} }
if (cc.image && !cc.image.tp_src && !cc.tp_src) { if (cc.image && !cc.image.tp_src && !cc.tp_src) {
if (cc.isRenderTargetTexture) { if (cc.isRenderTargetTexture) {
if (cc._target) { if (cc._target) {
// todo do same change in blueprint
// doing in the timeout so it doesnt hang when opening a folder which does deep refresh // doing in the timeout so it doesnt hang when opening a folder which does deep refresh
// if (!config._lastRtRefresh || Date.now() - config._lastRtRefresh > 5000) { // 5000 should be significantly more than 500 + 100 below // if (!config._lastRtRefresh || Date.now() - config._lastRtRefresh > 5000) { // 5000 should be significantly more than 500 + 100 below
setTimeout(() => { setTimeout(() => {
if (!cc._target) return
// here we are not doing cc.image.tp_src because cc.image can be shared across multiple textures in MRT // here we are not doing cc.image.tp_src because cc.image can be shared across multiple textures in MRT
const dataUrl = viewer.renderManager.renderTargetToDataUrl(cc._target, undefined, undefined, Array.isArray(cc._target.texture) ? cc._target.texture.indexOf(cc) : undefined) const dataUrl = viewer.renderManager.renderTargetToDataUrl(cc._target, undefined, undefined, Array.isArray(cc._target.texture) ? cc._target.texture.indexOf(cc) : undefined)
cc.tp_src = dataUrl cc.tp_src = dataUrl
} }
} }
if (cc.image) { if (cc.image) {
ret = cc.image.tp_src_uuid
ret = ret ? staticData.imageMap[ret] : undefined
const uid = cc.image.tp_src_uuid as string
ret = uid ? staticData.imageMap[uid] : undefined
if (!ret) ret = cc.image.tp_src || cc.image.src if (!ret) ret = cc.image.tp_src || cc.image.src
} }
if (cc.tp_src) ret = cc.tp_src if (cc.tp_src) ret = cc.tp_src
} else if (typeof cc === 'string') { } else if (typeof cc === 'string') {
ret = cc ret = cc
} else if (cc.domainMin) { // for lut CUBE files. } else if (cc.domainMin) { // for lut CUBE files.
ret = cc.texture
if (cc.texture.image && !cc.texture.image.tp_src) {
cc.texture.image.tp_src = staticData.lutCubeTexImage
}
if (cc.texture.image) {
ret = cc.texture.image.tp_src_uuid
ret = ret ? staticData.imageMap[ret] : undefined
if (!ret) ret = cc.texture.image.tp_src || cc.texture.image.src
// ret = cc.texture
const image = cc.texture.image
if (image) {
// todo this will always show placeholder, we need to snapshot data texture
if (!image.tp_src) {
image.tp_src = staticData.lutCubeTexImage
}
const uid = image.tp_src_uuid as string
ret = uid ? staticData.imageMap[uid] : undefined
if (!ret) ret = image.tp_src || image.src
} }
} else if (cc) { } else if (cc) {
console.error('unknown value', cc) console.error('unknown value', cc)
cc.image.tp_src_uuid = uuid cc.image.tp_src_uuid = uuid
staticData.tempMap[ret] = uuid staticData.tempMap[ret] = uuid
} }
if (typeof ret === 'string')
ret = staticData.imageMap[ret] ?? ret // Note: this will be a bottleneck if the length of src is too long.
ret = staticData.imageMap[ret] ?? ret // Note: this will be a bottleneck if the length of src is too long.
return ret return ret
} }


} }
} }
config.__proxy.value_ = v1 config.__proxy.value_ = v1
renderer.methods.setValue(config, v1, {last: true}, false, false)
renderer.methods.setValue(config, v1, {last: true}, false, true)
config.uiRefresh?.(false, 'postFrame') config.uiRefresh?.(false, 'postFrame')
} }


CustomContextMenu.Remove() CustomContextMenu.Remove()
const tex: ITexture&Partial<ImportResultExtras> = config.__proxy.value_ const tex: ITexture&Partial<ImportResultExtras> = config.__proxy.value_
if (!tex) return if (!tex) return
let vcv = tex.image ?? config.uiRef.controller_.valueController.value.rawValue
const vcv = tex.image ?? config.uiRef.controller_.valueController.value.rawValue
if (tex.__rootBlob && !tex.__rootBlob.objectUrl) tex.__rootBlob.objectUrl = URL.createObjectURL(tex.__rootBlob) if (tex.__rootBlob && !tex.__rootBlob.objectUrl) tex.__rootBlob.objectUrl = URL.createObjectURL(tex.__rootBlob)
let src = tex.__rootBlob ? tex.__rootBlob.objectUrl : tex.userData.rootPath || vcv?.src let src = tex.__rootBlob ? tex.__rootBlob.objectUrl : tex.userData.rootPath || vcv?.src
if (src && src.startsWith('blob:')) src = ''

let revokeSrc = false let revokeSrc = false


// HTML image/video/bitmap // HTML image/video/bitmap
if (vcv && (vcv instanceof ImageBitmap || vcv instanceof HTMLImageElement || vcv instanceof HTMLVideoElement) && !src) if (vcv && (vcv instanceof ImageBitmap || vcv instanceof HTMLImageElement || vcv instanceof HTMLVideoElement) && !src)
vcv = imageBitmapToBase64(vcv)
src = imageBitmapToBase64(vcv)


let name = tex.__rootBlob ? tex.__rootBlob.name || 'image.' + (tex.__rootBlob.ext || 'png') : null let name = tex.__rootBlob ? tex.__rootBlob.name || 'image.' + (tex.__rootBlob.ext || 'png') : null


get: () => { get: () => {
try { try {
config.__proxy.value_ = renderer.methods.getRawValue(config) // sending undefined to disable comparison for undo etc config.__proxy.value_ = renderer.methods.getRawValue(config) // sending undefined to disable comparison for undo etc
const ret = proxyGetValue(config.__proxy.value_, viewer, config)
const ret = proxyGetValue(config.__proxy.value_, viewer, config) as any
if (typeof ret !== 'string' && !ret.id?.length) ret.id = generateUUID() if (typeof ret !== 'string' && !ret.id?.length) ret.id = generateUUID()
const id = typeof ret === 'string' ? ret : ret.id ?? ret const id = typeof ret === 'string' ? ret : ret.id ?? ret
if (!staticData.textureMap[id]) staticData.textureMap[id] = config.__proxy.value_ if (!staticData.textureMap[id]) staticData.textureMap[id] = config.__proxy.value_

Loading…
Отказ
Запис