瀏覽代碼

Improve tweakpane ui

master
Palash Bansal 1 年之前
父節點
當前提交
05b46979e3
No account linked to committer's email address

+ 2
- 2
plugins/tweakpane-editor/package-lock.json 查看文件

{ {
"name": "@threepipe/plugin-tweakpane-editor", "name": "@threepipe/plugin-tweakpane-editor",
"version": "0.4.0",
"version": "0.4.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@threepipe/plugin-tweakpane-editor", "name": "@threepipe/plugin-tweakpane-editor",
"version": "0.4.0",
"version": "0.4.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@threepipe/plugin-tweakpane": "file:./../tweakpane/src/", "@threepipe/plugin-tweakpane": "file:./../tweakpane/src/",

+ 1
- 1
plugins/tweakpane-editor/package.json 查看文件

{ {
"name": "@threepipe/plugin-tweakpane-editor", "name": "@threepipe/plugin-tweakpane-editor",
"description": "Tweakpane Editor Plugin for ThreePipe", "description": "Tweakpane Editor Plugin for ThreePipe",
"version": "0.4.0",
"version": "0.4.1",
"devDependencies": { "devDependencies": {
"tippy.js": "^6.3.7", "tippy.js": "^6.3.7",
"treejs": "git://github.com/repalash/treejs.git#d303016bb74e75725d13e97291ac1d4727985918" "treejs": "git://github.com/repalash/treejs.git#d303016bb74e75725d13e97291ac1d4727985918"

+ 8
- 1
plugins/tweakpane-editor/src/TweakpaneEditorPlugin.css 查看文件

transition: background-color 0.5s ease; transition: background-color 0.5s ease;
background-color: #D1D4E7; background-color: #D1D4E7;
} }
body .tpTheme-blue{
/*other vars in tpTheme.css*/
body.tpTheme-light{
background-color: #E7EFF8;
}
body.tpTheme-dark{
background-color: #424852;
}
body.tpTheme-blue{
background-color: #D1D4E7; background-color: #D1D4E7;
} }
body.tpTheme-white{ body.tpTheme-white{

+ 2
- 2
plugins/tweakpane/package-lock.json 查看文件

{ {
"name": "@threepipe/plugin-tweakpane", "name": "@threepipe/plugin-tweakpane",
"version": "0.5.6",
"version": "0.6.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@threepipe/plugin-tweakpane", "name": "@threepipe/plugin-tweakpane",
"version": "0.5.6",
"version": "0.6.0",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"threepipe": "file:./../../src/" "threepipe": "file:./../../src/"

+ 1
- 1
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.6",
"version": "0.6.0",
"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",

+ 20
- 8
plugins/tweakpane/src/TweakpaneUiPlugin.ts 查看文件

import styles from './tpTheme.css?inline' import styles from './tpTheme.css?inline'
import {tpImageInputGenerator} from './tpImageInputGenerator' import {tpImageInputGenerator} from './tpImageInputGenerator'


const themeColors = ['black', 'white', 'blue', 'light', 'dark'] as const
type ThemeColors = typeof themeColors[number]

@uiFolderContainer('Tweakpane UI') @uiFolderContainer('Tweakpane UI')
export class TweakpaneUiPlugin extends UiConfigRendererTweakpane implements IViewerPluginSync { export class TweakpaneUiPlugin extends UiConfigRendererTweakpane implements IViewerPluginSync {
declare ['constructor']: typeof TweakpaneUiPlugin declare ['constructor']: typeof TweakpaneUiPlugin
static CONTAINER_SLOT = 'uiconfigMainPanelSlot' static CONTAINER_SLOT = 'uiconfigMainPanelSlot'


@onChange(TweakpaneUiPlugin.prototype._colorModeChanged) @onChange(TweakpaneUiPlugin.prototype._colorModeChanged)
@uiDropdown('Color Mode', ['black', 'white', 'blue'].map(label=>({label})))
colorMode: 'black'|'white'|'blue'
@uiDropdown('Color Mode', themeColors.map(label=>({label})))
colorMode: ThemeColors


constructor(expanded = !mobileAndTabletCheck(), bigTheme = true, container?: HTMLElement, colorMode?: 'black'|'white'|'blue') {
constructor(expanded = !mobileAndTabletCheck(), bigTheme = true, container?: HTMLElement, colorMode?: ThemeColors) {
super(container ?? document.getElementById(TweakpaneUiPlugin.CONTAINER_SLOT) ?? document.getElementById('tweakpaneMainPanelSlot') ?? document.body, { super(container ?? document.getElementById(TweakpaneUiPlugin.CONTAINER_SLOT) ?? document.getElementById('tweakpaneMainPanelSlot') ?? document.body, {
expanded, autoPostFrame: false, expanded, autoPostFrame: false,
}, false) }, false)
this.THREE = {Color, Vector4, Vector3, Vector2} as any this.THREE = {Color, Vector4, Vector3, Vector2} as any
this._root!.registerPlugin(TweakpaneImagePlugin as any) this._root!.registerPlugin(TweakpaneImagePlugin as any)
if (bigTheme) createStyles(styles, container) if (bigTheme) createStyles(styles, container)
this.colorMode = colorMode ?? (localStorage ? localStorage.getItem('tpTheme') as any : 'blue') ?? 'blue'
this.colorMode = colorMode ?? getThemeColor()


// @ts-expect-error required for tpTextureInputComponent so that it doesn't clone it. todo check others as well like object3d etc // @ts-expect-error required for tpTextureInputComponent so that it doesn't clone it. todo check others as well like object3d etc
Texture.prototype._ui_isPrimitive = true Texture.prototype._ui_isPrimitive = true
prompt = async(message?: string, _default?: string, cancel = true): Promise<string | null> =>this._viewer ? this._viewer.dialog.prompt(message, _default, cancel) : window?.prompt(message, _default) prompt = async(message?: string, _default?: string, cancel = true): Promise<string | null> =>this._viewer ? this._viewer.dialog.prompt(message, _default, cancel) : window?.prompt(message, _default)


protected _colorModeChanged() { protected _colorModeChanged() {
document.body.classList.remove('tpTheme-black', 'tpTheme-white', 'tpTheme-blue')
document.body.classList.add('tpTheme-' + this.colorMode)
if (!localStorage) return
localStorage.setItem('tpTheme', this.colorMode)
setThemeColor(this.colorMode)
} }


dispose() { dispose() {
} }


} }

function getThemeColor(): ThemeColors {
const c = localStorage ? localStorage.getItem('tpTheme') as ThemeColors : undefined
if (c && themeColors.includes(c)) return c
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
function setThemeColor(color: ThemeColors) {
document.body.classList.remove(...themeColors.map(t=>'tpTheme-' + t))
document.body.classList.add('tpTheme-' + color)
if (!localStorage) return
localStorage.setItem('tpTheme', color)
}

+ 76
- 6
plugins/tweakpane/src/tpTheme.css 查看文件

--tp-container-background-color-hover: rgba(32, 32, 32, 0.3); --tp-container-background-color-hover: rgba(32, 32, 32, 0.3);
--tp-container-background-color-active: rgba(50, 50, 50, 0.8); --tp-container-background-color-active: rgba(50, 50, 50, 0.8);
--tp-container-background-color-focus: rgba(50, 50, 50, 1.0); --tp-container-background-color-focus: rgba(50, 50, 50, 1.0);
--tp-container-border-color: rgba(50, 50, 50, 1.0);
/*--tp-base-border-radius: 0.4rem;*/ /*--tp-base-border-radius: 0.4rem;*/


/*--tp-button-background-color: hsla(0, 0%, 70%, 1.00);*/ /*--tp-button-background-color: hsla(0, 0%, 70%, 1.00);*/
--tp-container-background-color-active: hsla(230, 25%, 31%, 0.65); --tp-container-background-color-active: hsla(230, 25%, 31%, 0.65);
--tp-container-background-color-focus: hsla(230, 25%, 26%, 0.65); --tp-container-background-color-focus: hsla(230, 25%, 26%, 0.65);
--tp-container-background-color-hover: hsla(230, 25%, 21%, 0.65); --tp-container-background-color-hover: hsla(230, 25%, 21%, 0.65);
--tp-container-border-color: hsla(230, 36%, 25%, 1);
--tp-container-foreground-color: hsl(240, 10%, 92%); --tp-container-foreground-color: hsl(240, 10%, 92%);
--tp-groove-foreground-color: hsla(230, 20%, 8%, 1.00); --tp-groove-foreground-color: hsla(230, 20%, 8%, 1.00);
--tp-input-background-color: hsla(230, 20%, 8%, 1.00); --tp-input-background-color: hsla(230, 20%, 8%, 1.00);
--tp-container-background-color-active: hsla(230, 15%, 70%, 0.32); --tp-container-background-color-active: hsla(230, 15%, 70%, 0.32);
--tp-container-background-color-focus: hsla(230, 15%, 70%, 0.28); --tp-container-background-color-focus: hsla(230, 15%, 70%, 0.28);
--tp-container-background-color-hover: hsla(230, 15%, 70%, 0.24); --tp-container-background-color-hover: hsla(230, 15%, 70%, 0.24);
--tp-container-border-color: hsla(230, 15%, 70%, 0.6);
--tp-container-foreground-color: hsla(230, 10%, 30%, 1.00); --tp-container-foreground-color: hsla(230, 10%, 30%, 1.00);
--tp-groove-foreground-color: hsla(230, 15%, 20%, 0.10); --tp-groove-foreground-color: hsla(230, 15%, 20%, 0.10);
--tp-input-background-color: hsla(230, 15%, 30%, 0.10); --tp-input-background-color: hsla(230, 15%, 30%, 0.10);


} }


:root .tpTheme-light {
--tp-base-background-color: #E7EFF8;
--tp-base-shadow-color: rgba(0, 0, 0, 0.1);
--tp-button-background-color: #dae1ea;
--tp-button-background-color-active: #c3d4e7;
--tp-button-background-color-focus: #c3d4e7;
--tp-button-background-color-hover: #c3d4e7;
--tp-button-foreground-color: #1C2026;
--tp-container-background-color: #dae1ea22;
--tp-container-background-color-active: #c3d4e766;
--tp-container-background-color-focus: #c3d4e766;
--tp-container-background-color-hover: #c3d4e766;
--tp-container-border-color: #c3d4e799;
--tp-container-foreground-color: #1C2026;
--tp-groove-foreground-color: #6d7a8c;
--tp-input-background-color: #dae1ea;
--tp-input-background-color-active: #c3d4e7;
--tp-input-background-color-focus: #c3d4e7;
--tp-input-background-color-hover: #c3d4e7;
--tp-input-foreground-color: #1C2026;
--tp-label-foreground-color: #2b313a;
--tp-monitor-background-color: #dae1ea;
--tp-monitor-foreground-color: #6d7a8c;
}

:root .tpTheme-dark {
--tp-base-background-color: #1C2026;
--tp-base-shadow-color: rgba(0, 0, 0, 0.2);
--tp-button-background-color: #3e4550;
--tp-button-background-color-active: #555e6b;
--tp-button-background-color-focus: #555e6b;
--tp-button-background-color-hover: #555e6b;
--tp-button-foreground-color: #F6F7F9;
--tp-container-background-color: #3e455022;
--tp-container-background-color-active: #555e6b66;
--tp-container-background-color-focus: #555e6b66;
--tp-container-background-color-hover: #555e6b66;
--tp-container-border-color: #555e6b99;
--tp-container-foreground-color: #F6F7F9;
--tp-groove-foreground-color: #b6bfcb;
--tp-input-background-color: #3e4550;
--tp-input-background-color-active: #555e6b;
--tp-input-background-color-focus: #555e6b;
--tp-input-background-color-hover: #555e6b;
--tp-input-foreground-color: #F6F7F9;
--tp-label-foreground-color: #d2d3d5;
--tp-monitor-background-color: #3e4550;
--tp-monitor-foreground-color: #b6bfcb;
}

.tp-fldv { .tp-fldv {
margin-top: 0.25rem;
margin-bottom: 0.25rem;
/*margin-top: 0.25rem;*/
/*margin-bottom: 0.25rem;*/
background-blend-mode: luminosity; background-blend-mode: luminosity;
position: relative; position: relative;
/*outline: 1px solid var(--tp-input-foreground-color);*/
/*outline-offset: -1px;*/
border: 1px solid var(--tp-container-border-color);
/*border: 2px solid #c3d4e799;*/
/*border: 2px solid black;*/
/*border-left: 0px;*/
box-sizing: border-box;
} }


.tp-fldv .tp-fldv {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
/*.tp-fldv.tp-v-vlst{*/
/*}*/

/*.tp-fldv .tp-fldv {*/
/* margin-top: 0.5rem;*/
/* margin-bottom: 0.5rem;*/
/*}*/


/*.tp-rotv.tp-rotv-expanded .tp-rotv_c, .tp-fldv.tp-fldv-expanded>.tp-fldv_c{*/
/* padding-top: 0;*/
/*}*/
.tp-tabv_c .tp-brkv>.tp-cntv, .tp-fldv_c>.tp-cntv {
margin-left: 0;
}
.tp-fldv .tp-brkv { .tp-fldv .tp-brkv {
/*background-color: #ddddddcc;*/ /*background-color: #ddddddcc;*/
} }
.tp-rotv{ .tp-rotv{
font-size: 13px !important; font-size: 13px !important;
} }


Loading…
取消
儲存