Adding dark edge lines in light mode + enabling SSAO (#2219)
* adding dark edge lines in light mode + enabling SSAO * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * Rerun CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Frank Noirot <frank@zoo.dev> Co-authored-by: Frank Noirot <frank@kittycad.io>
This commit is contained in:
@ -7,6 +7,7 @@ export const TEST_SETTINGS = {
|
|||||||
theme: Themes.Dark,
|
theme: Themes.Dark,
|
||||||
onboardingStatus: 'dismissed',
|
onboardingStatus: 'dismissed',
|
||||||
projectDirectory: '',
|
projectDirectory: '',
|
||||||
|
enableSSAO: false,
|
||||||
},
|
},
|
||||||
modeling: {
|
modeling: {
|
||||||
defaultUnit: 'in',
|
defaultUnit: 'in',
|
||||||
|
@ -77,7 +77,7 @@ export const ModelingMachineProvider = ({
|
|||||||
auth,
|
auth,
|
||||||
settings: {
|
settings: {
|
||||||
context: {
|
context: {
|
||||||
app: { theme },
|
app: { theme, enableSSAO },
|
||||||
modeling: { defaultUnit, highlightEdges },
|
modeling: { defaultUnit, highlightEdges },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -87,6 +87,7 @@ export const ModelingMachineProvider = ({
|
|||||||
useSetupEngineManager(streamRef, token, {
|
useSetupEngineManager(streamRef, token, {
|
||||||
theme: theme.current,
|
theme: theme.current,
|
||||||
highlightEdges: highlightEdges.current,
|
highlightEdges: highlightEdges.current,
|
||||||
|
enableSSAO: enableSSAO.current,
|
||||||
})
|
})
|
||||||
const { htmlRef } = useStore((s) => ({
|
const { htmlRef } = useStore((s) => ({
|
||||||
htmlRef: s.htmlRef,
|
htmlRef: s.htmlRef,
|
||||||
|
@ -7,7 +7,12 @@ import React, { createContext, useEffect } from 'react'
|
|||||||
import useStateMachineCommands from '../hooks/useStateMachineCommands'
|
import useStateMachineCommands from '../hooks/useStateMachineCommands'
|
||||||
import { settingsMachine } from 'machines/settingsMachine'
|
import { settingsMachine } from 'machines/settingsMachine'
|
||||||
import { toast } from 'react-hot-toast'
|
import { toast } from 'react-hot-toast'
|
||||||
import { getThemeColorForEngine, setThemeClass, Themes } from 'lib/theme'
|
import {
|
||||||
|
getThemeColorForEngine,
|
||||||
|
getOppositeTheme,
|
||||||
|
setThemeClass,
|
||||||
|
Themes,
|
||||||
|
} from 'lib/theme'
|
||||||
import decamelize from 'decamelize'
|
import decamelize from 'decamelize'
|
||||||
import {
|
import {
|
||||||
AnyStateMachine,
|
AnyStateMachine,
|
||||||
@ -99,6 +104,9 @@ export const SettingsAuthProviderBase = ({
|
|||||||
{
|
{
|
||||||
context: loadedSettings,
|
context: loadedSettings,
|
||||||
actions: {
|
actions: {
|
||||||
|
//TODO: batch all these and if that's difficult to do from tsx,
|
||||||
|
// make it easy to do
|
||||||
|
|
||||||
setClientSideSceneUnits: (context, event) => {
|
setClientSideSceneUnits: (context, event) => {
|
||||||
const newBaseUnit =
|
const newBaseUnit =
|
||||||
event.type === 'set.modeling.defaultUnit'
|
event.type === 'set.modeling.defaultUnit'
|
||||||
@ -115,6 +123,16 @@ export const SettingsAuthProviderBase = ({
|
|||||||
color: getThemeColorForEngine(context.app.theme.current),
|
color: getThemeColorForEngine(context.app.theme.current),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const opposingTheme = getOppositeTheme(context.app.theme.current)
|
||||||
|
engineCommandManager.sendSceneCommand({
|
||||||
|
cmd_id: uuidv4(),
|
||||||
|
type: 'modeling_cmd_req',
|
||||||
|
cmd: {
|
||||||
|
type: 'set_default_system_properties',
|
||||||
|
color: getThemeColorForEngine(opposingTheme),
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setEngineEdges: (context) => {
|
setEngineEdges: (context) => {
|
||||||
engineCommandManager.sendSceneCommand({
|
engineCommandManager.sendSceneCommand({
|
||||||
|
@ -11,9 +11,11 @@ export function useSetupEngineManager(
|
|||||||
settings = {
|
settings = {
|
||||||
theme: Themes.System,
|
theme: Themes.System,
|
||||||
highlightEdges: true,
|
highlightEdges: true,
|
||||||
|
enableSSAO: true,
|
||||||
} as {
|
} as {
|
||||||
theme: Themes
|
theme: Themes
|
||||||
highlightEdges: boolean
|
highlightEdges: boolean
|
||||||
|
enableSSAO: boolean
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
|
@ -4,7 +4,7 @@ import { Models } from '@kittycad/lib'
|
|||||||
import { exportSave } from 'lib/exportSave'
|
import { exportSave } from 'lib/exportSave'
|
||||||
import { uuidv4 } from 'lib/utils'
|
import { uuidv4 } from 'lib/utils'
|
||||||
import { getNodePathFromSourceRange } from 'lang/queryAst'
|
import { getNodePathFromSourceRange } from 'lang/queryAst'
|
||||||
import { Themes, getThemeColorForEngine } from 'lib/theme'
|
import { Themes, getThemeColorForEngine, getOppositeTheme } from 'lib/theme'
|
||||||
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
|
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
|
||||||
|
|
||||||
let lastMessage = ''
|
let lastMessage = ''
|
||||||
@ -941,6 +941,7 @@ export class EngineCommandManager {
|
|||||||
settings = {
|
settings = {
|
||||||
theme: Themes.Dark,
|
theme: Themes.Dark,
|
||||||
highlightEdges: true,
|
highlightEdges: true,
|
||||||
|
enableSSAO: true,
|
||||||
},
|
},
|
||||||
}: {
|
}: {
|
||||||
setMediaStream: (stream: MediaStream) => void
|
setMediaStream: (stream: MediaStream) => void
|
||||||
@ -953,6 +954,7 @@ export class EngineCommandManager {
|
|||||||
settings?: {
|
settings?: {
|
||||||
theme: Themes
|
theme: Themes
|
||||||
highlightEdges: boolean
|
highlightEdges: boolean
|
||||||
|
enableSSAO: boolean
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
this.makeDefaultPlanes = makeDefaultPlanes
|
this.makeDefaultPlanes = makeDefaultPlanes
|
||||||
@ -969,7 +971,8 @@ export class EngineCommandManager {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${VITE_KC_API_WS_MODELING_URL}?video_res_width=${width}&video_res_height=${height}`
|
const additionalSettings = settings.enableSSAO ? '&post_effect=ssao' : ''
|
||||||
|
const url = `${VITE_KC_API_WS_MODELING_URL}?video_res_width=${width}&video_res_height=${height}${additionalSettings}`
|
||||||
this.engineConnection = new EngineConnection({
|
this.engineConnection = new EngineConnection({
|
||||||
engineCommandManager: this,
|
engineCommandManager: this,
|
||||||
url,
|
url,
|
||||||
@ -989,6 +992,18 @@ export class EngineCommandManager {
|
|||||||
color: getThemeColorForEngine(settings.theme),
|
color: getThemeColorForEngine(settings.theme),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Sets the default line colors
|
||||||
|
const opposingTheme = getOppositeTheme(settings.theme)
|
||||||
|
this.sendSceneCommand({
|
||||||
|
cmd_id: uuidv4(),
|
||||||
|
type: 'modeling_cmd_req',
|
||||||
|
cmd: {
|
||||||
|
type: 'set_default_system_properties',
|
||||||
|
color: getThemeColorForEngine(opposingTheme),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// Set the edge lines visibility
|
// Set the edge lines visibility
|
||||||
this.sendSceneCommand({
|
this.sendSceneCommand({
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
|
@ -156,6 +156,13 @@ export function createSettings() {
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
enableSSAO: new Setting<boolean>({
|
||||||
|
defaultValue: true,
|
||||||
|
description:
|
||||||
|
'Whether or not Screen Space Ambient Occlusion (SSAO) is enabled',
|
||||||
|
validate: (v) => typeof v === 'boolean',
|
||||||
|
hideOnPlatform: 'both', //for now
|
||||||
|
}),
|
||||||
onboardingStatus: new Setting<string>({
|
onboardingStatus: new Setting<string>({
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
validate: (v) => typeof v === 'string',
|
validate: (v) => typeof v === 'string',
|
||||||
|
@ -23,6 +23,17 @@ export function setThemeClass(theme: Themes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the resolved theme in use (Dark || Light)
|
||||||
|
export function getResolvedTheme(theme: Themes) {
|
||||||
|
return theme === Themes.System ? getSystemTheme() : theme
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the opposing theme
|
||||||
|
export function getOppositeTheme(theme: Themes) {
|
||||||
|
const resolvedTheme = getResolvedTheme(theme)
|
||||||
|
return resolvedTheme === Themes.Dark ? Themes.Light : Themes.Dark
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The engine takes RGBA values from 0-1
|
* The engine takes RGBA values from 0-1
|
||||||
* So we convert from the conventional 0-255 found in Figma
|
* So we convert from the conventional 0-255 found in Figma
|
||||||
@ -30,7 +41,7 @@ export function setThemeClass(theme: Themes) {
|
|||||||
* @returns { r: number, g: number, b: number, a: number }
|
* @returns { r: number, g: number, b: number, a: number }
|
||||||
*/
|
*/
|
||||||
export function getThemeColorForEngine(theme: Themes) {
|
export function getThemeColorForEngine(theme: Themes) {
|
||||||
const resolvedTheme = theme === Themes.System ? getSystemTheme() : theme
|
const resolvedTheme = getResolvedTheme(theme)
|
||||||
const dark = 28 / 255
|
const dark = 28 / 255
|
||||||
const light = 249 / 255
|
const light = 249 / 255
|
||||||
return resolvedTheme === Themes.Dark
|
return resolvedTheme === Themes.Dark
|
||||||
|
Reference in New Issue
Block a user